]> granicus.if.org Git - clang/log
clang
17 years agomake sure to parse postfix expression suffixes after builtin
Chris Lattner [Thu, 30 Aug 2007 15:52:49 +0000 (15:52 +0000)]
make sure to parse postfix expression suffixes after builtin
primary expressions.

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

17 years agoadd an action callback for __builtin_offsetof
Chris Lattner [Thu, 30 Aug 2007 15:51:11 +0000 (15:51 +0000)]
add an action callback for __builtin_offsetof

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

17 years ago-C mode doesn't return comments on "#" lines, so the diag checker doesn't pick them up.
Chris Lattner [Thu, 30 Aug 2007 06:38:49 +0000 (06:38 +0000)]
-C mode doesn't return comments on "#" lines, so the diag checker doesn't pick them up.
Test this the hard way.

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

17 years agoWhen relexing the file to find expected warnings/errors, make sure
Chris Lattner [Thu, 30 Aug 2007 06:34:23 +0000 (06:34 +0000)]
When relexing the file to find expected warnings/errors, make sure
to turn off all lexer-related warnings.

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

17 years agofix a bug that is causing CodeGen/complex.c to be grumpy.
Chris Lattner [Thu, 30 Aug 2007 06:19:11 +0000 (06:19 +0000)]
fix a bug that is causing CodeGen/complex.c to be grumpy.

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

17 years agoTeach the stmtdumper to dump location/range info when a SourceMgr is available.
Chris Lattner [Thu, 30 Aug 2007 06:17:34 +0000 (06:17 +0000)]
Teach the stmtdumper to dump location/range info when a SourceMgr is available.
For example, -parse-ast-dump now prints:

static inline int __inline_isinff(float __x)
(CompoundStmt 0x2409a20
  (ReturnStmt 0x2409a10
    (BinaryOperator 0x24099f0 'int' <///usr/include/architecture/i386/math.h:183:63, col:102> '=='
      (CallExpr 0x24098f0 'float' <col:63, col:82>
        (ImplicitCastExpr 0x24098e0 'float (*)(float)' <col:63>
          (DeclRefExpr 0x2409880 'float (float)' <col:63> Decl='__builtin_fabsf' 0x2409840))
        (DeclRefExpr 0x24098a0 'float' <col:79> Decl='__x' 0x2409810))
      (CallExpr 0x24099c0 'float' <col:87, col:102>
        (ImplicitCastExpr 0x2409870 'float (*)(void)' <col:87>
          (DeclRefExpr 0x2409980 'float (void)' <col:87> Decl='__builtin_inff' 0x2409940))))))

where it only prints filename/line# if it changes from the previous value.  We
really need loc info on stmts though, like we have on exprs.

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

17 years agoFix a regression on test/Sema/unused-expr.c by fixing the type predicates
Chris Lattner [Thu, 30 Aug 2007 06:10:41 +0000 (06:10 +0000)]
Fix a regression on test/Sema/unused-expr.c by fixing the type predicates
to test for the right type class.

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

17 years agoconstify a method.
Chris Lattner [Thu, 30 Aug 2007 05:59:30 +0000 (05:59 +0000)]
constify a method.

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

17 years agoFix the following redefinition errors submitted by Keith Bauer...
Steve Naroff [Thu, 30 Aug 2007 01:06:46 +0000 (01:06 +0000)]
Fix the following redefinition errors submitted by Keith Bauer...

[dylan:~/llvm/tools/clang] admin% cat tentative_decls.c
// incorrectly generates redefinition error
extern int array[3];
int array[3];

// incorrectly generates a redefinition error
extern void nup(int a[3]);
void nup(int a[3]) {}

It turns out that this exposed a fairly major flaw in the type system,
array types were never getting uniqued! This is because all array types
contained an expression, which aren't unique.

To solve this, we now have 2 array types, ConstantArrayType and
VariableArrayType. ConstantArrayType's are unique, VAT's aren't.

This is a fairly extensive set of fundamental changes. Fortunately,
all the tests pass. Nevertheless, there may be some collateral damage:-)
If so, let me know!

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

