]> granicus.if.org Git - clang/commitdiff
Struggle mightily against header inclusion in Sema.h.
authorJohn McCall <rjmccall@apple.com>
Tue, 24 Aug 2010 07:21:54 +0000 (07:21 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 24 Aug 2010 07:21:54 +0000 (07:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111904 91177308-0d34-0410-b5e6-96231b3b80d8

23 files changed:
include/clang/AST/DeclObjC.h
include/clang/AST/ExternalASTSource.h
include/clang/Sema/ExternalSemaSource.h
include/clang/Sema/IdentifierResolver.h
include/clang/Sema/ObjCMethodList.h [new file with mode: 0644]
include/clang/Sema/Sema.h
include/clang/Sema/Template.h
lib/Sema/AnalysisBasedWarnings.cpp
lib/Sema/CodeCompleteConsumer.cpp
lib/Sema/IdentifierResolver.cpp
lib/Sema/SemaCodeComplete.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaObjCProperty.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateDeduction.cpp
lib/Sema/SemaTemplateInstantiate.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
lib/Sema/SemaType.cpp
lib/Sema/TreeTransform.h

index 351f8bdae2b131f6cb5de7d48e08ca10bb7cd572..da1278cf5d8d6b222fb98cc5fb454af9e296b485 100644 (file)
@@ -321,21 +321,6 @@ public:
   }
 };
 
-/// ObjCMethodList - a linked list of methods with different signatures.
-struct ObjCMethodList {
-  ObjCMethodDecl *Method;
-  ObjCMethodList *Next;
-
-  ObjCMethodList() {
-    Method = 0;
-    Next = 0;
-  }
-  ObjCMethodList(ObjCMethodDecl *M, ObjCMethodList *C) {
-    Method = M;
-    Next = C;
-  }
-};
-
 /// ObjCContainerDecl - Represents a container for method declarations.
 /// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl,
 /// ObjCProtocolDecl, and ObjCImplDecl.
index 6bd72529e61df55a571bc0588f2a3f9a9852ff0c..96150a381ae8dde89df9b555cbdf3ae19ba0e972 100644 (file)
@@ -15,6 +15,7 @@
 #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>
