]> granicus.if.org Git - clang/commitdiff
Back out 46855 for now, it causes test failures on Darwin.
authorAnders Carlsson <andersca@mac.com>
Fri, 8 Feb 2008 00:23:11 +0000 (00:23 +0000)
committerAnders Carlsson <andersca@mac.com>
Fri, 8 Feb 2008 00:23:11 +0000 (00:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46867 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Decl.cpp
AST/DeclSerialization.cpp
CodeGen/ModuleBuilder.cpp
Driver/ASTConsumers.cpp
Parse/Parser.cpp
Sema/Sema.h
Sema/SemaDecl.cpp
include/clang/AST/Decl.h
include/clang/Parse/Action.h
include/clang/Parse/Parser.h

index 55abe6f34d5f60a0b9e7182a1c0c7eb2dbcbdbcb..78916c53b7cecb9eff8c006eb92840c4b2b08e38 100644 (file)
@@ -38,7 +38,6 @@ static unsigned nObjCCategoryImpl = 0;
 static unsigned nObjCCompatibleAlias = 0;
 static unsigned nObjCPropertyDecl = 0;
 static unsigned nLinkageSpecDecl = 0;
-static unsigned nFileScopeAsmDecl = 0;
 
 static bool StatSwitch = false;
 
@@ -170,8 +169,7 @@ void Decl::PrintStats() {
               nObjCCategoryImpl*sizeof(ObjCCategoryImplDecl)+
               nObjCCompatibleAlias*sizeof(ObjCCompatibleAliasDecl)+
               nObjCPropertyDecl*sizeof(ObjCPropertyDecl)+
-              nLinkageSpecDecl*sizeof(LinkageSpecDecl)+
-              nFileScopeAsmDecl*sizeof(FileScopeAsmDecl)));
+              nLinkageSpecDecl*sizeof(LinkageSpecDecl)));
     
 }
 
@@ -242,9 +240,6 @@ void Decl::addDeclKind(const Kind k) {
     case LinkageSpec:
       nLinkageSpecDecl++;
       break;
-    case FileScopeAsm:
-      nFileScopeAsmDecl++;
-      break;
   }
 }
 
index cb91846a027554211fd81252307ead3d1b702b43..146ebbacbe19331e43d57f300ca39f5a61453d7b 100644 (file)
@@ -67,9 +67,6 @@ Decl* Decl::Create(Deserializer& D) {
       
     case Typedef:
       return TypedefDecl::CreateImpl(D);
-      
-    case FileScopeAsm:
-      return FileScopeAsmDecl::CreateImpl(D);
   }
 }
 
@@ -441,23 +438,3 @@ void LinkageSpecDecl::ReadInRec(Deserializer& D) {
   Language = static_cast<LanguageIDs>(D.ReadInt());
   D.ReadPtr(this->D);
 }