17 years agoPrevious commit should have been:
Chris Lattner [Thu, 30 Aug 2007 01:00:35 +0000 (01:00 +0000)]
Previous commit should have been:
  Use Ted's child walking interface to allow the dumper to walk the tree
  in one place and only have node-specific callbacks worry about
  formatting the nodes (instead of formatting the nodes plus walking the
  tree).

This commit eliminates now default cases by letting them fall through with
the normal visitor stuff.

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

17 years agoelimiante some virtual calls.
Chris Lattner [Thu, 30 Aug 2007 00:53:54 +0000 (00:53 +0000)]
elimiante some virtual calls.

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

17 years agoAllow a SourceManager to optionally be passed into Stmt::dump
Chris Lattner [Thu, 30 Aug 2007 00:40:08 +0000 (00:40 +0000)]
Allow a SourceManager to optionally be passed into Stmt::dump

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

17 years agoAdded comments about -dump-cfg and -view-cfg modes for the clang driver.
Ted Kremenek [Wed, 29 Aug 2007 23:26:37 +0000 (23:26 +0000)]
Added comments about -dump-cfg and -view-cfg modes for the clang driver.

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

17 years agoAdded an (optional) explicit "Label" statement to CFGBlock. If a
Ted Kremenek [Wed, 29 Aug 2007 23:20:49 +0000 (23:20 +0000)]
Added an (optional) explicit "Label" statement to CFGBlock.  If a
block begins with a label or case statement, CFGBlock::getLabel() will
return the corresponding LabelStmt/CaseStmt/DefaultStmt.

LabelStmts and SwitchCases no longer appear within the "executable"
statements of a CFGBlock.

More cleanups on visualization/pretty-printing of CFGs (less verbose).

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

17 years agocleanup context-sensitive objc keyword recognition. Patch by Fariborz Jahanian.
Chris Lattner [Wed, 29 Aug 2007 22:54:08 +0000 (22:54 +0000)]
cleanup context-sensitive objc keyword recognition.  Patch by Fariborz Jahanian.

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

17 years agoSpaces not tabs.
Neil Booth [Wed, 29 Aug 2007 22:13:52 +0000 (22:13 +0000)]
Spaces not tabs.

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

17 years agoEnsure we diagnose long long literals in C90 mode.
Neil Booth [Wed, 29 Aug 2007 22:00:19 +0000 (22:00 +0000)]
Ensure we diagnose long long literals in C90 mode.

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

17 years agoAdded GraphTraits to source-level CFGs (CFG and CFGBlock) to allow
Ted Kremenek [Wed, 29 Aug 2007 21:56:09 +0000 (21:56 +0000)]
Added GraphTraits to source-level CFGs (CFG and CFGBlock) to allow
(LLVM-provided) graph algorithms such as DFS and graph visualization
to work effortless on source-level CFGs.

Further cleanup on pretty printing of CFGs.  CFGBlock::dump and
CFGBlock::print now take the parent CFG as an argument.  This allows
CFGBlocks to print their own appropriate label indicating whether or
not they are the Entry/Exit/IndirectGotoBlock without the CFG::print
routine doing it instead.

Added Graphviz visualization for CFGs: CFG::viewCFG.  This employs the
GraphTraits just implemented.

Added "-view-cfg" mode the to clang driver.  This is identical to
"-dump-cfg" except that it calls Graphviz to visualize the CFGs
instead of dumping them to the terminal.

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

17 years agoAdded checking (during parsing) of comparison of floating point values using == or !=.
Ted Kremenek [Wed, 29 Aug 2007 18:06:12 +0000 (18:06 +0000)]
Added checking (during parsing) of comparison of floating point values using == or !=.
This is the same functionality gcc provides via --Wfloat-equal.

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

17 years agoTeach Type::is[un]SignedIntegerType about enum decls. This allows the code generator
Chris Lattner [Wed, 29 Aug 2007 17:48:46 +0000 (17:48 +0000)]
Teach Type::is[un]SignedIntegerType about enum decls.  This allows the code generator
to emit signed comparisons when needed for enum decl references.  This implements
test/CodeGen/enum.c.  I think enums should be good now.

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

