]> granicus.if.org Git - clang/commitdiff
DeclPrinter: print the declaration's storage class specifier as
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 8 Nov 2011 02:52:52 +0000 (02:52 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 8 Nov 2011 02:52:52 +0000 (02:52 +0000)
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

lib/AST/DeclPrinter.cpp

index d3c9c7a1ec7a9a31f2be22890a274a0187ef844a..1553af1b130d2e4c27308a918b3bc18fcbdd71fc 100644 (file)
@@ -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 ";