]> granicus.if.org Git - clang/commitdiff
AST: Don't walk all redeclarations when looking for a uuid attr
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 15 Jul 2014 04:30:17 +0000 (04:30 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 15 Jul 2014 04:30:17 +0000 (04:30 +0000)
No funcionality changed, just a simplification of the existing code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213044 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprCXX.cpp

index c127b4a1dc013ed926b211728578cd8d66f1861a..54b043c3d5674fafc4a6ebcc51277407cf9a12f4 100644 (file)
@@ -64,17 +64,15 @@ const UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT,
   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;