]> granicus.if.org Git - clang/commitdiff
Implement *skeletal* support for representing GNU inline asm stmts in the AST,
authorChris Lattner <sabre@nondot.org>
Mon, 29 Oct 2007 04:04:16 +0000 (04:04 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 29 Oct 2007 04:04:16 +0000 (04:04 +0000)
resolving a crash on a .i file in PR1750.  We now generate 49 errors on the
.i file in that bug.

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

AST/Stmt.cpp
AST/StmtPrinter.cpp
Parse/ParseStmt.cpp
Sema/Sema.h
Sema/SemaStmt.cpp
clang.xcodeproj/project.pbxproj
include/clang/AST/Stmt.h
include/clang/AST/StmtNodes.def
include/clang/Parse/Action.h

index 96acbd15ba425d382e39026459ae7167d0bb8156..e8ecd0c987617cf1be755472298fd6305cfc300b 100644 (file)
@@ -189,3 +189,7 @@ Stmt::child_iterator ReturnStmt::child_end() {
   else return child_iterator();
 }
 
+// AsmStmt
+Stmt::child_iterator AsmStmt::child_begin() { return child_iterator(); }
+Stmt::child_iterator AsmStmt::child_end() { return child_iterator(); }
+
index 1a433a681546af9676b63c53685d9c8e3eb79ae6..ac6da0638d9bd5456c46d7e1b7318d9b50f57166 100644 (file)
@@ -316,6 +316,11 @@ void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
   OS << ";\n";
 }
 
+
+void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
+  Indent() << "asm (/*todo*/);\n";
+}
+
 //===----------------------------------------------------------------------===//
 //  Expr printing methods.
 //===----------------------------------------------------------------------===//
index 9df20b4adefc363ebd58af8a36a0843d69a1959a..68781c1be4c9961488e8da8e400896c52efa61d4 100644 (file)
@@ -903,7 +903,7 @@ Parser::StmtResult Parser::ParseReturnStatement() {
 ///
 Parser::StmtResult Parser::ParseAsmStatement() {
   assert(Tok.is(tok::kw_asm) && "Not an asm stmt");
-  ConsumeToken();
+  SourceLocation AsmLoc = ConsumeToken();
   
   DeclSpec DS;
   SourceLocation Loc = Tok.getLocation();
@@ -948,10 +948,10 @@ Parser::StmtResult Parser::ParseAsmStatement() {
     }
   }
   
-  MatchRHSPunctuation(tok::r_paren, Loc);
+  SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, Loc);
   
-  // FIXME: Implement action for asm parsing.
-  return false;
+  // FIXME: Pass all the details down to the action.
+  return Actions.ActOnAsmStmt(AsmLoc, RParenLoc);
 }
 
 /// ParseAsmOperands - Parse the asm-operands production as used by
index 70d2f55ff87044ae8439447e54dae60397bad33a..f553356657e5bc275a68c1b20cbc660785253890 100644 (file)
@@ -337,6 +337,9 @@ public:
   virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
                                      ExprTy *RetValExp);
   
+  virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc, 
+                                  SourceLocation RParenLoc);
+  
   //===--------------------------------------------------------------------===//
   // Expression Parsing Callbacks: SemaExpr.cpp.
 
index 460b50ccbf349b04def77ec2864b0b8068d58f12..31dc236709e92b91f2c5e7a8a29c81baae81536a 100644 (file)
@@ -644,3 +644,7 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprTy *rex) {
   return new ReturnStmt(ReturnLoc, (Expr*)RetValExp);
 }
 
+Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc, 
+                                    SourceLocation RParenLoc) {
+  return new AsmStmt(AsmLoc, RParenLoc);
+}
index fe4cf8d85be8296188b8454e3723b21a50eb5906..de41b4628d0c47ae944965792f26798c623eb63f 100644 (file)
                08FB7793FE84155DC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
                        projectDirPath = "";
index 2ebb387065e628f78fcfbc00f0f1c313565821dc..5f4c0d39c5acf89c0cc35d773eba227f84cc326d 100644 (file)
@@ -660,6 +660,27 @@ public:
   virtual child_iterator child_end();
 };
 
+/// AsmStmt - This represents a GNU inline-assembly statement extension.
+///
+class AsmStmt : public Stmt {
+  SourceLocation AsmLoc, RParenLoc;
+  // FIXME: This doesn't capture most of the interesting pieces.
+public:
+  AsmStmt(SourceLocation asmloc, SourceLocation rparenloc)
+    : Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc) {}
+  
+  virtual SourceRange getSourceRange() const {
+    return SourceRange(AsmLoc, RParenLoc);
+  }
+  
+  static bool classof(const Stmt *T) {return T->getStmtClass() == AsmStmtClass;}
+  static bool classof(const AsmStmt *) { return true; }
+  
+  virtual child_iterator child_begin();
+  virtual child_iterator child_end();
+};
+
+
 }  // end namespace clang
 
 //===----------------------------------------------------------------------===//
index c8b822139c25c01cec388c907938a4e7cc7b0dd5..469f0a8c2c29188259eab3a961f760f6f70741f0 100644 (file)
@@ -40,6 +40,9 @@ STMT(14, BreakStmt       , Stmt)
 STMT(15, ReturnStmt      , Stmt)
 STMT(16, DeclStmt        , Stmt)
 STMT(17, SwitchCase      , Stmt)
+
+// GNU Stmt Extensions
+STMT(18, AsmStmt         , Stmt)
 LAST_STMT(17)
 
 FIRST_EXPR(31)
index 24b47c660f77a83b9522a003a716cb51a6f52717..a237bf3c270420cfc05b3a24b22df61bc5312fd8 100644 (file)
@@ -282,6 +282,10 @@ public:
                                      ExprTy *RetValExp) {
     return 0;
   }
+  virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc, 
+                                  SourceLocation RParenLoc) {
+    return 0;
+  }
   
   //===--------------------------------------------------------------------===//
   // Expression Parsing Callbacks.