From 7dd42ecfa2a29bac89c965544c14b32805c8f02b Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 30 Jan 2021 19:28:11 +0000 Subject: [PATCH] clang: Exclude efi_main from -Wmissing-prototypes When compiling UEFI applications, the main function is named efi_main() instead of main(). Let's exclude efi_main() from -Wmissing-prototypes as well to avoid warnings when working on UEFI applications. Differential Revision: https://reviews.llvm.org/D95746 --- clang/lib/Sema/SemaDecl.cpp | 2 +- clang/test/Sema/no-warn-missing-prototype.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index cee107096947..0f5b5332364a 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -13873,7 +13873,7 @@ ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, // Don't warn about 'main'. if (isa(FD->getDeclContext()->getRedeclContext())) if (IdentifierInfo *II = FD->getIdentifier()) - if (II->isStr("main")) + if (II->isStr("main") || II->isStr("efi_main")) return false; // Don't warn about inline functions. diff --git a/clang/test/Sema/no-warn-missing-prototype.c b/clang/test/Sema/no-warn-missing-prototype.c index 4dbc25755922..6059b6aa0f14 100644 --- a/clang/test/Sema/no-warn-missing-prototype.c +++ b/clang/test/Sema/no-warn-missing-prototype.c @@ -4,3 +4,7 @@ int main() { return 0; } + +int efi_main() { + return 0; +}