@@ -633,7 +633,7 @@ static void printExplicitSpecifier(ExplicitSpecifier ES, llvm::raw_ostream &Out,
633
633
Out << Proto;
634
634
}
635
635
636
- static void maybePrintTagKeywordIfSupressingScopes (PrintingPolicy &Policy,
636
+ static void MaybePrintTagKeywordIfSupressingScopes (PrintingPolicy &Policy,
637
637
QualType T,
638
638
llvm::raw_ostream &Out) {
639
639
StringRef prefix = T->isClassType () ? " class "
@@ -643,22 +643,6 @@ static void maybePrintTagKeywordIfSupressingScopes(PrintingPolicy &Policy,
643
643
Out << prefix;
644
644
}
645
645
646
- // / Return the language of the linkage spec of `D`, if applicable.
647
- // /
648
- // / \Return - "C" if `D` has been declared with unbraced `extern "C"`
649
- // / - "C++" if `D` has been declared with unbraced `extern "C++"`
650
- // / - nullptr in any other case
651
- static const char *tryGetUnbracedLinkageLanguage (const Decl *D) {
652
- const auto *SD = dyn_cast<LinkageSpecDecl>(D->getDeclContext ());
653
- if (!SD || SD->hasBraces ())
654
- return nullptr ;
655
- if (SD->getLanguage () == LinkageSpecLanguageIDs::C)
656
- return " C" ;
657
- assert (SD->getLanguage () == LinkageSpecLanguageIDs::CXX &&
658
- " unknown language in linkage specification" );
659
- return " C++" ;
660
- }
661
-
662
646
void DeclPrinter::VisitFunctionDecl (FunctionDecl *D) {
663
647
if (!D->getDescribedFunctionTemplate () &&
664
648
!D->isFunctionTemplateSpecialization ()) {
@@ -678,11 +662,6 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
678
662
CXXConversionDecl *ConversionDecl = dyn_cast<CXXConversionDecl>(D);
679
663
CXXDeductionGuideDecl *GuideDecl = dyn_cast<CXXDeductionGuideDecl>(D);
680
664
if (!Policy.SuppressSpecifiers ) {
681
- if (const char *Lang = tryGetUnbracedLinkageLanguage (D)) {
682
- // the "extern" specifier is implicit
683
- assert (D->getStorageClass () == SC_None);
684
- Out << " extern \" " << Lang << " \" " ;
685
- }
686
665
switch (D->getStorageClass ()) {
687
666
case SC_None: break ;
688
667
case SC_Extern: Out << " extern " ; break ;
@@ -828,7 +807,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) {
828
807
}
829
808
if (!Policy.SuppressTagKeyword && Policy.SuppressScope &&
830
809
!Policy.SuppressUnwrittenScope )
831
- maybePrintTagKeywordIfSupressingScopes (Policy, AFT->getReturnType (),
810
+ MaybePrintTagKeywordIfSupressingScopes (Policy, AFT->getReturnType (),
832
811
Out);
833
812
AFT->getReturnType ().print (Out, Policy, Proto);
834
813
Proto.clear ();
@@ -953,11 +932,6 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
953
932
: D->getASTContext ().getUnqualifiedObjCPointerType (D->getType ());
954
933
955
934
if (!Policy.SuppressSpecifiers ) {
956
- if (const char *Lang = tryGetUnbracedLinkageLanguage (D)) {
957
- // the "extern" specifier is implicit
958
- assert (D->getStorageClass () == SC_None);
959
- Out << " extern \" " << Lang << " \" " ;
960
- }
961
935
StorageClass SC = D->getStorageClass ();
962
936
if (SC != SC_None)
963
937
Out << VarDecl::getStorageClassSpecifierString (SC) << " " ;
@@ -987,7 +961,7 @@ void DeclPrinter::VisitVarDecl(VarDecl *D) {
987
961
988
962
if (!Policy.SuppressTagKeyword && Policy.SuppressScope &&
989
963
!Policy.SuppressUnwrittenScope )
990
- maybePrintTagKeywordIfSupressingScopes (Policy, T, Out);
964
+ MaybePrintTagKeywordIfSupressingScopes (Policy, T, Out);
991
965
992
966
printDeclType (T, (isa<ParmVarDecl>(D) && Policy.CleanUglifiedParameters &&
993
967
D->getIdentifier ())
@@ -1090,8 +1064,6 @@ void DeclPrinter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
1090
1064
1091
1065
void DeclPrinter::VisitEmptyDecl (EmptyDecl *D) {
1092
1066
prettyPrintAttributes (D);
1093
- if (const char *Lang = tryGetUnbracedLinkageLanguage (D))
1094
- Out << " extern \" " << Lang << " \" ;" ;
1095
1067
}
1096
1068
1097
1069
void DeclPrinter::VisitCXXRecordDecl (CXXRecordDecl *D) {
@@ -1164,21 +1136,22 @@ void DeclPrinter::VisitCXXRecordDecl(CXXRecordDecl *D) {
1164
1136
}
1165
1137
1166
1138
void DeclPrinter::VisitLinkageSpecDecl (LinkageSpecDecl *D) {
1167
- if (!D->hasBraces ()) {
1168
- VisitDeclContext (D);
1169
- return ;
1170
- }
1171
- const char *L;
1139
+ const char *l;
1172
1140
if (D->getLanguage () == LinkageSpecLanguageIDs::C)
1173
- L = " C" ;
1141
+ l = " C" ;
1174
1142
else {
1175
1143
assert (D->getLanguage () == LinkageSpecLanguageIDs::CXX &&
1176
1144
" unknown language in linkage specification" );
1177
- L = " C++" ;
1145
+ l = " C++" ;
1178
1146
}
1179
- Out << " extern \" " << L << " \" {\n " ;
1180
- VisitDeclContext (D);
1181
- Indent () << " }" ;
1147
+
1148
+ Out << " extern \" " << l << " \" " ;
1149
+ if (D->hasBraces ()) {
1150
+ Out << " {\n " ;
1151
+ VisitDeclContext (D);
1152
+ Indent () << " }" ;
1153
+ } else
1154
+ Visit (*D->decls_begin ());
1182
1155
}
1183
1156
1184
1157
void DeclPrinter::printTemplateParameters (const TemplateParameterList *Params,
0 commit comments