ExprInspectionChecker.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. //==- ExprInspectionChecker.cpp - Used for regression tests ------*- C++ -*-==//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "clang/Analysis/IssueHash.h"
  9. #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
  10. #include "clang/StaticAnalyzer/Checkers/SValExplainer.h"
  11. #include "clang/StaticAnalyzer/Checkers/Taint.h"
  12. #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
  13. #include "clang/StaticAnalyzer/Core/Checker.h"
  14. #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
  15. #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
  16. #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h"
  17. #include "llvm/ADT/StringSwitch.h"
  18. #include "llvm/Support/ScopedPrinter.h"
  19. #include <optional>
  20. using namespace clang;
  21. using namespace ento;
  22. namespace {
  23. class ExprInspectionChecker
  24. : public Checker<eval::Call, check::DeadSymbols, check::EndAnalysis> {
  25. mutable std::unique_ptr<BugType> BT;
  26. // These stats are per-analysis, not per-branch, hence they shouldn't
  27. // stay inside the program state.
  28. struct ReachedStat {
  29. ExplodedNode *ExampleNode;
  30. unsigned NumTimesReached;
  31. };
  32. mutable llvm::DenseMap<const CallExpr *, ReachedStat> ReachedStats;
  33. void analyzerEval(const CallExpr *CE, CheckerContext &C) const;
  34. void analyzerCheckInlined(const CallExpr *CE, CheckerContext &C) const;
  35. void analyzerWarnIfReached(const CallExpr *CE, CheckerContext &C) const;
  36. void analyzerNumTimesReached(const CallExpr *CE, CheckerContext &C) const;
  37. void analyzerCrash(const CallExpr *CE, CheckerContext &C) const;
  38. void analyzerWarnOnDeadSymbol(const CallExpr *CE, CheckerContext &C) const;
  39. void analyzerValue(const CallExpr *CE, CheckerContext &C) const;
  40. void analyzerDumpSValType(const CallExpr *CE, CheckerContext &C) const;
  41. void analyzerDump(const CallExpr *CE, CheckerContext &C) const;
  42. void analyzerExplain(const CallExpr *CE, CheckerContext &C) const;
  43. void analyzerPrintState(const CallExpr *CE, CheckerContext &C) const;
  44. void analyzerGetExtent(const CallExpr *CE, CheckerContext &C) const;
  45. void analyzerDumpExtent(const CallExpr *CE, CheckerContext &C) const;
  46. void analyzerDumpElementCount(const CallExpr *CE, CheckerContext &C) const;
  47. void analyzerHashDump(const CallExpr *CE, CheckerContext &C) const;
  48. void analyzerDenote(const CallExpr *CE, CheckerContext &C) const;
  49. void analyzerExpress(const CallExpr *CE, CheckerContext &C) const;
  50. void analyzerIsTainted(const CallExpr *CE, CheckerContext &C) const;
  51. typedef void (ExprInspectionChecker::*FnCheck)(const CallExpr *,
  52. CheckerContext &C) const;
  53. // Optional parameter `ExprVal` for expression value to be marked interesting.
  54. ExplodedNode *reportBug(llvm::StringRef Msg, CheckerContext &C,
  55. std::optional<SVal> ExprVal = std::nullopt) const;
  56. ExplodedNode *reportBug(llvm::StringRef Msg, BugReporter &BR, ExplodedNode *N,
  57. std::optional<SVal> ExprVal = std::nullopt) const;
  58. template <typename T> void printAndReport(CheckerContext &C, T What) const;
  59. const Expr *getArgExpr(const CallExpr *CE, CheckerContext &C) const;
  60. const MemRegion *getArgRegion(const CallExpr *CE, CheckerContext &C) const;
  61. public:
  62. bool evalCall(const CallEvent &Call, CheckerContext &C) const;
  63. void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
  64. void checkEndAnalysis(ExplodedGraph &G, BugReporter &BR,
  65. ExprEngine &Eng) const;
  66. };
  67. } // namespace
  68. REGISTER_SET_WITH_PROGRAMSTATE(MarkedSymbols, SymbolRef)
  69. REGISTER_MAP_WITH_PROGRAMSTATE(DenotedSymbols, SymbolRef, const StringLiteral *)
  70. bool ExprInspectionChecker::evalCall(const CallEvent &Call,
  71. CheckerContext &C) const {
  72. const auto *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr());
  73. if (!CE)
  74. return false;
  75. // These checks should have no effect on the surrounding environment
  76. // (globals should not be invalidated, etc), hence the use of evalCall.
  77. FnCheck Handler =
  78. llvm::StringSwitch<FnCheck>(C.getCalleeName(CE))
  79. .Case("clang_analyzer_eval", &ExprInspectionChecker::analyzerEval)
  80. .Case("clang_analyzer_checkInlined",
  81. &ExprInspectionChecker::analyzerCheckInlined)
  82. .Case("clang_analyzer_crash", &ExprInspectionChecker::analyzerCrash)
  83. .Case("clang_analyzer_warnIfReached",
  84. &ExprInspectionChecker::analyzerWarnIfReached)
  85. .Case("clang_analyzer_warnOnDeadSymbol",
  86. &ExprInspectionChecker::analyzerWarnOnDeadSymbol)
  87. .StartsWith("clang_analyzer_explain",
  88. &ExprInspectionChecker::analyzerExplain)
  89. .Case("clang_analyzer_dumpExtent",
  90. &ExprInspectionChecker::analyzerDumpExtent)
  91. .Case("clang_analyzer_dumpElementCount",
  92. &ExprInspectionChecker::analyzerDumpElementCount)
  93. .Case("clang_analyzer_value", &ExprInspectionChecker::analyzerValue)
  94. .StartsWith("clang_analyzer_dumpSvalType",
  95. &ExprInspectionChecker::analyzerDumpSValType)
  96. .StartsWith("clang_analyzer_dump",
  97. &ExprInspectionChecker::analyzerDump)
  98. .Case("clang_analyzer_getExtent",
  99. &ExprInspectionChecker::analyzerGetExtent)
  100. .Case("clang_analyzer_printState",
  101. &ExprInspectionChecker::analyzerPrintState)
  102. .Case("clang_analyzer_numTimesReached",
  103. &ExprInspectionChecker::analyzerNumTimesReached)
  104. .Case("clang_analyzer_hashDump",
  105. &ExprInspectionChecker::analyzerHashDump)
  106. .Case("clang_analyzer_denote", &ExprInspectionChecker::analyzerDenote)
  107. .Case("clang_analyzer_express", // This also marks the argument as
  108. // interesting.
  109. &ExprInspectionChecker::analyzerExpress)
  110. .StartsWith("clang_analyzer_isTainted",
  111. &ExprInspectionChecker::analyzerIsTainted)
  112. .Default(nullptr);
  113. if (!Handler)
  114. return false;
  115. (this->*Handler)(CE, C);
  116. return true;
  117. }
  118. static const char *getArgumentValueString(const CallExpr *CE,
  119. CheckerContext &C) {
  120. if (CE->getNumArgs() == 0)
  121. return "Missing assertion argument";
  122. ExplodedNode *N = C.getPredecessor();
  123. const LocationContext *LC = N->getLocationContext();
  124. ProgramStateRef State = N->getState();
  125. const Expr *Assertion = CE->getArg(0);
  126. SVal AssertionVal = State->getSVal(Assertion, LC);
  127. if (AssertionVal.isUndef())
  128. return "UNDEFINED";
  129. ProgramStateRef StTrue, StFalse;
  130. std::tie(StTrue, StFalse) =
  131. State->assume(AssertionVal.castAs<DefinedOrUnknownSVal>());
  132. if (StTrue) {
  133. if (StFalse)
  134. return "UNKNOWN";
  135. else
  136. return "TRUE";
  137. } else {
  138. if (StFalse)
  139. return "FALSE";
  140. else
  141. llvm_unreachable("Invalid constraint; neither true or false.");
  142. }
  143. }
  144. ExplodedNode *
  145. ExprInspectionChecker::reportBug(llvm::StringRef Msg, CheckerContext &C,
  146. std::optional<SVal> ExprVal) const {
  147. ExplodedNode *N = C.generateNonFatalErrorNode();
  148. reportBug(Msg, C.getBugReporter(), N, ExprVal);
  149. return N;
  150. }
  151. ExplodedNode *
  152. ExprInspectionChecker::reportBug(llvm::StringRef Msg, BugReporter &BR,
  153. ExplodedNode *N,
  154. std::optional<SVal> ExprVal) const {
  155. if (!N)
  156. return nullptr;
  157. if (!BT)
  158. BT.reset(new BugType(this, "Checking analyzer assumptions", "debug"));
  159. auto R = std::make_unique<PathSensitiveBugReport>(*BT, Msg, N);
  160. if (ExprVal) {
  161. R->markInteresting(*ExprVal);
  162. }
  163. BR.emitReport(std::move(R));
  164. return N;
  165. }
  166. const Expr *ExprInspectionChecker::getArgExpr(const CallExpr *CE,
  167. CheckerContext &C) const {
  168. if (CE->getNumArgs() == 0) {
  169. reportBug("Missing argument", C);
  170. return nullptr;
  171. }
  172. return CE->getArg(0);
  173. }
  174. const MemRegion *ExprInspectionChecker::getArgRegion(const CallExpr *CE,
  175. CheckerContext &C) const {
  176. const Expr *Arg = getArgExpr(CE, C);
  177. if (!Arg)
  178. return nullptr;
  179. const MemRegion *MR = C.getSVal(Arg).getAsRegion();
  180. if (!MR) {
  181. reportBug("Cannot obtain the region", C);
  182. return nullptr;
  183. }
  184. return MR;
  185. }
  186. void ExprInspectionChecker::analyzerEval(const CallExpr *CE,
  187. CheckerContext &C) const {
  188. const LocationContext *LC = C.getPredecessor()->getLocationContext();
  189. // A specific instantiation of an inlined function may have more constrained
  190. // values than can generally be assumed. Skip the check.
  191. if (LC->getStackFrame()->getParent() != nullptr)
  192. return;
  193. reportBug(getArgumentValueString(CE, C), C);
  194. }
  195. void ExprInspectionChecker::analyzerWarnIfReached(const CallExpr *CE,
  196. CheckerContext &C) const {
  197. reportBug("REACHABLE", C);
  198. }
  199. void ExprInspectionChecker::analyzerNumTimesReached(const CallExpr *CE,
  200. CheckerContext &C) const {
  201. ++ReachedStats[CE].NumTimesReached;
  202. if (!ReachedStats[CE].ExampleNode) {
  203. // Later, in checkEndAnalysis, we'd throw a report against it.
  204. ReachedStats[CE].ExampleNode = C.generateNonFatalErrorNode();
  205. }
  206. }
  207. void ExprInspectionChecker::analyzerCheckInlined(const CallExpr *CE,
  208. CheckerContext &C) const {
  209. const LocationContext *LC = C.getPredecessor()->getLocationContext();
  210. // An inlined function could conceivably also be analyzed as a top-level
  211. // function. We ignore this case and only emit a message (TRUE or FALSE)
  212. // when we are analyzing it as an inlined function. This means that
  213. // clang_analyzer_checkInlined(true) should always print TRUE, but
  214. // clang_analyzer_checkInlined(false) should never actually print anything.
  215. if (LC->getStackFrame()->getParent() == nullptr)
  216. return;
  217. reportBug(getArgumentValueString(CE, C), C);
  218. }
  219. void ExprInspectionChecker::analyzerExplain(const CallExpr *CE,
  220. CheckerContext &C) const {
  221. const Expr *Arg = getArgExpr(CE, C);
  222. if (!Arg)
  223. return;
  224. SVal V = C.getSVal(Arg);
  225. SValExplainer Ex(C.getASTContext());
  226. reportBug(Ex.Visit(V), C);
  227. }
  228. static void printHelper(llvm::raw_svector_ostream &Out, CheckerContext &C,
  229. const llvm::APSInt &I) {
  230. Out << I.getBitWidth() << (I.isUnsigned() ? "u:" : "s:");
  231. Out << I;
  232. }
  233. static void printHelper(llvm::raw_svector_ostream &Out, CheckerContext &C,
  234. SymbolRef Sym) {
  235. C.getConstraintManager().printValue(Out, C.getState(), Sym);
  236. }
  237. static void printHelper(llvm::raw_svector_ostream &Out, CheckerContext &C,
  238. SVal V) {
  239. Out << V;
  240. }
  241. template <typename T>
  242. void ExprInspectionChecker::printAndReport(CheckerContext &C, T What) const {
  243. llvm::SmallString<64> Str;
  244. llvm::raw_svector_ostream OS(Str);
  245. printHelper(OS, C, What);
  246. reportBug(OS.str(), C);
  247. }
  248. void ExprInspectionChecker::analyzerValue(const CallExpr *CE,
  249. CheckerContext &C) const {
  250. const Expr *Arg = getArgExpr(CE, C);
  251. if (!Arg)
  252. return;
  253. SVal V = C.getSVal(Arg);
  254. if (const SymbolRef Sym = V.getAsSymbol())
  255. printAndReport(C, Sym);
  256. else if (const llvm::APSInt *I = V.getAsInteger())
  257. printAndReport(C, *I);
  258. else
  259. reportBug("n/a", C);
  260. }
  261. void ExprInspectionChecker::analyzerDumpSValType(const CallExpr *CE,
  262. CheckerContext &C) const {
  263. const Expr *Arg = getArgExpr(CE, C);
  264. if (!Arg)
  265. return;
  266. QualType Ty = C.getSVal(Arg).getType(C.getASTContext());
  267. reportBug(Ty.getAsString(), C);
  268. }
  269. void ExprInspectionChecker::analyzerDump(const CallExpr *CE,
  270. CheckerContext &C) const {
  271. const Expr *Arg = getArgExpr(CE, C);
  272. if (!Arg)
  273. return;
  274. SVal V = C.getSVal(Arg);
  275. printAndReport(C, V);
  276. }
  277. void ExprInspectionChecker::analyzerGetExtent(const CallExpr *CE,
  278. CheckerContext &C) const {
  279. const MemRegion *MR = getArgRegion(CE, C);
  280. if (!MR)
  281. return;
  282. ProgramStateRef State = C.getState();
  283. DefinedOrUnknownSVal Size = getDynamicExtent(State, MR, C.getSValBuilder());
  284. State = State->BindExpr(CE, C.getLocationContext(), Size);
  285. C.addTransition(State);
  286. }
  287. void ExprInspectionChecker::analyzerDumpExtent(const CallExpr *CE,
  288. CheckerContext &C) const {
  289. const MemRegion *MR = getArgRegion(CE, C);
  290. if (!MR)
  291. return;
  292. DefinedOrUnknownSVal Size =
  293. getDynamicExtent(C.getState(), MR, C.getSValBuilder());
  294. printAndReport(C, Size);
  295. }
  296. void ExprInspectionChecker::analyzerDumpElementCount(const CallExpr *CE,
  297. CheckerContext &C) const {
  298. const MemRegion *MR = getArgRegion(CE, C);
  299. if (!MR)
  300. return;
  301. QualType ElementTy;
  302. if (const auto *TVR = MR->getAs<TypedValueRegion>()) {
  303. ElementTy = TVR->getValueType();
  304. } else {
  305. ElementTy = MR->castAs<SymbolicRegion>()->getPointeeStaticType();
  306. }
  307. assert(!ElementTy->isPointerType());
  308. DefinedOrUnknownSVal ElementCount =
  309. getDynamicElementCount(C.getState(), MR, C.getSValBuilder(), ElementTy);
  310. printAndReport(C, ElementCount);
  311. }
  312. void ExprInspectionChecker::analyzerPrintState(const CallExpr *CE,
  313. CheckerContext &C) const {
  314. C.getState()->dump();
  315. }
  316. void ExprInspectionChecker::analyzerWarnOnDeadSymbol(const CallExpr *CE,
  317. CheckerContext &C) const {
  318. const Expr *Arg = getArgExpr(CE, C);
  319. if (!Arg)
  320. return;
  321. SVal Val = C.getSVal(Arg);
  322. SymbolRef Sym = Val.getAsSymbol();
  323. if (!Sym)
  324. return;
  325. ProgramStateRef State = C.getState();
  326. State = State->add<MarkedSymbols>(Sym);
  327. C.addTransition(State);
  328. }
  329. void ExprInspectionChecker::checkDeadSymbols(SymbolReaper &SymReaper,
  330. CheckerContext &C) const {
  331. ProgramStateRef State = C.getState();
  332. const MarkedSymbolsTy &Syms = State->get<MarkedSymbols>();
  333. ExplodedNode *N = C.getPredecessor();
  334. for (auto I = Syms.begin(), E = Syms.end(); I != E; ++I) {
  335. SymbolRef Sym = *I;
  336. if (!SymReaper.isDead(Sym))
  337. continue;
  338. // The non-fatal error node should be the same for all reports.
  339. if (ExplodedNode *BugNode = reportBug("SYMBOL DEAD", C))
  340. N = BugNode;
  341. State = State->remove<MarkedSymbols>(Sym);
  342. }
  343. for (auto I : State->get<DenotedSymbols>()) {
  344. SymbolRef Sym = I.first;
  345. if (!SymReaper.isLive(Sym))
  346. State = State->remove<DenotedSymbols>(Sym);
  347. }
  348. C.addTransition(State, N);
  349. }
  350. void ExprInspectionChecker::checkEndAnalysis(ExplodedGraph &G, BugReporter &BR,
  351. ExprEngine &Eng) const {
  352. for (auto Item : ReachedStats) {
  353. unsigned NumTimesReached = Item.second.NumTimesReached;
  354. ExplodedNode *N = Item.second.ExampleNode;
  355. reportBug(llvm::to_string(NumTimesReached), BR, N);
  356. }
  357. ReachedStats.clear();
  358. }
  359. void ExprInspectionChecker::analyzerCrash(const CallExpr *CE,
  360. CheckerContext &C) const {
  361. LLVM_BUILTIN_TRAP;
  362. }
  363. void ExprInspectionChecker::analyzerHashDump(const CallExpr *CE,
  364. CheckerContext &C) const {
  365. const LangOptions &Opts = C.getLangOpts();
  366. const SourceManager &SM = C.getSourceManager();
  367. FullSourceLoc FL(CE->getArg(0)->getBeginLoc(), SM);
  368. std::string HashContent =
  369. getIssueString(FL, getCheckerName().getName(), "Category",
  370. C.getLocationContext()->getDecl(), Opts);
  371. reportBug(HashContent, C);
  372. }
  373. void ExprInspectionChecker::analyzerDenote(const CallExpr *CE,
  374. CheckerContext &C) const {
  375. if (CE->getNumArgs() < 2) {
  376. reportBug("clang_analyzer_denote() requires a symbol and a string literal",
  377. C);
  378. return;
  379. }
  380. SymbolRef Sym = C.getSVal(CE->getArg(0)).getAsSymbol();
  381. if (!Sym) {
  382. reportBug("Not a symbol", C);
  383. return;
  384. }
  385. const auto *E = dyn_cast<StringLiteral>(CE->getArg(1)->IgnoreParenCasts());
  386. if (!E) {
  387. reportBug("Not a string literal", C);
  388. return;
  389. }
  390. ProgramStateRef State = C.getState();
  391. C.addTransition(C.getState()->set<DenotedSymbols>(Sym, E));
  392. }
  393. namespace {
  394. class SymbolExpressor
  395. : public SymExprVisitor<SymbolExpressor, std::optional<std::string>> {
  396. ProgramStateRef State;
  397. public:
  398. SymbolExpressor(ProgramStateRef State) : State(State) {}
  399. std::optional<std::string> lookup(const SymExpr *S) {
  400. if (const StringLiteral *const *SLPtr = State->get<DenotedSymbols>(S)) {
  401. const StringLiteral *SL = *SLPtr;
  402. return std::string(SL->getBytes());
  403. }
  404. return std::nullopt;
  405. }
  406. std::optional<std::string> VisitSymExpr(const SymExpr *S) {
  407. return lookup(S);
  408. }
  409. std::optional<std::string> VisitSymIntExpr(const SymIntExpr *S) {
  410. if (std::optional<std::string> Str = lookup(S))
  411. return Str;
  412. if (std::optional<std::string> Str = Visit(S->getLHS()))
  413. return (*Str + " " + BinaryOperator::getOpcodeStr(S->getOpcode()) + " " +
  414. std::to_string(S->getRHS().getLimitedValue()) +
  415. (S->getRHS().isUnsigned() ? "U" : ""))
  416. .str();
  417. return std::nullopt;
  418. }
  419. std::optional<std::string> VisitSymSymExpr(const SymSymExpr *S) {
  420. if (std::optional<std::string> Str = lookup(S))
  421. return Str;
  422. if (std::optional<std::string> Str1 = Visit(S->getLHS()))
  423. if (std::optional<std::string> Str2 = Visit(S->getRHS()))
  424. return (*Str1 + " " + BinaryOperator::getOpcodeStr(S->getOpcode()) +
  425. " " + *Str2)
  426. .str();
  427. return std::nullopt;
  428. }
  429. std::optional<std::string> VisitUnarySymExpr(const UnarySymExpr *S) {
  430. if (std::optional<std::string> Str = lookup(S))
  431. return Str;
  432. if (std::optional<std::string> Str = Visit(S->getOperand()))
  433. return (UnaryOperator::getOpcodeStr(S->getOpcode()) + *Str).str();
  434. return std::nullopt;
  435. }
  436. std::optional<std::string> VisitSymbolCast(const SymbolCast *S) {
  437. if (std::optional<std::string> Str = lookup(S))
  438. return Str;
  439. if (std::optional<std::string> Str = Visit(S->getOperand()))
  440. return (Twine("(") + S->getType().getAsString() + ")" + *Str).str();
  441. return std::nullopt;
  442. }
  443. };
  444. } // namespace
  445. void ExprInspectionChecker::analyzerExpress(const CallExpr *CE,
  446. CheckerContext &C) const {
  447. const Expr *Arg = getArgExpr(CE, C);
  448. if (!Arg)
  449. return;
  450. SVal ArgVal = C.getSVal(CE->getArg(0));
  451. SymbolRef Sym = ArgVal.getAsSymbol();
  452. if (!Sym) {
  453. reportBug("Not a symbol", C, ArgVal);
  454. return;
  455. }
  456. SymbolExpressor V(C.getState());
  457. auto Str = V.Visit(Sym);
  458. if (!Str) {
  459. reportBug("Unable to express", C, ArgVal);
  460. return;
  461. }
  462. reportBug(*Str, C, ArgVal);
  463. }
  464. void ExprInspectionChecker::analyzerIsTainted(const CallExpr *CE,
  465. CheckerContext &C) const {
  466. if (CE->getNumArgs() != 1) {
  467. reportBug("clang_analyzer_isTainted() requires exactly one argument", C);
  468. return;
  469. }
  470. const bool IsTainted =
  471. taint::isTainted(C.getState(), CE->getArg(0), C.getLocationContext());
  472. reportBug(IsTainted ? "YES" : "NO", C);
  473. }
  474. void ento::registerExprInspectionChecker(CheckerManager &Mgr) {
  475. Mgr.registerChecker<ExprInspectionChecker>();
  476. }
  477. bool ento::shouldRegisterExprInspectionChecker(const CheckerManager &mgr) {
  478. return true;
  479. }