16 #include "llvm/ADT/SmallString.h" 17 #include "llvm/ADT/StringSwitch.h" 18 #include "llvm/ADT/StringRef.h" 19 #include "llvm/ADT/Twine.h" 20 #include "llvm/Support/ErrorHandling.h" 21 #include "llvm/Support/FileSystem.h" 22 #include "llvm/Support/FormattedStream.h" 23 #include "llvm/Support/raw_ostream.h" 29 using namespace clang;
33 std::vector<StringRef>
35 static const StringRef StaticAnalyzerChecks[] = {
37 #define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \ 39 #include "clang/StaticAnalyzer/Checkers/Checkers.inc" 43 std::vector<StringRef> Result;
44 for (StringRef CheckName : StaticAnalyzerChecks) {
45 if (!CheckName.startswith(
"debug.") &&
46 (IncludeExperimental || !CheckName.startswith(
"alpha.")))
47 Result.push_back(CheckName);
53 llvm::raw_ostream &Out,
54 std::pair<StringRef, StringRef> EntryDescPair,
55 size_t InitialPad,
size_t EntryWidth,
size_t MinLineWidth) {
57 llvm::formatted_raw_ostream FOut(Out);
59 const size_t PadForDesc = InitialPad + EntryWidth;
61 FOut.PadToColumn(InitialPad) << EntryDescPair.first;
63 if (FOut.getColumn() > PadForDesc)
66 FOut.PadToColumn(PadForDesc);
68 if (MinLineWidth == 0) {
69 FOut << EntryDescPair.second;
73 for (
char C : EntryDescPair.second) {
74 if (FOut.getColumn() > MinLineWidth && C ==
' ') {
76 FOut.PadToColumn(PadForDesc);
86 llvm::StringSwitch<llvm::Optional<ExplorationStrategyKind>>(
90 .Case(
"unexplored_first",
92 .Case(
"unexplored_first_queue",
94 .Case(
"unexplored_first_location_queue",
96 .Case(
"bfs_block_dfs_contents",
99 assert(K.hasValue() &&
"User mode is invalid.");
104 auto K = llvm::StringSwitch<llvm::Optional<IPAKind>>(IPAMode)
111 assert(K.hasValue() &&
"IPA Mode is invalid.");
123 llvm::StringSwitch<llvm::Optional<CXXInlineableMemberKind>>(
124 CXXMemberInliningMode)
131 assert(K.hasValue() &&
"Invalid c++ member function inlining mode.");
137 StringRef OptionName,
138 bool SearchInParents)
const {
139 assert(!CheckerName.empty() &&
140 "Empty checker name! Make sure the checker object (including it's " 141 "bases!) if fully initialized before calling this function!");
143 ConfigTable::const_iterator E = Config.end();
145 ConfigTable::const_iterator I =
146 Config.find((Twine(CheckerName) +
":" + OptionName).str());
148 return StringRef(I->getValue());
149 size_t Pos = CheckerName.rfind(
'.');
150 if (Pos == StringRef::npos)
153 CheckerName = CheckerName.substr(0, Pos);
154 }
while (!CheckerName.empty() && SearchInParents);
156 llvm_unreachable(
"Unknown checker option! Did you call getChecker*Option " 157 "with incorrect parameters? User input must've been " 158 "verified by CheckerRegistry.");
164 StringRef OptionName,
165 bool SearchInParents)
const {
166 return getCheckerStringOption(
171 StringRef OptionName,
172 bool SearchInParents)
const {
173 auto Ret = llvm::StringSwitch<llvm::Optional<bool>>(
174 getCheckerStringOption(CheckerName, OptionName,
177 .Case(
"false",
false)
181 "This option should be either 'true' or 'false', and should've been " 182 "validated by CheckerRegistry!");
188 StringRef OptionName,
189 bool SearchInParents)
const {
190 return getCheckerBooleanOption(
195 StringRef OptionName,
196 bool SearchInParents)
const {
198 bool HasFailed = getCheckerStringOption(CheckerName, OptionName,
200 .getAsInteger(0, Ret);
202 "This option should be numeric, and should've been validated by " 209 StringRef OptionName,
210 bool SearchInParents)
const {
211 return getCheckerIntegerOption(
Inline C functions and blocks when their definitions are available.
IPAKind
Describes the different modes of inter-procedural analysis.
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
StringRef getCheckerStringOption(StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const
Query an option's string value.
Perform only intra-procedural analysis.
A dummy mode in which no C++ inlining is enabled.
static void printFormattedEntry(llvm::raw_ostream &Out, std::pair< StringRef, StringRef > EntryDescPair, size_t EntryWidth, size_t InitialPad, size_t MinLineWidth=0)
Convenience function for printing options or checkers and their description in a formatted manner...
Inline callees(C, C++, ObjC) when their definitions are available.
StringRef getTagDescription() const override
static std::vector< StringRef > getRegisteredCheckers(bool IncludeExperimental=false)
Refers to regular member function and operator calls.
Refers to constructors (implicit or explicit).
Enable inlining of dynamically dispatched methods.
IPAKind getIPAMode() const
Returns the inter-procedural analysis mode.
Refers to destructors (implicit or explicit).
ExplorationStrategyKind getExplorationStrategy() const
bool getCheckerBooleanOption(StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const
Interprets an option's string value as a boolean.
Dataflow Directional Tag Classes.
bool mayInlineCXXMemberFunction(CXXInlineableMemberKind K) const
Returns the option controlling which C++ member functions will be considered for inlining.
int getCheckerIntegerOption(StringRef CheckerName, StringRef OptionName, bool SearchInParents=false) const
Interprets an option's string value as an integer value.
CXXInlineableMemberKind
Describes the different kinds of C++ member functions which can be considered for inlining by the ana...
Enable inlining of dynamically dispatched methods, bifurcate paths when exact type info is unavailabl...