[clang] 0ff992e - [clang][Interp][NFC] Get ComplexType directly

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 22 01:35:10 PDT 2024


Author: Timm Bäder
Date: 2024-04-22T10:34:43+02:00
New Revision: 0ff992e5f210fdcbfdd1dcc3687c9aeabde318c3

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

LOG: [clang][Interp][NFC] Get ComplexType directly

Instead of doing a isa<> + getAs<>

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index f317f506d24f4b..486ad9db625ddb 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -922,9 +922,9 @@ bool ByteCodeExprGen<Emitter>::VisitImplicitValueInitExpr(const ImplicitValueIni
     return true;
   }
 
-  if (QT->isAnyComplexType()) {
+  if (const auto *ComplexTy = E->getType()->getAs<ComplexType>()) {
     assert(Initializing);
-    QualType ElemQT = QT->getAs<ComplexType>()->getElementType();
+    QualType ElemQT = ComplexTy->getElementType();
     PrimType ElemT = classifyPrim(ElemQT);
     for (unsigned I = 0; I < 2; ++I) {
       if (!this->visitZeroInitializer(ElemT, ElemQT, E))
@@ -1098,13 +1098,13 @@ bool ByteCodeExprGen<Emitter>::VisitInitListExpr(const InitListExpr *E) {
     return true;
   }
 
-  if (T->isAnyComplexType()) {
+  if (const auto *ComplexTy = E->getType()->getAs<ComplexType>()) {
     unsigned NumInits = E->getNumInits();
 
     if (NumInits == 1)
       return this->delegate(E->inits()[0]);
 
-    QualType ElemQT = E->getType()->getAs<ComplexType>()->getElementType();
+    QualType ElemQT = ComplexTy->getElementType();
     PrimType ElemT = classifyPrim(ElemQT);
     if (NumInits == 0) {
       // Zero-initialize both elements.


        


More information about the cfe-commits mailing list