clang: lib/Basic/ProfileList.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
17#include "llvm/Support/SpecialCaseList.h"
18
19#include "llvm/Support/raw_ostream.h"
20#include
21
22using namespace clang;
23
25
27public:
28 static std::unique_ptr
29 create(const std::vectorstd::string &Paths, llvm::vfs::FileSystem &VFS,
30 std::string &Error);
31
32 static std::unique_ptr
33 createOrDie(const std::vectorstd::string &Paths,
34 llvm::vfs::FileSystem &VFS);
35
36 bool isEmpty() const { return Sections.empty(); }
37
39 for (const auto &It : Sections)
40 if (It.second.Entries.count(Prefix) > 0)
41 return true;
42 return false;
43 }
44};
45
46std::unique_ptr
48 llvm::vfs::FileSystem &VFS,
49 std::string &Error) {
50 auto PSCL = std::make_unique();
51 if (PSCL->createInternal(Paths, VFS, Error))
52 return PSCL;
53 return nullptr;
54}
55
56std::unique_ptr
58 llvm::vfs::FileSystem &VFS) {
59 std::string Error;
60 if (auto PSCL = create(Paths, VFS, Error))
61 return PSCL;
62 llvm::report_fatal_error(llvm::Twine(Error));
63}
64
65}
66
69 Paths, SM.getFileManager().getVirtualFileSystem())),
71
73
75 switch (Kind) {
77 return "";
79 return "clang";
81 return "llvm";
83 return "csllvm";
84 }
85 llvm_unreachable("Unhandled CodeGenOptions::ProfileInstrKind enum");
86}
87
91
92 if (SCL->inSection(Section, "default", "allow"))
94 if (SCL->inSection(Section, "default", "skip"))
96 if (SCL->inSection(Section, "default", "forbid"))
98
99 if (SCL->hasPrefix("fun") || SCL->hasPrefix("src"))
102}
103
104std::optionalProfileList::ExclusionType
105ProfileList::inSection(StringRef Section, StringRef Prefix,
106 StringRef Query) const {
107 if (SCL->inSection(Section, Prefix, Query, "allow"))
109 if (SCL->inSection(Section, Prefix, Query, "skip"))
111 if (SCL->inSection(Section, Prefix, Query, "forbid"))
113 if (SCL->inSection(Section, Prefix, Query))
115 return std::nullopt;
116}
117
118std::optionalProfileList::ExclusionType
122
123 if (auto V = inSection(Section, "function", FunctionName))
124 return V;
125 if (SCL->inSection(Section, "!fun", FunctionName))
127 if (SCL->inSection(Section, "fun", FunctionName))
129 return std::nullopt;
130}
131
132std::optionalProfileList::ExclusionType
136}
137
138std::optionalProfileList::ExclusionType
142
143 if (auto V = inSection(Section, "source", FileName))
144 return V;
145 if (SCL->inSection(Section, "!src", FileName))
147 if (SCL->inSection(Section, "src", FileName))
149 return std::nullopt;
150}
Defines the clang::FileManager interface and associated types.
static StringRef getSectionName(CodeGenOptions::ProfileInstrKind Kind)
Defines the SourceManager interface.
std::optional< ExclusionType > isFunctionExcluded(StringRef FunctionName, CodeGenOptions::ProfileInstrKind Kind) const
std::optional< ExclusionType > isLocationExcluded(SourceLocation Loc, CodeGenOptions::ProfileInstrKind Kind) const
ExclusionType
Represents if an how something should be excluded from profiling.
@ Forbid
Profiling is forbidden using the noprofile attribute.
@ Skip
Profiling is skipped using the skipprofile attribute.
@ Allow
Profiling is allowed.
ExclusionType getDefault(CodeGenOptions::ProfileInstrKind Kind) const
ProfileList(ArrayRef< std::string > Paths, SourceManager &SM)
std::optional< ExclusionType > isFileExcluded(StringRef FileName, CodeGenOptions::ProfileInstrKind Kind) const
static std::unique_ptr< ProfileSpecialCaseList > createOrDie(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &VFS)
bool hasPrefix(StringRef Prefix) const
static std::unique_ptr< ProfileSpecialCaseList > create(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &VFS, std::string &Error)
Encodes a location in the source.
This class handles loading and caching of source files into memory.
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location,...
StringRef getFilename(SourceLocation SpellingLoc) const
Return the filename of the file containing a SourceLocation.
The JSON file list parser is used to communicate input to InstallAPI.