[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 5 02:56:21 PDT 2024
================
@@ -3292,11 +3292,9 @@ bool FunctionDecl::isImmediateFunction() const {
}
bool FunctionDecl::isMain() const {
- const TranslationUnitDecl *tunit =
- dyn_cast<TranslationUnitDecl>(getDeclContext()->getRedeclContext());
- return tunit &&
- !tunit->getASTContext().getLangOpts().Freestanding &&
- isNamed(this, "main");
+ const DeclContext *DC = getDeclContext();
+ return isNamed(this, "main") && !getLangOpts().Freestanding &&
----------------
Sirraide wrote:
I don’t see how they couldn’t be the same seeing as `Decl`’s `getLangOpts()` just gets them from the `ASTContext` either way. I think this change is fine.
https://github.com/llvm/llvm-project/pull/101853
More information about the cfe-commits
mailing list