Change a whole lot of diagnostics to take QualType's directly
instead of converting them to strings first. This also fixes a
bunch of minor inconsistencies in the diagnostics emitted by clang
and adds a bunch of FIXME's to DiagnosticKinds.def.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59948 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 7000c3f..d878e46 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -204,13 +204,13 @@
if (!EltTy->isIncompleteOrObjectType()) {
Diag(DS.getRestrictSpecLoc(),
diag::err_typecheck_invalid_restrict_invalid_pointee)
- << EltTy.getAsString() << DS.getSourceRange();
+ << EltTy << DS.getSourceRange();
TypeQuals &= ~QualType::Restrict; // Remove the restrict qualifier.
}
} else {
Diag(DS.getRestrictSpecLoc(),
diag::err_typecheck_invalid_restrict_not_pointer)
- << Result.getAsString() << DS.getSourceRange();
+ << Result << DS.getSourceRange();
TypeQuals &= ~QualType::Restrict; // Remove the restrict qualifier.
}
}
@@ -229,7 +229,7 @@
Loc = DS.getVolatileSpecLoc();
}
Diag(Loc, diag::warn_typecheck_function_qualifiers)
- << Result.getAsString() << DS.getSourceRange();
+ << Result << DS.getSourceRange();
}
// C++ [dcl.ref]p1:
@@ -286,7 +286,7 @@
if ((DeclType.Ptr.TypeQuals & QualType::Restrict) &&
!T->isIncompleteOrObjectType()) {
Diag(DeclType.Loc, diag::err_typecheck_invalid_restrict_invalid_pointee)
- << T.getAsString();
+ << T;
DeclType.Ptr.TypeQuals &= QualType::Restrict;
}
@@ -327,7 +327,7 @@
if (DeclType.Ref.HasRestrict &&
!T->isIncompleteOrObjectType()) {
Diag(DeclType.Loc, diag::err_typecheck_invalid_restrict_invalid_pointee)
- << T.getAsString();
+ << T;
DeclType.Ref.HasRestrict = false;
}
@@ -356,7 +356,7 @@
// reject it (e.g. void ary[7], struct foo ary[7], void ary[7]())
if (T->isIncompleteType()) {
Diag(D.getIdentifierLoc(), diag::err_illegal_decl_array_incomplete_type)
- << T.getAsString();
+ << T;
T = Context.IntTy;
D.setInvalidType(true);
} else if (T->isFunctionType()) {
@@ -374,20 +374,18 @@
// If the element type is a struct or union that contains a variadic
// array, reject it: C99 6.7.2.1p2.
if (EltTy->getDecl()->hasFlexibleArrayMember()) {
- Diag(DeclType.Loc, diag::err_flexible_array_in_array)
- << T.getAsString();
+ Diag(DeclType.Loc, diag::err_flexible_array_in_array) << T;
T = Context.IntTy;
D.setInvalidType(true);
}
} else if (T->isObjCInterfaceType()) {
- Diag(DeclType.Loc, diag::warn_objc_array_of_interfaces)
- << T.getAsString();
+ Diag(DeclType.Loc, diag::warn_objc_array_of_interfaces) << T;
}
// C99 6.7.5.2p1: The size expression shall have integer type.
if (ArraySize && !ArraySize->getType()->isIntegerType()) {
Diag(ArraySize->getLocStart(), diag::err_array_size_non_int)
- << ArraySize->getType().getAsString() << ArraySize->getSourceRange();
+ << ArraySize->getType() << ArraySize->getSourceRange();
D.setInvalidType(true);
delete ArraySize;
ATI.NumElts = ArraySize = 0;
@@ -436,8 +434,7 @@
// C99 6.7.5.3p1: The return type may not be a function or array type.
if (T->isArrayType() || T->isFunctionType()) {
- Diag(DeclType.Loc, diag::err_func_returning_array_function)
- << T.getAsString();
+ Diag(DeclType.Loc, diag::err_func_returning_array_function) << T;
T = Context.IntTy;
D.setInvalidType(true);
}