[clang] [Clang] strengthen checks for 'main' function to meet [basic.start.main] p3 requirements (PR #101853)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 7 09:09:59 PDT 2024
================
@@ -7353,13 +7353,26 @@ void emitReadOnlyPlacementAttrWarning(Sema &S, const VarDecl *VD) {
}
}
-// Checks if VD is declared at global scope or with C language linkage.
-static bool isMainVar(DeclarationName Name, VarDecl *VD) {
- return Name.getAsIdentifierInfo() &&
- Name.getAsIdentifierInfo()->isStr("main") &&
- !VD->getDescribedVarTemplate() &&
- (VD->getDeclContext()->getRedeclContext()->isTranslationUnit() ||
- VD->isExternC());
+enum MainVarClassificationKind {
+ IMV_NotMain,
+ IMV_GlobalMain,
+ IMV_CLinkageMain,
+};
----------------
Sirraide wrote:
I don’t think this needs to exist:
1. We’re not even using all of these enumerators.
2. We test for them in exactly one place.
3. The test in question ends up being more complex as a result.
It was fine the way it was before, so I’d suggest you just revert this commit.
(Also, for future reference, we prefer scoped enumerations these days.)
https://github.com/llvm/llvm-project/pull/101853
More information about the cfe-commits
mailing list