17 #include "llvm/ADT/SmallString.h"
18 #include "llvm/ADT/StringSwitch.h"
19 #include "llvm/Support/ErrorHandling.h"
20 #include "llvm/Support/raw_ostream.h"
22 using namespace clang;
27 if (UserMode == UMK_NotSet) {
29 Config.insert(std::make_pair(
"mode",
"deep")).first->second;
30 UserMode = llvm::StringSwitch<UserModeKind>(ModeStr)
31 .Case(
"shallow", UMK_Shallow)
32 .Case(
"deep", UMK_Deep)
34 assert(UserMode != UMK_NotSet &&
"User mode is invalid.");
45 const char *DefaultIPA =
nullptr;
46 UserModeKind HighLevelMode = getUserMode();
47 if (HighLevelMode == UMK_Shallow)
48 DefaultIPA =
"inlining";
49 else if (HighLevelMode == UMK_Deep)
50 DefaultIPA =
"dynamic-bifurcate";
55 Config.insert(std::make_pair(
"ipa", DefaultIPA)).first->second;
56 IPAKind IPAConfig = llvm::StringSwitch<IPAKind>(ModeStr)
63 assert(IPAConfig !=
IPAK_NotSet &&
"IPA Mode is invalid.");
77 if (!CXXMemberInliningMode) {
78 static const char *ModeKey =
"c++-inlining";
81 Config.insert(std::make_pair(ModeKey,
"destructors")).first->second;
86 MutableMode = llvm::StringSwitch<CXXInlineableMemberKind>(ModeStr)
100 return CXXMemberInliningMode >= K;
103 static StringRef
toString(
bool b) {
return b ?
"true" :
"false"; }
105 StringRef AnalyzerOptions::getCheckerOption(StringRef CheckerName,
106 StringRef OptionName,
108 bool SearchInParents) {
111 ConfigTable::const_iterator E = Config.end();
113 ConfigTable::const_iterator I =
114 Config.find((Twine(CheckerName) +
":" + OptionName).str());
116 return StringRef(I->getValue());
117 size_t Pos = CheckerName.rfind(
'.');
118 if (Pos == StringRef::npos)
120 CheckerName = CheckerName.substr(0, Pos);
121 }
while (!CheckerName.empty() && SearchInParents);
127 bool SearchInParents) {
131 StringRef Default =
toString(DefaultVal);
135 : StringRef(Config.insert(std::make_pair(Name, Default)).first->second);
136 return llvm::StringSwitch<bool>(V)
138 .Case(
"false",
false)
139 .Default(DefaultVal);
144 bool SearchInParents) {
146 V = getBooleanOption(Name, DefaultVal, C, SearchInParents);
151 return getBooleanOption(IncludeTemporaryDtorsInCFG,
152 "cfg-temporary-dtors",
157 return getBooleanOption(InlineCXXStandardLibrary,
158 "c++-stdlib-inlining",
163 return getBooleanOption(InlineTemplateFunctions,
164 "c++-template-inlining",
169 return getBooleanOption(InlineCXXAllocator,
170 "c++-allocator-inlining",
175 return getBooleanOption(InlineCXXContainerMethods,
176 "c++-container-inlining",
181 return getBooleanOption(InlineCXXSharedPtrDtor,
182 "c++-shared_ptr-inlining",
188 return getBooleanOption(ObjCInliningMode,
194 return getBooleanOption(SuppressNullReturnPaths,
195 "suppress-null-return-paths",
200 return getBooleanOption(AvoidSuppressingNullArgumentPaths,
201 "avoid-suppressing-null-argument-paths",
206 return getBooleanOption(SuppressInlinedDefensiveChecks,
207 "suppress-inlined-defensive-checks",
212 return getBooleanOption(SuppressFromCXXStandardLibrary,
213 "suppress-c++-stdlib",
218 return getBooleanOption(ReportIssuesInMainSourceFile,
219 "report-in-main-source-file",
225 return getBooleanOption(StableReportFilename,
226 "stable-report-filename",
232 bool SearchInParents) {
234 llvm::raw_svector_ostream OS(StrBuf);
239 : StringRef(Config.insert(std::make_pair(Name, OS.str()))
242 int Res = DefaultVal;
243 bool b = V.getAsInteger(10, Res);
244 assert(!b &&
"analyzer-config option should be numeric");
250 StringRef DefaultVal,
252 bool SearchInParents) {
256 Config.insert(std::make_pair(Name, DefaultVal)).first->second);
260 if (!AlwaysInlineSize.hasValue())
261 AlwaysInlineSize = getOptionAsInteger(
"ipa-always-inline-size", 3);
262 return AlwaysInlineSize.getValue();
266 if (!MaxInlinableSize.hasValue()) {
268 int DefaultValue = 0;
269 UserModeKind HighLevelMode = getUserMode();
270 switch (HighLevelMode) {
272 llvm_unreachable(
"Invalid mode.");
281 MaxInlinableSize = getOptionAsInteger(
"max-inlinable-size", DefaultValue);
283 return MaxInlinableSize.getValue();
287 if (!GraphTrimInterval.hasValue())
288 GraphTrimInterval = getOptionAsInteger(
"graph-trim-interval", 1000);
289 return GraphTrimInterval.getValue();
293 if (!MaxTimesInlineLarge.hasValue())
294 MaxTimesInlineLarge = getOptionAsInteger(
"max-times-inline-large", 32);
295 return MaxTimesInlineLarge.getValue();
299 if (!MaxNodesPerTopLevelFunction.hasValue()) {
300 int DefaultValue = 0;
301 UserModeKind HighLevelMode = getUserMode();
302 switch (HighLevelMode) {
304 llvm_unreachable(
"Invalid mode.");
306 DefaultValue = 75000;
309 DefaultValue = 150000;
312 MaxNodesPerTopLevelFunction = getOptionAsInteger(
"max-nodes", DefaultValue);
314 return MaxNodesPerTopLevelFunction.getValue();
318 return getBooleanOption(
"faux-bodies",
true);
322 return getBooleanOption(
"prune-paths",
true);
326 return getBooleanOption(
"cfg-conditional-static-initializers",
true);
Inline C functions and blocks when their definitions are available.
IPAKind
Describes the different modes of inter-procedural analysis.
bool shouldSuppressNullReturnPaths()
bool shouldAvoidSuppressingNullArgumentPaths()
Perform only intra-procedural analysis.
A dummy mode in which no C++ inlining is enabled.
bool mayInlineTemplateFunctions()
Inline callees(C, C++, ObjC) when their definitions are available.
StringRef getOptionAsString(StringRef Name, StringRef DefaultVal, const ento::CheckerBase *C=nullptr, bool SearchInParents=false)
StringRef getTagDescription() const override
bool mayInlineCXXContainerMethods()
unsigned getMaxInlinableSize()
UserModeKind getUserMode()
Retrieves and sets the UserMode. This is a high-level option, which is used to set other low-level op...
bool shouldSuppressInlinedDefensiveChecks()
bool shouldWriteStableReportFilename()
IPAKind getIPAMode()
Returns the inter-procedural analysis mode.
Refers to regular member function and operator calls.
bool mayInlineObjCMethod()
Returns true if ObjectiveC inlining is enabled, false otherwise.
bool shouldConditionalizeStaticInitializers()
Enable inlining of dynamically dispatched methods.
bool getBooleanOption(StringRef Name, bool DefaultVal, const ento::CheckerBase *C=nullptr, bool SearchInParents=false)
unsigned getAlwaysInlineSize()
unsigned getMaxNodesPerTopLevelFunction()
bool mayInlineCXXStandardLibrary()
Refers to destructors (implicit or explicit).
unsigned getGraphTrimInterval()
bool includeTemporaryDtorsInCFG()
bool shouldSuppressFromCXXStandardLibrary()
bool shouldSynthesizeBodies()
bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K)
unsigned getMaxTimesInlineLarge()
CXXInlineableMemberKind
Describes the different kinds of C++ member functions which can be considered for inlining by the ana...
int getOptionAsInteger(StringRef Name, int DefaultVal, const ento::CheckerBase *C=nullptr, bool SearchInParents=false)
bool mayInlineCXXAllocator()
bool mayInlineCXXSharedPtrDtor()
bool shouldReportIssuesInMainSourceFile()
static StringRef toString(bool b)