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) {
3006
3006
return false ;
3007
3007
}
3008
3008
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))
3015
3017
return false ;
3016
3018
3019
+ // C output mode only accepts @cdecl functions.
3020
+ if (outputLang == OutputLanguageMode::C &&
3021
+ !cdeclKind) {
3022
+ return false ;
3023
+ }
3024
+
3017
3025
if (VD->getAttrs ().hasAttribute <ImplementationOnlyAttr>())
3018
3026
return false ;
3019
3027
You can’t perform that action at this time.
0 commit comments