Move things around so that Sema.h no longer depends on even DeclBase.h.
It still depends on Type because DeclarationName.h does.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112177 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index 999e45a..79e4541 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -642,6 +642,25 @@
   virtual void print(llvm::raw_ostream &OS) const;
 };
 
+class DeclContextLookupResult : public std::pair<NamedDecl**,NamedDecl**> {
+public:
+  DeclContextLookupResult(NamedDecl **I, NamedDecl **E) : pair(I, E) {}
+  DeclContextLookupResult() : pair() {}
+
+  using pair::operator=;
+};
+
+class DeclContextLookupConstResult
+  : public std::pair<NamedDecl*const*, NamedDecl*const*> {
+public:
+  DeclContextLookupConstResult(std::pair<NamedDecl**,NamedDecl**> R)
+    : pair(R) {}
+  DeclContextLookupConstResult(NamedDecl * const *I, NamedDecl * const *E)
+    : pair(I, E) {}
+  DeclContextLookupConstResult() : pair() {}
+
+  using pair::operator=;
+};
 
 /// DeclContext - This is used only as base class of specific decl types that
 /// can act as declaration contexts. These decls are (only the top classes
@@ -1063,9 +1082,8 @@
   /// access to the results of lookup up a name within this context.
   typedef NamedDecl * const * lookup_const_iterator;
 
-  typedef std::pair<lookup_iterator, lookup_iterator> lookup_result;
-  typedef std::pair<lookup_const_iterator, lookup_const_iterator>
-    lookup_const_result;
+  typedef DeclContextLookupResult lookup_result;
+  typedef DeclContextLookupConstResult lookup_const_result;
 
   /// lookup - Find the declarations (if any) with the given Name in
   /// this context. Returns a range of iterators that contains all of
@@ -1173,7 +1191,6 @@
          getKind() == TemplateTemplateParm;
 }
 
-
 // Specialization selected when ToTy is not a known subclass of DeclContext.
 template <class ToTy,
           bool IsKnownSubtype = ::llvm::is_base_of< DeclContext, ToTy>::value>
diff --git a/include/clang/AST/ExternalASTSource.h b/include/clang/AST/ExternalASTSource.h
index 96150a3..a8ef005 100644
--- a/include/clang/AST/ExternalASTSource.h
+++ b/include/clang/AST/ExternalASTSource.h
@@ -14,16 +14,23 @@
 #ifndef LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
 #define LLVM_CLANG_AST_EXTERNAL_AST_SOURCE_H
 
-#include "clang/AST/DeclarationName.h"
-#include "clang/AST/DeclBase.h"
-#include "clang/AST/Type.h"
-#include "llvm/ADT/SmallVector.h"
 #include <cassert>
 #include <vector>
+
+namespace llvm {
+template <class T> class SmallVectorImpl;
+}
+
 namespace clang {
 
 class ASTConsumer;
+class Decl;
+class DeclContext;
+class DeclContextLookupResult;
+class DeclarationName;
 class ExternalSemaSource; // layering violation required for downcasting
+class NamedDecl;
+class Selector;
 class Stmt;
 
 /// \brief Abstract interface for external sources of AST nodes.
@@ -90,7 +97,7 @@
   /// Generally the final step of this method is either to call
   /// SetExternalVisibleDeclsForName or to recursively call lookup on
   /// the DeclContext after calling SetExternalVisibleDecls.
-  virtual DeclContext::lookup_result
+  virtual DeclContextLookupResult
   FindExternalVisibleDeclsByName(const DeclContext *DC,
                                  DeclarationName Name) = 0;
 
@@ -135,17 +142,17 @@
   virtual void PrintStats();
 
 protected:
-  static DeclContext::lookup_result
+  static DeclContextLookupResult
   SetExternalVisibleDeclsForName(const DeclContext *DC,
                                  DeclarationName Name,
                                  llvm::SmallVectorImpl<NamedDecl*> &Decls);
 
-  static DeclContext::lookup_result
+  static DeclContextLookupResult
   SetNoExternalVisibleDeclsForName(const DeclContext *DC,
                                    DeclarationName Name);
 
   void MaterializeVisibleDeclsForName(const DeclContext *DC,
-                                 DeclarationName Name,
+                                      DeclarationName Name,
                                  llvm::SmallVectorImpl<NamedDecl*> &Decls);
 };
 
diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h
index 8a88073..9504f77 100644
--- a/include/clang/Sema/Sema.h
+++ b/include/clang/Sema/Sema.h
@@ -20,7 +20,6 @@
 #include "clang/Sema/IdentifierResolver.h"
 #include "clang/Sema/ObjCMethodList.h"
 #include "clang/AST/OperationKinds.h"
-#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "llvm/ADT/OwningPtr.h"
@@ -65,11 +64,13 @@
   class DeclSpec;
   class DeclaratorDecl;
   class DeducedTemplateArgument;
+  class DependentDiagnostic;
   class DesignatedInitExpr;
   class EnumConstantDecl;
   class Expr;
   class ExtVectorType;
   class ExternalSemaSource;
+  class FormatAttr;
   class FriendDecl;
   class FullExpr;
   class FunctionDecl;
@@ -87,6 +88,7 @@
   class LookupResult;
   class MultiLevelTemplateArgumentList;
   class NamedDecl;
+  class NonNullAttr;
   class ObjCCategoryDecl;
   class ObjCCategoryImplDecl;
   class ObjCCompatibleAliasDecl;
@@ -128,6 +130,7 @@
   class UsingShadowDecl;
   class ValueDecl;
   class VarDecl;
+  class VisibilityAttr;
   class VisibleDeclConsumer;
 
 namespace sema {
@@ -1204,7 +1207,8 @@
   void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
                                     QualType T1, QualType T2,
                                     UnresolvedSetImpl &Functions);
-  DeclContext::lookup_result LookupConstructors(CXXRecordDecl *Class);
+
+  DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class);
   CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
 
   void ArgumentDependentLookup(DeclarationName Name, bool Operator,
@@ -3768,15 +3772,14 @@
   /// FreePackedContext - Deallocate and null out PackContext.
   void FreePackedContext();
 
+  /// PushVisibilityAttr - Note that we've entered a context with a
+  /// visibility attribute.
+  void PushVisibilityAttr(const VisibilityAttr *Attr);
+
   /// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
   /// add an appropriate visibility attribute.
   void AddPushedVisibilityAttribute(Decl *RD);
 
-  /// PushPragmaVisibility - Push the top element of the visibility stack; used
-  ///  for '#pragma GCC visibility' and visibility attributes on namespaces.
-  void PushPragmaVisibility(VisibilityAttr::VisibilityType type,
-                            SourceLocation loc);
-
   /// PopPragmaVisibility - Pop the top element of the visibility stack; used
   /// for '#pragma GCC visibility' and visibility attributes on namespaces.
   void PopPragmaVisibility();