• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "repr/ir_reader.h"
16 
17 #include "repr/ir_representation.h"
18 #include "repr/json/api.h"
19 #include "repr/protobuf/api.h"
20 
21 #include <list>
22 #include <memory>
23 #include <set>
24 #include <string>
25 
26 #include <llvm/Support/raw_ostream.h>
27 
28 
29 namespace header_checker {
30 namespace repr {
31 
32 
33 std::unique_ptr<IRReader>
CreateIRReader(TextFormatIR text_format,const std::set<std::string> * exported_headers)34 IRReader::CreateIRReader(
35     TextFormatIR text_format, const std::set<std::string> *exported_headers) {
36   switch (text_format) {
37     case TextFormatIR::ProtobufTextFormat:
38       return CreateProtobufIRReader(exported_headers);
39     case TextFormatIR::Json:
40       return CreateJsonIRReader(exported_headers);
41     default:
42       llvm::errs() << "Text format not supported yet\n";
43       return nullptr;
44   }
45 }
46 
47 
ReadDump(const std::string & dump_file)48 bool IRReader::ReadDump(const std::string &dump_file) {
49   module_->SetCompilationUnitPath(dump_file);
50   return ReadDumpImpl(dump_file);
51 }
52 
53 
54 }  // namespace repr
55 }  // header_checker
56