diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-22 00:27:42 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-01-22 00:27:42 +0000 |
commit | e81daee21b6aa9a2f80941103f1a32f36a0b4ec9 (patch) | |
tree | 338c80f191e165c7f7e74a7c18820306621b24d9 /clang/lib/AST/DeclarationName.cpp | |
parent | 6ba68f10c4f6b5f9f068b29def27cb6f6a55b11d (diff) | |
download | bcm5719-llvm-e81daee21b6aa9a2f80941103f1a32f36a0b4ec9.tar.gz bcm5719-llvm-e81daee21b6aa9a2f80941103f1a32f36a0b4ec9.zip |
When formatting a C++-only declaration name, enable C++ mode in the formatter's
language options. This is not really ideal -- we should require the right
language options to be passed in, or not require language options to format a
name -- but it fixes a number of *obviously* wrong formattings. Patch by
Olivier Goffart!
llvm-svn: 199778
Diffstat (limited to 'clang/lib/AST/DeclarationName.cpp')
-rw-r--r-- | clang/lib/AST/DeclarationName.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/AST/DeclarationName.cpp b/clang/lib/AST/DeclarationName.cpp index 56b75746008..e5019ab8d9f 100644 --- a/clang/lib/AST/DeclarationName.cpp +++ b/clang/lib/AST/DeclarationName.cpp @@ -150,7 +150,9 @@ raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) { QualType ClassType = N.getCXXNameType(); if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) return OS << *ClassRec->getDecl(); - return OS << ClassType.getAsString(); + LangOptions LO; + LO.CPlusPlus = true; + return OS << ClassType.getAsString(PrintingPolicy(LO)); } case DeclarationName::CXXDestructorName: { @@ -158,7 +160,9 @@ raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) { QualType Type = N.getCXXNameType(); if (const RecordType *Rec = Type->getAs<RecordType>()) return OS << *Rec->getDecl(); - return OS << Type.getAsString(); + LangOptions LO; + LO.CPlusPlus = true; + return OS << Type.getAsString(PrintingPolicy(LO)); } case DeclarationName::CXXOperatorName: { @@ -185,7 +189,9 @@ raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) { QualType Type = N.getCXXNameType(); if (const RecordType *Rec = Type->getAs<RecordType>()) return OS << *Rec->getDecl(); - return OS << Type.getAsString(); + LangOptions LO; + LO.CPlusPlus = true; + return OS << Type.getAsString(PrintingPolicy(LO)); } case DeclarationName::CXXUsingDirective: return OS << "<using-directive>"; @@ -538,7 +544,9 @@ void DeclarationNameInfo::printName(raw_ostream &OS) const { OS << '~'; else if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName) OS << "operator "; - OS << TInfo->getType().getAsString(); + LangOptions LO; + LO.CPlusPlus = true; + OS << TInfo->getType().getAsString(PrintingPolicy(LO)); } else OS << Name; return; |