17 years agoImplement GCC-compatible layout and typing of enum constants and enum decl.
Chris Lattner [Wed, 29 Aug 2007 17:31:48 +0000 (17:31 +0000)]
Implement GCC-compatible layout and typing of enum constants and enum decl.
A small bit of codegen work is still pending.

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

17 years agoadd some accessors
Chris Lattner [Wed, 29 Aug 2007 17:23:37 +0000 (17:23 +0000)]
add some accessors

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

17 years agoFix a null dereference Neil ran into
Chris Lattner [Wed, 29 Aug 2007 16:03:41 +0000 (16:03 +0000)]
Fix a null dereference Neil ran into

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

17 years agoremove some ugly code now that implicit defs are being generated in this case, thanks...
Chris Lattner [Wed, 29 Aug 2007 06:38:44 +0000 (06:38 +0000)]
remove some ugly code now that implicit defs are being generated in this case, thanks Steve!

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

17 years agoRe-teach Expr::isNullPointerConstant() about ImplicitCastExpr:-)
Steve Naroff [Wed, 29 Aug 2007 00:00:02 +0000 (00:00 +0000)]
Re-teach Expr::isNullPointerConstant() about ImplicitCastExpr:-)

This fixes the following bug submitted by Neil...

const char *f (void) { return 0; }

...which would incorrectly warn with -pedantic enabled.

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

17 years agoImplement default argument promotions (for old-style function calls and variable...
Steve Naroff [Tue, 28 Aug 2007 23:30:39 +0000 (23:30 +0000)]
Implement default argument promotions (for old-style function calls and variable argument lists).

[dylan:~/llvm/tools/clang] admin% cat x.c

int printf(const char *, ...);

int oldschool();

void foo() {
  float f;
  short i;
  printf("foo %f", 1.0f);

  oldschool(f,i);
}

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang x.c -parse-ast-dump

int printf(char const *, ...);

int oldschool();

void foo()
(CompoundStmt 0x3105f00
  (DeclStmt 0x3105ba0
    0x3105ce0 "float f")
  (DeclStmt 0x3105c90
    0x3105d10 "short i")
  (CallExpr 0x3105df0 'int'
    (ImplicitCastExpr 0x3105dc0 'int (*)(char const *, ...)'
      (DeclRefExpr 0x3105c20 'int (char const *, ...)' Decl='printf' 0x3105bd0))
    (ImplicitCastExpr 0x3105dd0 'char const *'
      (StringLiteral 0x3105d60 'char *' "foo %f"))
    (ImplicitCastExpr 0x3105de0 'double'
      (FloatingLiteral 0x3105d80 'float' 1.000000)))
  (CallExpr 0x3105ed0 'int'
    (ImplicitCastExpr 0x3105ea0 'int (*)()'
      (DeclRefExpr 0x3105e20 'int ()' Decl='oldschool' 0x3105c40))
    (ImplicitCastExpr 0x3105eb0 'double'
      (DeclRefExpr 0x3105e40 'float' Decl='f' 0x3105ce0))
    (ImplicitCastExpr 0x3105ec0 'int'
      (DeclRefExpr 0x3105e60 'short' Decl='i' 0x3105d10))))

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

17 years agoTeach Expr::isNullPointerConstant() about ImplicitCastExpr's.
Steve Naroff [Tue, 28 Aug 2007 21:20:34 +0000 (21:20 +0000)]
Teach Expr::isNullPointerConstant() about ImplicitCastExpr's.

This fixes the following (recent) regression noticed by Keith Bauer (thanks!).

void func(void *a);

main() {
  void *p;
  p = 0;
  func(0);
}

...which now works as you would expect.

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

17 years agoFinish converting decls over to the new invalid decl API.
Steve Naroff [Tue, 28 Aug 2007 20:14:24 +0000 (20:14 +0000)]
Finish converting decls over to the new invalid decl API.

Also removed an old FIXME (FIXME: "auto func();" passes through...).

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

17 years agoAdded support for indirect-gotos (GCC extension) in source-level CFGs.
Ted Kremenek [Tue, 28 Aug 2007 19:26:49 +0000 (19:26 +0000)]
Added support for indirect-gotos (GCC extension) in source-level CFGs.
This involves the construction of a specialized "dispatch" block that
all basic blocks containing indirect gotos unconditionally transfer
control-flow to.  The successors of the dispatch block has as its successors
all of the blocks containing labels whose address was taken somewhere in
the function.

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

17 years agoMove the "invalid decl" idiom up to Decl (where we have some bits to steal:-)
Steve Naroff [Tue, 28 Aug 2007 18:45:29 +0000 (18:45 +0000)]
Move the "invalid decl" idiom up to Decl (where we have some bits to steal:-)

Converted ParmVarDecl, FileVarDecl, BlockVarDecl, and Sema::ParseIdentifierExpr() to use the idiom.

Updated array-constraint.c to make sure we no longer get "undeclared identifier" errors:-)

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

