Commit Graph

39 Commits

Author SHA1 Message Date
Chris Lattner b4522b4dec Pretty print storage classes for vardecls.
llvm-svn: 39556
2007-06-02 05:27:01 +00:00
Chris Lattner e0c4ae1f24 Generalize this to support printing any valuedecl, e.g. function definitions.
We now print:
  extern void blah();
as:
  void (blah)();

Strange, but ok :)

llvm-svn: 39549
2007-06-02 03:38:08 +00:00
Chris Lattner a076fde1e3 more minor improvements to pretty printer.
llvm-svn: 39538
2007-05-31 18:21:33 +00:00
Chris Lattner b4619481e6 add some ;'s
llvm-svn: 39537
2007-05-31 06:00:14 +00:00
Chris Lattner df3cafb796 fix a small printer bug, to emit:
a = b;
  {
    int c;
    c = a + b;
    int d;
    d++;
  }
  int e;

instead of:

  a = b;
  {
    int c;
    c = a + b;
    int d;
    d++;
  }  int e;

llvm-svn: 39535
2007-05-31 05:08:56 +00:00
Chris Lattner fc068c15d9 pretty print exprs in stmt contexts with a trailing semicolon.
llvm-svn: 39531
2007-05-30 17:57:36 +00:00
Steve Naroff 9992bbab14 Bug #:
Submitted by:
Reviewed by:
- ParseForStatement(): Put back a test/assignment. My removal of
ParseExprStmt() was a bit over zealous:-(thanks to Chris for pointing it out)
- Add assert to VisitDeclStmt().
- Removed an out-of-date FIXME
- Added some curlies for a couple multi-line calls to Diag().

llvm-svn: 39528
2007-05-30 16:27:15 +00:00
Chris Lattner d5322cd27e Don't print billions of spaces for a label with no indent.
llvm-svn: 39521
2007-05-29 23:49:07 +00:00
Steve Naroff 2a8ad18e71 Bug #:
Submitted by:
Reviewed by:
Implement some FIXME's that stand in the way of fully typechecking "for"
statements. This involved:

- Adding a DeclStmt AST node (with statement visitor). The DeclStmt
printer is preliminary.
- Added a ParseDeclStmt action, called from Parser::ParseForStatement()
and Parser::ParseStatementOrDeclaration(). DID NOT add to
Parser::ParseIdentifierStatement()...probably could have, however didn't
really understand the context of this rule (will speak with Chris).
- Removed ParseExprStmt (and it's clients)...it was vestigial.

llvm-svn: 39518
2007-05-29 22:59:26 +00:00
Chris Lattner eefa10e78a implement full sema support for the GCC address-of-label extension.
llvm-svn: 39510
2007-05-28 06:56:27 +00:00
Chris Lattner e2473068d4 Change GotoStmt's to have a pointer to the LabelStmt instead of a pointer to
the label identifier.  Handle fwd references etc.  This allows us to detect
uses of undefined labels and label redefinitions, such as:

t.c:2:12: error: redefinition of label 'abc'
  abc: ;   abc:
           ^
t.c:2:3: error: previous definition is here
  abc: ;   abc:
  ^
t.c:12:12: error: use of undeclared label 'hijl'
      goto hijl;
           ^

llvm-svn: 39509
2007-05-28 06:28:18 +00:00
Chris Lattner 2f6ac263ef Null pointers in the ast are no longer considered to be the null stmt.
llvm-svn: 39507
2007-05-28 01:47:47 +00:00
Chris Lattner 012a6cf1de add a NullStmt ast node.
llvm-svn: 39505
2007-05-28 01:41:58 +00:00
Chris Lattner f95211394a implement printer support for C++ bool literals
llvm-svn: 39489
2007-05-24 00:50:25 +00:00
Chris Lattner 24e0d6cf40 Implement a fixme
llvm-svn: 39488
2007-05-24 00:47:01 +00:00
Bill Wendling 48fbdd0302 Bug #:
Submitted by: Bill Wendling
Reviewed by: Chris Lattner

- Changed "std::cerr" to "OS" stream to be consistent with the other
  outputs in the method.

llvm-svn: 39483
2007-05-23 08:04:21 +00:00
Chris Lattner 0643041f6c In the yet-another-crazy-idea department, we now print the actual *value* of
integer constants, whoa! :)

llvm-svn: 39475
2007-05-21 05:45:03 +00:00
Chris Lattner 073926e39a pretty print switch/if stmts whose bodies are compound stmts.
llvm-svn: 39469
2007-05-20 23:04:55 +00:00
Chris Lattner b9eb5a1cec Pretty print labels and case stmts better. This leads to output like this:
void foo() {
abc:
def:
hij:
case 1:
case 1:
  goto abc
baz:
  goto def
}

