[PATCH] [Static Analyzer] Fix Analysis being skipped for code with declarations in .h file

Anna Zaks zaks.anna at gmail.com
Wed Jun 24 18:48:34 PDT 2015


I think this should be all that's needed:

     // - System headers: don't run any checks.
     SourceManager &SM = Ctx->getSourceManager();
  -  SourceLocation SL = SM.getExpansionLoc(D->getLocation());
  +  
  +  SourceLocation SL = D->hasBody() ? D->getBody()->getLocStart() 
  +                                   : D->getLocation(); 
  +  SL = SM.getExpansionLoc(SL);
  +  
     if (!Opts->AnalyzeAll && !SM.isWrittenInMainFile(SL)) {

There are 2 differences from your patch:

1. I am not sure why the second if statement is added in your patch.
2. Getting the ExpansionLoc for the body. (In case it's a macro, it won't get analyzed.) Would be great if you add the macro test case as well.

Thanks!
Anna.


================
Comment at: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:603
@@ -595,1 +602,3 @@
+    if (SM.isInMainFile(SL))
+      return Mode;
     return Mode & ~AM_Path;
----------------
I don't think this if-statement is needed.

http://reviews.llvm.org/D10156

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list