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 @@ -3007,14 +3007,22 @@ bool DeclAndTypePrinter::shouldInclude(const ValueDecl *VD) {
3007
3007
return false ;
3008
3008
}
3009
3009
3010
- // In C output mode print only @cdecls and skip them in other modes.
3011
- bool isCDeclForC = false ;
3012
- auto *FD = dyn_cast<AbstractFunctionDecl>(VD);
3013
- if (FD)
3014
- isCDeclForC = FD->getCDeclKind () == ForeignLanguage::C;
3015
- if (isCDeclForC != (outputLang == OutputLanguageMode::C))
3010
+ // In C output mode print only the C variant `@cdecl` (no `@_cdecl`),
3011
+ // while in other modes print only `@_cdecl`.
3012
+ std::optional<ForeignLanguage> cdeclKind = std::nullopt;
3013
+ if (auto *FD = dyn_cast<AbstractFunctionDecl>(VD))
3014
+ cdeclKind = FD->getCDeclKind ();
3015
+ if (cdeclKind &&
3016
+ (*cdeclKind == ForeignLanguage::C) !=
3017
+ (outputLang == OutputLanguageMode::C))
3016
3018
return false ;
3017
3019
3020
+ // C output mode only accepts @cdecl functions.
3021
+ if (outputLang == OutputLanguageMode::C &&
3022
+ !cdeclKind) {
3023
+ return false ;
3024
+ }
3025
+
3018
3026
if (VD->getAttrs ().hasAttribute <ImplementationOnlyAttr>())
3019
3027
return false ;
3020
3028
You can’t perform that action at this time.
0 commit comments