Home | History | Annotate | Download | only in protobuf
      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/converter.h"
     21 #include "repr/protobuf/ir_dumper.h"
     22 
     23 
     24 namespace header_checker {
     25 namespace repr {
     26 
     27 
     28 class ProtobufIRDumper : public IRDumper, public IRToProtobufConverter {
     29  private:
     30   // Types
     31   bool AddRecordTypeIR(const RecordTypeIR *);
     32 
     33   bool AddEnumTypeIR(const EnumTypeIR *);
     34 
     35   bool AddPointerTypeIR(const PointerTypeIR *);
     36 
     37   bool AddQualifiedTypeIR(const QualifiedTypeIR *);
     38 
     39   bool AddLvalueReferenceTypeIR(const LvalueReferenceTypeIR *);
     40 
     41   bool AddRvalueReferenceTypeIR(const RvalueReferenceTypeIR *);
     42 
     43   bool AddArrayTypeIR(const ArrayTypeIR *);
     44 
     45   bool AddBuiltinTypeIR(const BuiltinTypeIR *);
     46 
     47   bool AddFunctionTypeIR(const FunctionTypeIR *function_typep);
     48 
     49   // Functions and global variables.
     50   bool AddFunctionIR(const FunctionIR *);
     51 
     52   bool AddGlobalVarIR(const GlobalVarIR *);
     53 
     54   bool AddElfFunctionIR(const ElfFunctionIR *);
     55 
     56   bool AddElfObjectIR(const ElfObjectIR *);
     57 
     58 
     59  public:
     60   ProtobufIRDumper(const std::string &dump_path)
     61       : IRDumper(dump_path), tu_ptr_(new abi_dump::TranslationUnit()) {}
     62 
     63   ~ProtobufIRDumper() override {}
     64 
     65   bool Dump(const ModuleIR &module) override;
     66 
     67 
     68  private:
     69   bool AddLinkableMessageIR(const LinkableMessageIR *) override;
     70 
     71   bool AddElfSymbolMessageIR(const ElfSymbolIR *) override;
     72 
     73 
     74  private:
     75   std::unique_ptr<abi_dump::TranslationUnit> tu_ptr_;
     76 };
     77 
     78 
     79 }  // namespace repr
     80 }  // namespace header_checker
     81 
     82 
     83 #endif  // HEADER_CHECKER_REPR_PROTOBUF_IR_DUMPER_H_
     84