1 // Copyright (C) 2019 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef HEADER_CHECKER_REPR_PROTOBUF_IR_DUMPER_H_ 16 #define HEADER_CHECKER_REPR_PROTOBUF_IR_DUMPER_H_ 17 18 #include "repr/ir_dumper.h" 19 #include "repr/protobuf/abi_dump.h" 20 #include "repr/protobuf/ir_dumper.h" 21 22 23 namespace header_checker { 24 namespace repr { 25 26 27 class ProtobufIRDumper : public IRDumper { 28 private: 29 // Types 30 bool AddRecordTypeIR(const RecordTypeIR *); 31 32 bool AddEnumTypeIR(const EnumTypeIR *); 33 34 bool AddPointerTypeIR(const PointerTypeIR *); 35 36 bool AddQualifiedTypeIR(const QualifiedTypeIR *); 37 38 bool AddLvalueReferenceTypeIR(const LvalueReferenceTypeIR *); 39 40 bool AddRvalueReferenceTypeIR(const RvalueReferenceTypeIR *); 41 42 bool AddArrayTypeIR(const ArrayTypeIR *); 43 44 bool AddBuiltinTypeIR(const BuiltinTypeIR *); 45 46 bool AddFunctionTypeIR(const FunctionTypeIR *function_typep); 47 48 // Functions and global variables. 49 bool AddFunctionIR(const FunctionIR *); 50 51 bool AddGlobalVarIR(const GlobalVarIR *); 52 53 bool AddElfFunctionIR(const ElfFunctionIR *); 54 55 bool AddElfObjectIR(const ElfObjectIR *); 56 57 58 public: ProtobufIRDumper(const std::string & dump_path)59 ProtobufIRDumper(const std::string &dump_path) 60 : IRDumper(dump_path), tu_ptr_(new abi_dump::TranslationUnit()) {} 61 ~ProtobufIRDumper()62 ~ProtobufIRDumper() override {} 63 64 bool Dump(const ModuleIR &module) override; 65 66 67 private: 68 bool AddLinkableMessageIR(const LinkableMessageIR *) override; 69 70 bool AddElfSymbolMessageIR(const ElfSymbolIR *) override; 71 72 73 private: 74 std::unique_ptr<abi_dump::TranslationUnit> tu_ptr_; 75 }; 76 77 78 } // namespace repr 79 } // namespace header_checker 80 81 82 #endif // HEADER_CHECKER_REPR_PROTOBUF_IR_DUMPER_H_ 83