r191493 - AST: Handle multidimensional arrays inside of __uuidof()
David Majnemer
david.majnemer at gmail.com
Fri Sep 27 00:57:34 PDT 2013
Author: majnemer
Date: Fri Sep 27 02:57:34 2013
New Revision: 191493
URL: http://llvm.org/viewvc/llvm-project?rev=191493&view=rev
Log:
AST: Handle multidimensional arrays inside of __uuidof()
We previously handled one-dimensional arrays but didn't consider the
general case. The fix is simple: keep going through subsequent
dimensions until we get to the base element.
Modified:
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=191493&r1=191492&r2=191493&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Fri Sep 27 02:57:34 2013
@@ -62,7 +62,7 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfTy
if (QT->isPointerType() || QT->isReferenceType())
Ty = QT->getPointeeType().getTypePtr();
else if (QT->isArrayType())
- Ty = cast<ArrayType>(QT)->getElementType().getTypePtr();
+ Ty = Ty->getBaseElementTypeUnsafe();
// Loop all record redeclaration looking for an uuid attribute.
CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=191493&r1=191492&r2=191493&view=diff
==============================================================================
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Fri Sep 27 02:57:34 2013
@@ -72,6 +72,10 @@ int uuid_sema_test()
__uuidof(struct_without_uuid); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
__uuidof(struct_with_uuid*);
__uuidof(struct_without_uuid*); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+ __uuidof(struct_with_uuid[1]);
+ __uuidof(struct_with_uuid*[1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
+ __uuidof(const struct_with_uuid[1][1]);
+ __uuidof(const struct_with_uuid*[1][1]); // expected-error {{cannot call operator __uuidof on a type with no GUID}}
__uuidof(var_with_uuid);
__uuidof(var_without_uuid);// expected-error {{cannot call operator __uuidof on a type with no GUID}}
More information about the cfe-commits
mailing list