Don't use magic constants in the digraph diagnostic
llvm-svn: 198605
This commit is contained in:
parent
a231ad2216
commit
addd3669d4
|
@ -641,9 +641,7 @@ def err_ctor_init_missing_comma : Error<
|
||||||
def err_friend_decl_defines_type : Error<
|
def err_friend_decl_defines_type : Error<
|
||||||
"cannot define a type in a friend declaration">;
|
"cannot define a type in a friend declaration">;
|
||||||
def err_missing_whitespace_digraph : Error<
|
def err_missing_whitespace_digraph : Error<
|
||||||
"found '<::' after a "
|
"found '<::' after a %0 which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?">;
|
||||||
"%select{template name|const_cast|dynamic_cast|reinterpret_cast|static_cast}0"
|
|
||||||
" which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?">;
|
|
||||||
|
|
||||||
def ext_deleted_function : ExtWarn<
|
def ext_deleted_function : ExtWarn<
|
||||||
"deleted function definitions are a C++11 extension">, InGroup<CXX11>;
|
"deleted function definitions are a C++11 extension">, InGroup<CXX11>;
|
||||||
|
|
|
@ -24,18 +24,6 @@
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
static int SelectDigraphErrorMessage(tok::TokenKind Kind) {
|
|
||||||
switch (Kind) {
|
|
||||||
case tok::kw_template: return 0;
|
|
||||||
case tok::kw_const_cast: return 1;
|
|
||||||
case tok::kw_dynamic_cast: return 2;
|
|
||||||
case tok::kw_reinterpret_cast: return 3;
|
|
||||||
case tok::kw_static_cast: return 4;
|
|
||||||
default:
|
|
||||||
llvm_unreachable("Unknown type for digraph error message.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Are the two tokens adjacent in the same source file?
|
// Are the two tokens adjacent in the same source file?
|
||||||
bool Parser::areTokensAdjacent(const Token &First, const Token &Second) {
|
bool Parser::areTokensAdjacent(const Token &First, const Token &Second) {
|
||||||
SourceManager &SM = PP.getSourceManager();
|
SourceManager &SM = PP.getSourceManager();
|
||||||
|
@ -56,8 +44,7 @@ static void FixDigraph(Parser &P, Preprocessor &PP, Token &DigraphToken,
|
||||||
Range.setBegin(DigraphToken.getLocation());
|
Range.setBegin(DigraphToken.getLocation());
|
||||||
Range.setEnd(ColonToken.getLocation());
|
Range.setEnd(ColonToken.getLocation());
|
||||||
P.Diag(DigraphToken.getLocation(), diag::err_missing_whitespace_digraph)
|
P.Diag(DigraphToken.getLocation(), diag::err_missing_whitespace_digraph)
|
||||||
<< SelectDigraphErrorMessage(Kind)
|
<< Kind << FixItHint::CreateReplacement(Range, "< ::");
|
||||||
<< FixItHint::CreateReplacement(Range, "< ::");
|
|
||||||
|
|
||||||
// Update token information to reflect their change in token type.
|
// Update token information to reflect their change in token type.
|
||||||
ColonToken.setKind(tok::coloncolon);
|
ColonToken.setKind(tok::coloncolon);
|
||||||
|
@ -93,7 +80,7 @@ void Parser::CheckForTemplateAndDigraph(Token &Next, ParsedType ObjectType,
|
||||||
Template, MemberOfUnknownSpecialization))
|
Template, MemberOfUnknownSpecialization))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FixDigraph(*this, PP, Next, SecondToken, tok::kw_template,
|
FixDigraph(*this, PP, Next, SecondToken, tok::annot_template_id,
|
||||||
/*AtDigraph*/ false);
|
/*AtDigraph*/ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue