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_IR_READER_H_ 16 #define HEADER_CHECKER_REPR_IR_READER_H_ 17 18 #include "repr/ir_representation.h" 19 20 #include <memory> 21 #include <set> 22 #include <string> 23 24 25 namespace header_checker { 26 namespace repr { 27 28 29 class IRReader { 30 public: 31 static std::unique_ptr<IRReader> CreateIRReader( 32 TextFormatIR text_format, 33 const std::set<std::string> *exported_headers = nullptr); 34 IRReader(const std::set<std::string> * exported_headers)35 IRReader(const std::set<std::string> *exported_headers) 36 : module_(new ModuleIR(exported_headers)) {} 37 ~IRReader()38 virtual ~IRReader() {} 39 40 bool ReadDump(const std::string &dump_file); 41 GetModule()42 ModuleIR &GetModule() { 43 return *module_; 44 } 45 TakeModule()46 std::unique_ptr<ModuleIR> TakeModule() { 47 return std::move(module_); 48 } 49 50 private: 51 virtual bool ReadDumpImpl(const std::string &dump_file) = 0; 52 53 protected: 54 std::unique_ptr<ModuleIR> module_; 55 }; 56 57 58 } // namespace repr 59 } // namespace header_checker 60 61 62 #endif // HEADER_CHECKER_REPR_IR_READER_H_ 63