@@ -300,6 +300,8 @@ class StdLibraryFunctionsChecker
300
300
DefaultBool ChecksEnabled[CK_NumCheckKinds];
301
301
CheckerNameRef CheckNames[CK_NumCheckKinds];
302
302
303
+ bool DisplayLoadedSummaries = false ;
304
+
303
305
private:
304
306
Optional<Summary> findFunctionSummary (const FunctionDecl *FD,
305
307
CheckerContext &C) const ;
@@ -639,8 +641,12 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
639
641
struct AddToFunctionSummaryMap {
640
642
const ASTContext &ACtx;
641
643
FunctionSummaryMapType ⤅
642
- AddToFunctionSummaryMap (const ASTContext &ACtx, FunctionSummaryMapType &FSM)
643
- : ACtx(ACtx), Map(FSM) {}
644
+ bool DisplayLoadedSummaries;
645
+ AddToFunctionSummaryMap (const ASTContext &ACtx, FunctionSummaryMapType &FSM,
646
+ bool DisplayLoadedSummaries)
647
+ : ACtx(ACtx), Map(FSM), DisplayLoadedSummaries(DisplayLoadedSummaries) {
648
+ }
649
+
644
650
// Add a summary to a FunctionDecl found by lookup. The lookup is performed
645
651
// by the given Name, and in the global scope. The summary will be attached
646
652
// to the found FunctionDecl only if the signatures match.
@@ -655,6 +661,11 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
655
661
auto Res = Map.insert ({FD->getCanonicalDecl (), S});
656
662
assert (Res.second && " Function already has a summary set!" );
657
663
(void )Res;
664
+ if (DisplayLoadedSummaries) {
665
+ llvm::errs () << " Loaded summary for: " ;
666
+ FD->print (llvm::errs ());
667
+ llvm::errs () << " \n " ;
668
+ }
658
669
return ;
659
670
}
660
671
}
@@ -665,7 +676,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
665
676
for (const Summary &S : Summaries)
666
677
operator ()(Name, S);
667
678
}
668
- } addToFunctionSummaryMap (ACtx, FunctionSummaryMap);
679
+ } addToFunctionSummaryMap (ACtx, FunctionSummaryMap, DisplayLoadedSummaries );
669
680
670
681
// We are finally ready to define specifications for all supported functions.
671
682
//
@@ -937,7 +948,10 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
937
948
}
938
949
939
950
void ento::registerStdCLibraryFunctionsChecker (CheckerManager &mgr) {
940
- mgr.registerChecker <StdLibraryFunctionsChecker>();
951
+ auto *Checker = mgr.registerChecker <StdLibraryFunctionsChecker>();
952
+ Checker->DisplayLoadedSummaries =
953
+ mgr.getAnalyzerOptions ().getCheckerBooleanOption (
954
+ Checker, " DisplayLoadedSummaries" );
941
955
}
942
956
943
957
bool ento::shouldRegisterStdCLibraryFunctionsChecker (const CheckerManager &mgr) {
0 commit comments