diff options
author | Gabor Marton <gabor.marton@ericsson.com> | 2020-04-14 17:40:42 +0200 |
---|---|---|
committer | Gabor Marton <gabor.marton@ericsson.com> | 2020-05-14 15:40:58 +0200 |
commit | ff4492c89feb54e6ddfd6edaea59c98776963208 (patch) | |
tree | f3128d5aa1dea746f3461c9a5f9d415bbb51423d /clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | |
parent | 79941086fba3df115e5e7b54a5f826096c933102 (diff) | |
download | llvm-ff4492c89feb54e6ddfd6edaea59c98776963208.zip llvm-ff4492c89feb54e6ddfd6edaea59c98776963208.tar.gz llvm-ff4492c89feb54e6ddfd6edaea59c98776963208.tar.bz2 |
[analyzer] StdLibraryFunctionsChecker: Add option to display loaded summaries
Reviewers: NoQ, Szelethus, baloghadamsoftware, balazske
Subscribers: whisperity, xazax.hun, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, gamesh411, Charusso, steakhal, ASDenysPetrov, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D78118
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp index b9719a0..b8d52f0 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -300,6 +300,8 @@ public: DefaultBool ChecksEnabled[CK_NumCheckKinds]; CheckerNameRef CheckNames[CK_NumCheckKinds]; + bool DisplayLoadedSummaries = false; + private: Optional<Summary> findFunctionSummary(const FunctionDecl *FD, CheckerContext &C) const; @@ -639,8 +641,12 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( struct AddToFunctionSummaryMap { const ASTContext &ACtx; FunctionSummaryMapType ⤅ - AddToFunctionSummaryMap(const ASTContext &ACtx, FunctionSummaryMapType &FSM) - : ACtx(ACtx), Map(FSM) {} + bool DisplayLoadedSummaries; + AddToFunctionSummaryMap(const ASTContext &ACtx, FunctionSummaryMapType &FSM, + bool DisplayLoadedSummaries) + : ACtx(ACtx), Map(FSM), DisplayLoadedSummaries(DisplayLoadedSummaries) { + } + // Add a summary to a FunctionDecl found by lookup. The lookup is performed // by the given Name, and in the global scope. The summary will be attached // to the found FunctionDecl only if the signatures match. @@ -655,6 +661,11 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( auto Res = Map.insert({FD->getCanonicalDecl(), S}); assert(Res.second && "Function already has a summary set!"); (void)Res; + if (DisplayLoadedSummaries) { + llvm::errs() << "Loaded summary for: "; + FD->print(llvm::errs()); + llvm::errs() << "\n"; + } return; } } @@ -665,7 +676,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( for (const Summary &S : Summaries) operator()(Name, S); } - } addToFunctionSummaryMap(ACtx, FunctionSummaryMap); + } addToFunctionSummaryMap(ACtx, FunctionSummaryMap, DisplayLoadedSummaries); // We are finally ready to define specifications for all supported functions. // @@ -937,7 +948,10 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( } void ento::registerStdCLibraryFunctionsChecker(CheckerManager &mgr) { - mgr.registerChecker<StdLibraryFunctionsChecker>(); + auto *Checker = mgr.registerChecker<StdLibraryFunctionsChecker>(); + Checker->DisplayLoadedSummaries = + mgr.getAnalyzerOptions().getCheckerBooleanOption( + Checker, "DisplayLoadedSummaries"); } bool ento::shouldRegisterStdCLibraryFunctionsChecker(const CheckerManager &mgr) { |