[clang] 560dd94 - [clang] [NFC] In GetDiagForGotoScopeDecl(), limit Init to inside the if condition (#116080)

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 19 23:59:46 PST 2024


Author: Boaz Brickner
Date: 2024-11-20T08:59:43+01:00
New Revision: 560dd940f5731fc255b67dde076427cabcddb149

URL: https://github.com/llvm/llvm-project/commit/560dd940f5731fc255b67dde076427cabcddb149
DIFF: https://github.com/llvm/llvm-project/commit/560dd940f5731fc255b67dde076427cabcddb149.diff

LOG: [clang] [NFC] In GetDiagForGotoScopeDecl(), limit Init to inside the if condition (#116080)

Added: 
    

Modified: 
    clang/lib/Sema/JumpDiagnostics.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp
index 8c830769a969cd..d465599450e7ff 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -179,9 +179,9 @@ static ScopePair GetDiagForGotoScopeDecl(Sema &S, const Decl *D) {
       }
     }
 
-    const Expr *Init = VD->getInit();
-    if (S.Context.getLangOpts().CPlusPlus && VD->hasLocalStorage() && Init &&
-        !Init->containsErrors()) {
+    if (const Expr *Init = VD->getInit(); S.Context.getLangOpts().CPlusPlus &&
+                                          VD->hasLocalStorage() && Init &&
+                                          !Init->containsErrors()) {
       // C++11 [stmt.dcl]p3:
       //   A program that jumps from a point where a variable with automatic
       //   storage duration is not in scope to a point where it is in scope


        


More information about the cfe-commits mailing list