[cfe-commits] r59868 - in /cfe/trunk: include/clang/Parse/DeclSpec.h lib/Parse/DeclSpec.cpp
Chris Lattner
sabre at nondot.org
Sat Nov 22 00:32:36 PST 2008
Author: lattner
Date: Sat Nov 22 02:32:36 2008
New Revision: 59868
URL: http://llvm.org/viewvc/llvm-project?rev=59868&view=rev
Log:
remove some more old Diag methods, replace with a single static helper function
Modified:
cfe/trunk/include/clang/Parse/DeclSpec.h
cfe/trunk/lib/Parse/DeclSpec.cpp
Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=59868&r1=59867&r2=59868&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Sat Nov 22 02:32:36 2008
@@ -317,13 +317,6 @@
/// things like "_Imaginary" (lacking an FP type). After calling this method,
/// DeclSpec is guaranteed self-consistent, even if an error occurred.
void Finish(Diagnostic &D, SourceManager& SrcMgr, const LangOptions &Lang);
-
-private:
- void Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr,
- unsigned DiagID);
-
- void Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr,
- unsigned DiagID, const std::string &info);
};
/// ObjCDeclSpec - This class captures information about
Modified: cfe/trunk/lib/Parse/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/DeclSpec.cpp?rev=59868&r1=59867&r2=59868&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Parse/DeclSpec.cpp Sat Nov 22 02:32:36 2008
@@ -16,6 +16,14 @@
#include "clang/Basic/LangOptions.h"
using namespace clang;
+
+static DiagnosticBuilder Diag(Diagnostic &D, SourceLocation Loc,
+ SourceManager &SrcMgr, unsigned DiagID) {
+ return D.Report(FullSourceLoc(Loc, SrcMgr), DiagID);
+}
+
+
+
/// getParsedSpecifiers - Return a bitmask of which flavors of specifiers this
///
unsigned DeclSpec::getParsedSpecifiers() const {
@@ -124,7 +132,7 @@
bool DeclSpec::SetStorageClassSpec(SCS S, SourceLocation Loc,
const char *&PrevSpec) {
if (StorageClassSpec != SCS_unspecified)
- return BadSpecifier( (SCS)StorageClassSpec, PrevSpec);
+ return BadSpecifier((SCS)StorageClassSpec, PrevSpec);
StorageClassSpec = S;
StorageClassSpecLoc = Loc;
assert((unsigned)S == StorageClassSpec && "SCS constants overflow bitfield");
@@ -151,7 +159,7 @@
if (TypeSpecWidth != TSW_unspecified &&
// Allow turning long -> long long.
(W != TSW_longlong || TypeSpecWidth != TSW_long))
- return BadSpecifier( (TSW)TypeSpecWidth, PrevSpec);
+ return BadSpecifier((TSW)TypeSpecWidth, PrevSpec);
TypeSpecWidth = W;
TSWLoc = Loc;
return false;
@@ -160,7 +168,7 @@
bool DeclSpec::SetTypeSpecComplex(TSC C, SourceLocation Loc,
const char *&PrevSpec) {
if (TypeSpecComplex != TSC_unspecified)
- return BadSpecifier( (TSC)TypeSpecComplex, PrevSpec);
+ return BadSpecifier((TSC)TypeSpecComplex, PrevSpec);
TypeSpecComplex = C;
TSCLoc = Loc;
return false;
@@ -169,7 +177,7 @@
bool DeclSpec::SetTypeSpecSign(TSS S, SourceLocation Loc,
const char *&PrevSpec) {
if (TypeSpecSign != TSS_unspecified)
- return BadSpecifier( (TSS)TypeSpecSign, PrevSpec);
+ return BadSpecifier((TSS)TypeSpecSign, PrevSpec);
TypeSpecSign = S;
TSSLoc = Loc;
return false;
@@ -178,7 +186,7 @@
bool DeclSpec::SetTypeSpecType(TST T, SourceLocation Loc,
const char *&PrevSpec, Action::TypeTy *Rep) {
if (TypeSpecType != TST_unspecified)
- return BadSpecifier( (TST)TypeSpecType, PrevSpec);
+ return BadSpecifier((TST)TypeSpecType, PrevSpec);
TypeSpecType = T;
TypeRep = Rep;
TSTLoc = Loc;
@@ -237,8 +245,8 @@
TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int.
else if (TypeSpecType != TST_int &&
TypeSpecType != TST_char && TypeSpecType != TST_wchar) {
- Diag(D, TSSLoc, SrcMgr, diag::err_invalid_sign_spec,
- getSpecifierName( (TST)TypeSpecType));
+ Diag(D, TSSLoc, SrcMgr, diag::err_invalid_sign_spec)
+ << getSpecifierName((TST)TypeSpecType);
// signed double -> double.
TypeSpecSign = TSS_unspecified;
}
@@ -254,8 +262,8 @@
else if (TypeSpecType != TST_int) {
Diag(D, TSWLoc, SrcMgr,
TypeSpecWidth == TSW_short ? diag::err_invalid_short_spec
- : diag::err_invalid_longlong_spec,
- getSpecifierName( (TST)TypeSpecType));
+ : diag::err_invalid_longlong_spec)
+ << getSpecifierName((TST)TypeSpecType);
TypeSpecType = TST_int;
}
break;
@@ -263,8 +271,8 @@
if (TypeSpecType == TST_unspecified)
TypeSpecType = TST_int; // long -> long int.
else if (TypeSpecType != TST_int && TypeSpecType != TST_double) {
- Diag(D, TSWLoc, SrcMgr, diag::err_invalid_long_spec,
- getSpecifierName( (TST)TypeSpecType));
+ Diag(D, TSWLoc, SrcMgr, diag::err_invalid_long_spec)
+ << getSpecifierName((TST)TypeSpecType);
TypeSpecType = TST_int;
}
break;
@@ -280,8 +288,8 @@
// Note that this intentionally doesn't include _Complex _Bool.
Diag(D, TSTLoc, SrcMgr, diag::ext_integer_complex);
} else if (TypeSpecType != TST_float && TypeSpecType != TST_double) {
- Diag(D, TSCLoc, SrcMgr, diag::err_invalid_complex_spec,
- getSpecifierName( (TST)TypeSpecType));
+ Diag(D, TSCLoc, SrcMgr, diag::err_invalid_complex_spec)
+ << getSpecifierName((TST)TypeSpecType);
TypeSpecComplex = TSC_unspecified;
}
}
@@ -292,8 +300,8 @@
StorageClassSpec = SCS_extern; // '__thread int' -> 'extern __thread int'
} else if (StorageClassSpec != SCS_extern &&
StorageClassSpec != SCS_static) {
- Diag(D, getStorageClassSpecLoc(), SrcMgr, diag::err_invalid_thread_spec,
- getSpecifierName( (SCS)StorageClassSpec));
+ Diag(D, getStorageClassSpecLoc(), SrcMgr, diag::err_invalid_thread_spec)
+ << getSpecifierName((SCS)StorageClassSpec);
SCS_thread_specified = false;
}
}
@@ -305,12 +313,3 @@
// 'data definition has no type or storage class'?
}
-void DeclSpec::Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr,
- unsigned DiagID) {
- D.Report(FullSourceLoc(Loc,SrcMgr), DiagID);
-}
-
-void DeclSpec::Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr,
- unsigned DiagID, const std::string &Info) {
- D.Report(FullSourceLoc(Loc,SrcMgr), DiagID) << Info;
-}
More information about the cfe-commits
mailing list