ccotter created this revision.
Herald added a subscriber: carlosgalvezp.
Herald added a reviewer: njames93.
Herald added a project: All.
ccotter requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.
Provide a no-argument dump methods to avoid having to do
additional gymnastics to dump a DynTypedNode.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D141570
Files:
clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
clang/include/clang/AST/ASTTypeTraits.h
clang/lib/AST/ASTTypeTraits.cpp
Index: clang/lib/AST/ASTTypeTraits.cpp
===================================================================
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -213,6 +213,17 @@
OS << "Unable to dump values of type " << NodeKind.asStringRef() << "\n";
}
+void DynTypedNode::dump() const {
+ if (const Decl *D = get<Decl>())
+ D->dump();
+ else if (const Stmt *S = get<Stmt>())
+ S->dump();
+ else if (const Type *T = get<Type>())
+ T->dump();
+ else
+ llvm::errs() << "Unable to dump values of type " << NodeKind.asStringRef()
<< "\n";
+}
+
SourceRange DynTypedNode::getSourceRange() const {
if (const CXXCtorInitializer *CCI = get<CXXCtorInitializer>())
return CCI->getSourceRange();
Index: clang/include/clang/AST/ASTTypeTraits.h
===================================================================
--- clang/include/clang/AST/ASTTypeTraits.h
+++ clang/include/clang/AST/ASTTypeTraits.h
@@ -296,6 +296,9 @@
/// Dumps the node to the given output stream.
void dump(llvm::raw_ostream &OS, const ASTContext &Context) const;
+ /// Dumps the node to \c llvm::errs().
+ void dump() const;
+
/// For nodes which represent textual entities in the source code,
/// return their SourceRange. For all other nodes, return SourceRange().
SourceRange getSourceRange() const;
Index: clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -430,6 +430,9 @@
// be fine since for the statements we care about there should only be one
// parent, except for the case specified below.
+ llvm::errs() << "DUMP\n";
+ Start.dump();
+
assert(MacroLoc.isFileID());
while (true) {
Index: clang/lib/AST/ASTTypeTraits.cpp
===================================================================
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -213,6 +213,17 @@
OS << "Unable to dump values of type " << NodeKind.asStringRef() << "\n";
}
+void DynTypedNode::dump() const {
+ if (const Decl *D = get<Decl>())
+ D->dump();
+ else if (const Stmt *S = get<Stmt>())
+ S->dump();
+ else if (const Type *T = get<Type>())
+ T->dump();
+ else
+ llvm::errs() << "Unable to dump values of type " << NodeKind.asStringRef() << "\n";
+}
+
SourceRange DynTypedNode::getSourceRange() const {
if (const CXXCtorInitializer *CCI = get<CXXCtorInitializer>())
return CCI->getSourceRange();
Index: clang/include/clang/AST/ASTTypeTraits.h
===================================================================
--- clang/include/clang/AST/ASTTypeTraits.h
+++ clang/include/clang/AST/ASTTypeTraits.h
@@ -296,6 +296,9 @@
/// Dumps the node to the given output stream.
void dump(llvm::raw_ostream &OS, const ASTContext &Context) const;
+ /// Dumps the node to \c llvm::errs().
+ void dump() const;
+
/// For nodes which represent textual entities in the source code,
/// return their SourceRange. For all other nodes, return SourceRange().
SourceRange getSourceRange() const;
Index: clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -430,6 +430,9 @@
// be fine since for the statements we care about there should only be one
// parent, except for the case specified below.
+ llvm::errs() << "DUMP\n";
+ Start.dump();
+
assert(MacroLoc.isFileID());
while (true) {
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits