r213044 - AST: Don't walk all redeclarations when looking for a uuid attr

David Majnemer david.majnemer at gmail.com
Mon Jul 14 21:30:17 PDT 2014


Author: majnemer
Date: Mon Jul 14 23:30:17 2014
New Revision: 213044

URL: http://llvm.org/viewvc/llvm-project?rev=213044&view=rev
Log:
AST: Don't walk all redeclarations when looking for a uuid attr

No funcionality changed, just a simplification of the existing code.

Modified:
    cfe/trunk/lib/AST/ExprCXX.cpp

Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=213044&r1=213043&r2=213044&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Jul 14 23:30:17 2014
@@ -64,17 +64,15 @@ const UuidAttr *CXXUuidofExpr::GetUuidAt
   else if (QT->isArrayType())
     Ty = Ty->getBaseElementTypeUnsafe();
 
-  CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
+  const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
   if (!RD)
     return nullptr;
 
-  // Loop over all record redeclarations looking for a uuid attribute.
-  for (const TagDecl *I : RD->redecls())
-    if (const UuidAttr *Uuid = I->getAttr<UuidAttr>())
-      return Uuid;
+  if (const UuidAttr *Uuid = RD->getMostRecentDecl()->getAttr<UuidAttr>())
+    return Uuid;
 
   // __uuidof can grab UUIDs from template arguments.
-  if (ClassTemplateSpecializationDecl *CTSD =
+  if (const ClassTemplateSpecializationDecl *CTSD =
           dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
     const TemplateArgumentList &TAL = CTSD->getTemplateArgs();
     const UuidAttr *UuidForRD = nullptr;





More information about the cfe-commits mailing list