[clang] 235dad3 - [clang][Interp][NFC] Make some variables const

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 16 22:55:12 PDT 2023


Author: Timm Bäder
Date: 2023-08-17T07:54:37+02:00
New Revision: 235dad33284a6c7514e4eadff21cb5e8157d4edc

URL: https://github.com/llvm/llvm-project/commit/235dad33284a6c7514e4eadff21cb5e8157d4edc
DIFF: https://github.com/llvm/llvm-project/commit/235dad33284a6c7514e4eadff21cb5e8157d4edc.diff

LOG: [clang][Interp][NFC] Make some variables const

Added: 
    

Modified: 
    clang/lib/AST/Interp/EvalEmitter.cpp
    clang/lib/AST/Interp/Pointer.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/EvalEmitter.cpp b/clang/lib/AST/Interp/EvalEmitter.cpp
index f22cca90d4f412..d26ee8e40a437b 100644
--- a/clang/lib/AST/Interp/EvalEmitter.cpp
+++ b/clang/lib/AST/Interp/EvalEmitter.cpp
@@ -119,10 +119,10 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
   // Method to recursively traverse composites.
   std::function<bool(QualType, const Pointer &, APValue &)> Composite;
   Composite = [this, &Composite](QualType Ty, const Pointer &Ptr, APValue &R) {
-    if (auto *AT = Ty->getAs<AtomicType>())
+    if (const auto *AT = Ty->getAs<AtomicType>())
       Ty = AT->getValueType();
 
-    if (auto *RT = Ty->getAs<RecordType>()) {
+    if (const auto *RT = Ty->getAs<RecordType>()) {
       const auto *Record = Ptr.getRecord();
       assert(Record && "Missing record descriptor");
 
@@ -130,7 +130,7 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
       if (RT->getDecl()->isUnion()) {
         const FieldDecl *ActiveField = nullptr;
         APValue Value;
-        for (auto &F : Record->fields()) {
+        for (const auto &F : Record->fields()) {
           const Pointer &FP = Ptr.atField(F.Offset);
           QualType FieldTy = F.Decl->getType();
           if (FP.isActive()) {
@@ -179,7 +179,7 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
       }
       return Ok;
     }
-    if (auto *AT = Ty->getAsArrayTypeUnsafe()) {
+    if (const auto *AT = Ty->getAsArrayTypeUnsafe()) {
       const size_t NumElems = Ptr.getNumElems();
       QualType ElemTy = AT->getElementType();
       R = APValue(APValue::UninitArray{}, NumElems, NumElems);

diff  --git a/clang/lib/AST/Interp/Pointer.cpp b/clang/lib/AST/Interp/Pointer.cpp
index e0ea25d8f560b9..613521facd63c2 100644
--- a/clang/lib/AST/Interp/Pointer.cpp
+++ b/clang/lib/AST/Interp/Pointer.cpp
@@ -122,8 +122,8 @@ APValue Pointer::toAPValue() const {
           bool IsVirtual = false;
 
           // Create a path entry for the field.
-          Descriptor *Desc = Ptr.getFieldDesc();
-          if (auto *BaseOrMember = Desc->asDecl()) {
+          const Descriptor *Desc = Ptr.getFieldDesc();
+          if (const auto *BaseOrMember = Desc->asDecl()) {
             Path.push_back(APValue::LValuePathEntry({BaseOrMember, IsVirtual}));
             Ptr = Ptr.getBase();
             continue;


        


More information about the cfe-commits mailing list