diff options
author | Alp Toker <alp@nuanti.com> | 2014-07-11 20:53:51 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-07-11 20:53:51 +0000 |
commit | 5d96e0a3a79534f4ab6fb91f4cfa3e01e199f26e (patch) | |
tree | 2c961bd7cc507d3848139353817fbb7477bbdff7 /clang/lib/Sema/SemaDecl.cpp | |
parent | 4ce9863d0bc423bb4616e6ca14337e6c900339b8 (diff) | |
download | bcm5719-llvm-5d96e0a3a79534f4ab6fb91f4cfa3e01e199f26e.tar.gz bcm5719-llvm-5d96e0a3a79534f4ab6fb91f4cfa3e01e199f26e.zip |
Consolidate header inclusion diagnostics
Make argument orders match, unify diagnostic IDs and reword the message to be a
little less saccharine.
llvm-svn: 212845
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 253ec39a844..042fe264526 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1602,6 +1602,20 @@ static void LookupPredefedObjCSuperType(Sema &ThisSema, Scope *S, Context.setObjCSuperType(Context.getTagDeclType(TD)); } +static StringRef getHeaderName(ASTContext::GetBuiltinTypeError Error) { + switch (Error) { + case ASTContext::GE_None: + return ""; + case ASTContext::GE_Missing_stdio: + return "stdio.h"; + case ASTContext::GE_Missing_setjmp: + return "setjmp.h"; + case ASTContext::GE_Missing_ucontext: + return "ucontext.h"; + } + llvm_unreachable("unhandled error kind"); +} + /// LazilyCreateBuiltin - The specified Builtin-ID was first used at /// file scope. lazily create a decl for it. ForRedeclaration is true /// if we're creating this built-in in anticipation of redeclaring the @@ -1615,27 +1629,11 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, ASTContext::GetBuiltinTypeError Error; QualType R = Context.GetBuiltinType(BID, Error); - switch (Error) { - case ASTContext::GE_None: - // Okay - break; - - case ASTContext::GE_Missing_stdio: - if (ForRedeclaration) - Diag(Loc, diag::warn_implicit_decl_requires_stdio) - << Context.BuiltinInfo.GetName(BID); - return nullptr; - - case ASTContext::GE_Missing_setjmp: - if (ForRedeclaration) - Diag(Loc, diag::warn_implicit_decl_requires_setjmp) - << Context.BuiltinInfo.GetName(BID); - return nullptr; - - case ASTContext::GE_Missing_ucontext: + if (Error) { if (ForRedeclaration) - Diag(Loc, diag::warn_implicit_decl_requires_ucontext) - << Context.BuiltinInfo.GetName(BID); + Diag(Loc, diag::warn_implicit_decl_requires_sysheader) + << getHeaderName(Error) + << Context.BuiltinInfo.GetName(BID); return nullptr; } @@ -1645,9 +1643,9 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid, << R; if (Context.BuiltinInfo.getHeaderName(BID) && !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc)) - Diag(Loc, diag::note_please_include_header) - << Context.BuiltinInfo.getHeaderName(BID) - << Context.BuiltinInfo.GetName(BID); + Diag(Loc, diag::note_include_header_or_declare) + << Context.BuiltinInfo.getHeaderName(BID) + << Context.BuiltinInfo.GetName(BID); } DeclContext *Parent = Context.getTranslationUnitDecl(); |