clang: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H

15#define LLVM_CLANG_STATICANALYZER_CORE_ANALYZEROPTIONS_H

16

19#include "llvm/ADT/IntrusiveRefCntPtr.h"

20#include "llvm/ADT/StringMap.h"

21#include "llvm/ADT/StringRef.h"

22#include

23#include

24#include

25

27

28namespace ento {

29

30class CheckerBase;

31

32}

33

34

36#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) NAME##Model,

37#include "clang/StaticAnalyzer/Core/Analyses.def"

40

41

42

44#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN) PD_##NAME,

45#include "clang/StaticAnalyzer/Core/Analyses.def"

49

50

52#define ANALYSIS_PURGE(NAME, CMDFLAG, DESC) NAME,

53#include "clang/StaticAnalyzer/Core/Analyses.def"

56

57

59#define ANALYSIS_INLINING_MODE(NAME, CMDFLAG, DESC) NAME,

60#include "clang/StaticAnalyzer/Core/Analyses.def"

63

64

65

66

67

68

70

71

72

74

75

77

78

79

80

81

83

84

87

88

90

92

93

95

96

98

99

101

102

103

106

114};

115

116

118

120

121

124

126

128public:

131 assert(Value > 0 && "only positive values are accepted");

132 }

137 return *this;

138 }

139

140 static constexpr std::optional create(unsigned Val) {

141 if (Val == 0)

142 return std::nullopt;

144 }

145 static std::optional create(StringRef Str) {

146 unsigned Parsed = 0;

147 if (Str.getAsInteger(0, Parsed))

148 return std::nullopt;

150 }

152

153private:

154 unsigned Value = 1;

155};

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

180public:

182

183

184

185 static std::vector

187

188

189

190 static std::vector

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

211 std::pair<StringRef, StringRef> EntryDescPair,

212 size_t InitialPad, size_t EntryWidth,

213 size_t MinLineWidth = 0);

214

215

217

218

220

221

222

227

229

230

232

233

234

236

237

239

240

241

242

243

244

246

250

254

261

266

267

268

270

271

273

274

276

277

279

280

281#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \

282 SHALLOW_VAL, DEEP_VAL) \

283 ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL)

284

285#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL) \

286 TYPE NAME;

287

288#include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"

289#undef ANALYZER_OPTION

290#undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE

291

293 static std::vectorllvm::StringLiteral AnalyzerConfigCmdFlags = []() {

294

295 std::vectorllvm::StringLiteral AnalyzerConfigCmdFlags = {

296#define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC, \

297 SHALLOW_VAL, DEEP_VAL) \

298 ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL)

299

300#define ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, DEFAULT_VAL) \

301 llvm::StringLiteral(CMDFLAG),

302

303#include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"

304#undef ANALYZER_OPTION

305#undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE

306 };

307

308 llvm::sort(AnalyzerConfigCmdFlags);

309 return AnalyzerConfigCmdFlags;

310 }();

311

312 return !std::binary_search(AnalyzerConfigCmdFlags.begin(),

313 AnalyzerConfigCmdFlags.end(), Name);

314 }

315

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

344 bool SearchInParents = false) const;

345

347 bool SearchInParents = false) const;

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

364 bool SearchInParents = false) const;

365

367 bool SearchInParents = false) const;

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

384 bool SearchInParents = false) const;

385

387 StringRef OptionName,

388 bool SearchInParents = false) const;

389

392

393

395

396

397

398

399

400

401

403

406 ShouldDisplayMacroExpansions,

407 ShouldSerializeStats,

408

409

410

411

412 ShouldWriteStableReportFilename || ShouldWriteVerboseReportFilename,

414 ShouldApplyFixIts,

415 ShouldDisplayCheckerNameForText};

416 }

417};

418

420

421

422

423

424

425

426

427

428

429inline std::vector

431 static constexpr llvm::StringLiteral StaticAnalyzerCheckerNames[] = {

432#define GET_CHECKERS

433#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \

434 llvm::StringLiteral(FULLNAME),

435#include "clang/StaticAnalyzer/Checkers/Checkers.inc"

436#undef CHECKER

437#undef GET_CHECKERS

438 };

439 std::vector Checkers;

440 for (StringRef CheckerName : StaticAnalyzerCheckerNames) {

441 if (!CheckerName.starts_with("debug.") &&

442 (IncludeExperimental || !CheckerName.starts_with("alpha.")))

443 Checkers.push_back(CheckerName);

444 }

445 return Checkers;

446}

447

448inline std::vector

450 static constexpr llvm::StringLiteral StaticAnalyzerPackageNames[] = {

451#define GET_PACKAGES

452#define PACKAGE(FULLNAME) llvm::StringLiteral(FULLNAME),

453#include "clang/StaticAnalyzer/Checkers/Checkers.inc"

454#undef PACKAGE

455#undef GET_PACKAGES

456 };

457 std::vector Packages;

458 for (StringRef PackageName : StaticAnalyzerPackageNames) {

459 if (PackageName != "debug" &&

460 (IncludeExperimental || PackageName != "alpha"))

461 Packages.push_back(PackageName);

462 }

463 return Packages;

464}

465

466}

467

468#endif

Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.

Stores options for the analyzer from the command line.

