[clang] 8990763 - [clang][codegen][NFC] Improve const correctness

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 23 07:35:33 PDT 2024


Author: Timm Bäder
Date: 2024-06-23T16:35:06+02:00
New Revision: 8990763d2c974a179dd0ed42b0cfb7b8b60e9c0c

URL: https://github.com/llvm/llvm-project/commit/8990763d2c974a179dd0ed42b0cfb7b8b60e9c0c
DIFF: https://github.com/llvm/llvm-project/commit/8990763d2c974a179dd0ed42b0cfb7b8b60e9c0c.diff

LOG: [clang][codegen][NFC] Improve const correctness

Added: 
    

Modified: 
    clang/lib/CodeGen/CGExprConstant.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index dffb8ce83b643..0f3e29707cb79 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -2041,10 +2041,10 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) {
       return ConstantLValue(C);
     };
 
-    if (auto FD = dyn_cast<FunctionDecl>(D))
+    if (const auto *FD = dyn_cast<FunctionDecl>(D))
       return PtrAuthSign(CGM.getRawFunctionPointer(FD));
 
-    if (auto VD = dyn_cast<VarDecl>(D)) {
+    if (const auto *VD = dyn_cast<VarDecl>(D)) {
       // We can never refer to a variable with local storage.
       if (!VD->hasLocalStorage()) {
         if (VD->isFileVarDecl() || VD->hasExternalStorage())
@@ -2057,13 +2057,13 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) {
       }
     }
 
-    if (auto *GD = dyn_cast<MSGuidDecl>(D))
+    if (const auto *GD = dyn_cast<MSGuidDecl>(D))
       return CGM.GetAddrOfMSGuidDecl(GD);
 
-    if (auto *GCD = dyn_cast<UnnamedGlobalConstantDecl>(D))
+    if (const auto *GCD = dyn_cast<UnnamedGlobalConstantDecl>(D))
       return CGM.GetAddrOfUnnamedGlobalConstantDecl(GCD);
 
-    if (auto *TPO = dyn_cast<TemplateParamObjectDecl>(D))
+    if (const auto *TPO = dyn_cast<TemplateParamObjectDecl>(D))
       return CGM.GetAddrOfTemplateParamObject(TPO);
 
     return nullptr;


        


More information about the cfe-commits mailing list