-
-//===----------------------------------------------------------------------===//
-//      FileScopeAsm Serialization.
-//===----------------------------------------------------------------------===//
-
-void FileScopeAsmDecl::EmitImpl(llvm::Serializer& S) const
-{
-  Decl::EmitInRec(S);
-  S.EmitOwnedPtr(AsmString);
-}
-
-FileScopeAsmDecl* FileScopeAsmDecl::CreateImpl(Deserializer& D) { 
-  FileScopeAsmDecl* decl = new FileScopeAsmDecl(SourceLocation(), 0);
-
-  decl->Decl::ReadInRec(D);
-  decl->AsmString = cast<StringLiteral>(D.ReadOwnedPtr<Expr>());
-//  D.ReadOwnedPtr(D.ReadOwnedPtr<StringLiteral>())<#T * * Ptr#>, <#bool AutoRegister#>)(decl->AsmString);
-  
-  return decl;
-}
index 06467488a5e945aec3974210c8ba72fba1a13105..50d6fedadd597f0afd4883f445bb18e0a743b2ee 100644 (file)
@@ -70,15 +70,6 @@ namespace {
           Builder->WarnUnsupported(LSD, "linkage spec");
         // FIXME: implement C++ linkage, C linkage works mostly by C
         // language reuse already.
-      } else if (FileScopeAsmDecl *AD = dyn_cast<FileScopeAsmDecl>(D)) {
-        std::string AsmString(AD->getAsmString()->getStrData(),
-                              AD->getAsmString()->getByteLength());
-        
-        const std::string &S = Builder->getModule().getModuleInlineAsm();
-        if (S.empty())
-          Builder->getModule().setModuleInlineAsm(AsmString);
-        else
-          Builder->getModule().setModuleInlineAsm(S + '\n' + AsmString);
       } else {
         assert(isa<TypeDecl>(D) && "Unknown top level decl");
         // TODO: handle debug info?
index 688619438b9de28e9afbeedefff0133c761d8f38..3868e7d75c3836535e35eef77ce44dd5e1cc0161 100644 (file)
@@ -97,10 +97,6 @@ void DeclPrinter:: PrintDecl(Decl *D) {
     Out << "Read top-level variable decl: '" << SD->getName() << "'\n";
   } else if (LinkageSpecDecl *LSD = dyn_cast<LinkageSpecDecl>(D)) {
     PrintLinkageSpec(LSD);
-  } else if (FileScopeAsmDecl *AD = dyn_cast<FileScopeAsmDecl>(D)) {
-    Out << "asm(";
-    AD->getAsmString()->printPretty(Out);
-    Out << ")\n";
   } else {
     assert(0 && "Unknown decl type!");
   }
@@ -406,8 +402,6 @@ namespace {
         Out << "Read objc fwd protocol decl\n";
       } else if (isa<ObjCClassDecl>(D)) {
         Out << "Read objc fwd class decl\n";
-      } else if (isa<FileScopeAsmDecl>(D)) {
-        Out << "Read file scope asm decl\n";
       } else {
         assert(0 && "Unknown decl type!");
       }
index 32856fe82b345cbf74b5640c74d985fd53fe8805..6f2a71257a059d50bd2eeb65a3b51b5f33413bdc 100644 (file)
@@ -321,7 +321,11 @@ Parser::DeclTy *Parser::ParseExternalDeclaration() {
     return RV;
   }
   case tok::kw_asm:
-    return ParseSimpleAsm();
+    ParseSimpleAsm();
+    ExpectAndConsume(tok::semi, diag::err_expected_semi_after,
+                     "top-level asm block");
+    // TODO: Invoke action for top-level asm.
+    return 0;
   case tok::at:
     // @ is not a legal token unless objc is enabled, no need to check.
     return ParseObjCAtDirectives();
@@ -606,25 +610,19 @@ Parser::ExprResult Parser::ParseAsmStringLiteral() {
 /// [GNU] simple-asm-expr:
 ///         'asm' '(' asm-string-literal ')'
 ///
-Parser::DeclTy *Parser::ParseSimpleAsm() {
+void Parser::ParseSimpleAsm() {
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
-  SourceLocation Loc = ConsumeToken();
+  ConsumeToken();
   
   if (Tok.isNot(tok::l_paren)) {
     Diag(Tok, diag::err_expected_lparen_after, "asm");
-    return 0;
+    return;
   }
   
-  ConsumeParen();
+  SourceLocation Loc = ConsumeParen();
   
-  ExprResult Result = ParseAsmStringLiteral();
+  ParseAsmStringLiteral();
   
   MatchRHSPunctuation(tok::r_paren, Loc);
-  
-  if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after,
-                       "top-level asm block"))
-    return 0;
-  
-  return Actions.ActOnFileScopeAsmDecl(Loc, Result.Val);
 }
 
index f3595e10767e5086969be7f89e63af841bbeff2e..06a12e4f7f402f3e24b92546ccba4775d0ea8148 100644 (file)
@@ -197,8 +197,7 @@ private:
   virtual DeclTy *ActOnLinkageSpec(SourceLocation Loc, SourceLocation LBrace,
                                   SourceLocation RBrace, const char *Lang,
                                   unsigned StrSize, DeclTy *D);
-  virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprTy *expr);
-
+  
   /// Scope actions.
   virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
   virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S);