static std::vector< StringRef > getRegisteredPackages(bool IncludeExperimental=false)

Retrieves the list of packages generated from Checkers.td.

std::vector< std::pair< std::string, bool > > CheckersAndPackages

Pairs of checker/package name and enable/disable.

unsigned ShowCheckerOptionDeveloperList

unsigned DisableAllCheckers

Disable all analyzer checkers.

std::vector< std::string > SilencedCheckersAndPackages

Vector of checker/package names which will not emit warnings.

unsigned ShowEnabledCheckerList

unsigned ShowCheckerHelpAlpha

unsigned NoRetryExhausted

Do not re-analyze paths leading to exhausted nodes with a different strategy.

AnalysisDiagClients AnalysisDiagOpt

bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const

Returns the option controlling which C++ member functions will be considered for inlining.

AnalysisConstraints AnalysisConstraintsOpt

unsigned ShowConfigOptionsList

unsigned visualizeExplodedGraphWithGraphViz

bool AnalyzerWerror

Emit analyzer warnings as errors.

unsigned AnalyzerNoteAnalysisEntryPoints

ConfigTable Config

A key-value table of use-specified configuration values.

bool getCheckerBooleanOption(StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const

Interprets an option's string value as a boolean.

unsigned maxBlockVisitOnPath

The maximum number of times the analyzer visits a block.

std::string AnalyzeSpecificFunction

unsigned ShowCheckerHelpDeveloper

IPAKind getIPAMode() const

Returns the inter-procedural analysis mode.

std::string DumpExplodedGraphTo

File path to which the exploded graph should be dumped.

unsigned ShouldEmitErrorsOnInvalidConfigValue

ento::PathDiagnosticConsumerOptions getDiagOpts() const

CTUPhase1InliningKind getCTUPhase1Inlining() const

AnalysisPurgeMode AnalysisPurgeOpt

unsigned ShowCheckerOptionList

bool isUnknownAnalyzerConfig(llvm::StringRef Name)

static std::vector< StringRef > getRegisteredCheckers(bool IncludeExperimental=false)

Retrieves the list of checkers generated from Checkers.td.

unsigned InlineMaxStackDepth

The inlining stack depth limit.

llvm::StringMap< std::string > ConfigTable

unsigned AnalyzerDisplayProgress

int getCheckerIntegerOption(StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const

Interprets an option's string value as an integer value.

static void printFormattedEntry(llvm::raw_ostream &Out, std::pair< StringRef, StringRef > EntryDescPair, size_t InitialPad, size_t EntryWidth, size_t MinLineWidth=0)

Convenience function for printing options or checkers and their description in a formatted manner.

ExplorationStrategyKind getExplorationStrategy() const

StringRef getCheckerStringOption(StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const

Query an option's string value.

unsigned ShowCheckerOptionAlphaList

std::string FullCompilerInvocation

Store full compiler invocation for reproducible instructions in the generated report.

AnalysisInliningMode InliningMode

The mode of function selection used during inlining.

static std::optional< PositiveAnalyzerOption > create(StringRef Str)

constexpr PositiveAnalyzerOption(const PositiveAnalyzerOption &)=default

constexpr PositiveAnalyzerOption(unsigned Value)

constexpr PositiveAnalyzerOption()=default

static constexpr std::optional< PositiveAnalyzerOption > create(unsigned Val)

constexpr PositiveAnalyzerOption & operator=(const PositiveAnalyzerOption &Other)

The JSON file list parser is used to communicate input to InstallAPI.

UserModeKind

Describes the kinds for high-level analyzer mode.

@ UMK_Deep

Perform deep analyzes.

@ UMK_Shallow

Perform shallow but fast analyzes.

IPAKind

Describes the different modes of inter-procedural analysis.

@ IPAK_Inlining

Inline callees(C, C++, ObjC) when their definitions are available.

@ IPAK_BasicInlining

Inline C functions and blocks when their definitions are available.

@ IPAK_None

Perform only intra-procedural analysis.

@ IPAK_DynamicDispatch

Enable inlining of dynamically dispatched methods.

@ IPAK_DynamicDispatchBifurcate

Enable inlining of dynamically dispatched methods, bifurcate paths when exact type info is unavailabl...

AnalysisConstraints

AnalysisConstraints - Set of available constraint models.

CXXInlineableMemberKind

Describes the different kinds of C++ member functions which can be considered for inlining by the ana...

@ CIMK_Destructors

Refers to destructors (implicit or explicit).

@ CIMK_MemberFunctions

Refers to regular member function and operator calls.

@ CIMK_Constructors

Refers to constructors (implicit or explicit).

@ CIMK_None

A dummy mode in which no C++ inlining is enabled.

AnalysisPurgeMode

AnalysisPurgeModes - Set of available strategies for dead symbol removal.

AnalysisDiagClients

AnalysisDiagClients - Set of available diagnostic clients for rendering analysis results.

@ NUM_ANALYSIS_DIAG_CLIENTS

AnalysisInliningMode

AnalysisInlineFunctionSelection - Set of inlining function selection heuristics.

@ None

The alignment was not explicit in code.

@ UnexploredFirstLocationQueue

@ Other

Other implicit parameter.

These options tweak the behavior of path diangostic consumers.