]> granicus.if.org Git - clang/commitdiff
Added a function to check whether a Decl is in
authorSean Callanan <scallanan@apple.com>
Sat, 4 May 2013 02:04:27 +0000 (02:04 +0000)
committerSean Callanan <scallanan@apple.com>
Sat, 4 May 2013 02:04:27 +0000 (02:04 +0000)
the list of Decls for a given DeclContext.  This
is useful for LLDB's implementation of
FindExternalLexicalDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181093 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclBase.h
lib/AST/DeclBase.cpp

index 5d5d45267a58f22583850239531a6a51858dc3cb..a4a52e2a78dfdbec131329cfad9fec69b2a70048 100644 (file)
@@ -1412,6 +1412,9 @@ public:
 
   /// @brief Removes a declaration from this context.
   void removeDecl(Decl *D);
+    
+  /// @brief Checks whether a declaration is in this context.
+  bool containsDecl(Decl *D) const;
 
   /// lookup_iterator - An iterator that provides access to the results
   /// of looking up a name within this context.
index c1fbdb996d37957d6dde65848ded36d1e29cc16c..7b7900640b2a9681ef4f82f5f76d1df5dfc8a695 100644 (file)
@@ -1064,6 +1064,11 @@ bool DeclContext::decls_empty() const {
   return !FirstDecl;
 }
 
+bool DeclContext::containsDecl(Decl *D) const {
+  return (D->getLexicalDeclContext() == this &&
+          (D->NextInContextAndBits.getPointer() || D == LastDecl));
+}
+
 void DeclContext::removeDecl(Decl *D) {
   assert(D->getLexicalDeclContext() == this &&
          "decl being removed from non-lexical context");