diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 44 |
2 files changed, 25 insertions, 26 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index f7d56231885..976f3a696df 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3867,7 +3867,8 @@ static void emitReplacement(Sema &S, SourceLocation Loc, SourceRange Range, if (!EmitHeaderHint) return; - S.Diag(Loc, diag::note_please_include_header) << HeaderName << FunctionName; + S.Diag(Loc, diag::note_include_header_or_declare) << HeaderName + << FunctionName; } static bool IsFunctionStdAbs(const FunctionDecl *FDecl) { @@ -3907,8 +3908,8 @@ void Sema::CheckAbsoluteValueFunction(const CallExpr *Call, QualType ArgType = Call->getArg(0)->IgnoreParenImpCasts()->getType(); QualType ParamType = Call->getArg(0)->getType(); - // Unsigned types can not be negative. Suggest to drop the absolute value - // function. + // Unsigned types cannot be negative. Suggest removing the absolute value + // function call. if (ArgType->isUnsignedIntegerType()) { const char *FunctionName = IsStdAbs ? "std::abs" : Context.BuiltinInfo.GetName(AbsKind); 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(); |