[PATCH] D114441: [analyzer][NFC] Refactor AnalysisConsumer::getModeForDecl()

Bal√°zs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 29 05:48:03 PST 2021


steakhal added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:599-603
+  const SourceLocation Loc = [&SM](Decl *D) -> SourceLocation {
+    const Stmt *Body = D->getBody();
+    SourceLocation SL = Body ? Body->getBeginLoc() : D->getLocation();
+    return SM.getExpansionLoc(SL);
+  }(D);
----------------
ASDenysPetrov wrote:
> Why don't just leave this snippet as it was but add `const SourceLocation Loc` instead of re-assigning `SL`? Your construction made me stumbled for a while. As this patch is meant to bring readability, I wouldn't like to see such a code-trick. I see your intention to hide `SL` but IMO let compiler do this for us. See suggested.
Hm, you are probably right. The main idea was to reduce the number of unrelated declarations in the scope by nesting them into the calculation of the important ones.
However, we could relax in this case. I agree that would be even better.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114441/new/

https://reviews.llvm.org/D114441



More information about the cfe-commits mailing list