]> granicus.if.org Git - clang/commitdiff
AST: Remove layering violation with Sema
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 5 Mar 2014 18:55:38 +0000 (18:55 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 5 Mar 2014 18:55:38 +0000 (18:55 +0000)
Scope lives in Sema and cannot be used in AST. Shuffle things around.

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

include/clang/AST/MangleNumberingContext.h
include/clang/Parse/Parser.h
include/clang/Sema/Sema.h
lib/AST/ItaniumCXXABI.cpp
lib/AST/MicrosoftCXXABI.cpp
lib/Sema/SemaDecl.cpp

index adf2b308180a7d1570ec4e17556e8c093cc01667..56c995264b325a8049ba9b2b038dddc84cfa9dd2 100644 (file)
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_MANGLENUMBERINGCONTEXT_H
 
 #include "clang/Basic/LLVM.h"
-#include "clang/Sema/Scope.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 
@@ -51,11 +50,13 @@ public:
 
   /// \brief Retrieve the mangling number of a static local variable within
   /// this context.
-  virtual unsigned getManglingNumber(const VarDecl *VD, Scope *S) = 0;
+  virtual unsigned getManglingNumber(const VarDecl *VD,
+                                     unsigned MSLocalManglingNumber) = 0;
 
   /// \brief Retrieve the mangling number of a static local variable within
   /// this context.
-  virtual unsigned getManglingNumber(const TagDecl *TD, Scope *S) = 0;
+  virtual unsigned getManglingNumber(const TagDecl *TD,
+                                     unsigned MSLocalManglingNumber) = 0;
 };
   
 } // end namespace clang
index e452ecff131b5de7d89b9586e2f55830843079f1..93fc611bdbdde29cd5a59618f68a4aced59ffb6b 100644 (file)
@@ -235,6 +235,9 @@ public:
 
   const Token &getCurToken() const { return Tok; }
   Scope *getCurScope() const { return Actions.getCurScope(); }
+  void incrementMSLocalManglingNumber() const {
+    return Actions.incrementMSLocalManglingNumber();
+  }
 
   Decl  *getObjCDeclContext() const { return Actions.getObjCDeclContext(); }
 
@@ -745,7 +748,7 @@ public:
         Self->EnterScope(ScopeFlags);
       else {
         if (BeforeCompoundStmt)
-          Self->getCurScope()->incrementMSLocalManglingNumber();
+          Self->incrementMSLocalManglingNumber();
 
         this->Self = 0;
       }
index c3844fb57f7654205d64730522d5930e33819863..b56995ba82fbb66dc7ce2d98cd6a49c2e78eb61a 100644 (file)
@@ -38,6 +38,7 @@
 #include "clang/Sema/LocInfoType.h"
 #include "clang/Sema/ObjCMethodList.h"
 #include "clang/Sema/Ownership.h"
+#include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/TypoCorrection.h"
 #include "clang/Sema/Weak.h"
@@ -8052,6 +8053,10 @@ public:
   /// template substitution or instantiation.
   Scope *getCurScope() const { return CurScope; }
 
+  void incrementMSLocalManglingNumber() const {
+    return CurScope->incrementMSLocalManglingNumber();
+  }
+
   IdentifierInfo *getSuperIdentifier() const;
   IdentifierInfo *getFloat128Identifier() const;
 
index f0d20c36968716d12de90b828779adbc64b6ae35..e1bc0da83bb62843754cedc4ab81e29158fef3f7 100644 (file)
@@ -37,11 +37,11 @@ class ItaniumNumberingContext : public MangleNumberingContext {
 
 public:
   /// Variable decls are numbered by identifier.
-  virtual unsigned getManglingNumber(const VarDecl *VD, Scope *) {
+  virtual unsigned getManglingNumber(const VarDecl *VD, unsigned) {
     return ++VarManglingNumbers[VD->getIdentifier()];
   }
 
-  virtual unsigned getManglingNumber(const TagDecl *TD, Scope *) {
+  virtual unsigned getManglingNumber(const TagDecl *TD, unsigned) {
     return ++TagManglingNumbers[TD->getIdentifier()];
   }
 };
index f2fd848d264598f0ef3bd1e9f715f3e3c5bdc181..9ee0321b0b3b5e2bd9658b3453c42dc37346d428 100644 (file)
@@ -29,12 +29,14 @@ namespace {
 /// Typically these are things like static locals, lambdas, or blocks.
 class MicrosoftNumberingContext : public MangleNumberingContext {
 public:
-  virtual unsigned getManglingNumber(const VarDecl *VD, Scope *S) {
-    return S->getMSLocalManglingNumber();
+  virtual unsigned getManglingNumber(const VarDecl *VD,
+                                     unsigned MSLocalManglingNumber) {
+    return MSLocalManglingNumber;
   }
 
-  virtual unsigned getManglingNumber(const TagDecl *TD, Scope *S) {
-    return S->getMSLocalManglingNumber();
+  virtual unsigned getManglingNumber(const TagDecl *TD,
+                                     unsigned MSLocalManglingNumber) {
+    return MSLocalManglingNumber;
   }
 };
 
index 71a79b226163af17b7c154c95b27c860dacdc779..9870ab1e5425797e583c243bf9f917845de65ad8 100644 (file)
@@ -3168,7 +3168,8 @@ static void HandleTagNumbering(Sema &S, const TagDecl *Tag, Scope *TagScope) {
       return;
     MangleNumberingContext &MCtx =
         S.Context.getManglingNumberContext(Tag->getParent());
-    S.Context.setManglingNumber(Tag, MCtx.getManglingNumber(Tag, TagScope));
+    S.Context.setManglingNumber(
+        Tag, MCtx.getManglingNumber(Tag, TagScope->getMSLocalManglingNumber()));
     return;
   }
 
@@ -3177,7 +3178,9 @@ static void HandleTagNumbering(Sema &S, const TagDecl *Tag, Scope *TagScope) {
   if (MangleNumberingContext *MCtx =
           S.getCurrentMangleNumberContext(Tag->getDeclContext(),
                                           ManglingContextDecl)) {
-    S.Context.setManglingNumber(Tag, MCtx->getManglingNumber(Tag, TagScope));
+    S.Context.setManglingNumber(
+        Tag,
+        MCtx->getManglingNumber(Tag, TagScope->getMSLocalManglingNumber()));
   }
 }
 
@@ -3816,7 +3819,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
       if (MangleNumberingContext *MCtx =
               getCurrentMangleNumberContext(NewVD->getDeclContext(),
                                             ManglingContextDecl)) {
-        Context.setManglingNumber(NewVD, MCtx->getManglingNumber(NewVD, S));
+        Context.setManglingNumber(NewVD, MCtx->getManglingNumber(NewVD, S->getMSLocalManglingNumber()));
         Context.setStaticLocalNumber(NewVD, MCtx->getStaticLocalNumber(NewVD));
       }
     }
@@ -5482,7 +5485,8 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
     if (MangleNumberingContext *MCtx =
             getCurrentMangleNumberContext(NewVD->getDeclContext(),
                                           ManglingContextDecl)) {
-      Context.setManglingNumber(NewVD, MCtx->getManglingNumber(NewVD, S));
+      Context.setManglingNumber(
+          NewVD, MCtx->getManglingNumber(NewVD, S->getMSLocalManglingNumber()));
       Context.setStaticLocalNumber(NewVD, MCtx->getStaticLocalNumber(NewVD));
     }
   }