[clang] 8ad37a8 - [clang][Interp][NFC] Return array element type in Pointer::getType()

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 5 01:34:43 PDT 2023


Author: Timm Bäder
Date: 2023-09-05T10:28:47+02:00
New Revision: 8ad37a894b0b54fe71afa5ea3c003eea6ba76676

URL: https://github.com/llvm/llvm-project/commit/8ad37a894b0b54fe71afa5ea3c003eea6ba76676
DIFF: https://github.com/llvm/llvm-project/commit/8ad37a894b0b54fe71afa5ea3c003eea6ba76676.diff

LOG: [clang][Interp][NFC] Return array element type in Pointer::getType()

This is irrelevant for the current tests, but makes sense and later
changes easier.

Added: 
    

Modified: 
    clang/lib/AST/Interp/Pointer.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Pointer.h b/clang/lib/AST/Interp/Pointer.h
index 7012009c675af2..48aa4df1430fc1 100644
--- a/clang/lib/AST/Interp/Pointer.h
+++ b/clang/lib/AST/Interp/Pointer.h
@@ -212,7 +212,11 @@ class Pointer {
   }
 
   /// Returns the type of the innermost field.
-  QualType getType() const { return getFieldDesc()->getType(); }
+  QualType getType() const {
+    if (inPrimitiveArray() && Offset != Base)
+      return getFieldDesc()->getType()->getAsArrayTypeUnsafe()->getElementType();
+    return getFieldDesc()->getType();
+  }
 
   Pointer getDeclPtr() const { return Pointer(Pointee); }
 


        


More information about the cfe-commits mailing list