Remove the Sema::Diag helper that takes a type. Convert clients to use
the version that takes a string.
llvm-svn: 39450
diff --git a/clang/AST/Sema.cpp b/clang/AST/Sema.cpp
index 817c4d0..3439a78 100644
--- a/clang/AST/Sema.cpp
+++ b/clang/AST/Sema.cpp
@@ -44,12 +44,6 @@
return true;
}
-bool Sema::Diag(SourceLocation Loc, unsigned DiagID, QualType t) {
- std::string Name = t.getAsString();
- PP.getDiagnostics().Report(Loc, DiagID, &Name, 1);
- return true;
-}
-
bool Sema::Diag(const LexerToken &Tok, unsigned DiagID) {
PP.getDiagnostics().Report(Tok.getLocation(), DiagID);
return true;
diff --git a/clang/AST/Sema.h b/clang/AST/Sema.h
index e59e459..758fcb9 100644
--- a/clang/AST/Sema.h
+++ b/clang/AST/Sema.h
@@ -62,7 +62,6 @@
const std::string &Msg2);
bool Diag(const LexerToken &Tok, unsigned DiagID);
bool Diag(const LexerToken &Tok, unsigned DiagID, const std::string &M);
- bool Diag(SourceLocation Loc, unsigned DiagID, QualType t);
//===--------------------------------------------------------------------===//
// Type Analysis / Processing: SemaType.cpp.
diff --git a/clang/AST/SemaDecl.cpp b/clang/AST/SemaDecl.cpp
index 1a353aa..e6bc634 100644
--- a/clang/AST/SemaDecl.cpp
+++ b/clang/AST/SemaDecl.cpp
@@ -36,7 +36,7 @@
return false;
}
if (!size->getType()->isIntegerType()) {
- Diag(loc, diag::err_array_size_non_int, size->getType());
+ Diag(loc, diag::err_array_size_non_int, size->getType().getAsString());
return false;
}
// We have a constant expression with an integer type, now make sure
@@ -282,7 +282,8 @@
default: assert(0 && "Unknown storage class!");
case DeclSpec::SCS_auto:
case DeclSpec::SCS_register:
- Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_func, R);
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_func,
+ R.getAsString());
return 0;
case DeclSpec::SCS_unspecified: SC = FunctionDecl::None; break;
case DeclSpec::SCS_extern: SC = FunctionDecl::Extern; break;
@@ -322,13 +323,15 @@
// a tentative definition and has internal linkage (C99 6.2.2p3), the
// declared type shall not be an incomplete type.
if (R->isIncompleteType()) {
- Diag(D.getIdentifierLoc(), diag::err_typecheck_decl_incomplete_type, R);
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_decl_incomplete_type,
+ R.getAsString());
return 0;
}
}
// FIXME: Find C99 spec reference
if (SC == VarDecl::Auto || SC == VarDecl::Register) {
- Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope, R);
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope,
+ R.getAsString());
return 0;
}
// C99 6.7.5.2p2: If an identifier is declared to be an object with
@@ -343,7 +346,8 @@
// no linkage (C99 6.2.2p6), the type for the object shall be complete...
if (SC != VarDecl::Extern) {
if (R->isIncompleteType()) {
- Diag(D.getIdentifierLoc(), diag::err_typecheck_decl_incomplete_type, R);
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_decl_incomplete_type,
+ R.getAsString());
return 0;
}
}
diff --git a/clang/AST/SemaExpr.cpp b/clang/AST/SemaExpr.cpp
index 4506ec9..6e4aaf2 100644
--- a/clang/AST/SemaExpr.cpp
+++ b/clang/AST/SemaExpr.cpp
@@ -261,7 +261,8 @@
// in practice, the following check catches trying to index a pointer
// to a function (e.g. void (*)(int)). Functions are not objects in c99.
if (!resultType->isObjectType())
- return Diag(LLoc, diag::err_typecheck_subscript_not_object, baseType);
+ return Diag(LLoc, diag::err_typecheck_subscript_not_object,
+ baseType.getAsString());
}
return new ArraySubscriptExpr((Expr*)Base, (Expr*)Idx, resultType);
}
@@ -753,12 +754,14 @@
// C99 6.5.2.4p1
if (const PointerType *pt = dyn_cast<PointerType>(resType)) {
if (!pt->getPointeeType()->isObjectType()) { // C99 6.5.2.4p2, 6.5.6p2
- Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type, resType);
+ Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type,
+ resType.getAsString());
return QualType();
}
} else if (!resType->isRealType()) {
// FIXME: Allow Complex as a GCC extension.
- Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement, resType);
+ Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement,
+ resType.getAsString());
return QualType();
}
// At this point, we know we have a real or pointer type. Now make sure
@@ -832,7 +835,7 @@
if (PointerType *PT = dyn_cast<PointerType>(qType))
return PT->getPointeeType();
- Diag(OpLoc, diag::err_typecheck_unary_expr, qType);
+ Diag(OpLoc, diag::err_typecheck_unary_expr, qType.getAsString());
return QualType();
}
@@ -1022,17 +1025,20 @@
case UnaryOperator::Minus:
resultType = UsualUnaryConversion(((Expr *)Input)->getType());
if (!resultType->isArithmeticType()) // C99 6.5.3.3p1
- return Diag(OpLoc, diag::err_typecheck_unary_expr, resultType);
+ return Diag(OpLoc, diag::err_typecheck_unary_expr,
+ resultType.getAsString());
break;
case UnaryOperator::Not: // bitwise complement
resultType = UsualUnaryConversion(((Expr *)Input)->getType());
if (!resultType->isIntegerType()) // C99 6.5.3.3p1
- return Diag(OpLoc, diag::err_typecheck_unary_expr, resultType);
+ return Diag(OpLoc, diag::err_typecheck_unary_expr,
+ resultType.getAsString());
break;
case UnaryOperator::LNot: // logical negation
resultType = UsualUnaryConversion(((Expr *)Input)->getType());
if (!resultType->isScalarType()) // C99 6.5.3.3p1
- return Diag(OpLoc, diag::err_typecheck_unary_expr, resultType);
+ return Diag(OpLoc, diag::err_typecheck_unary_expr,
+ resultType.getAsString());
break;
case UnaryOperator::SizeOf:
resultType = CheckSizeOfAlignOfOperand(((Expr *)Input)->getType(), OpLoc,
diff --git a/clang/Sema/Sema.cpp b/clang/Sema/Sema.cpp
index 817c4d0..3439a78 100644
--- a/clang/Sema/Sema.cpp
+++ b/clang/Sema/Sema.cpp
@@ -44,12 +44,6 @@
return true;
}
-bool Sema::Diag(SourceLocation Loc, unsigned DiagID, QualType t) {
- std::string Name = t.getAsString();
- PP.getDiagnostics().Report(Loc, DiagID, &Name, 1);
- return true;
-}
-
bool Sema::Diag(const LexerToken &Tok, unsigned DiagID) {
PP.getDiagnostics().Report(Tok.getLocation(), DiagID);
return true;
diff --git a/clang/Sema/Sema.h b/clang/Sema/Sema.h
index e59e459..758fcb9 100644
--- a/clang/Sema/Sema.h
+++ b/clang/Sema/Sema.h
@@ -62,7 +62,6 @@
const std::string &Msg2);
bool Diag(const LexerToken &Tok, unsigned DiagID);
bool Diag(const LexerToken &Tok, unsigned DiagID, const std::string &M);
- bool Diag(SourceLocation Loc, unsigned DiagID, QualType t);
//===--------------------------------------------------------------------===//
// Type Analysis / Processing: SemaType.cpp.
diff --git a/clang/Sema/SemaDecl.cpp b/clang/Sema/SemaDecl.cpp
index 1a353aa..e6bc634 100644
--- a/clang/Sema/SemaDecl.cpp
+++ b/clang/Sema/SemaDecl.cpp
@@ -36,7 +36,7 @@
return false;
}
if (!size->getType()->isIntegerType()) {
- Diag(loc, diag::err_array_size_non_int, size->getType());
+ Diag(loc, diag::err_array_size_non_int, size->getType().getAsString());
return false;
}
// We have a constant expression with an integer type, now make sure
@@ -282,7 +282,8 @@
default: assert(0 && "Unknown storage class!");
case DeclSpec::SCS_auto:
case DeclSpec::SCS_register:
- Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_func, R);
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_func,
+ R.getAsString());
return 0;
case DeclSpec::SCS_unspecified: SC = FunctionDecl::None; break;
case DeclSpec::SCS_extern: SC = FunctionDecl::Extern; break;
@@ -322,13 +323,15 @@
// a tentative definition and has internal linkage (C99 6.2.2p3), the
// declared type shall not be an incomplete type.
if (R->isIncompleteType()) {
- Diag(D.getIdentifierLoc(), diag::err_typecheck_decl_incomplete_type, R);
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_decl_incomplete_type,
+ R.getAsString());
return 0;
}
}
// FIXME: Find C99 spec reference
if (SC == VarDecl::Auto || SC == VarDecl::Register) {
- Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope, R);
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope,
+ R.getAsString());
return 0;
}
// C99 6.7.5.2p2: If an identifier is declared to be an object with
@@ -343,7 +346,8 @@
// no linkage (C99 6.2.2p6), the type for the object shall be complete...
if (SC != VarDecl::Extern) {
if (R->isIncompleteType()) {
- Diag(D.getIdentifierLoc(), diag::err_typecheck_decl_incomplete_type, R);
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_decl_incomplete_type,
+ R.getAsString());
return 0;
}
}
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp
index 4506ec9..6e4aaf2 100644
--- a/clang/Sema/SemaExpr.cpp
+++ b/clang/Sema/SemaExpr.cpp
@@ -261,7 +261,8 @@
// in practice, the following check catches trying to index a pointer
// to a function (e.g. void (*)(int)). Functions are not objects in c99.
if (!resultType->isObjectType())
- return Diag(LLoc, diag::err_typecheck_subscript_not_object, baseType);
+ return Diag(LLoc, diag::err_typecheck_subscript_not_object,
+ baseType.getAsString());
}
return new ArraySubscriptExpr((Expr*)Base, (Expr*)Idx, resultType);
}
@@ -753,12 +754,14 @@
// C99 6.5.2.4p1
if (const PointerType *pt = dyn_cast<PointerType>(resType)) {
if (!pt->getPointeeType()->isObjectType()) { // C99 6.5.2.4p2, 6.5.6p2
- Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type, resType);
+ Diag(OpLoc, diag::err_typecheck_arithmetic_incomplete_type,
+ resType.getAsString());
return QualType();
}
} else if (!resType->isRealType()) {
// FIXME: Allow Complex as a GCC extension.
- Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement, resType);
+ Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement,
+ resType.getAsString());
return QualType();
}
// At this point, we know we have a real or pointer type. Now make sure
@@ -832,7 +835,7 @@
if (PointerType *PT = dyn_cast<PointerType>(qType))
return PT->getPointeeType();
- Diag(OpLoc, diag::err_typecheck_unary_expr, qType);
+ Diag(OpLoc, diag::err_typecheck_unary_expr, qType.getAsString());
return QualType();
}
@@ -1022,17 +1025,20 @@
case UnaryOperator::Minus:
resultType = UsualUnaryConversion(((Expr *)Input)->getType());
if (!resultType->isArithmeticType()) // C99 6.5.3.3p1
- return Diag(OpLoc, diag::err_typecheck_unary_expr, resultType);
+ return Diag(OpLoc, diag::err_typecheck_unary_expr,
+ resultType.getAsString());
break;
case UnaryOperator::Not: // bitwise complement
resultType = UsualUnaryConversion(((Expr *)Input)->getType());
if (!resultType->isIntegerType()) // C99 6.5.3.3p1
- return Diag(OpLoc, diag::err_typecheck_unary_expr, resultType);
+ return Diag(OpLoc, diag::err_typecheck_unary_expr,
+ resultType.getAsString());
break;
case UnaryOperator::LNot: // logical negation
resultType = UsualUnaryConversion(((Expr *)Input)->getType());
if (!resultType->isScalarType()) // C99 6.5.3.3p1
- return Diag(OpLoc, diag::err_typecheck_unary_expr, resultType);
+ return Diag(OpLoc, diag::err_typecheck_unary_expr,
+ resultType.getAsString());
break;
case UnaryOperator::SizeOf:
resultType = CheckSizeOfAlignOfOperand(((Expr *)Input)->getType(), OpLoc,