kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/cxx/extractor/cxx_details.h (about) 1 /* 2 * Copyright 2015 The Kythe Authors. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef KYTHE_CXX_EXTRACTOR_CXX_DETAILS_H_ 18 #define KYTHE_CXX_EXTRACTOR_CXX_DETAILS_H_ 19 20 #include <vector> 21 22 #include "clang/Basic/SourceManager.h" 23 #include "clang/Lex/HeaderSearch.h" 24 #include "clang/Lex/HeaderSearchOptions.h" 25 #include "kythe/proto/cxx.pb.h" 26 27 namespace kythe { 28 /// \brief Reproduces Clang's internal header search state. 29 struct HeaderSearchInfo { 30 /// An include path to be searched. 31 struct Path { 32 /// The path to search. 33 std::string path; 34 /// Whether files in this path are normal, system, or implicitly extern C 35 /// headers. 36 clang::SrcMgr::CharacteristicKind characteristic_kind; 37 /// Whether this Path is a framework. 38 bool is_framework; 39 }; 40 /// The first of the paths that is an <include>. 41 unsigned angled_dir_idx = 0; 42 /// The first of the system include paths. Must be >= angled_dir_idx. 43 unsigned system_dir_idx = 0; 44 /// Include paths to be searched, along with the kind of files found there. 45 std::vector<Path> paths; 46 /// Prefixes on include paths that override the system property. 47 /// The second part of the pair determines whether the property is set. 48 std::vector<std::pair<std::string, bool>> system_prefixes; 49 /// Copies HeaderSearchInfo from Clang. Returns true if we can represent the 50 /// state; false if Clang is using features we don't support. This object 51 /// has undefined state until the next successful CopyFrom completes. 52 bool CopyFrom(const clang::HeaderSearchOptions& header_search_options, 53 const clang::HeaderSearch& header_search_info); 54 /// Copies HeaderSearchInfo from a serialized format. Returns true if the 55 /// data are well-formed; false if this object should not be used and 56 /// has undefined state until the next successful CopyFrom completes. 57 bool CopyFrom(const kythe::proto::CxxCompilationUnitDetails& cxx_details); 58 /// Copies HeaderSearchInfo to a serializable format. 59 void CopyTo(kythe::proto::CxxCompilationUnitDetails* cxx_details) const; 60 }; 61 62 /// The type URI for C++ details. 63 extern const char kCxxCompilationUnitDetailsURI[]; 64 } // namespace kythe 65 66 #endif // KYTHE_CXX_EXTRACTOR_CXX_DETAILS_H_