17#include "llvm/Support/SpecialCaseList.h"
19#include "llvm/Support/raw_ostream.h"
28 static std::unique_ptr<ProfileSpecialCaseList>
29 create(
const std::vector<std::string> &Paths, llvm::vfs::FileSystem &VFS,
32 static std::unique_ptr<ProfileSpecialCaseList>
34 llvm::vfs::FileSystem &VFS);
36 bool isEmpty()
const {
return Sections.empty(); }
39 for (
const auto &It : Sections)
40 if (It.second.Entries.count(Prefix) > 0)
46std::unique_ptr<ProfileSpecialCaseList>
48 llvm::vfs::FileSystem &VFS,
50 auto PSCL = std::make_unique<ProfileSpecialCaseList>();
51 if (PSCL->createInternal(Paths, VFS, Error))
56std::unique_ptr<ProfileSpecialCaseList>
58 llvm::vfs::FileSystem &VFS) {
60 if (
auto PSCL =
create(Paths, VFS, Error))
62 llvm::report_fatal_error(llvm::Twine(Error));
69 Paths,
SM.getFileManager().getVirtualFileSystem())),
85 llvm_unreachable(
"Unhandled CodeGenOptions::ProfileInstrKind enum");
92 if (SCL->inSection(Section,
"default",
"allow"))
94 if (SCL->inSection(Section,
"default",
"skip"))
96 if (SCL->inSection(Section,
"default",
"forbid"))
99 if (SCL->hasPrefix(
"fun") || SCL->hasPrefix(
"src"))
104std::optional<ProfileList::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))
118std::optional<ProfileList::ExclusionType>
123 if (
auto V = inSection(Section,
"function", FunctionName))
125 if (SCL->inSection(Section,
"!fun", FunctionName))
127 if (SCL->inSection(Section,
"fun", FunctionName))
132std::optional<ProfileList::ExclusionType>
138std::optional<ProfileList::ExclusionType>
143 if (
auto V = inSection(Section,
"source",
FileName))
145 if (SCL->inSection(Section,
"!src",
FileName))
147 if (SCL->inSection(Section,
"src",
FileName))
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.