diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Basic/XRayLists.cpp | 24 | ||||
-rw-r--r-- | clang/lib/Driver/XRayArgs.cpp | 15 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 1 |
4 files changed, 35 insertions, 8 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 79ac53cde23..4b095ce45ab 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -788,7 +788,8 @@ ASTContext::ASTContext(LangOptions &LOpts, SourceManager &SM, SubstTemplateTemplateParmPacks(this_()), SourceMgr(SM), LangOpts(LOpts), SanitizerBL(new SanitizerBlacklist(LangOpts.SanitizerBlacklistFiles, SM)), XRayFilter(new XRayFunctionFilter(LangOpts.XRayAlwaysInstrumentFiles, - LangOpts.XRayNeverInstrumentFiles, SM)), + LangOpts.XRayNeverInstrumentFiles, + LangOpts.XRayAttrListFiles, SM)), PrintingPolicy(LOpts), Idents(idents), Selectors(sels), BuiltinInfo(builtins), DeclarationNames(*this), Comments(SM), CommentCommandTraits(BumpAlloc, LOpts.CommentOpts), LastSDM(nullptr, 0) { diff --git a/clang/lib/Basic/XRayLists.cpp b/clang/lib/Basic/XRayLists.cpp index 462777d5340..ad331899d2e 100644 --- a/clang/lib/Basic/XRayLists.cpp +++ b/clang/lib/Basic/XRayLists.cpp @@ -16,24 +16,32 @@ using namespace clang; XRayFunctionFilter::XRayFunctionFilter( ArrayRef<std::string> AlwaysInstrumentPaths, - ArrayRef<std::string> NeverInstrumentPaths, SourceManager &SM) + ArrayRef<std::string> NeverInstrumentPaths, + ArrayRef<std::string> AttrListPaths, SourceManager &SM) : AlwaysInstrument( llvm::SpecialCaseList::createOrDie(AlwaysInstrumentPaths)), NeverInstrument(llvm::SpecialCaseList::createOrDie(NeverInstrumentPaths)), - SM(SM) {} + AttrList(llvm::SpecialCaseList::createOrDie(AttrListPaths)), SM(SM) {} XRayFunctionFilter::ImbueAttribute XRayFunctionFilter::shouldImbueFunction(StringRef FunctionName) const { // First apply the always instrument list, than if it isn't an "always" see // whether it's treated as a "never" instrument function. + // TODO: Remove these as they're deprecated; use the AttrList exclusively. if (AlwaysInstrument->inSection("xray_always_instrument", "fun", FunctionName, - "arg1")) + "arg1") || + AttrList->inSection("always", "fun", FunctionName, "arg1")) return ImbueAttribute::ALWAYS_ARG1; if (AlwaysInstrument->inSection("xray_always_instrument", "fun", - FunctionName)) + FunctionName) || + AttrList->inSection("always", "fun", FunctionName)) return ImbueAttribute::ALWAYS; - if (NeverInstrument->inSection("xray_never_instrument", "fun", FunctionName)) + + if (NeverInstrument->inSection("xray_never_instrument", "fun", + FunctionName) || + AttrList->inSection("never", "fun", FunctionName)) return ImbueAttribute::NEVER; + return ImbueAttribute::NONE; } @@ -41,10 +49,12 @@ XRayFunctionFilter::ImbueAttribute XRayFunctionFilter::shouldImbueFunctionsInFile(StringRef Filename, StringRef Category) const { if (AlwaysInstrument->inSection("xray_always_instrument", "src", Filename, - Category)) + Category) || + AttrList->inSection("always", "src", Filename, Category)) return ImbueAttribute::ALWAYS; if (NeverInstrument->inSection("xray_never_instrument", "src", Filename, - Category)) + Category) || + AttrList->inSection("never", "src", Filename, Category)) return ImbueAttribute::NEVER; return ImbueAttribute::NONE; } diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp index e151cb907cd..cc109d10cf3 100644 --- a/clang/lib/Driver/XRayArgs.cpp +++ b/clang/lib/Driver/XRayArgs.cpp @@ -99,6 +99,15 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) { } else D.Diag(clang::diag::err_drv_no_such_file) << Filename; } + + for (const auto &Filename : + Args.getAllArgValues(options::OPT_fxray_attr_list)) { + if (llvm::sys::fs::exists(Filename)) { + AttrListFiles.push_back(Filename); + ExtraDeps.push_back(Filename); + } else + D.Diag(clang::diag::err_drv_no_such_file) << Filename; + } } } @@ -127,6 +136,12 @@ void XRayArgs::addArgs(const ToolChain &TC, const ArgList &Args, CmdArgs.push_back(Args.MakeArgString(NeverInstrumentOpt)); } + for (const auto&AttrFile : AttrListFiles) { + SmallString<64> AttrListFileOpt("-fxray-attr-list="); + AttrListFileOpt += AttrFile; + CmdArgs.push_back(Args.MakeArgString(AttrListFileOpt)); + } + for (const auto &Dep : ExtraDeps) { SmallString<64> ExtraDepOpt("-fdepfile-entry="); ExtraDepOpt += Dep; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 1a3b67f0968..687dc688e1d 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2640,6 +2640,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Args.getAllArgValues(OPT_fxray_always_instrument); Opts.XRayNeverInstrumentFiles = Args.getAllArgValues(OPT_fxray_never_instrument); + Opts.XRayAttrListFiles = Args.getAllArgValues(OPT_fxray_attr_list); // -fallow-editor-placeholders Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders); |