[cfe-commits] r43433 - in /cfe/trunk: 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
Chris Lattner
sabre at nondot.org
Sun Oct 28 21:04:17 PDT 2007
Author: lattner
Date: Sun Oct 28 23:04:16 2007
New Revision: 43433
URL: http://llvm.org/viewvc/llvm-project?rev=43433&view=rev
Log:
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.
Modified:
cfe/trunk/AST/Stmt.cpp
cfe/trunk/AST/StmtPrinter.cpp
cfe/trunk/Parse/ParseStmt.cpp
cfe/trunk/Sema/Sema.h
cfe/trunk/Sema/SemaStmt.cpp
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/AST/StmtNodes.def
cfe/trunk/include/clang/Parse/Action.h
Modified: cfe/trunk/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Stmt.cpp?rev=43433&r1=43432&r2=43433&view=diff
==============================================================================
--- cfe/trunk/AST/Stmt.cpp (original)
+++ cfe/trunk/AST/Stmt.cpp Sun Oct 28 23:04:16 2007
@@ -189,3 +189,7 @@
else return child_iterator();
}
+// AsmStmt
+Stmt::child_iterator AsmStmt::child_begin() { return child_iterator(); }
+Stmt::child_iterator AsmStmt::child_end() { return child_iterator(); }
+
Modified: cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtPrinter.cpp?rev=43433&r1=43432&r2=43433&view=diff
==============================================================================
--- cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/AST/StmtPrinter.cpp Sun Oct 28 23:04:16 2007
@@ -316,6 +316,11 @@
OS << ";\n";
}
+
+void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
+ Indent() << "asm (/*todo*/);\n";
+}
+
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseStmt.cpp?rev=43433&r1=43432&r2=43433&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/Parse/ParseStmt.cpp Sun Oct 28 23:04:16 2007
@@ -903,7 +903,7 @@
///
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 @@
}
}
- 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
Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=43433&r1=43432&r2=43433&view=diff
==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Sun Oct 28 23:04:16 2007
@@ -337,6 +337,9 @@
virtual StmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
ExprTy *RetValExp);
+ virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ SourceLocation RParenLoc);
+
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks: SemaExpr.cpp.
Modified: cfe/trunk/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaStmt.cpp?rev=43433&r1=43432&r2=43433&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/Sema/SemaStmt.cpp Sun Oct 28 23:04:16 2007
@@ -644,3 +644,7 @@
return new ReturnStmt(ReturnLoc, (Expr*)RetValExp);
}
+Sema::StmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
+ SourceLocation RParenLoc) {
+ return new AsmStmt(AsmLoc, RParenLoc);
+}
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=43433&r1=43432&r2=43433&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Sun Oct 28 23:04:16 2007
@@ -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 = "";
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=43433&r1=43432&r2=43433&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sun Oct 28 23:04:16 2007
@@ -660,6 +660,27 @@
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
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/include/clang/AST/StmtNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtNodes.def?rev=43433&r1=43432&r2=43433&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtNodes.def (original)
+++ cfe/trunk/include/clang/AST/StmtNodes.def Sun Oct 28 23:04:16 2007
@@ -40,6 +40,9 @@
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)
Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=43433&r1=43432&r2=43433&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Sun Oct 28 23:04:16 2007
@@ -282,6 +282,10 @@
ExprTy *RetValExp) {
return 0;
}
+ virtual StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
+ SourceLocation RParenLoc) {
+ return 0;
+ }
//===--------------------------------------------------------------------===//
// Expression Parsing Callbacks.
More information about the cfe-commits
mailing list