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.

llvm-svn: 144062
This commit is contained in:
Peter Collingbourne 2011-11-08 02:52:52 +00:00
parent 1d8859668f
commit 32fab902de
1 changed files with 4 additions and 3 deletions

View 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 ";