aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-29 04:04:16 +0000
committerChris Lattner <sabre@nondot.org>2007-10-29 04:04:16 +0000
commitfe795956194141c91ae555985c9b930595bff43f (patch)
tree16fba0f7b4c01941311fc170497dc0c46756d5f9
parentdea6146deede4b89a1757d46cd92ebf158659c25 (diff)
Implement *skeletal* support for representing GNU inline asm stmts in the AST,
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
-rw-r--r--AST/Stmt.cpp4
-rw-r--r--AST/StmtPrinter.cpp5
-rw-r--r--Parse/ParseStmt.cpp8
-rw-r--r--Sema/Sema.h3
-rw-r--r--Sema/SemaStmt.cpp4
-rw-r--r--clang.xcodeproj/project.pbxproj1
-rw-r--r--include/clang/AST/Stmt.h21
-rw-r--r--include/clang/AST/StmtNodes.def3
-rw-r--r--include/clang/Parse/Action.h4
9 files changed, 48 insertions, 5 deletions
diff --git a/AST/Stmt.cpp b/AST/Stmt.cpp
index 96acbd15ba..e8ecd0c987 100644
--- a/AST/Stmt.cpp
+++ b/AST/Stmt.cpp
@@ -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(); }
+
diff --git a/AST/StmtPrinter.cpp b/AST/StmtPrinter.cpp
index 1a433a6815..ac6da0638d 100644
--- a/AST/StmtPrinter.cpp
+++ b/AST/StmtPrinter.cpp
@@ -316,6 +316,11 @@ void StmtPrinter::VisitReturnStmt(ReturnStmt *Node) {
OS << ";\n";
}
+
+void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
+ Indent() << "asm (/*todo*/);\n";
+}
+
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
diff --git a/Parse/ParseStmt.cpp b/Parse/ParseStmt.cpp
index 9df20b4ade..68781c1be4 100644
--- a/Parse/ParseStmt.cpp
+++ b/Parse/ParseStmt.cpp
@@ -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
diff --git a/Sema/Sema.h b/Sema/Sema.h
index 70d2f55ff8..f553356657 100644
--- a/Sema/Sema.h
+++ b/Sema/Sema.h
@@ -337,6 +337,9 @@ public:
virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
ExprTy *RetValExp);
+ virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ SourceLocation RParenLoc);
+
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks: SemaExpr.cpp.
diff --git a/Sema/SemaStmt.cpp b/Sema/SemaStmt.cpp
index 460b50ccbf..31dc236709 100644
--- a/Sema/SemaStmt.cpp
+++ b/Sema/SemaStmt.cpp
@@ -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);
+}
diff --git a/clang.xcodeproj/project.pbxproj b/clang.xcodeproj/project.pbxproj
index fe4cf8d85b..de41b4628d 100644
--- a/clang.xcodeproj/project.pbxproj
+++ b/clang.xcodeproj/project.pbxproj
@@ -756,7 +756,6 @@
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 2ebb387065..5f4c0d39c5 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -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
//===----------------------------------------------------------------------===//
diff --git a/include/clang/AST/StmtNodes.def b/include/clang/AST/StmtNodes.def
index c8b822139c..469f0a8c2c 100644
--- a/include/clang/AST/StmtNodes.def
+++ b/include/clang/AST/StmtNodes.def
@@ -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)
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index 24b47c660f..a237bf3c27 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -282,6 +282,10 @@ public:
ExprTy *RetValExp) {
return 0;
}
+ virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ SourceLocation RParenLoc) {
+ return 0;
+ }
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks.