@@ -87,7 +87,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
87
87
ASTContext *Ctx;
88
88
Preprocessor &PP;
89
89
const std::string OutDir;
90
- AnalyzerOptionsRef Opts;
90
+ AnalyzerOptions & Opts;
91
91
ArrayRef<std::string> Plugins;
92
92
CodeInjector *Injector;
93
93
cross_tu::CrossTranslationUnitContext CTU;
@@ -121,15 +121,15 @@ class AnalysisConsumer : public AnalysisASTConsumer,
121
121
FunctionSummariesTy FunctionSummaries;
122
122
123
123
AnalysisConsumer (CompilerInstance &CI, const std::string &outdir,
124
- AnalyzerOptionsRef opts, ArrayRef<std::string> plugins,
124
+ AnalyzerOptions & opts, ArrayRef<std::string> plugins,
125
125
CodeInjector *injector)
126
126
: RecVisitorMode(0 ), RecVisitorBR(nullptr ), Ctx(nullptr ),
127
- PP (CI.getPreprocessor()), OutDir(outdir), Opts(std::move( opts) ),
127
+ PP (CI.getPreprocessor()), OutDir(outdir), Opts(opts),
128
128
Plugins(plugins), Injector(injector), CTU(CI),
129
129
MacroExpansions(CI.getLangOpts()) {
130
130
DigestAnalyzerOptions ();
131
- if (Opts-> AnalyzerDisplayProgress || Opts-> PrintStats ||
132
- Opts-> ShouldSerializeStats ) {
131
+ if (Opts. AnalyzerDisplayProgress || Opts. PrintStats ||
132
+ Opts. ShouldSerializeStats ) {
133
133
AnalyzerTimers = std::make_unique<llvm::TimerGroup>(
134
134
" analyzer" , " Analyzer timers" );
135
135
SyntaxCheckTimer = std::make_unique<llvm::Timer>(
@@ -141,27 +141,27 @@ class AnalysisConsumer : public AnalysisASTConsumer,
141
141
*AnalyzerTimers);
142
142
}
143
143
144
- if (Opts-> PrintStats || Opts-> ShouldSerializeStats ) {
144
+ if (Opts. PrintStats || Opts. ShouldSerializeStats ) {
145
145
llvm::EnableStatistics (/* DoPrintOnExit= */ false );
146
146
}
147
147
148
- if (Opts-> ShouldDisplayMacroExpansions )
148
+ if (Opts. ShouldDisplayMacroExpansions )
149
149
MacroExpansions.registerForPreprocessor (PP);
150
150
}
151
151
152
152
~AnalysisConsumer () override {
153
- if (Opts-> PrintStats ) {
153
+ if (Opts. PrintStats ) {
154
154
llvm::PrintStatistics ();
155
155
}
156
156
}
157
157
158
158
void DigestAnalyzerOptions () {
159
- switch (Opts-> AnalysisDiagOpt ) {
159
+ switch (Opts. AnalysisDiagOpt ) {
160
160
case PD_NONE:
161
161
break ;
162
162
#define ANALYSIS_DIAGNOSTICS (NAME, CMDFLAG, DESC, CREATEFN ) \
163
163
case PD_##NAME: \
164
- CREATEFN (Opts-> getDiagOpts (), PathConsumers, OutDir, PP, CTU, \
164
+ CREATEFN (Opts. getDiagOpts (), PathConsumers, OutDir, PP, CTU, \
165
165
MacroExpansions); \
166
166
break ;
167
167
#include " clang/StaticAnalyzer/Core/Analyses.def"
@@ -172,7 +172,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
172
172
// Create the analyzer component creators.
173
173
CreateStoreMgr = &CreateRegionStoreManager;
174
174
175
- switch (Opts-> AnalysisConstraintsOpt ) {
175
+ switch (Opts. AnalysisConstraintsOpt ) {
176
176
default :
177
177
llvm_unreachable (" Unknown constraint manager." );
178
178
#define ANALYSIS_CONSTRAINTS (NAME, CMDFLAG, DESC, CREATEFN ) \
@@ -182,7 +182,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
182
182
}
183
183
184
184
void DisplayTime (llvm::TimeRecord &Time) {
185
- if (!Opts-> AnalyzerDisplayProgress ) {
185
+ if (!Opts. AnalyzerDisplayProgress ) {
186
186
return ;
187
187
}
188
188
llvm::errs () << " : " << llvm::format (" %1.1f" , Time.getWallTime () * 1000 )
@@ -191,7 +191,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
191
191
192
192
void DisplayFunction (const Decl *D, AnalysisMode Mode,
193
193
ExprEngine::InliningModes IMode) {
194
- if (!Opts-> AnalyzerDisplayProgress )
194
+ if (!Opts. AnalyzerDisplayProgress )
195
195
return ;
196
196
197
197
SourceManager &SM = Mgr->getASTContext ().getSourceManager ();
@@ -222,12 +222,12 @@ class AnalysisConsumer : public AnalysisASTConsumer,
222
222
223
223
void Initialize (ASTContext &Context) override {
224
224
Ctx = &Context;
225
- checkerMgr = std::make_unique<CheckerManager>(*Ctx, * Opts, PP, Plugins,
225
+ checkerMgr = std::make_unique<CheckerManager>(*Ctx, Opts, PP, Plugins,
226
226
CheckerRegistrationFns);
227
227
228
228
Mgr = std::make_unique<AnalysisManager>(*Ctx, PP, PathConsumers,
229
229
CreateStoreMgr, CreateConstraintMgr,
230
- checkerMgr.get (), * Opts, Injector);
230
+ checkerMgr.get (), Opts, Injector);
231
231
}
232
232
233
233
// / Store the top level decls in the set to be processed later on.
@@ -278,7 +278,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
278
278
}
279
279
280
280
bool VisitVarDecl (VarDecl *VD) {
281
- if (!Opts-> IsNaiveCTUEnabled )
281
+ if (!Opts. IsNaiveCTUEnabled )
282
282
return true ;
283
283
284
284
if (VD->hasExternalStorage () || VD->isStaticDataMember ()) {
@@ -293,8 +293,8 @@ class AnalysisConsumer : public AnalysisASTConsumer,
293
293
return true ;
294
294
295
295
llvm::Expected<const VarDecl *> CTUDeclOrError =
296
- CTU.getCrossTUDefinition (VD, Opts-> CTUDir , Opts-> CTUIndexName ,
297
- Opts-> DisplayCTUProgress );
296
+ CTU.getCrossTUDefinition (VD, Opts. CTUDir , Opts. CTUIndexName ,
297
+ Opts. DisplayCTUProgress );
298
298
299
299
if (!CTUDeclOrError) {
300
300
handleAllErrors (CTUDeclOrError.takeError (),
@@ -356,7 +356,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
356
356
AnalysisMode getModeForDecl (Decl *D, AnalysisMode Mode);
357
357
void runAnalysisOnTranslationUnit (ASTContext &C);
358
358
359
- // / Print \p S to stderr if \c Opts-> AnalyzerDisplayProgress is set.
359
+ // / Print \p S to stderr if \c Opts. AnalyzerDisplayProgress is set.
360
360
void reportAnalyzerProgress (StringRef S);
361
361
}; // namespace
362
362
} // end anonymous namespace
@@ -567,12 +567,12 @@ void AnalysisConsumer::runAnalysisOnTranslationUnit(ASTContext &C) {
567
567
// name correctly.
568
568
// FIXME: The user might have analyzed the requested function in Syntax mode,
569
569
// but we are unaware of that.
570
- if (!Opts-> AnalyzeSpecificFunction .empty () && NumFunctionsAnalyzed == 0 )
571
- reportAnalyzerFunctionMisuse (* Opts, *Ctx);
570
+ if (!Opts. AnalyzeSpecificFunction .empty () && NumFunctionsAnalyzed == 0 )
571
+ reportAnalyzerFunctionMisuse (Opts, *Ctx);
572
572
}
573
573
574
574
void AnalysisConsumer::reportAnalyzerProgress (StringRef S) {
575
- if (Opts-> AnalyzerDisplayProgress )
575
+ if (Opts. AnalyzerDisplayProgress )
576
576
llvm::errs () << S;
577
577
}
578
578
@@ -589,21 +589,21 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
589
589
const auto DiagFlusherScopeExit =
590
590
llvm::make_scope_exit ([this ] { Mgr.reset (); });
591
591
592
- if (Opts-> ShouldIgnoreBisonGeneratedFiles &&
592
+ if (Opts. ShouldIgnoreBisonGeneratedFiles &&
593
593
fileContainsString (" /* A Bison parser, made by" , C)) {
594
594
reportAnalyzerProgress (" Skipping bison-generated file\n " );
595
595
return ;
596
596
}
597
597
598
- if (Opts-> ShouldIgnoreFlexGeneratedFiles &&
598
+ if (Opts. ShouldIgnoreFlexGeneratedFiles &&
599
599
fileContainsString (" /* A lexical scanner generated by flex" , C)) {
600
600
reportAnalyzerProgress (" Skipping flex-generated file\n " );
601
601
return ;
602
602
}
603
603
604
604
// Don't analyze if the user explicitly asked for no checks to be performed
605
605
// on this file.
606
- if (Opts-> DisableAllCheckers ) {
606
+ if (Opts. DisableAllCheckers ) {
607
607
reportAnalyzerProgress (" All checks are disabled using a supplied option\n " );
608
608
return ;
609
609
}
@@ -623,16 +623,16 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
623
623
624
624
AnalysisConsumer::AnalysisMode
625
625
AnalysisConsumer::getModeForDecl (Decl *D, AnalysisMode Mode) {
626
- if (!Opts-> AnalyzeSpecificFunction .empty () &&
627
- AnalysisDeclContext::getFunctionName (D) != Opts-> AnalyzeSpecificFunction )
626
+ if (!Opts. AnalyzeSpecificFunction .empty () &&
627
+ AnalysisDeclContext::getFunctionName (D) != Opts. AnalyzeSpecificFunction )
628
628
return AM_None;
629
629
630
630
// Unless -analyze-all is specified, treat decls differently depending on
631
631
// where they came from:
632
632
// - Main source file: run both path-sensitive and non-path-sensitive checks.
633
633
// - Header files: run non-path-sensitive checks only.
634
634
// - System headers: don't run any checks.
635
- if (Opts-> AnalyzeAll )
635
+ if (Opts. AnalyzeAll )
636
636
return Mode;
637
637
638
638
const SourceManager &SM = Ctx->getSourceManager ();
@@ -757,8 +757,8 @@ ento::CreateAnalysisConsumer(CompilerInstance &CI) {
757
757
// Disable the effects of '-Werror' when using the AnalysisConsumer.
758
758
CI.getPreprocessor ().getDiagnostics ().setWarningsAsErrors (false );
759
759
760
- AnalyzerOptionsRef analyzerOpts = CI.getAnalyzerOpts ();
761
- bool hasModelPath = analyzerOpts-> Config .count (" model-path" ) > 0 ;
760
+ AnalyzerOptions & analyzerOpts = CI.getAnalyzerOpts ();
761
+ bool hasModelPath = analyzerOpts. Config .count (" model-path" ) > 0 ;
762
762
763
763
return std::make_unique<AnalysisConsumer>(
764
764
CI, CI.getFrontendOpts ().OutputFile , analyzerOpts,
0 commit comments