File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -3006,14 +3006,22 @@ bool DeclAndTypePrinter::shouldInclude(const ValueDecl *VD) {
30063006 return false ;
30073007 }
30083008
3009- // In C output mode print only @cdecls and skip them in other modes.
3010- bool isCDeclForC = false ;
3011- auto *FD = dyn_cast<AbstractFunctionDecl>(VD);
3012- if (FD)
3013- isCDeclForC = FD->getCDeclKind () == ForeignLanguage::C;
3014- if (isCDeclForC != (outputLang == OutputLanguageMode::C))
3009+ // In C output mode print only the C variant `@cdecl` (no `@_cdecl`),
3010+ // while in other modes print only `@_cdecl`.
3011+ std::optional<ForeignLanguage> cdeclKind = std::nullopt ;
3012+ if (auto *FD = dyn_cast<AbstractFunctionDecl>(VD))
3013+ cdeclKind = FD->getCDeclKind ();
3014+ if (cdeclKind &&
3015+ (*cdeclKind == ForeignLanguage::C) !=
3016+ (outputLang == OutputLanguageMode::C))
30153017 return false ;
30163018
3019+ // C output mode only accepts @cdecl functions.
3020+ if (outputLang == OutputLanguageMode::C &&
3021+ !cdeclKind) {
3022+ return false ;
3023+ }
3024+
30173025 if (VD->getAttrs ().hasAttribute <ImplementationOnlyAttr>())
30183026 return false ;
30193027
You can’t perform that action at this time.
0 commit comments