[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

Olivier Goffart via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 03:47:20 PST 2017


ogoffart created this revision.

Do not perform the analysis based warning if all warnings are ignored.

This saves some cycles when compiling with "-w".

But more importantly, for my tool, this fixes a potential crash which may happen on invalid code. Because the analysis might compute the CFG which crashes if the code contains invalid declaration. This does not happen normally with because we also don't perform these analysis if there was an error.  But the tool is better at recovering and hit this condition.


https://reviews.llvm.org/D40242

Files:
  lib/Sema/AnalysisBasedWarnings.cpp


Index: lib/Sema/AnalysisBasedWarnings.cpp
===================================================================
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -2080,10 +2080,10 @@
   //     time.
   DiagnosticsEngine &Diags = S.getDiagnostics();
 
-  // Do not do any analysis for declarations in system headers if we are
-  // going to just ignore them.
-  if (Diags.getSuppressSystemWarnings() &&
-      S.SourceMgr.isInSystemHeader(D->getLocation()))
+  // Do not do any analysis if we are going to just ignore them.
+  if (Diags.getIgnoreAllWarnings() ||
+      (Diags.getSuppressSystemWarnings() &&
+       S.SourceMgr.isInSystemHeader(D->getLocation())))
     return;
 
   // For code in dependent contexts, we'll do this at instantiation time.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40242.123557.patch
Type: text/x-patch
Size: 783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171120/961ffad4/attachment-0001.bin>


More information about the cfe-commits mailing list