|
@@ -133,36 +133,43 @@ int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
|
|
llvm_unreachable("Invalid DeclarationName Kind!");
|
|
llvm_unreachable("Invalid DeclarationName Kind!");
|
|
}
|
|
}
|
|
|
|
|
|
-raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
|
|
|
|
|
|
+static void printCXXConstructorDestructorName(QualType ClassType,
|
|
|
|
+ raw_ostream &OS,
|
|
|
|
+ const PrintingPolicy &Policy) {
|
|
|
|
+ if (const RecordType *ClassRec = ClassType->getAs<RecordType>()) {
|
|
|
|
+ OS << *ClassRec->getDecl();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (!Policy.LangOpts.CPlusPlus) {
|
|
|
|
+ // Passed policy is the default one from operator <<, use a C++ policy.
|
|
|
|
+ LangOptions LO;
|
|
|
|
+ LO.CPlusPlus = true;
|
|
|
|
+ ClassType.print(OS, PrintingPolicy(LO));
|
|
|
|
+ } else {
|
|
|
|
+ ClassType.print(OS, Policy);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void DeclarationName::print(raw_ostream &OS, const PrintingPolicy &Policy) {
|
|
|
|
+ DeclarationName &N = *this;
|
|
switch (N.getNameKind()) {
|
|
switch (N.getNameKind()) {
|
|
case DeclarationName::Identifier:
|
|
case DeclarationName::Identifier:
|
|
if (const IdentifierInfo *II = N.getAsIdentifierInfo())
|
|
if (const IdentifierInfo *II = N.getAsIdentifierInfo())
|
|
OS << II->getName();
|
|
OS << II->getName();
|
|
- return OS;
|
|
|
|
|
|
+ return;
|
|
|
|
|
|
case DeclarationName::ObjCZeroArgSelector:
|
|
case DeclarationName::ObjCZeroArgSelector:
|
|
case DeclarationName::ObjCOneArgSelector:
|
|
case DeclarationName::ObjCOneArgSelector:
|
|
case DeclarationName::ObjCMultiArgSelector:
|
|
case DeclarationName::ObjCMultiArgSelector:
|
|
N.getObjCSelector().print(OS);
|
|
N.getObjCSelector().print(OS);
|
|
- return OS;
|
|
|
|
|
|
+ return;
|
|
|
|
|
|
- case DeclarationName::CXXConstructorName: {
|
|
|
|
- QualType ClassType = N.getCXXNameType();
|
|
|
|
- if (const RecordType *ClassRec = ClassType->getAs<RecordType>())
|
|
|
|
- return OS << *ClassRec->getDecl();
|
|
|
|
- LangOptions LO;
|
|
|
|
- LO.CPlusPlus = true;
|
|
|
|
- return OS << ClassType.getAsString(PrintingPolicy(LO));
|
|
|
|
- }
|
|
|
|
|
|
+ case DeclarationName::CXXConstructorName:
|
|
|
|
+ return printCXXConstructorDestructorName(N.getCXXNameType(), OS, Policy);
|
|
|
|
|
|
case DeclarationName::CXXDestructorName: {
|
|
case DeclarationName::CXXDestructorName: {
|
|
OS << '~';
|
|
OS << '~';
|
|
- QualType Type = N.getCXXNameType();
|
|
|
|
- if (const RecordType *Rec = Type->getAs<RecordType>())
|
|
|
|
- return OS << *Rec->getDecl();
|
|
|
|
- LangOptions LO;
|
|
|
|
- LO.CPlusPlus = true;
|
|
|
|
- return OS << Type.getAsString(PrintingPolicy(LO));
|
|
|
|
|
|
+ return printCXXConstructorDestructorName(N.getCXXNameType(), OS, Policy);
|
|
}
|
|
}
|
|
|
|
|
|
case DeclarationName::CXXOperatorName: {
|
|
case DeclarationName::CXXOperatorName: {
|
|
@@ -178,29 +185,46 @@ raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
|
|
OS << "operator";
|
|
OS << "operator";
|
|
if (OpName[0] >= 'a' && OpName[0] <= 'z')
|
|
if (OpName[0] >= 'a' && OpName[0] <= 'z')
|
|
OS << ' ';
|
|
OS << ' ';
|
|
- return OS << OpName;
|
|
|
|
|
|
+ OS << OpName;
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
case DeclarationName::CXXLiteralOperatorName:
|
|
case DeclarationName::CXXLiteralOperatorName:
|
|
- return OS << "operator\"\"" << N.getCXXLiteralIdentifier()->getName();
|
|
|
|
|
|
+ OS << "operator\"\"" << N.getCXXLiteralIdentifier()->getName();
|
|
|
|
+ return;
|
|
|
|
|
|
case DeclarationName::CXXConversionFunctionName: {
|
|
case DeclarationName::CXXConversionFunctionName: {
|
|
OS << "operator ";
|
|
OS << "operator ";
|
|
QualType Type = N.getCXXNameType();
|
|
QualType Type = N.getCXXNameType();
|
|
- if (const RecordType *Rec = Type->getAs<RecordType>())
|
|
|
|
- return OS << *Rec->getDecl();
|
|
|
|
- LangOptions LO;
|
|
|
|
- LO.CPlusPlus = true;
|
|
|
|
- LO.Bool = true;
|
|
|
|
- return OS << Type.getAsString(PrintingPolicy(LO));
|
|
|
|
|
|
+ if (const RecordType *Rec = Type->getAs<RecordType>()) {
|
|
|
|
+ OS << *Rec->getDecl();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (!Policy.LangOpts.CPlusPlus) {
|
|
|
|
+ // Passed policy is the default one from operator <<, use a C++ policy.
|
|
|
|
+ LangOptions LO;
|
|
|
|
+ LO.CPlusPlus = true;
|
|
|
|
+ LO.Bool = true;
|
|
|
|
+ Type.print(OS, PrintingPolicy(LO));
|
|
|
|
+ } else {
|
|
|
|
+ Type.print(OS, Policy);
|
|
|
|
+ }
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
case DeclarationName::CXXUsingDirective:
|
|
case DeclarationName::CXXUsingDirective:
|
|
- return OS << "<using-directive>";
|
|
|
|
|
|
+ OS << "<using-directive>";
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
llvm_unreachable("Unexpected declaration name kind");
|
|
llvm_unreachable("Unexpected declaration name kind");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+raw_ostream &operator<<(raw_ostream &OS, DeclarationName N) {
|
|
|
|
+ LangOptions LO;
|
|
|
|
+ N.print(OS, PrintingPolicy(LO));
|
|
|
|
+ return OS;
|
|
|
|
+}
|
|
|
|
+
|
|
} // end namespace clang
|
|
} // end namespace clang
|
|
|
|
|
|
DeclarationName::NameKind DeclarationName::getNameKind() const {
|
|
DeclarationName::NameKind DeclarationName::getNameKind() const {
|