@@ -22,8 +23,6 @@
 namespace clang {
 
 class ASTConsumer;
-class Decl;
-class DeclContext;
 class ExternalSemaSource; // layering violation required for downcasting
 class Stmt;
 
index ad42a847fa48e771647ad6605946f6b649c19e9d..7be003390b102d00b503ad2da8bc6c886fd11474 100644 (file)
@@ -13,8 +13,8 @@
 #ifndef LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H
 #define LLVM_CLANG_SEMA_EXTERNAL_SEMA_SOURCE_H
 
-#include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExternalASTSource.h"
+#include "clang/Sema/ObjCMethodList.h"
 
 namespace clang {
 
index 540d6987d07e8ffd6d93a74283c40fb8fe0dcfeb..7e9d338293eee472d1f9ae0d464b50a90841aa64 100644 (file)
 #define LLVM_CLANG_AST_SEMA_IDENTIFIERRESOLVER_H
 
 #include "clang/Basic/IdentifierTable.h"
-#include "clang/Sema/Scope.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclarationName.h"
-#include "clang/AST/DeclCXX.h"
 
 namespace clang {
 
+class ASTContext;
+class Decl;
+class DeclContext;
+class DeclarationName;
+class NamedDecl;
+class Scope;
+
 /// IdentifierResolver - Keeps track of shadowed decls on enclosing
 /// scopes.  It manages the shadowing chains of declaration names and
 /// implements efficent decl lookup based on a declaration name.
@@ -95,6 +98,8 @@ public:
     }
 
     friend class IdentifierResolver;
+
+    void incrementSlowCase();
   public:
     iterator() : Ptr(0) {}
 
@@ -116,18 +121,8 @@ public:
     iterator& operator++() {
       if (!isIterator()) // common case.
         Ptr = 0;
-      else {
-        NamedDecl *D = **this;
-        void *InfoPtr = D->getDeclName().getFETokenInfo<void>();
-        assert(!isDeclPtr(InfoPtr) && "Decl with wrong id ?");
-        IdDeclInfo *Info = toIdDeclInfo(InfoPtr);
-
-        BaseIter I = getIterator();
-        if (I != Info->decls_begin())
-          *this = iterator(I-1);
-        else // No more decls.
-          *this = iterator();
-      }
+      else
+        incrementSlowCase();
       return *this;
     }
 
diff --git a/include/clang/Sema/ObjCMethodList.h b/include/clang/Sema/ObjCMethodList.h
new file mode 100644 (file)
index 0000000..225c137
--- /dev/null
@@ -0,0 +1,38 @@
+//===--- ObjCMethodList.h - A singly linked list of methods -----*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines ObjCMethodList, a singly-linked list of methods.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_SEMA_OBJC_METHOD_LIST_H
+#define LLVM_CLANG_SEMA_OBJC_METHOD_LIST_H
+
+namespace clang {
+
+class ObjCMethodDecl;
+
+/// ObjCMethodList - a linked list of methods with different signatures.
+struct ObjCMethodList {
+  ObjCMethodDecl *Method;
+  ObjCMethodList *Next;
+
+  ObjCMethodList() {
+    Method = 0;
+    Next = 0;
+  }
+  ObjCMethodList(ObjCMethodDecl *M, ObjCMethodList *C) {
+    Method = M;
+    Next = C;
+  }
+};
+
+}
+
+#endif
index 8f397de1c1a7b0a6642cf2de1be3ecacff0d9a16..c56fbe44cb9f8f47f08eeef4c888fe6ec7742154 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_AST_SEMA_H
-#define LLVM_CLANG_AST_SEMA_H
+#ifndef LLVM_CLANG_SEMA_SEMA_H
+#define LLVM_CLANG_SEMA_SEMA_H
 
 #include "clang/Sema/Action.h"
 #include "clang/Sema/IdentifierResolver.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/CXXFieldCollector.h"
+#include "clang/Sema/ObjCMethodList.h"
 #include "clang/Sema/Overload.h"
-#include "clang/Sema/Template.h"
 #include "clang/Sema/AnalysisBasedWarnings.h"
-#include "clang/AST/Attr.h"
-#include "clang/AST/DeclBase.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/DeclTemplate.h"
-#include "clang/AST/ExprCXX.h"
-#include "clang/AST/FullExpr.h"
+#include "clang/Sema/Scope.h"
 #include "clang/Sema/SemaDiagnostic.h"
+#include "clang/AST/ExprCXX.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -83,8 +78,12 @@ namespace clang {
   class TemplateArgumentList;
   class TemplateParameterList;
   class TemplateTemplateParmDecl;
+  class MultiLevelTemplateArgumentList;
+  class DeducedTemplateArgument;
+  class TemplatePartialOrderingContext;
   class ClassTemplatePartialSpecializationDecl;
   class ClassTemplateDecl;
+  template <class T> class ObjCList;
   class ObjCInterfaceDecl;
   class ObjCCompatibleAliasDecl;
   class ObjCProtocolDecl;
@@ -855,9 +854,7 @@ public:
                                        CXXScopeSpec *SS,
                                        ParsedType &SuggestedType);
 
-  virtual Decl *ActOnDeclarator(Scope *S, Declarator &D) {
-    return HandleDeclarator(S, D, MultiTemplateParamsArg(*this), false);
-  }
+  virtual Decl *ActOnDeclarator(Scope *S, Declarator &D);
 
   Decl *HandleDeclarator(Scope *S, Declarator &D,
                          MultiTemplateParamsArg TemplateParameterLists,
@@ -2323,8 +2320,8 @@ public:
   /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
   /// the default expr if needed.
   ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
-                                          FunctionDecl *FD,
-                                          ParmVarDecl *Param);
+                                    FunctionDecl *FD,
+                                    ParmVarDecl *Param);
 
   /// FinalizeVarWithDestructor - Prepare for calling destructor on the
   /// constructed variable.
index b3f46519ab7f2fc17bf5ef5632dee709cd14daf6..0c1bd31d420f66d6a6a7f6356731dd970ea402cf 100644 (file)
@@ -101,7 +101,7 @@ namespace clang {
   };
   
   /// \brief The context in which partial ordering of function templates occurs.
