[clang] [clang] NFCI: Make ASTContext optional again (PR #94522)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 5 12:06:43 PDT 2024
https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/94522
Previous patches 3cabbf60393cc8d55fe635e35e89e5973162de33 and 1a2f3309765fdc143fdc3809211fb85d2e2ca341 broke the assumption that the AST Context was optional for the text node dumper.
While missing an ASTContext makes some helpful information unavailable, the pure `dump` overloads taking no parameters are quite convenient for quick debugging, so let's make that work again.
>From 422e23d1daed53e096eb55ceb2e915904ee3635b Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Wed, 5 Jun 2024 16:01:33 -0300
Subject: [PATCH] [clang] NFCI: Make ASTContext optional again
Previous patches 3cabbf60393cc8d55fe635e35e89e5973162de33 and 1a2f3309765fdc143fdc3809211fb85d2e2ca341
broke the assumption that the AST Context was optional for the text node dumper.
While missing an ASTContext makes some helpful information unavailable,
the pure `dump` overloads taking no parameters are quite convenient for
quick debugging, so let's make that work again.
---
clang/lib/AST/TextNodeDumper.cpp | 21 +++++++++++++--------
clang/lib/AST/Type.cpp | 1 -
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 8bacceea0f22b..1076dcd40a694 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -958,6 +958,9 @@ void TextNodeDumper::dumpTemplateArgument(const TemplateArgument &TA) {
}
OS << " '" << Str << "'";
+ if (!Context)
+ return;
+
if (TemplateArgument CanonTA = Context->getCanonicalTemplateArgument(TA);
!CanonTA.structurallyEquals(TA)) {
llvm::SmallString<128> CanonStr;
@@ -1139,15 +1142,17 @@ void TextNodeDumper::dumpTemplateName(TemplateName TN, StringRef Label) {
}
OS << " '" << Str << "'";
- if (TemplateName CanonTN = Context->getCanonicalTemplateName(TN);
- CanonTN != TN) {
- llvm::SmallString<128> CanonStr;
- {
- llvm::raw_svector_ostream SS(CanonStr);
- CanonTN.print(SS, PrintPolicy);
+ if (Context) {
+ if (TemplateName CanonTN = Context->getCanonicalTemplateName(TN);
+ CanonTN != TN) {
+ llvm::SmallString<128> CanonStr;
+ {
+ llvm::raw_svector_ostream SS(CanonStr);
+ CanonTN.print(SS, PrintPolicy);
+ }
+ if (CanonStr != Str)
+ OS << ":'" << CanonStr << "'";
}
- if (CanonStr != Str)
- OS << ":'" << CanonStr << "'";
}
}
dumpBareTemplateName(TN);
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 2097b29b7e0b6..2cc06a3df9d18 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -4444,7 +4444,6 @@ static CachedProperties computeCachedProperties(const Type *T) {
#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
#include "clang/AST/TypeNodes.inc"
// Treat instantiation-dependent types as external.
- if (!T->isInstantiationDependentType()) T->dump();
assert(T->isInstantiationDependentType());
return CachedProperties(Linkage::External, false);
More information about the cfe-commits
mailing list