[PATCH] D30593: Add correct "-isystem" warning handling to static analysis' BugReporter.

Kevin Marshall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 3 15:14:19 PST 2017


kmarshall created this revision.

The Clang static analyzer doesn't follow the warning suppression semantics of the "-isystem" command line flag. This patch adds a check to BugReporter which causes it to drop any BugReports which originated from a system header (descendant of an -isystem path).


Repository:
  rL LLVM

https://reviews.llvm.org/D30593

Files:
  lib/StaticAnalyzer/Core/BugReporter.cpp


Index: lib/StaticAnalyzer/Core/BugReporter.cpp
===================================================================
--- lib/StaticAnalyzer/Core/BugReporter.cpp
+++ lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -3251,6 +3251,12 @@
       return;
   }

+  // Suppress BugReports which originate from system headers (located beneath
+  // an -isystem include path).
+  if (getSourceManager().isInSystemHeader(
+          R->getLocation(getSourceManager()).asLocation()))
+    return;
+
   bool ValidSourceLoc = R->getLocation(getSourceManager()).isValid();
   assert(ValidSourceLoc);
   // If we mess up in a release build, we'd still prefer to just drop the bug


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30593.90543.patch
Type: text/x-patch
Size: 656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170303/74eabde4/attachment.bin>


More information about the cfe-commits mailing list