[PATCH] D108403: Fix assertion when generating diagnostic for inline namespaces

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 20 09:05:33 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/AST/DeclBase.cpp:1222
+  DeclContext *DC = this;
+  while (DC && DC->isTransparentContext())
+    DC = DC->getParent();
----------------
erichkeane wrote:
> cor3ntin wrote:
> > Can getParent() be null? If it cam, then this function can return null which you don't check when you call that function. Or it can't and your test is not doing anything.
> I don't think it can ever be null, a DC of transparent-context type is always going to have at least a TranslationUnit as a parent.
> 
> I might think an assertion here to replace the `DC &&` part might be worth it.
Thanks for the suggestions! I switched to an assert in 65bcdeaa15b729dae40190c6a990cd67c12e9f10.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108403/new/

https://reviews.llvm.org/D108403



More information about the cfe-commits mailing list