17 years agoEmit a slightly better warning for unused values for unary and binary operators:
Chris Lattner [Tue, 28 Aug 2007 18:40:30 +0000 (18:40 +0000)]
Emit a slightly better warning for unused values for unary and binary operators:

t2.c:3:18: warning: expression result unused
     x = ++x, ++y, y+2;
     ~~~~~~~~~~~~^ ~~~

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

17 years agoadd a sourcelocation to binary operator to keep track of the location of the operator.
Chris Lattner [Tue, 28 Aug 2007 18:36:55 +0000 (18:36 +0000)]
add a sourcelocation to binary operator to keep track of the location of the operator.

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

17 years agoAdded support for GCC-style statement expressions in source-level CFGs.
Ted Kremenek [Tue, 28 Aug 2007 18:30:10 +0000 (18:30 +0000)]
Added support for GCC-style statement expressions in source-level CFGs.

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

17 years agoChange EnumDecl to store its corresponding integer type
Chris Lattner [Tue, 28 Aug 2007 18:24:31 +0000 (18:24 +0000)]
Change EnumDecl to store its corresponding integer type
directly in it.  Remove TargetInfo::getEnumPolicy, as there is only
one policy that we support right now.

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

17 years agoAdded support for comma expressions and DeclStmts which may have
Ted Kremenek [Tue, 28 Aug 2007 18:14:37 +0000 (18:14 +0000)]
Added support for comma expressions and DeclStmts which may have
arbitrarily complex control-flow in their subexpressions.

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

17 years agoFixed return-of-stack-address checker to correctly handle stack/global
Ted Kremenek [Tue, 28 Aug 2007 17:02:55 +0000 (17:02 +0000)]
Fixed return-of-stack-address checker to correctly handle stack/global
variables that have a pointer type, or arrays that contain pointers.

This fixes a crash on the following code:

int *h[3];

int **foo(int i)
{
   return &(h[i]);
}

This bug was reported by Keith Bauer (thanks!).

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

17 years agoextwarn about VLAs in C89 mode.
Chris Lattner [Tue, 28 Aug 2007 16:54:00 +0000 (16:54 +0000)]
extwarn about VLAs in C89 mode.

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

17 years agoc++'0x has long long also.
Chris Lattner [Tue, 28 Aug 2007 16:41:29 +0000 (16:41 +0000)]
c++'0x has long long also.

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

17 years agowarn about long long when in c89 mode.
Chris Lattner [Tue, 28 Aug 2007 16:40:32 +0000 (16:40 +0000)]
warn about long long when in c89 mode.

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

17 years agoTweak declaration...
Steve Naroff [Tue, 28 Aug 2007 16:31:47 +0000 (16:31 +0000)]
Tweak declaration...

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

17 years agonew testcase
Chris Lattner [Tue, 28 Aug 2007 16:20:14 +0000 (16:20 +0000)]
new testcase

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

17 years agoRemoved special-casing in CFG construction for ParenExprs.
Ted Kremenek [Tue, 28 Aug 2007 16:18:58 +0000 (16:18 +0000)]
Removed special-casing in CFG construction for ParenExprs.

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

17 years agofix 80 col violation
Chris Lattner [Tue, 28 Aug 2007 06:17:15 +0000 (06:17 +0000)]
fix 80 col violation

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

