///
/// Accepts the strings "true" and "false".
/// If an option value is not provided, returns the given \p DefaultVal.
- bool getBooleanOption(StringRef Name, bool DefaultVal) const;
+ bool getBooleanOption(StringRef Name, bool DefaultVal);
/// Interprets an option's string value as an integer value.
int getOptionAsInteger(llvm::StringRef Name, int DefaultVal) const;
bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const;
/// Returns true if ObjectiveC inlining is enabled, false otherwise.
- bool mayInlineObjCMethod() const;
+ bool mayInlineObjCMethod();
/// Returns whether or not the destructors for C++ temporary objects should
/// be included in the CFG.
///
/// This is controlled by the 'cfg-temporary-dtors' config option, which
/// accepts the values "true" and "false".
- bool includeTemporaryDtorsInCFG() const;
+ bool includeTemporaryDtorsInCFG();
/// Returns whether or not C++ standard library functions may be considered
/// for inlining.
///
/// This is controlled by the 'c++-stdlib-inlining' config option, which
/// accepts the values "true" and "false".
- bool mayInlineCXXStandardLibrary() const;
+ bool mayInlineCXXStandardLibrary();
/// Returns whether or not templated functions may be considered for inlining.
///
/// This is controlled by the 'c++-template-inlining' config option, which
/// accepts the values "true" and "false".
- bool mayInlineTemplateFunctions() const;
+ bool mayInlineTemplateFunctions();
/// Returns whether or not paths that go through null returns should be
/// suppressed.
///
/// This is controlled by the 'suppress-null-return-paths' config option,
/// which accepts the values "true" and "false".
- bool shouldPruneNullReturnPaths() const;
+ bool shouldPruneNullReturnPaths();
// Returns the size of the functions (in basic blocks), which should be
// considered to be small enough to always inline.
/// Returns true if the analyzer engine should synthesize fake bodies
/// for well-known functions.
- bool shouldSynthesizeBodies() const;
+ bool shouldSynthesizeBodies();
public:
AnalyzerOptions() : CXXMemberInliningMode() {
CheckerManager *CheckerMgr;
public:
- const AnalyzerOptions &options;
+ AnalyzerOptions &options;
AnalysisManager(ASTContext &ctx,DiagnosticsEngine &diags,
const LangOptions &lang,
StoreManagerCreator storemgr,
ConstraintManagerCreator constraintmgr,
CheckerManager *checkerMgr,
- const AnalyzerOptions &Options);
+ AnalyzerOptions &Options);
~AnalysisManager();
StoreManagerCreator storemgr,
ConstraintManagerCreator constraintmgr,
CheckerManager *checkerMgr,
- const AnalyzerOptions &Options)
+ AnalyzerOptions &Options)
: AnaCtxMgr(Options.UnoptimizedCFG,
/*AddImplicitDtors=*/true,
/*AddInitializers=*/true,
return CXXMemberInliningMode >= K;
}
-bool AnalyzerOptions::getBooleanOption(StringRef Name, bool DefaultVal) const {
+static StringRef toString(bool b) { return b ? "true" : "false"; }
+
+bool AnalyzerOptions::getBooleanOption(StringRef Name, bool DefaultVal) {
// FIXME: We should emit a warning here if the value is something other than
// "true", "false", or the empty string (meaning the default value),
// but the AnalyzerOptions doesn't have access to a diagnostic engine.
- return llvm::StringSwitch<bool>(Config.lookup(Name))
- .Case("true", true)
- .Case("false", false)
- .Default(DefaultVal);
+ StringRef V(Config.GetOrCreateValue(Name, toString(DefaultVal)).getValue());
+ return llvm::StringSwitch<bool>(V)
+ .Case("true", true)
+ .Case("false", false)
+ .Default(DefaultVal);
}
-bool AnalyzerOptions::includeTemporaryDtorsInCFG() const {
+bool AnalyzerOptions::includeTemporaryDtorsInCFG() {
if (!IncludeTemporaryDtorsInCFG.hasValue())
const_cast<llvm::Optional<bool> &>(IncludeTemporaryDtorsInCFG) =
getBooleanOption("cfg-temporary-dtors", /*Default=*/false);
return *IncludeTemporaryDtorsInCFG;
}
-bool AnalyzerOptions::mayInlineCXXStandardLibrary() const {
+bool AnalyzerOptions::mayInlineCXXStandardLibrary() {
if (!InlineCXXStandardLibrary.hasValue())
const_cast<llvm::Optional<bool> &>(InlineCXXStandardLibrary) =
getBooleanOption("c++-stdlib-inlining", /*Default=*/true);
return *InlineCXXStandardLibrary;
}
-bool AnalyzerOptions::mayInlineTemplateFunctions() const {
+bool AnalyzerOptions::mayInlineTemplateFunctions() {
if (!InlineTemplateFunctions.hasValue())
const_cast<llvm::Optional<bool> &>(InlineTemplateFunctions) =
getBooleanOption("c++-template-inlining", /*Default=*/true);
return *InlineTemplateFunctions;
}
-bool AnalyzerOptions::mayInlineObjCMethod() const {
+bool AnalyzerOptions::mayInlineObjCMethod() {
if (!ObjCInliningMode.hasValue())
const_cast<llvm::Optional<bool> &>(ObjCInliningMode) =
getBooleanOption("objc-inlining", /*Default=*/true);
return *ObjCInliningMode;
}
-bool AnalyzerOptions::shouldPruneNullReturnPaths() const {
+bool AnalyzerOptions::shouldPruneNullReturnPaths() {
if (!PruneNullReturnPaths.hasValue())
const_cast<llvm::Optional<bool> &>(PruneNullReturnPaths) =
getBooleanOption("suppress-null-return-paths", /*Default=*/true);
return AlwaysInlineSize.getValue();
}
-bool AnalyzerOptions::shouldSynthesizeBodies() const {
+bool AnalyzerOptions::shouldSynthesizeBodies() {
return getBooleanOption("faux-bodies", true);
}
const StackFrameContext *CallerSFC = CurLC->getCurrentStackFrame();
const LocationContext *ParentOfCallee = 0;
- const AnalyzerOptions &Opts = getAnalysisManager().options;
+ AnalyzerOptions &Opts = getAnalysisManager().options;
// FIXME: Refactor this check into a hypothetical CallEvent::canInline.
switch (Call.getKind()) {
--- /dev/null
+// RUN: %clang --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+void bar() {}
+void foo() { bar(); }
+
+// CHECK: [config]
+// CHECK-NEXT: cfg-temporary-dtors = false
+// CHECK-NEXT: faux-bodies = true
+// CHECK-NEXT: [stats]
+// CHECK-NEXT: num-entries = 2