aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index 8e6bc69cc4..d64aa39feb 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2137,7 +2137,32 @@ void BugReporter::Register(BugType *BT) {
BugTypes = F.add(BugTypes, BT);
}
+bool BugReporter::suppressReport(BugReport *R) {
+ const Stmt *S = R->getStmt();
+ if (!S)
+ return false;
+
+ // Here we suppress false positives coming from system macros. This list is
+ // based on known issues.
+
+ // Skip reports within the sys/queue.h macros as we do not have the ability to
+ // reason about data structure shapes.
+ SourceManager &SM = getSourceManager();
+ SourceLocation Loc = S->getLocStart();
+ while (Loc.isMacroID()) {
+ if (SM.isInSystemMacro(Loc) &&
+ (SM.getFilename(SM.getSpellingLoc(Loc)).endswith("sys/queue.h")))
+ return true;
+ Loc = SM.getSpellingLoc(Loc);
+ }
+
+ return false;
+}
+
void BugReporter::emitReport(BugReport* R) {
+ if (suppressReport(R))
+ return;
+
// Compute the bug report's hash to determine its equivalence class.
llvm::FoldingSetNodeID ID;
R->Profile(ID);