17 years agocompute the required destination type for an enum, emitting various warnings.
Chris Lattner [Tue, 28 Aug 2007 06:15:15 +0000 (06:15 +0000)]
compute the required destination type for an enum, emitting various warnings.

TODO: update the types of the constants and the enum.

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

17 years agoremove dead method.
Chris Lattner [Tue, 28 Aug 2007 05:56:37 +0000 (05:56 +0000)]
remove dead method.

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

17 years agoadd a diagnostic:
Chris Lattner [Tue, 28 Aug 2007 05:27:00 +0000 (05:27 +0000)]
add a diagnostic:

t.c:1:12: warning: ISO C restricts enumerator values to range of 'int' (180388626432 is too large)
enum e {A, B = 42LL << 32, C = -4, D = 12456 };
           ^

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

17 years agomove a todo
Chris Lattner [Tue, 28 Aug 2007 05:10:31 +0000 (05:10 +0000)]
move a todo

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

17 years agonow that all the infrastructure is in place, enforce C99 6.8.5p3.
Chris Lattner [Tue, 28 Aug 2007 05:03:08 +0000 (05:03 +0000)]
now that all the infrastructure is in place, enforce C99 6.8.5p3.

Note the FIXME: we need some way to mark a decl erroneous :)

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

17 years agoIf the condition of a for statement is promoted, make sure the
Chris Lattner [Tue, 28 Aug 2007 04:55:47 +0000 (04:55 +0000)]
If the condition of a for statement is promoted, make sure the
implicit cast gets linked back into the AST.

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

17 years agoImplement more thoughful error recovery when dealing with bogus declarator types.
Steve Naroff [Tue, 28 Aug 2007 03:03:08 +0000 (03:03 +0000)]
Implement more thoughful error recovery when dealing with bogus declarator types.

For example, the following code was resulting in spurious warnings. This was the result of
Sema::GetTypeForDeclarator() synthesizing a type to hand back to the caller (in this case,
"int []", instead of "struct s[]", which is invalid).

struct s;
struct s* t (struct s z[]) {   // expected-error {{array has incomplete element type}}
  return z;
}

Strategy: Flag the error in Declarator/DeclaratorChunk. This info is later stored in
the ParmVarDecl. If the decl is referenced, Sema::ParseIdentifierExpr() will check if
the type is invalid. If so, it quietly returns "true", without instantiating a DeclRefExpr.

This seems to work nicely. If Chris is happy with the approach, I will generalize this to
all VarDecls.

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

17 years agoAdded support for short-circuit '&&' and '||' operators in source-level CFGs.
Ted Kremenek [Mon, 27 Aug 2007 21:54:41 +0000 (21:54 +0000)]
Added support for short-circuit '&&' and '||' operators in source-level CFGs.

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

17 years agoSome minor aesthetic changes to the control flow.
Steve Naroff [Mon, 27 Aug 2007 21:43:43 +0000 (21:43 +0000)]
Some minor aesthetic changes to the control flow.

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

17 years agoFix remaining bugs with complex/float promotions.
Steve Naroff [Mon, 27 Aug 2007 21:32:55 +0000 (21:32 +0000)]
Fix remaining bugs with complex/float promotions.

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

17 years agoImplemented support for ternary "?" operators in source-level CFGs.
Ted Kremenek [Mon, 27 Aug 2007 21:27:44 +0000 (21:27 +0000)]
Implemented support for ternary "?" operators in source-level CFGs.

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

17 years agoFix a few enum-related fixme's
Chris Lattner [Mon, 27 Aug 2007 21:16:18 +0000 (21:16 +0000)]
Fix a few enum-related fixme's

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

17 years agoFixed bug in child_begin/child_end for CallExpr where we incorrectly calculated a...
Ted Kremenek [Mon, 27 Aug 2007 21:11:44 +0000 (21:11 +0000)]
Fixed bug in child_begin/child_end for CallExpr where we incorrectly calculated a Stmt** pointer
based on an offset within SubExprs.

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

