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

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 29 03:31:01 PST 2021


ASDenysPetrov 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);
----------------
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.


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