From: Peter Collingbourne Date: Tue, 8 Nov 2011 02:52:52 +0000 (+0000) Subject: DeclPrinter: print the declaration's storage class specifier as X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13330c4e85993b348b94958197f9a5be9b778741;p=clang DeclPrinter: print the declaration's storage class specifier as written, instead of the resolved storage class, which might not be legal to specify on the declaration (such as out-of-line definitions of static class members in C++, and __local variables in OpenCL). Initial patch by Richard Membarth. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144062 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index d3c9c7a1ec..1553af1b13 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -376,7 +376,7 @@ void DeclPrinter::VisitEnumConstantDecl(EnumConstantDecl *D) { void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { if (!Policy.SuppressSpecifiers) { - switch (D->getStorageClass()) { + switch (D->getStorageClassAsWritten()) { case SC_None: break; case SC_Extern: Out << "extern "; break; case SC_Static: Out << "static "; break; @@ -596,8 +596,9 @@ void DeclPrinter::VisitLabelDecl(LabelDecl *D) { void DeclPrinter::VisitVarDecl(VarDecl *D) { - if (!Policy.SuppressSpecifiers && D->getStorageClass() != SC_None) - Out << VarDecl::getStorageClassSpecifierString(D->getStorageClass()) << " "; + StorageClass SCAsWritten = D->getStorageClassAsWritten(); + if (!Policy.SuppressSpecifiers && SCAsWritten != SC_None) + Out << VarDecl::getStorageClassSpecifierString(SCAsWritten) << " "; if (!Policy.SuppressSpecifiers && D->isThreadSpecified()) Out << "__thread ";