On Feb 25, 2008, at 2:45 PM, Chris Lattner wrote:
+/* -*- indent-tabs-mode:nil; -*- */Please don't do this.
FIxed.
+ class CXXThrowExpr : public Expr { ... + virtual SourceRange getSourceRange() const {+ return SourceRange(ThrowLoc, getSubExpr()- >getSourceRange().getEnd());+ }If getSubExpr() is null, this should return SourceRange(ThrowLoc, ThrowLoc).
Ah, yes, of course. Fixed.
+++ ./AST/StmtPrinter.cpp 2008-02-25 13:35:57.000000000 -0800
@@ -780,6 +780,12 @@ void StmtPrinter::VisitCXXBoolLiteralExp
OS << (Node->getValue() ? "true" : "false");
}
+void StmtPrinter::VisitCXXThrowExpr(CXXThrowExpr *Node) {
+ OS << "throw ";
+ if (Node->getSubExpr())
+ PrintExpr(Node->getSubExpr());
It would be slightly nicer to not print the space after the throw if
subexpr is null.
Yeah, I thought about doing that when I first implemented it and decided against worrying about it as it didn't seem as bad as the extra {} in extern "C" handling. But, it is easy, localized and doesn't require any more data in the AST to do it, sooo.... Fixed.
I also added a FIXME for handling throw when not followed by a ';' nor an assignment-expression. Something parser generators do automagically for us, but something we have to compute. Do we have a tentative parse system yet or some other easy way to do this? [ I think I know the answer, I bet not. ]The fixme is fine for a first step. However, it would be better to eventually add a predicate that determines whether a token is the start of an expression.
Agreed.
I don't think there are any cases where a declaration is allowed after a throw,
You mean like this: throw int(1); ? Yup, that's valid.
so this predicate should be relatively straight-forward, something like Parser::isDeclarationSpecifier().I agree this is somewhat ugly, but it could be worse
Just wait, we'll get there.
eh-1a.diffs
Description: Binary data
_______________________________________________ cfe-dev mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
