From: Richard Smith Date: Wed, 2 Nov 2016 23:57:18 +0000 (+0000) Subject: Teach clang-query to dump types. I couldn't find any existing tests for clang-query... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44d4e59f5e7458c0f0b7dac1c7eaef86dbde9e49;p=clang Teach clang-query to dump types. I couldn't find any existing tests for clang-query's dumping functionality. =( git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285869 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index c8b8260ac0..1208cb7311 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -985,6 +985,7 @@ public: void dump(const char *s) const; void dump() const; + void dump(llvm::raw_ostream &OS) const; void Profile(llvm::FoldingSetNodeID &ID) const { ID.AddPointer(getAsOpaquePtr()); @@ -2005,6 +2006,7 @@ public: } CanQualType getCanonicalTypeUnqualified() const; // in CanonicalType.h void dump() const; + void dump(llvm::raw_ostream &OS) const; friend class ASTReader; friend class ASTWriter; diff --git a/include/clang/Basic/DiagnosticLexKinds.td b/include/clang/Basic/DiagnosticLexKinds.td index fa5aa0e7da..8bcbc21c80 100644 --- a/include/clang/Basic/DiagnosticLexKinds.td +++ b/include/clang/Basic/DiagnosticLexKinds.td @@ -183,7 +183,7 @@ def ext_hex_constant_invalid : Extension< def ext_hex_literal_invalid : Extension< "hexadecimal floating literals are a C++1z feature">, InGroup; def warn_cxx1z_hex_literal : Warning< - "hexidecimal floating literals are incompatible with " + "hexadecimal floating literals are incompatible with " "C++ standards before C++1z">, InGroup, DefaultIgnore; def ext_binary_literal : Extension< diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 55f9309f66..61a38af8dc 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -2466,12 +2466,18 @@ void QualType::dump(const char *msg) const { dump(); } -LLVM_DUMP_METHOD void QualType::dump() const { - ASTDumper Dumper(llvm::errs(), nullptr, nullptr); +LLVM_DUMP_METHOD void QualType::dump() const { dump(llvm::errs()); } + +LLVM_DUMP_METHOD void QualType::dump(llvm::raw_ostream &OS) const { + ASTDumper Dumper(OS, nullptr, nullptr); Dumper.dumpTypeAsChild(*this); } -LLVM_DUMP_METHOD void Type::dump() const { QualType(this, 0).dump(); } +LLVM_DUMP_METHOD void Type::dump() const { dump(llvm::errs()); } + +LLVM_DUMP_METHOD void Type::dump(llvm::raw_ostream &OS) const { + QualType(this, 0).dump(OS); +} //===----------------------------------------------------------------------===// // Decl method implementations diff --git a/lib/AST/ASTTypeTraits.cpp b/lib/AST/ASTTypeTraits.cpp index 680f526f00..461084ce70 100644 --- a/lib/AST/ASTTypeTraits.cpp +++ b/lib/AST/ASTTypeTraits.cpp @@ -135,6 +135,8 @@ void DynTypedNode::dump(llvm::raw_ostream &OS, SourceManager &SM) const { D->dump(OS); else if (const Stmt *S = get()) S->dump(OS, SM); + else if (const Type *T = get()) + T->dump(OS); else OS << "Unable to dump values of type " << NodeKind.asStringRef() << "\n"; }