diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp b/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp index 3252671991b7..cbd9df4d6a7b 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp @@ -5703,6 +5703,13 @@ static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, return false; } +/// Returns true if the declaration is declared in a system header or from a +/// system macro. +static bool isFromSystemHeader(SourceManager &SM, const Decl *D) { + return SM.isInSystemHeader(D->getLocation()) || + SM.isInSystemMacro(D->getLocation()); +} + void Sema::warnOnReservedIdentifier(const NamedDecl *D) { // Avoid warning twice on the same identifier, and don't warn on redeclaration // of system decl. @@ -5710,9 +5717,10 @@ void Sema::warnOnReservedIdentifier(const NamedDecl *D) { return; ReservedIdentifierStatus Status = D->isReserved(getLangOpts()); if (Status != ReservedIdentifierStatus::NotReserved && - !Context.getSourceManager().isInSystemHeader(D->getLocation())) + !isFromSystemHeader(Context.getSourceManager(), D)) { Diag(D->getLocation(), diag::warn_reserved_extern_symbol) << D << static_cast<int>(Status); + } } Decl *Sema::ActOnDeclarator(Scope *S, Declarator &D) { @@ -14188,6 +14196,9 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, if (!FD->isGlobal()) return false; + if (!FD->isExternallyVisible()) + return false; + // Don't warn about C++ member functions. if (isa<CXXMethodDecl>(FD)) return false; |