r213009 - AST: Cleanup __uuidof related code
David Majnemer
david.majnemer at gmail.com
Mon Jul 14 16:12:54 PDT 2014
Author: majnemer
Date: Mon Jul 14 18:12:54 2014
New Revision: 213009
URL: http://llvm.org/viewvc/llvm-project?rev=213009&view=rev
Log:
AST: Cleanup __uuidof related code
Switch some things to use range-based for loops.
Change CXXUuidofExpr::GetUuidAttrOfType's return type to be const.
No functionality changed.
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/lib/AST/ExprCXX.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=213009&r1=213008&r2=213009&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Jul 14 18:12:54 2014
@@ -737,8 +737,8 @@ public:
/// Grabs __declspec(uuid()) off a type, or returns 0 if we cannot resolve to
/// a single GUID.
- static UuidAttr *GetUuidAttrOfType(QualType QT,
- bool *HasMultipleGUIDsPtr = nullptr);
+ static const UuidAttr *GetUuidAttrOfType(QualType QT,
+ bool *HasMultipleGUIDsPtr = nullptr);
// Iterators
child_range children() {
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=213009&r1=213008&r2=213009&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Jul 14 18:12:54 2014
@@ -55,8 +55,8 @@ QualType CXXUuidofExpr::getTypeOperand(A
}
// static
-UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT,
- bool *RDHasMultipleGUIDsPtr) {
+const UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT,
+ bool *RDHasMultipleGUIDsPtr) {
// Optionally remove one level of pointer, reference or array indirection.
const Type *Ty = QT.getTypePtr();
if (QT->isPointerType() || QT->isReferenceType())
@@ -64,7 +64,6 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfTy
else if (QT->isArrayType())
Ty = Ty->getBaseElementTypeUnsafe();
- // Loop all record redeclaration looking for an uuid attribute.
CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
if (!RD)
return nullptr;
@@ -73,13 +72,12 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfTy
if (ClassTemplateSpecializationDecl *CTSD =
dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
const TemplateArgumentList &TAL = CTSD->getTemplateArgs();
- UuidAttr *UuidForRD = nullptr;
+ const UuidAttr *UuidForRD = nullptr;
- for (unsigned I = 0, N = TAL.size(); I != N; ++I) {
- const TemplateArgument &TA = TAL[I];
+ for (const TemplateArgument &TA : TAL.asArray()) {
bool SeenMultipleGUIDs = false;
- UuidAttr *UuidForTA = nullptr;
+ const UuidAttr *UuidForTA = nullptr;
if (TA.getKind() == TemplateArgument::Type)
UuidForTA = GetUuidAttrOfType(TA.getAsType(), &SeenMultipleGUIDs);
else if (TA.getKind() == TemplateArgument::Declaration)
@@ -108,8 +106,9 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfTy
return UuidForRD;
}
- for (auto I : RD->redecls())
- if (auto Uuid = I->getAttr<UuidAttr>())
+ // 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;
return nullptr;
More information about the cfe-commits
mailing list