instead of:

void foo() {
  abc:
    def:
      hij:
        case 1:
          case 1:
            goto abc
  baz:
    goto def
}

llvm-svn: 39468
2007-05-20 22:52:15 +00:00
Chris Lattner 3dc3d775fb Rename type::getAsString to getAsStringInternal. Add a new
QualType::getAsString() that returns a string, which is much easier
for clients to use.  Convert clients to use it.

llvm-svn: 39449
2007-05-16 18:07:12 +00:00
Steve Naroff ae4143ea90 Bug #:
Submitted by:
Reviewed by:
Misc. changes driven by getting "carbon.h" to compile...

- Added ParseCharacterConstant() hook to Action, Sema, etc.
- Added CheckAssignmentOperands() & CheckCommaOperands() to Sema.
- Added CharacterLiteral AST node.
- Fixed CallExpr instantiation - install the correct type.
- Install a bunch of temp types and annotate with FIXME's.

llvm-svn: 39416
2007-04-26 20:39:23 +00:00
Steve Naroff 7f890eb790 More changes to complete the dynamic type support for Stmt/Expr.
This set of changes includes:
- convert ExprCXX.h and add to the Xcode project file.
-- required adding CXXBoolLiteralExpr to StmtNodes.def.
-- required adding visitor support (decl/defn).
- make the class codes in StmtNodes.def explicit (to enable range checking).
-- this required changing all clients of the STMT macro.
- declare the instance data const.

llvm-svn: 39344
2007-02-27 02:53:10 +00:00
Steve Naroff df7855bb17 Batch search/replace snafu (inadvertantly changed IntegerConstant->StringLiteral).
clang still compiled/linked/ran properly...simply a confusing name regression.
From now on I'll make sure I run "cvs diff" before committing any changes!

llvm-svn: 39342
2007-02-21 23:46:25 +00:00
Steve Naroff ab62488ae3 rename IntegerConstant->IntegerLiteral
rename FloatingConstant->FloatingLiteral
rename StringExpr->StringLiteral

llvm-svn: 39341
2007-02-21 22:05:47 +00:00
Chris Lattner 29375654b6 Add support for parsing and pretty printing const_cast, dynamic_cast,
reinterpret_cast, and static_cast.  Patch by Bill!

llvm-svn: 39247
2006-12-04 18:06:35 +00:00
Chris Lattner 5efbb33a6b remember referenced decls in our AST's
llvm-svn: 39193
2006-11-20 05:01:40 +00:00
Chris Lattner 0d8b1a1eff remember and pretty-print cast types
llvm-svn: 39191
2006-11-20 04:34:45 +00:00
Chris Lattner f0a40e7ef4 correctly handle stuff like:
typedef int G;
  X = sizeof(const G);
  X = sizeof(restrict G);

llvm-svn: 39190
2006-11-20 04:17:27 +00:00
Chris Lattner 33e8a55ed0 Parse and remember types enough that we can pretty print:
void foo(int X) {
  X = __alignof(int);
  X = sizeof(const int** restrict ** volatile*);
}

as:

x = __alignof(int)
x = sizeof(int const **restrict **volatile *)

llvm-svn: 39181
2006-11-19 01:48:02 +00:00
Chris Lattner 1576870356 pretty print postfix ++/-- nicer
llvm-svn: 39137
2006-11-05 23:54:51 +00:00
Chris Lattner 36ad123dea print indirect goto correctly
llvm-svn: 39122
2006-11-05 01:51:06 +00:00
Chris Lattner 16976d3e83 build ast nodes and print goto/goto*/break/continue.
llvm-svn: 39121
2006-11-05 01:46:01 +00:00
Chris Lattner 6c0ff13761 Add ast node support for case/default/label stmts.
llvm-svn: 39120
2006-11-05 00:19:50 +00:00
Chris Lattner f2174b633b implement AST node for switch stmt
llvm-svn: 39119
2006-11-04 20:59:27 +00:00
Chris Lattner 85ed873bdc implement ast nodes for while and do loops
llvm-svn: 39116
2006-11-04 20:40:44 +00:00
Chris Lattner 5d8f494c00 pretty print strings more nicely
llvm-svn: 39114
2006-11-04 20:29:31 +00:00
Chris Lattner 71e23ce2e1 Add AST node, AST building, actions, and printing for 'for' stmts.
llvm-svn: 39113
2006-11-04 20:18:38 +00:00
Chris Lattner 882f788ef4 Implement the rest of the printer, restoring parity of functionality.
llvm-svn: 39111
2006-11-04 18:52:07 +00:00
Chris Lattner a3bcb7a104 start converting dumper to be a simple visitor
llvm-svn: 39109
2006-11-04 07:16:25 +00:00