[clang] 9f08ae8 - [clang][Interp][NFC] Fix getting the record decl from a pointer type

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 24 07:54:57 PDT 2024


Author: Timm Bäder
Date: 2024-07-24T16:54:38+02:00
New Revision: 9f08ae8d2dd1ff9ec3b033d099282dee05528413

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

LOG: [clang][Interp][NFC] Fix getting the record decl from a pointer type

Added: 
    

Modified: 
    clang/lib/AST/Interp/Compiler.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Compiler.cpp b/clang/lib/AST/Interp/Compiler.cpp
index 0455eec3f0145..58a0852aca755 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -5281,8 +5281,8 @@ template <class Emitter>
 unsigned Compiler<Emitter>::collectBaseOffset(const QualType BaseType,
                                               const QualType DerivedType) {
   const auto extractRecordDecl = [](QualType Ty) -> const CXXRecordDecl * {
-    if (const auto *PT = dyn_cast<PointerType>(Ty))
-      return PT->getPointeeType()->getAsCXXRecordDecl();
+    if (const auto *R = Ty->getPointeeCXXRecordDecl())
+      return R;
     return Ty->getAsCXXRecordDecl();
   };
   const CXXRecordDecl *BaseDecl = extractRecordDecl(BaseType);


        


More information about the cfe-commits mailing list