[clang] 096c033 - [clang][sema][NFC] Make some local variables const

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 18 07:19:33 PST 2022


Author: Timm Bäder
Date: 2022-11-18T16:19:09+01:00
New Revision: 096c033634d230fdb5eae4a0c3777e629cce0d82

URL: https://github.com/llvm/llvm-project/commit/096c033634d230fdb5eae4a0c3777e629cce0d82
DIFF: https://github.com/llvm/llvm-project/commit/096c033634d230fdb5eae4a0c3777e629cce0d82.diff

LOG: [clang][sema][NFC] Make some local variables const

We don't modify them. Also use auto here since we already wrote the full
type in the cast.

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplate.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 08ff4f4aecb5e..bb419e79a347a 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -109,7 +109,7 @@ NamedDecl *Sema::getAsTemplateNameDecl(NamedDecl *D,
     return D;
   }
 
-  if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(D)) {
+  if (const auto *Record = dyn_cast<CXXRecordDecl>(D)) {
     // C++ [temp.local]p1:
     //   Like normal (non-template) classes, class templates have an
     //   injected-class-name (Clause 9). The injected-class-name
@@ -126,8 +126,7 @@ NamedDecl *Sema::getAsTemplateNameDecl(NamedDecl *D,
       if (Record->getDescribedClassTemplate())
         return Record->getDescribedClassTemplate();
 
-      if (ClassTemplateSpecializationDecl *Spec
-            = dyn_cast<ClassTemplateSpecializationDecl>(Record))
+      if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(Record))
         return Spec->getSpecializedTemplate();
     }
 


        


More information about the cfe-commits mailing list