clang-tools 8.0.0

PathConfig.cpp
Go to the documentation of this file.
1 //===-- PathConfig.cpp - Process paths of symbols ---------------*- C++ -*-===//
2 //
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 #include "PathConfig.h"
12 #include "llvm/Support/Path.h"
13
14 namespace clang {
15 namespace find_all_symbols {
16
17 std::string getIncludePath(const SourceManager &SM, SourceLocation Loc,
18 const HeaderMapCollector *Collector) {
19 llvm::StringRef FilePath;
20 // Walk up the include stack to skip .inc files.
21 while (true) {
22 if (!Loc.isValid() || SM.isInMainFile(Loc))
23 return "";
24 FilePath = SM.getFilename(Loc);
25 if (FilePath.empty())
26 return "";
27 if (!FilePath.endswith(".inc"))
28 break;
29 FileID ID = SM.getFileID(Loc);
30 Loc = SM.getIncludeLoc(ID);
31 }
32
33 if (Collector)
34 FilePath = Collector->getMappedHeader(FilePath);
35 SmallString<256> CleanedFilePath = FilePath;
36 llvm::sys::path::remove_dots(CleanedFilePath, /*remove_dot_dot=*/false);
37
38 return CleanedFilePath.str();
39 }
40
41 } // namespace find_all_symbols
42 } // namespace clang
Loc
SourceLocation Loc
&#39;#&#39; location in the include directive
Definition: IncludeOrderCheck.cpp:37
clang::find_all_symbols::HeaderMapCollector
HeaderMappCollector collects all remapping header files.
Definition: HeaderMapCollector.h:23
clang::find_all_symbols::getIncludePath
std::string getIncludePath(const SourceManager &SM, SourceLocation Loc, const HeaderMapCollector *Collector)
This calculates the include path for Loc.
Definition: PathConfig.cpp:17
clang::find_all_symbols::HeaderMapCollector::getMappedHeader
llvm::StringRef getMappedHeader(llvm::StringRef Header) const
Check if there is a mapping from Header or a regex pattern that matches it to another header name...
Definition: HeaderMapCollector.cpp:27
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
PathConfig.h