diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-09-27 07:04:31 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-09-27 07:04:31 +0000 |
commit | 143c55ead2e3fa089f6a0b8af3d84560dfd6e9d6 (patch) | |
tree | ae3e6073e3d61fe8be2e3b8a78ca7d59636f64bb /clang/lib/AST/ExprCXX.cpp | |
parent | acfcd0d51be7022b5d18ca26832892a5cc7bc1c2 (diff) | |
download | bcm5719-llvm-143c55ead2e3fa089f6a0b8af3d84560dfd6e9d6.tar.gz bcm5719-llvm-143c55ead2e3fa089f6a0b8af3d84560dfd6e9d6.zip |
AST: Handle qualified array types in typeid() expressions
The intent of getTypeOperand() was to yield an unqualified type.
However QualType::getUnqualifiedType() does not strip away qualifiers on
arrays.
N.B. This worked fine when typeid() was applied to an expression
because we would inject as implicit cast to the unqualified array type
in the AST.
llvm-svn: 191487
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 7478678bf0b..c7d2f78104b 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -40,16 +40,18 @@ bool CXXTypeidExpr::isPotentiallyEvaluated() const { return false; } -QualType CXXTypeidExpr::getTypeOperand() const { +QualType CXXTypeidExpr::getTypeOperand(ASTContext &Context) const { assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); - return Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType() - .getUnqualifiedType(); + Qualifiers Quals; + return Context.getUnqualifiedArrayType( + Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals); } -QualType CXXUuidofExpr::getTypeOperand() const { +QualType CXXUuidofExpr::getTypeOperand(ASTContext &Context) const { assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); - return Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType() - .getUnqualifiedType(); + Qualifiers Quals; + return Context.getUnqualifiedArrayType( + Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals); } // static @@ -118,7 +120,7 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT, StringRef CXXUuidofExpr::getUuidAsStringRef(ASTContext &Context) const { StringRef Uuid; if (isTypeOperand()) - Uuid = CXXUuidofExpr::GetUuidAttrOfType(getTypeOperand())->getGuid(); + Uuid = CXXUuidofExpr::GetUuidAttrOfType(getTypeOperand(Context))->getGuid(); else { // Special case: __uuidof(0) means an all-zero GUID. Expr *Op = getExprOperand(); |