Add support for sending QualType's directly into diags and convert two
diags over to use this. QualTypes implicitly print single quotes around
them for uniformity and future extension.
Doing this requires a little function pointer dance to prevent libbasic
from depending on libast.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59907 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index ef3ead4..bebde38 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2054,7 +2054,7 @@
QualType Sema::InvalidOperands(SourceLocation Loc, Expr *&lex, Expr *&rex) {
Diag(Loc, diag::err_typecheck_invalid_operands)
- << lex->getType().getAsString() << rex->getType().getAsString()
+ << lex->getType() << rex->getType()
<< lex->getSourceRange() << rex->getSourceRange();
return QualType();
}
@@ -2809,20 +2809,19 @@
return Context.getPointerType(op->getType());
}
-QualType Sema::CheckIndirectionOperand(Expr *op, SourceLocation OpLoc) {
- UsualUnaryConversions(op);
- QualType qType = op->getType();
+QualType Sema::CheckIndirectionOperand(Expr *Op, SourceLocation OpLoc) {
+ UsualUnaryConversions(Op);
+ QualType Ty = Op->getType();
- if (const PointerType *PT = qType->getAsPointerType()) {
- // Note that per both C89 and C99, this is always legal, even
- // if ptype is an incomplete type or void.
- // It would be possible to warn about dereferencing a
- // void pointer, but it's completely well-defined,
- // and such a warning is unlikely to catch any mistakes.
+ // Note that per both C89 and C99, this is always legal, even if ptype is an
+ // incomplete type or void. It would be possible to warn about dereferencing
+ // a void pointer, but it's completely well-defined, and such a warning is
+ // unlikely to catch any mistakes.
+ if (const PointerType *PT = Ty->getAsPointerType())
return PT->getPointeeType();
- }
+
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
- << qType.getAsString() << op->getSourceRange();
+ << Ty << Op->getSourceRange();
return QualType();
}