17 years agoFixed bug in child_begin/child_end for ReturnStmt where the iterator
Ted Kremenek [Mon, 27 Aug 2007 20:58:16 +0000 (20:58 +0000)]
Fixed bug in child_begin/child_end for ReturnStmt where the iterator
would be invalid when RetValExp == NULL.

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

17 years agoChanges to CFGBuilder:
Ted Kremenek [Mon, 27 Aug 2007 19:46:09 +0000 (19:46 +0000)]
Changes to CFGBuilder:
+ Added the creation of an empty Entry block at the end of CFG
  construction if the Entry block in the CFG contains multiple
  predecessors (which can happen with labels and do loops).

+ Fixed bug in the creation of an empty Exit block with functions where not
  all paths end in a return statement (but some do).  Basic blocks with
  return statements were jumping to a (sometimes) non-empty block.

+ FinishBlock no longer checks for labels at the beginning of a basic
  block before reversing the statements in the block.  This is because
  the recursion invariants of the builder methods have been cleaned up,
  and blocks are only passed to FinishBlock at most once.

+ Modified handling of "if", "for", "while", "do", and "switch" to allow
  condition expressions that can span multiple basic blocks.  This allows
  such conditions to contain short-circuit expressions (which span multiple
  blocks in the CFG).

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

17 years agoconstify some stuff
Chris Lattner [Mon, 27 Aug 2007 17:56:57 +0000 (17:56 +0000)]
constify some stuff

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

17 years agoteach codegen to lay out enum types.
Chris Lattner [Mon, 27 Aug 2007 17:44:34 +0000 (17:44 +0000)]
teach codegen to lay out enum types.

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

17 years agoimplement sizeof(enum x), patch inspired by Keith Bauer.
Chris Lattner [Mon, 27 Aug 2007 17:38:00 +0000 (17:38 +0000)]
implement sizeof(enum x), patch inspired by Keith Bauer.

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

17 years agobetter error recovery for non-i-c-e enum constants.
Chris Lattner [Mon, 27 Aug 2007 17:37:24 +0000 (17:37 +0000)]
better error recovery for non-i-c-e enum constants.

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

17 years agoC++ allows empty enum list.
Chris Lattner [Mon, 27 Aug 2007 17:24:30 +0000 (17:24 +0000)]
C++ allows empty enum list.

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

17 years agoadd some accessors.
Chris Lattner [Mon, 27 Aug 2007 16:50:56 +0000 (16:50 +0000)]
add some accessors.

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

17 years agoAdd enum type conversion policies, patch by Keith Bauer
Chris Lattner [Mon, 27 Aug 2007 16:48:59 +0000 (16:48 +0000)]
Add enum type conversion policies, patch by Keith Bauer

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

17 years agoUpdated checker for "return of address of stack variable" to look for
Ted Kremenek [Mon, 27 Aug 2007 16:39:17 +0000 (16:39 +0000)]
Updated checker for "return of address of stack variable" to look for
implicit casts from T to T& at the topmost part of the return-value expression.

This checking may be needed within EvalAddr later on.  We'll wait until
test cases show this kind of logic is necessary (as more C++ features are
implemented in clang).

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

17 years agoadd some more testcases now that sema is happier :)
Chris Lattner [Mon, 27 Aug 2007 16:37:44 +0000 (16:37 +0000)]
add some more testcases now that sema is happier :)

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

17 years agoReplaced ASTContext::maxFloatingType() with ASTContext::compareFloatingType().
Steve Naroff [Mon, 27 Aug 2007 15:30:22 +0000 (15:30 +0000)]
Replaced ASTContext::maxFloatingType() with ASTContext::compareFloatingType().

Changed Sema::UsualArithmeticConversions to use the new API.

This fixes the following case...

_Complex double X;
double y;

void foo() {
  X = X + y;
}

