aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2021-08-20 09:49:07 -0400
committerAaron Ballman <aaron@aaronballman.com>2021-08-20 09:50:24 -0400
commit48f73ee666a264d23716ff6bb671cad836b65ccf (patch)
tree18a7eb7845240f87a9b330534128c0ceaddf7e16 /clang/lib/AST/DeclBase.cpp
parent9efda541bfbd145de90f7db38d935db6246dc45a (diff)
downloadllvm-48f73ee666a264d23716ff6bb671cad836b65ccf.zip
llvm-48f73ee666a264d23716ff6bb671cad836b65ccf.tar.gz
llvm-48f73ee666a264d23716ff6bb671cad836b65ccf.tar.bz2
Fix assertion when generating diagnostic for inline namespaces
When calculating the name to display for inline namespaces, we have custom logic to try to hide redundant inline namespaces from the diagnostic. Calculating these redundancies requires performing a lookup in the parent declaration context, but that lookup should not try to look through transparent declaration contexts, like linkage specifications. Instead, loop up the declaration context chain until we find a non-transparent context and use that instead. This fixes PR49954.
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 3467da2..53dd2ae 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1217,6 +1217,13 @@ bool DeclContext::Encloses(const DeclContext *DC) const {
return false;
}
+DeclContext *DeclContext::getNonTransparentContext() {
+ DeclContext *DC = this;
+ while (DC && DC->isTransparentContext())
+ DC = DC->getParent();
+ return DC;
+}
+
DeclContext *DeclContext::getPrimaryContext() {
switch (getDeclKind()) {
case Decl::ExternCContext: