[clang] 8e0c9bb - [clang] NFCI: Change returned AnalyzerOptions smart pointer to reference
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 5 13:24:03 PDT 2023
Author: Jan Svoboda
Date: 2023-09-05T13:23:53-07:00
New Revision: 8e0c9bb91f484b7d2fa86c01919d96a41a7071d7
URL: https://github.com/llvm/llvm-project/commit/8e0c9bb91f484b7d2fa86c01919d96a41a7071d7
DIFF: https://github.com/llvm/llvm-project/commit/8e0c9bb91f484b7d2fa86c01919d96a41a7071d7.diff
LOG: [clang] NFCI: Change returned AnalyzerOptions smart pointer to reference
Added:
Modified:
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang/include/clang/Frontend/CompilerInstance.h
clang/include/clang/Frontend/CompilerInvocation.h
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
clang/unittests/StaticAnalyzer/CheckerRegistration.h
clang/unittests/StaticAnalyzer/Reusables.h
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 47253570e91da6f..695bfd6e2edf7ef 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -435,13 +435,13 @@ ClangTidyASTConsumerFactory::createASTConsumer(
Consumers.push_back(Finder->newASTConsumer());
#if CLANG_TIDY_ENABLE_STATIC_ANALYZER
- AnalyzerOptionsRef AnalyzerOptions = Compiler.getAnalyzerOpts();
- AnalyzerOptions->CheckersAndPackages = getAnalyzerCheckersAndPackages(
+ AnalyzerOptions &AnalyzerOptions = Compiler.getAnalyzerOpts();
+ AnalyzerOptions.CheckersAndPackages = getAnalyzerCheckersAndPackages(
Context, Context.canEnableAnalyzerAlphaCheckers());
- if (!AnalyzerOptions->CheckersAndPackages.empty()) {
- setStaticAnalyzerCheckerOpts(Context.getOptions(), *AnalyzerOptions);
- AnalyzerOptions->AnalysisDiagOpt = PD_NONE;
- AnalyzerOptions->eagerlyAssumeBinOpBifurcation = true;
+ if (!AnalyzerOptions.CheckersAndPackages.empty()) {
+ setStaticAnalyzerCheckerOpts(Context.getOptions(), AnalyzerOptions);
+ AnalyzerOptions.AnalysisDiagOpt = PD_NONE;
+ AnalyzerOptions.eagerlyAssumeBinOpBifurcation = true;
std::unique_ptr<ento::AnalysisASTConsumer> AnalysisConsumer =
ento::CreateAnalysisConsumer(Compiler);
AnalysisConsumer->AddDiagnosticConsumer(
diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h
index 44ba3f83695e7e3..1255d2c8ff556b2 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -252,9 +252,7 @@ class CompilerInstance : public ModuleLoader {
/// @name Forwarding Methods
/// @{
- AnalyzerOptionsRef getAnalyzerOpts() {
- return Invocation->getAnalyzerOpts();
- }
+ AnalyzerOptions &getAnalyzerOpts() { return Invocation->getAnalyzerOpts(); }
CodeGenOptions &getCodeGenOpts() {
return Invocation->getCodeGenOpts();
diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h
index 8b43edf7b932695..5dc55bb7abdbab7 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -129,7 +129,8 @@ class CompilerInvocationRefBase {
return *PreprocessorOpts;
}
- AnalyzerOptionsRef getAnalyzerOpts() const { return AnalyzerOpts; }
+ AnalyzerOptions &getAnalyzerOpts() { return *AnalyzerOpts; }
+ const AnalyzerOptions &getAnalyzerOpts() const { return *AnalyzerOpts; }
};
/// The base class of CompilerInvocation with value semantics.
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 1ead01e49ec1215..540c22d078654c0 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -392,11 +392,11 @@ void CrossTranslationUnitContext::emitCrossTUDiagnostics(const IndexError &IE) {
CrossTranslationUnitContext::ASTUnitStorage::ASTUnitStorage(
CompilerInstance &CI)
- : Loader(CI, CI.getAnalyzerOpts()->CTUDir,
- CI.getAnalyzerOpts()->CTUInvocationList),
+ : Loader(CI, CI.getAnalyzerOpts().CTUDir,
+ CI.getAnalyzerOpts().CTUInvocationList),
LoadGuard(CI.getASTContext().getLangOpts().CPlusPlus
- ? CI.getAnalyzerOpts()->CTUImportCppThreshold
- : CI.getAnalyzerOpts()->CTUImportThreshold) {}
+ ? CI.getAnalyzerOpts().CTUImportCppThreshold
+ : CI.getAnalyzerOpts().CTUImportThreshold) {}
llvm::Expected<ASTUnit *>
CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFile(
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index e9e2445c879ce0f..11ffb3d6630d1fb 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -140,7 +140,7 @@ CompilerInvocationRefBase::CompilerInvocationRefBase(
DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
- AnalyzerOpts(new AnalyzerOptions(*X.getAnalyzerOpts())) {}
+ AnalyzerOpts(new AnalyzerOptions(X.getAnalyzerOpts())) {}
CompilerInvocationRefBase::CompilerInvocationRefBase(
CompilerInvocationRefBase &&X) = default;
@@ -4385,7 +4385,7 @@ bool CompilerInvocation::CreateFromArgsImpl(
ParseFileSystemArgs(Res.getFileSystemOpts(), Args, Diags);
ParseMigratorArgs(Res.getMigratorOpts(), Args, Diags);
- ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
+ ParseAnalyzerArgs(Res.getAnalyzerOpts(), Args, Diags);
ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
/*DefaultDiagColor=*/false);
ParseFrontendArgs(Res.getFrontendOpts(), Args, Diags, LangOpts.IsHeaderFile);
diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 81145d2a68eee5f..b280a1359d2f272 100644
--- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -233,7 +233,7 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) {
#if CLANG_ENABLE_STATIC_ANALYZER
// These should happen AFTER plugins have been loaded!
- AnalyzerOptions &AnOpts = *Clang->getAnalyzerOpts();
+ AnalyzerOptions &AnOpts = Clang->getAnalyzerOpts();
// Honor -analyzer-checker-help and -analyzer-checker-help-hidden.
if (AnOpts.ShowCheckerHelp || AnOpts.ShowCheckerHelpAlpha ||
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index 54e0f4bee5eb6b7..142acab7cd081d4 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -87,7 +87,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
ASTContext *Ctx;
Preprocessor &PP;
const std::string OutDir;
- AnalyzerOptionsRef Opts;
+ AnalyzerOptions &Opts;
ArrayRef<std::string> Plugins;
CodeInjector *Injector;
cross_tu::CrossTranslationUnitContext CTU;
@@ -121,15 +121,15 @@ class AnalysisConsumer : public AnalysisASTConsumer,
FunctionSummariesTy FunctionSummaries;
AnalysisConsumer(CompilerInstance &CI, const std::string &outdir,
- AnalyzerOptionsRef opts, ArrayRef<std::string> plugins,
+ AnalyzerOptions &opts, ArrayRef<std::string> plugins,
CodeInjector *injector)
: RecVisitorMode(0), RecVisitorBR(nullptr), Ctx(nullptr),
- PP(CI.getPreprocessor()), OutDir(outdir), Opts(std::move(opts)),
+ PP(CI.getPreprocessor()), OutDir(outdir), Opts(opts),
Plugins(plugins), Injector(injector), CTU(CI),
MacroExpansions(CI.getLangOpts()) {
DigestAnalyzerOptions();
- if (Opts->AnalyzerDisplayProgress || Opts->PrintStats ||
- Opts->ShouldSerializeStats) {
+ if (Opts.AnalyzerDisplayProgress || Opts.PrintStats ||
+ Opts.ShouldSerializeStats) {
AnalyzerTimers = std::make_unique<llvm::TimerGroup>(
"analyzer", "Analyzer timers");
SyntaxCheckTimer = std::make_unique<llvm::Timer>(
@@ -141,27 +141,27 @@ class AnalysisConsumer : public AnalysisASTConsumer,
*AnalyzerTimers);
}
- if (Opts->PrintStats || Opts->ShouldSerializeStats) {
+ if (Opts.PrintStats || Opts.ShouldSerializeStats) {
llvm::EnableStatistics(/* DoPrintOnExit= */ false);
}
- if (Opts->ShouldDisplayMacroExpansions)
+ if (Opts.ShouldDisplayMacroExpansions)
MacroExpansions.registerForPreprocessor(PP);
}
~AnalysisConsumer() override {
- if (Opts->PrintStats) {
+ if (Opts.PrintStats) {
llvm::PrintStatistics();
}
}
void DigestAnalyzerOptions() {
- switch (Opts->AnalysisDiagOpt) {
+ switch (Opts.AnalysisDiagOpt) {
case PD_NONE:
break;
#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN) \
case PD_##NAME: \
- CREATEFN(Opts->getDiagOpts(), PathConsumers, OutDir, PP, CTU, \
+ CREATEFN(Opts.getDiagOpts(), PathConsumers, OutDir, PP, CTU, \
MacroExpansions); \
break;
#include "clang/StaticAnalyzer/Core/Analyses.def"
@@ -172,7 +172,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
// Create the analyzer component creators.
CreateStoreMgr = &CreateRegionStoreManager;
- switch (Opts->AnalysisConstraintsOpt) {
+ switch (Opts.AnalysisConstraintsOpt) {
default:
llvm_unreachable("Unknown constraint manager.");
#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATEFN) \
@@ -182,7 +182,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
}
void DisplayTime(llvm::TimeRecord &Time) {
- if (!Opts->AnalyzerDisplayProgress) {
+ if (!Opts.AnalyzerDisplayProgress) {
return;
}
llvm::errs() << " : " << llvm::format("%1.1f", Time.getWallTime() * 1000)
@@ -191,7 +191,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
void DisplayFunction(const Decl *D, AnalysisMode Mode,
ExprEngine::InliningModes IMode) {
- if (!Opts->AnalyzerDisplayProgress)
+ if (!Opts.AnalyzerDisplayProgress)
return;
SourceManager &SM = Mgr->getASTContext().getSourceManager();
@@ -222,12 +222,12 @@ class AnalysisConsumer : public AnalysisASTConsumer,
void Initialize(ASTContext &Context) override {
Ctx = &Context;
- checkerMgr = std::make_unique<CheckerManager>(*Ctx, *Opts, PP, Plugins,
+ checkerMgr = std::make_unique<CheckerManager>(*Ctx, Opts, PP, Plugins,
CheckerRegistrationFns);
Mgr = std::make_unique<AnalysisManager>(*Ctx, PP, PathConsumers,
CreateStoreMgr, CreateConstraintMgr,
- checkerMgr.get(), *Opts, Injector);
+ checkerMgr.get(), Opts, Injector);
}
/// Store the top level decls in the set to be processed later on.
@@ -278,7 +278,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
}
bool VisitVarDecl(VarDecl *VD) {
- if (!Opts->IsNaiveCTUEnabled)
+ if (!Opts.IsNaiveCTUEnabled)
return true;
if (VD->hasExternalStorage() || VD->isStaticDataMember()) {
@@ -293,8 +293,8 @@ class AnalysisConsumer : public AnalysisASTConsumer,
return true;
llvm::Expected<const VarDecl *> CTUDeclOrError =
- CTU.getCrossTUDefinition(VD, Opts->CTUDir, Opts->CTUIndexName,
- Opts->DisplayCTUProgress);
+ CTU.getCrossTUDefinition(VD, Opts.CTUDir, Opts.CTUIndexName,
+ Opts.DisplayCTUProgress);
if (!CTUDeclOrError) {
handleAllErrors(CTUDeclOrError.takeError(),
@@ -356,7 +356,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
AnalysisMode getModeForDecl(Decl *D, AnalysisMode Mode);
void runAnalysisOnTranslationUnit(ASTContext &C);
- /// Print \p S to stderr if \c Opts->AnalyzerDisplayProgress is set.
+ /// Print \p S to stderr if \c Opts.AnalyzerDisplayProgress is set.
void reportAnalyzerProgress(StringRef S);
}; // namespace
} // end anonymous namespace
@@ -567,12 +567,12 @@ void AnalysisConsumer::runAnalysisOnTranslationUnit(ASTContext &C) {
// name correctly.
// FIXME: The user might have analyzed the requested function in Syntax mode,
// but we are unaware of that.
- if (!Opts->AnalyzeSpecificFunction.empty() && NumFunctionsAnalyzed == 0)
- reportAnalyzerFunctionMisuse(*Opts, *Ctx);
+ if (!Opts.AnalyzeSpecificFunction.empty() && NumFunctionsAnalyzed == 0)
+ reportAnalyzerFunctionMisuse(Opts, *Ctx);
}
void AnalysisConsumer::reportAnalyzerProgress(StringRef S) {
- if (Opts->AnalyzerDisplayProgress)
+ if (Opts.AnalyzerDisplayProgress)
llvm::errs() << S;
}
@@ -589,13 +589,13 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
const auto DiagFlusherScopeExit =
llvm::make_scope_exit([this] { Mgr.reset(); });
- if (Opts->ShouldIgnoreBisonGeneratedFiles &&
+ if (Opts.ShouldIgnoreBisonGeneratedFiles &&
fileContainsString("/* A Bison parser, made by", C)) {
reportAnalyzerProgress("Skipping bison-generated file\n");
return;
}
- if (Opts->ShouldIgnoreFlexGeneratedFiles &&
+ if (Opts.ShouldIgnoreFlexGeneratedFiles &&
fileContainsString("/* A lexical scanner generated by flex", C)) {
reportAnalyzerProgress("Skipping flex-generated file\n");
return;
@@ -603,7 +603,7 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
// Don't analyze if the user explicitly asked for no checks to be performed
// on this file.
- if (Opts->DisableAllCheckers) {
+ if (Opts.DisableAllCheckers) {
reportAnalyzerProgress("All checks are disabled using a supplied option\n");
return;
}
@@ -623,8 +623,8 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
AnalysisConsumer::AnalysisMode
AnalysisConsumer::getModeForDecl(Decl *D, AnalysisMode Mode) {
- if (!Opts->AnalyzeSpecificFunction.empty() &&
- AnalysisDeclContext::getFunctionName(D) != Opts->AnalyzeSpecificFunction)
+ if (!Opts.AnalyzeSpecificFunction.empty() &&
+ AnalysisDeclContext::getFunctionName(D) != Opts.AnalyzeSpecificFunction)
return AM_None;
// Unless -analyze-all is specified, treat decls
diff erently depending on
@@ -632,7 +632,7 @@ AnalysisConsumer::getModeForDecl(Decl *D, AnalysisMode Mode) {
// - Main source file: run both path-sensitive and non-path-sensitive checks.
// - Header files: run non-path-sensitive checks only.
// - System headers: don't run any checks.
- if (Opts->AnalyzeAll)
+ if (Opts.AnalyzeAll)
return Mode;
const SourceManager &SM = Ctx->getSourceManager();
@@ -757,8 +757,8 @@ ento::CreateAnalysisConsumer(CompilerInstance &CI) {
// Disable the effects of '-Werror' when using the AnalysisConsumer.
CI.getPreprocessor().getDiagnostics().setWarningsAsErrors(false);
- AnalyzerOptionsRef analyzerOpts = CI.getAnalyzerOpts();
- bool hasModelPath = analyzerOpts->Config.count("model-path") > 0;
+ AnalyzerOptions &analyzerOpts = CI.getAnalyzerOpts();
+ bool hasModelPath = analyzerOpts.Config.count("model-path") > 0;
return std::make_unique<AnalysisConsumer>(
CI, CI.getFrontendOpts().OutputFile, analyzerOpts,
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
index 7cd15f0f65954ae..ea75c794f0b703c 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
@@ -30,18 +30,18 @@ void ento::printCheckerHelp(raw_ostream &out, CompilerInstance &CI) {
out << "USAGE: -analyzer-checker <CHECKER or PACKAGE,...>\n\n";
auto CheckerMgr = std::make_unique<CheckerManager>(
- *CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
+ CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
CI.getFrontendOpts().Plugins);
CheckerMgr->getCheckerRegistryData().printCheckerWithDescList(
- *CI.getAnalyzerOpts(), out);
+ CI.getAnalyzerOpts(), out);
}
void ento::printEnabledCheckerList(raw_ostream &out, CompilerInstance &CI) {
out << "OVERVIEW: Clang Static Analyzer Enabled Checkers List\n\n";
auto CheckerMgr = std::make_unique<CheckerManager>(
- *CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
+ CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
CI.getFrontendOpts().Plugins);
CheckerMgr->getCheckerRegistryData().printEnabledCheckerList(out);
@@ -50,11 +50,11 @@ void ento::printEnabledCheckerList(raw_ostream &out, CompilerInstance &CI) {
void ento::printCheckerConfigList(raw_ostream &out, CompilerInstance &CI) {
auto CheckerMgr = std::make_unique<CheckerManager>(
- *CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
+ CI.getAnalyzerOpts(), CI.getLangOpts(), CI.getDiagnostics(),
CI.getFrontendOpts().Plugins);
CheckerMgr->getCheckerRegistryData().printCheckerOptionList(
- *CI.getAnalyzerOpts(), out);
+ CI.getAnalyzerOpts(), out);
}
void ento::printAnalyzerConfigList(raw_ostream &out) {
diff --git a/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp b/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
index 7baae6778ebd49c..ae11fbbe32b7627 100644
--- a/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp
@@ -48,8 +48,7 @@ void ModelInjector::onBodySynthesis(const NamedDecl *D) {
SourceManager &SM = CI.getSourceManager();
FileID mainFileID = SM.getMainFileID();
- AnalyzerOptionsRef analyzerOpts = CI.getAnalyzerOpts();
- llvm::StringRef modelPath = analyzerOpts->ModelPath;
+ llvm::StringRef modelPath = CI.getAnalyzerOpts().ModelPath;
llvm::SmallString<128> fileName;
diff --git a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
index d39bacdf50e8ff7..28f71d61e2c57f1 100644
--- a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -125,8 +125,8 @@ class CTUAction : public clang::ASTFrontendAction {
protected:
std::unique_ptr<clang::ASTConsumer>
CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
- CI.getAnalyzerOpts()->CTUImportThreshold = OverrideLimit;
- CI.getAnalyzerOpts()->CTUImportCppThreshold = OverrideLimit;
+ CI.getAnalyzerOpts().CTUImportThreshold = OverrideLimit;
+ CI.getAnalyzerOpts().CTUImportCppThreshold = OverrideLimit;
return std::make_unique<CTUASTConsumer>(CI, Success);
}
diff --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 673b34dc088fa7f..36a2edaf362818b 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -102,23 +102,23 @@ TEST(ContainsN, Two) {
TEST(CompilerInvocationTest, DeepCopyConstructor) {
CompilerInvocation A;
- A.getAnalyzerOpts()->Config["Key"] = "Old";
+ A.getAnalyzerOpts().Config["Key"] = "Old";
CompilerInvocation B(A);
- B.getAnalyzerOpts()->Config["Key"] = "New";
+ B.getAnalyzerOpts().Config["Key"] = "New";
- ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
+ ASSERT_EQ(A.getAnalyzerOpts().Config["Key"], "Old");
}
TEST(CompilerInvocationTest, DeepCopyAssignment) {
CompilerInvocation A;
- A.getAnalyzerOpts()->Config["Key"] = "Old";
+ A.getAnalyzerOpts().Config["Key"] = "Old";
CompilerInvocation B;
B = A;
- B.getAnalyzerOpts()->Config["Key"] = "New";
+ B.getAnalyzerOpts().Config["Key"] = "New";
- ASSERT_EQ(A.getAnalyzerOpts()->Config["Key"], "Old");
+ ASSERT_EQ(A.getAnalyzerOpts().Config["Key"], "Old");
}
// Boolean option with a keypath that defaults to true.
@@ -982,8 +982,8 @@ TEST_F(CommandLineTest, RoundTrip) {
Contains(std::make_pair(std::string("XY=AB"), false)));
ASSERT_EQ(Invocation.getPreprocessorOpts().ImplicitPCHInclude, "a.pch");
- ASSERT_EQ(Invocation.getAnalyzerOpts()->Config["ctu-import-threshold"], "42");
- ASSERT_TRUE(Invocation.getAnalyzerOpts()->UnoptimizedCFG);
+ ASSERT_EQ(Invocation.getAnalyzerOpts().Config["ctu-import-threshold"], "42");
+ ASSERT_TRUE(Invocation.getAnalyzerOpts().UnoptimizedCFG);
ASSERT_TRUE(Invocation.getMigratorOpts().NoNSAllocReallocError);
diff --git a/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp b/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
index 26f69df5dddc14f..5f562b1c98b0ee4 100644
--- a/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
+++ b/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
@@ -118,7 +118,7 @@ class TestAction : public ASTFrontendAction {
Registry.addChecker<InterestingnessTestChecker>("test.Interestingness",
"Description", "");
});
- Compiler.getAnalyzerOpts()->CheckersAndPackages = {
+ Compiler.getAnalyzerOpts().CheckersAndPackages = {
{"test.Interestingness", true}};
return std::move(AnalysisConsumer);
}
diff --git a/clang/unittests/StaticAnalyzer/CheckerRegistration.h b/clang/unittests/StaticAnalyzer/CheckerRegistration.h
index bccdb94d2938334..82646167ba54536 100644
--- a/clang/unittests/StaticAnalyzer/CheckerRegistration.h
+++ b/clang/unittests/StaticAnalyzer/CheckerRegistration.h
@@ -99,7 +99,7 @@ template <AddCheckerFn... Fns> class TestAction : public ASTFrontendAction {
else
AnalysisConsumer->AddDiagnosticConsumer(
new PathDiagConsumer(DiagsOutput));
- addChecker<Fns...>(*AnalysisConsumer, *Compiler.getAnalyzerOpts());
+ addChecker<Fns...>(*AnalysisConsumer, Compiler.getAnalyzerOpts());
return std::move(AnalysisConsumer);
}
};
diff --git a/clang/unittests/StaticAnalyzer/Reusables.h b/clang/unittests/StaticAnalyzer/Reusables.h
index 609983e783ffd00..5bd62a3e6804726 100644
--- a/clang/unittests/StaticAnalyzer/Reusables.h
+++ b/clang/unittests/StaticAnalyzer/Reusables.h
@@ -58,11 +58,11 @@ class ExprEngineConsumer : public ASTConsumer {
public:
ExprEngineConsumer(CompilerInstance &C)
: C(C),
- ChkMgr(C.getASTContext(), *C.getAnalyzerOpts(), C.getPreprocessor()),
+ ChkMgr(C.getASTContext(), C.getAnalyzerOpts(), C.getPreprocessor()),
CTU(C), Consumers(),
AMgr(C.getASTContext(), C.getPreprocessor(), Consumers,
CreateRegionStoreManager, CreateRangeConstraintManager, &ChkMgr,
- *C.getAnalyzerOpts()),
+ C.getAnalyzerOpts()),
VisitedCallees(), FS(),
Eng(CTU, AMgr, &VisitedCallees, &FS, ExprEngine::Inline_Regular) {}
};
More information about the cfe-commits
mailing list