[clang] c3329b1 - [clang][Interp][NFC] Limit Pointer::isArrayElement() to actual arrays

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 15 04:40:31 PST 2023


Author: Timm Bäder
Date: 2023-11-15T13:40:16+01:00
New Revision: c3329b1cac3158bba62aab14d648b9dc615f8c67

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

LOG: [clang][Interp][NFC] Limit Pointer::isArrayElement() to actual arrays

Similar to what we do in isArrayRoot() - only return true here if the
Pointee is actually of array type.

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 843bcad16b5d1e3..a8f6e62fa76d356 100644
--- a/clang/lib/AST/Interp/Pointer.h
+++ b/clang/lib/AST/Interp/Pointer.h
@@ -279,7 +279,7 @@ class Pointer {
     return getFieldDesc()->isUnknownSizeArray();
   }
   /// Checks if the pointer points to an array.
-  bool isArrayElement() const { return Base != Offset; }
+  bool isArrayElement() const { return inArray() && Base != Offset; }
   /// Pointer points directly to a block.
   bool isRoot() const {
     return (Base == 0 || Base == RootPtrMark) && Offset == 0;


        


More information about the cfe-commits mailing list