[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p2 requirements (PR #101853)
Mital Ashok via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 5 01:28:01 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 &&
----------------
MitalAshok wrote:
This is slightly changed from `tunit->getASTContext()->getLangOpts().FreeStanding` to `getLangOpts().Freestanding`. Is there any reason for this change? I don't know if these can have different values, but better safe than sorry
https://github.com/llvm/llvm-project/pull/101853
More information about the cfe-commits
mailing list