index 00776912b0203faa3c83e31a7d0803c23f78eed7..cd546f3efc5916363462fdb70b2a652a89dd5d45 100644 (file)
@@ -1711,13 +1711,6 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDeclX,
   Consumer.HandleTagDeclDefinition(Enum);
 }
 
-Sema::DeclTy *Sema::ActOnFileScopeAsmDecl(SourceLocation Loc,
-                                          ExprTy *expr) {
-  StringLiteral *AsmString = cast<StringLiteral>((Expr*)expr);
-  
-  return new FileScopeAsmDecl(Loc, AsmString);
-}
-
 Sema::DeclTy* Sema::ActOnLinkageSpec(SourceLocation Loc,
                                     SourceLocation LBrace,
                                     SourceLocation RBrace,
index 07588e4c06c312307b9bdfe52e36bcb3ca96e56a..cc96b0732dffd736b97d18bd9680f09cdb622566 100644 (file)
@@ -27,7 +27,6 @@ class Decl;
 namespace clang {
 class Expr;
 class Stmt;
-class StringLiteral;
 class FunctionDecl;
 class IdentifierInfo;
 
@@ -72,7 +71,6 @@ public:
          ObjCClass,
          ObjCForwardProtocol,
         LinkageSpec,
-   FileScopeAsm,
   
     // For each non-leaf class, we now define a mapping to the first/last member
     // of the class, to allow efficient classof.
@@ -757,27 +755,6 @@ protected:
   friend Decl* Decl::Create(llvm::Deserializer& D);
 };
 
-class FileScopeAsmDecl : public Decl {
-  StringLiteral *AsmString;
-public:
-  FileScopeAsmDecl(SourceLocation L, StringLiteral *asmstring)
-    : Decl(FileScopeAsm, L), AsmString(asmstring) {}
-
-  const StringLiteral *getAsmString() const { return AsmString; }
-  StringLiteral *getAsmString() { return AsmString; }
-  static bool classof(const Decl *D) {
-    return D->getKind() == FileScopeAsm;
-  }
-  static bool classof(const FileScopeAsmDecl *D) { return true; }  
-protected:
-  /// EmitImpl - Serialize this FileScopeAsmDecl. Called by Decl::Emit.
-  virtual void EmitImpl(llvm::Serializer& S) const;
-  
-  /// CreateImpl - Deserialize a FileScopeAsmDecl.  Called by Decl::Create.
-  static FileScopeAsmDecl* CreateImpl(llvm::Deserializer& D);
-  
-  friend Decl* Decl::Create(llvm::Deserializer& D);
-};
 
 /// LinkageSpecDecl - This represents a linkage specification.  For example:
 ///   extern "C" void foo();
index 003dd9e01b90e8f5be58392ac3a1531bc2420505..7a2081978d5dba08e6c0936bc4fe1c101def4958 100644 (file)
@@ -141,10 +141,6 @@ public:
     return Decl;
   }
 
-  virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprTy *AsmString) {
-    return 0;
-  }
-  
   /// ActOnPopScope - This callback is called immediately before the specified
   /// scope is popped and deleted.
   virtual void ActOnPopScope(SourceLocation Loc, Scope *S) {}
index aae86549f0b418ed9da9d1daa1eeef3ddae1c3cd..2712daa2453d94d3136e71fd2be233ad8e33d225 100644 (file)
@@ -256,7 +256,7 @@ private:
   DeclTy *ParseDeclarationOrFunctionDefinition();
   DeclTy *ParseFunctionDefinition(Declarator &D);
   void ParseKNRParamDeclarations(Declarator &D);
-  DeclTy *ParseSimpleAsm();
+  void ParseSimpleAsm();
   ExprResult ParseAsmStringLiteral();
 
   // Objective-C External Declarations