-  enum TemplatePartialOrderingContext {
+  enum TPOC {
     /// \brief Partial ordering of function templates for a function call.
     TPOC_Call,
     /// \brief Partial ordering of function templates for a call to a 
@@ -113,6 +113,17 @@ namespace clang {
     TPOC_Other
   };
 
+  // This is lame but unavoidable in a world without forward
+  // declarations of enums.  The alternatives are to either pollute
+  // Sema.h (by including this file) or sacrifice type safety (by
+  // making Sema.h declare things as enums).
+  class TemplatePartialOrderingContext {
+    TPOC Value;
+  public:
+    TemplatePartialOrderingContext(TPOC Value) : Value(Value) {}
+    operator TPOC() const { return Value; }
+  };
+
   /// \brief Captures a template argument whose value has been deduced
   /// via c++ template argument deduction.
   class DeducedTemplateArgument : public TemplateArgument {
index c8e8357afc1c2731371df6c8ead1472130760ef0..c95dd1470377d109216a235e55d7b1d5d2e3622a 100644 (file)
@@ -16,6 +16,7 @@
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/AnalysisBasedWarnings.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/StmtObjC.h"
index cab853a5cb53e2a349dcc37506438ed6a1213a08..79569a8c321a6fdb405cb526dc526a3b9de76312 100644 (file)
@@ -14,6 +14,7 @@
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/Sema.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang-c/Index.h"
 #include "llvm/ADT/STLExtras.h"
index 9421cad2243a0f582062621ada4663835ce68a99..384fbec67679d8ed759d4968a16be23310b9fb0a 100644 (file)
@@ -13,6 +13,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Sema/IdentifierResolver.h"
+#include "clang/Sema/Scope.h"
+#include "clang/AST/Decl.h"
 #include "clang/Basic/LangOptions.h"
 
 using namespace clang;
@@ -271,3 +273,16 @@ IdentifierResolver::IdDeclInfoMap::operator[](DeclarationName Name) {
   ++CurIndex;
   return *IDI;
 }
+
+void IdentifierResolver::iterator::incrementSlowCase() {
+  NamedDecl *D = **this;
+  void *InfoPtr = D->getDeclName().getFETokenInfo<void>();
+  assert(!isDeclPtr(InfoPtr) && "Decl with wrong id ?");
+  IdDeclInfo *Info = toIdDeclInfo(InfoPtr);
+
+  BaseIter I = getIterator();
+  if (I != Info->decls_begin())
+    *this = iterator(I-1);
+  else // No more decls.
+    *this = iterator();
+}
index 649f70b7b4e98e4e1392e60d0f62353a9030cd41..9d5bc0be0f20dc3a5f2bcce3a4086958fa1d2c26 100644 (file)
@@ -14,6 +14,7 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
 #include "clang/Sema/ExternalSemaSource.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/Lex/MacroInfo.h"
index 944993b2c9e12329aa95603531f8e611710c9e7a..48f5b0d24683bf083b9cc2e9fdd23f1c9e7b695f 100644 (file)
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/StmtCXX.h"
@@ -2177,6 +2178,10 @@ static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D,
   return false;
 }
 
+Decl *Sema::ActOnDeclarator(Scope *S, Declarator &D) {
+  return HandleDeclarator(S, D, MultiTemplateParamsArg(*this), false);
+}
+
 Decl *Sema::HandleDeclarator(Scope *S, Declarator &D,
                              MultiTemplateParamsArg TemplateParamLists,
                              bool IsFunctionDefinition) {
index 1aede96a256a11aa6904450ce207601628644137..bd76b9ff129f5527e029a76b0b22407ac156d568 100644 (file)
@@ -33,6 +33,7 @@
 #include "clang/Sema/Designator.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ParsedTemplate.h"
+#include "clang/Sema/Template.h"
 using namespace clang;
 
 
index a8b1bd091df8a7ed081b31afd14348bf39ef1cc0..e9fb26942c9b612521f2f70058e3b0e496ace40c 100644 (file)
@@ -16,6 +16,7 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/TypeLoc.h"
index a4d0b5164bd7a305e4e5d42468499de66c160ce0..05dd56275c365c9f4b6b25f43a40a56162bde261 100644 (file)
@@ -21,6 +21,7 @@
 #include "clang/Sema/Sema.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/TypeLoc.h"
index 56b0918bef090be2785fd0c53969559312d36e07..ccb9a15ff257b9cdbcf2dcc5542da54a591e9763 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Initialization.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprObjC.h"
 
 using namespace clang;
index cadaa4a91d69efc97d1a76b690ab47981ac4a8e4..7458a24dc8f4c1744c1c479ff6476c452c7886a6 100644 (file)
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Initialization.h"
+#include "clang/Sema/Template.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/TypeOrdering.h"
index 05d0ec172aae4fed792a9bec390d58c41af251eb..c05f5d3818ead5d7fa97d3bf9ad8e454d8652c2a 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/Template.h"
 #include "TreeTransform.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Expr.h"
index ee631b05891e89bb064e1fb3c66a7fec52d7d3d1..81ecdc018533efeb2fe9a629d2be132aadb59169 100644 (file)
@@ -12,7 +12,9 @@
 
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/DeclSpec.h"
+#include "clang/Sema/Template.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/Expr.h"
index 18e6560a3c2e588ccf10a1a2281307d2d4392085..82289e9416aba6594c9d319bd47d8e7dd732877f 100644 (file)
@@ -14,6 +14,7 @@
 #include "TreeTransform.h"
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/Template.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Expr.h"
index 5574a61df2d1ca6956eb9013b6272e044e6bba8d..5774b694beac2405f505c8707087969543902bfa 100644 (file)
@@ -11,6 +11,7 @@
 //===----------------------------------------------------------------------===/
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/Template.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclTemplate.h"
index b7c41a67dd7af64b61588a24ec6dcbce058ed1f7..e05766448c16fb73c0a1915821ee6bdf1d987a45 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Sema/Sema.h"
+#include "clang/Sema/Template.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclObjC.h"
index 8f869e0cfb4c280e88094bae1f291a4069e8b44c..fe1f6b96e866e45491de9ad88c8498ae83052813 100644 (file)
@@ -17,6 +17,7 @@
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclObjC.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"