17#include "llvm/Support/SpecialCaseList.h"
27 static std::unique_ptr<ProfileSpecialCaseList>
28 create(
const std::vector<std::string> &Paths, llvm::vfs::FileSystem &VFS,
31 static std::unique_ptr<ProfileSpecialCaseList>
33 llvm::vfs::FileSystem &VFS);
35 bool isEmpty()
const {
return Sections.empty(); }
38 for (
const auto &It : Sections)
39 if (It.Entries.count(Prefix) > 0)
45std::unique_ptr<ProfileSpecialCaseList>
47 llvm::vfs::FileSystem &VFS, std::string &Error) {
48 auto PSCL = std::make_unique<ProfileSpecialCaseList>();
49 if (PSCL->createInternal(Paths, VFS, Error))
54std::unique_ptr<ProfileSpecialCaseList>
56 llvm::vfs::FileSystem &VFS) {
58 if (
auto PSCL =
create(Paths, VFS, Error))
60 llvm::report_fatal_error(llvm::Twine(Error));
67 Paths,
SM.getFileManager().getVirtualFileSystem())),
74 case llvm::driver::ProfileInstrKind::ProfileNone:
76 case llvm::driver::ProfileInstrKind::ProfileClangInstr:
78 case llvm::driver::ProfileInstrKind::ProfileIRInstr:
80 case llvm::driver::ProfileInstrKind::ProfileCSIRInstr:
82 case llvm::driver::ProfileInstrKind::ProfileIRSampleColdCov:
83 return "sample-coldcov";
85 llvm_unreachable(
"Unhandled llvm::driver::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>
120 llvm::driver::ProfileInstrKind Kind)
const {
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>
134 llvm::driver::ProfileInstrKind Kind)
const {
138std::optional<ProfileList::ExclusionType>
140 llvm::driver::ProfileInstrKind Kind)
const {
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(llvm::driver::ProfileInstrKind Kind)
Defines the SourceManager interface.
ExclusionType getDefault(llvm::driver::ProfileInstrKind Kind) const
std::optional< ExclusionType > isFunctionExcluded(StringRef FunctionName, llvm::driver::ProfileInstrKind Kind) const
std::optional< ExclusionType > isFileExcluded(StringRef FileName, llvm::driver::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.
ProfileList(ArrayRef< std::string > Paths, SourceManager &SM)
std::optional< ExclusionType > isLocationExcluded(SourceLocation Loc, llvm::driver::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.