[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang complex.c -parse-ast-dump
Read top-level variable decl: 'X'
Read top-level variable decl: 'y'

void foo()
(CompoundStmt 0x2605cc0
  (BinaryOperator 0x2605ca0 '_Complex double' '='
    (DeclRefExpr 0x2605c10 '_Complex double' Decl='X' 0x2605ab0)
    (BinaryOperator 0x2605c80 '_Complex double' '+'
      (DeclRefExpr 0x2605c30 '_Complex double' Decl='X' 0x2605ab0)
      (ImplicitCastExpr 0x2605c70 '_Complex double'
        (DeclRefExpr 0x2605c50 'double' Decl='y' 0x2605ae0)))))

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

17 years agotestcase that doesn't work quite yet
Chris Lattner [Mon, 27 Aug 2007 05:23:45 +0000 (05:23 +0000)]
testcase that doesn't work quite yet

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

17 years agoextwarn about decls intermixed with code in c89 mode.
Chris Lattner [Mon, 27 Aug 2007 04:29:41 +0000 (04:29 +0000)]
extwarn about decls intermixed with code in c89 mode.

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

17 years agoAdd Type::getAsBuiltinType() and Type::builtinTypesAreCompatible().
Steve Naroff [Mon, 27 Aug 2007 04:08:11 +0000 (04:08 +0000)]
Add Type::getAsBuiltinType() and Type::builtinTypesAreCompatible().
Modified Type::typesAreCompatible() to use the above.

This fixes the following bug submitted by Keith Bauer (thanks!).

int equal(char *a, const char *b)
{
    return a == b;
}

Also tweaked Sema::CheckCompareOperands() to ignore the qualifiers when
comparing two pointer types (though it doesn't relate directly to this bug).

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

17 years agoTweak a comment and assert.
Steve Naroff [Mon, 27 Aug 2007 01:41:48 +0000 (01:41 +0000)]
Tweak a comment and assert.

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

17 years agoReplaced ASTContext::maxComplexType() with ASTContext::getFloatingTypeOfSizeWithinDom...
Steve Naroff [Mon, 27 Aug 2007 01:27:54 +0000 (01:27 +0000)]
Replaced ASTContext::maxComplexType() with ASTContext::getFloatingTypeOfSizeWithinDomain().

Changed Sema::UsualArithmeticConversions to correctly implement complex/float conversions,
using maxFloatingType() with getFloatingTypeOfSizeWithinDomain().

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

17 years agoimplement a fixme: __extension__ marker on decls in compound stmts.
Chris Lattner [Mon, 27 Aug 2007 01:01:57 +0000 (01:01 +0000)]
implement a fixme: __extension__ marker on decls in compound stmts.

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

17 years agomove EmitAggregateCopy into AggExprEmitter
Chris Lattner [Sun, 26 Aug 2007 23:13:56 +0000 (23:13 +0000)]
move EmitAggregateCopy into AggExprEmitter

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

17 years agoFix test/Parser/if-scope-*.c. Patch by Neil Booth!
Chris Lattner [Sun, 26 Aug 2007 23:08:06 +0000 (23:08 +0000)]
Fix test/Parser/if-scope-*.c.  Patch by Neil Booth!

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

17 years agoremove dead code
Chris Lattner [Sun, 26 Aug 2007 23:02:57 +0000 (23:02 +0000)]
remove dead code

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

17 years agoremove dead protos
Chris Lattner [Sun, 26 Aug 2007 23:01:23 +0000 (23:01 +0000)]
remove dead protos

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

17 years agoeliminate EmitAnyExpr, inlining it and simplifying it into its only caller.
Chris Lattner [Sun, 26 Aug 2007 22:58:05 +0000 (22:58 +0000)]
eliminate EmitAnyExpr, inlining it and simplifying it into its only caller.

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

17 years agoeliminate use of EmitAnyExpr.
Chris Lattner [Sun, 26 Aug 2007 22:55:13 +0000 (22:55 +0000)]
eliminate use of EmitAnyExpr.

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

17 years agoimplement a fixme
Chris Lattner [Sun, 26 Aug 2007 22:47:40 +0000 (22:47 +0000)]
implement a fixme

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

17 years agonew testcases
Chris Lattner [Sun, 26 Aug 2007 22:41:57 +0000 (22:41 +0000)]
new testcases

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

17 years agoImplement compound assignment operators whose LHS is scalar but RHS is complex.
Chris Lattner [Sun, 26 Aug 2007 22:37:40 +0000 (22:37 +0000)]
Implement compound assignment operators whose LHS is scalar but RHS is complex.

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

17 years agoimplement codegen of compound assignment operators for complex.
Chris Lattner [Sun, 26 Aug 2007 22:09:01 +0000 (22:09 +0000)]
implement codegen of compound assignment operators for complex.

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

17 years agoIf a visitor doesn't define VisitBinMulAssign, fallback to VisitCompoundAssignOperator
Chris Lattner [Sun, 26 Aug 2007 22:08:29 +0000 (22:08 +0000)]
If a visitor doesn't define VisitBinMulAssign, fallback to VisitCompoundAssignOperator
instead of VisitBinaryOperator.

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

17 years agocompound assignment operators are of type CompoundAssignOperator
Chris Lattner [Sun, 26 Aug 2007 21:41:21 +0000 (21:41 +0000)]
compound assignment operators are of type CompoundAssignOperator

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

17 years agodispatch to functions like VisitBinRemAssign with knowledge that
Chris Lattner [Sun, 26 Aug 2007 21:40:28 +0000 (21:40 +0000)]
dispatch to functions like VisitBinRemAssign  with knowledge that
the operand is of type CompoundAssignOperator, not just BinaryOperator.

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

17 years agoupdate fixme's
Chris Lattner [Sun, 26 Aug 2007 21:27:07 +0000 (21:27 +0000)]
update fixme's

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

17 years agoimplement complex division
Chris Lattner [Sun, 26 Aug 2007 21:24:19 +0000 (21:24 +0000)]
implement complex division

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

17 years agoAdd isysroot support, patch by Keith Bauer
Chris Lattner [Sun, 26 Aug 2007 17:47:35 +0000 (17:47 +0000)]
Add isysroot support, patch by Keith Bauer

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

17 years agoFix %p format checking, patch by Keith Bauer.
Chris Lattner [Sun, 26 Aug 2007 17:39:38 +0000 (17:39 +0000)]
Fix %p format checking, patch by Keith Bauer.

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

17 years agoFor warnings like this:
Chris Lattner [Sun, 26 Aug 2007 17:38:22 +0000 (17:38 +0000)]
For warnings like this:

t.c:3:9: warning: invalid conversion '%B'
printf("%B\a\n", p);
~~~~~~  ^

Don't beep the console or print the newline.

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

17 years agoFix a bug reported by Keith Bauer
Chris Lattner [Sun, 26 Aug 2007 17:32:59 +0000 (17:32 +0000)]
Fix a bug reported by Keith Bauer

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

17 years agofix a typo noticed by Gordon Henriksen
Chris Lattner [Sun, 26 Aug 2007 17:25:57 +0000 (17:25 +0000)]
fix a typo noticed by Gordon Henriksen

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

17 years agollvmgcc is right :)
Chris Lattner [Sun, 26 Aug 2007 16:54:05 +0000 (16:54 +0000)]
llvmgcc is right :)

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

17 years agocompound assignmetns work for scalars.
Chris Lattner [Sun, 26 Aug 2007 16:52:57 +0000 (16:52 +0000)]
compound assignmetns work for scalars.

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

17 years agoimplement conversions of complex to bool.
Chris Lattner [Sun, 26 Aug 2007 16:52:28 +0000 (16:52 +0000)]
implement conversions of complex to bool.

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

17 years agoremove ConvertScalarValueToBool.
Chris Lattner [Sun, 26 Aug 2007 16:46:58 +0000 (16:46 +0000)]
remove ConvertScalarValueToBool.

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

17 years agoreimplement ConvertScalarValueToBool in CGExprScalar.cpp
Chris Lattner [Sun, 26 Aug 2007 16:42:57 +0000 (16:42 +0000)]
reimplement ConvertScalarValueToBool in CGExprScalar.cpp

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

17 years agorefactor some code to expose compex->scalar conversion to CGF
Chris Lattner [Sun, 26 Aug 2007 16:34:22 +0000 (16:34 +0000)]
refactor some code to expose compex->scalar conversion to CGF

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