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.

llvm-svn: 213009
This commit is contained in:
David Majnemer 2014-07-14 23:12:54 +00:00
parent 3be31a6319
commit 48b0863f52
2 changed files with 10 additions and 11 deletions

View File

@ -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() {

View File

@ -55,8 +55,8 @@ QualType CXXUuidofExpr::getTypeOperand(ASTContext &Context) const {
}
// 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::GetUuidAttrOfType(QualType QT,
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::GetUuidAttrOfType(QualType QT,
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::GetUuidAttrOfType(QualType QT,
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;