[clang] 65bcdea - Replace an unnecessary null check with an assert; NFC

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 20 09:04:55 PDT 2021


Author: Aaron Ballman
Date: 2021-08-20T12:04:46-04:00
New Revision: 65bcdeaa15b729dae40190c6a990cd67c12e9f10

URL: https://github.com/llvm/llvm-project/commit/65bcdeaa15b729dae40190c6a990cd67c12e9f10
DIFF: https://github.com/llvm/llvm-project/commit/65bcdeaa15b729dae40190c6a990cd67c12e9f10.diff

LOG: Replace an unnecessary null check with an assert; NFC

Added: 
    

Modified: 
    clang/lib/AST/DeclBase.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 53dd2ae3cbd3..e042ae8dae4a 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1219,8 +1219,10 @@ bool DeclContext::Encloses(const DeclContext *DC) const {
 
 DeclContext *DeclContext::getNonTransparentContext() {
   DeclContext *DC = this;
-  while (DC && DC->isTransparentContext())
+  while (DC->isTransparentContext()) {
     DC = DC->getParent();
+    assert(DC && "All transparent contexts should have a parent!");
+  }
   return DC;
 }
 


        


More information about the cfe-commits mailing list