]> granicus.if.org Git - clang/log
clang
17 years agooptimize scope push/pop to avoid work in the common case.
Chris Lattner [Wed, 22 Aug 2007 05:33:11 +0000 (05:33 +0000)]
optimize scope push/pop to avoid work in the common case.

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

17 years agoFix the scoping issue Neil pointed out for the rest of
Chris Lattner [Wed, 22 Aug 2007 05:28:50 +0000 (05:28 +0000)]
Fix the scoping issue Neil pointed out for the rest of
the selection statements and iteration statements.  Add
spec citations.

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

17 years agoFix a nasty C99 scope issue that Neil pointed out (for ifs)
Chris Lattner [Wed, 22 Aug 2007 05:16:28 +0000 (05:16 +0000)]
Fix a nasty C99 scope issue that Neil pointed out (for ifs)
This fixes test/Parser/control-scope.c

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

17 years agoAdded CFG support for gotos and labels.
Ted Kremenek [Tue, 21 Aug 2007 23:26:17 +0000 (23:26 +0000)]
Added CFG support for gotos and labels.

Modified CFG so that getEntry(), getExit(), front() and back() return
CFGBlock& instead of CFGBlock*.

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

17 years agoadd some fixme's, implement complex struct members.
Chris Lattner [Tue, 21 Aug 2007 22:33:41 +0000 (22:33 +0000)]
add some fixme's, implement complex struct members.

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

17 years agoimplement codegen for --/++
Chris Lattner [Tue, 21 Aug 2007 22:25:29 +0000 (22:25 +0000)]
implement codegen for --/++

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

17 years agoConverted CFGBuilder to use StmtVisitor instead of doing a switch
Ted Kremenek [Tue, 21 Aug 2007 22:06:14 +0000 (22:06 +0000)]
Converted CFGBuilder to use StmtVisitor instead of doing a switch
dispatch to walk the AST.

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

17 years agoadd cfg.h/cfg.cpp to the xcode project at Ted's request.
Chris Lattner [Tue, 21 Aug 2007 21:44:59 +0000 (21:44 +0000)]
add cfg.h/cfg.cpp to the xcode project at Ted's request.

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

17 years agoAdded CFG infrastructure (CFG.cpp and CFG.h) for clang ASTs.
Ted Kremenek [Tue, 21 Aug 2007 21:42:03 +0000 (21:42 +0000)]
Added CFG infrastructure (CFG.cpp and CFG.h) for clang ASTs.

Added builder code to translate ASTs to CFGs.  This currently supports
if, return, and non-control flow statements.

Added pretty-printer to debug CFGs.

Added a "-dump-cfg" option to the clang driver to dump CFGs for code
sent through the frontend.

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

17 years agoImplement parsing for objc instance variables.
Steve Naroff [Tue, 21 Aug 2007 21:17:12 +0000 (21:17 +0000)]
Implement parsing for objc instance variables.

Next step, method...

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

17 years agoimplement __extension__ and unary~ for complex.
Chris Lattner [Tue, 21 Aug 2007 20:41:44 +0000 (20:41 +0000)]
implement __extension__ and unary~ for complex.

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

17 years agoAdded reverse iterators for the body of CompountStmt. These are useful for
Ted Kremenek [Tue, 21 Aug 2007 20:29:50 +0000 (20:29 +0000)]
Added reverse iterators for the body of CompountStmt.  These are useful for
CFG construction (among other potential uses).

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

17 years agoimplement codegen for complex unary +/-
Chris Lattner [Tue, 21 Aug 2007 20:08:23 +0000 (20:08 +0000)]
implement codegen for complex unary +/-

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

17 years agoDon't remove the grammar construct, just the TODO.
Anders Carlsson [Tue, 21 Aug 2007 19:18:49 +0000 (19:18 +0000)]
Don't remove the grammar construct, just the TODO.

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

17 years agominor nicities.
Chris Lattner [Tue, 21 Aug 2007 18:51:13 +0000 (18:51 +0000)]
minor nicities.

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

17 years agoTweak error recovery for missing semicolon after decl. For this:
Chris Lattner [Tue, 21 Aug 2007 18:36:18 +0000 (18:36 +0000)]
Tweak error recovery for missing semicolon after decl.  For this:

void foo() {
  int x
  if (x) {
  }
}

We now emit:

a.c:5:3: error: parse error
  if (x) {
  ^
1 diagnostic generated.

instead of:

a.c:5:3: error: parse error
  if (x) {
  ^
a.c:9:1: error: expected '}'

^
2 diagnostics generated.

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

17 years agoadd unary operator support to the stmtvisitor
Chris Lattner [Tue, 21 Aug 2007 18:18:25 +0000 (18:18 +0000)]
add unary operator support to the stmtvisitor

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

17 years agoRemove objc-string-literal since it's been implemented now.
Anders Carlsson [Tue, 21 Aug 2007 18:14:25 +0000 (18:14 +0000)]
Remove objc-string-literal since it's been implemented now.

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

17 years agoimplement support for complex subscripts.
Chris Lattner [Tue, 21 Aug 2007 18:03:58 +0000 (18:03 +0000)]
implement support for complex subscripts.

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

17 years agoallow support for volatile lvalues even though it's still not right.
Chris Lattner [Tue, 21 Aug 2007 18:02:02 +0000 (18:02 +0000)]
allow support for volatile lvalues even though it's still not right.

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

17 years agoImplement parsing and code generation of Objective-C string literals.
Anders Carlsson [Tue, 21 Aug 2007 17:43:55 +0000 (17:43 +0000)]
Implement parsing and code generation of Objective-C string literals.

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

17 years agoadd a new builder ivar.
Chris Lattner [Tue, 21 Aug 2007 17:39:38 +0000 (17:39 +0000)]
add a new builder ivar.

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

17 years agomove EmitLoadOfComplex/EmitStoreOfComplex into ComplexExprEmitter.
Chris Lattner [Tue, 21 Aug 2007 17:28:34 +0000 (17:28 +0000)]
move EmitLoadOfComplex/EmitStoreOfComplex into ComplexExprEmitter.

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

17 years agoimplement comma for complex.
Chris Lattner [Tue, 21 Aug 2007 17:15:50 +0000 (17:15 +0000)]
implement comma for complex.

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

17 years agoand/or/xor are invalid for complex, even integer complex apparently.
Chris Lattner [Tue, 21 Aug 2007 17:12:50 +0000 (17:12 +0000)]
and/or/xor are invalid for complex, even integer complex apparently.

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

17 years agosimplify code slightly
Chris Lattner [Tue, 21 Aug 2007 17:03:38 +0000 (17:03 +0000)]
simplify code slightly

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

17 years agoadd sema support for complex integer types
Chris Lattner [Tue, 21 Aug 2007 17:02:28 +0000 (17:02 +0000)]
add sema support for complex integer types

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

17 years agoreimplement support for complex comparisons, add support for integer complex compares.
Chris Lattner [Tue, 21 Aug 2007 16:57:55 +0000 (16:57 +0000)]
reimplement support for complex comparisons, add support for integer complex compares.

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

17 years agoadd getAsComplexType() for consistency
Chris Lattner [Tue, 21 Aug 2007 16:54:08 +0000 (16:54 +0000)]
add getAsComplexType() for consistency

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

17 years agoAdd the comparisons and logical binops to the visitor.
Chris Lattner [Tue, 21 Aug 2007 16:38:51 +0000 (16:38 +0000)]
Add the comparisons and logical binops to the visitor.

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

17 years agoreimplement complex mul
Chris Lattner [Tue, 21 Aug 2007 16:34:16 +0000 (16:34 +0000)]
reimplement complex mul

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

17 years agoadd a testcase I forgot to check in long ago
Chris Lattner [Tue, 21 Aug 2007 05:56:30 +0000 (05:56 +0000)]
add a testcase I forgot to check in long ago

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

17 years agoupdate some comments.
Chris Lattner [Tue, 21 Aug 2007 05:54:53 +0000 (05:54 +0000)]
update some comments.

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

17 years agoSplit complex arithmetic codegen out from aggregate codegen.
Chris Lattner [Tue, 21 Aug 2007 05:54:00 +0000 (05:54 +0000)]
Split complex arithmetic codegen out from aggregate codegen.
This means that we get rid of tons of intermediate allocas.  For
example:

void foo(double _Complex a, double _Complex b) {
   a = b+a+a;
}

this used to have 4 temporary allocas, now it has zero of them.
This also simplifies the individual visitor methods because they
now can all operate on real/imag pairs instead of having to
load/store all over the place.

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

17 years agosimplify this a bit to remove indirection
Chris Lattner [Tue, 21 Aug 2007 05:02:10 +0000 (05:02 +0000)]
simplify this a bit to remove indirection

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

17 years agoreimplement addition of complex numbers.
Chris Lattner [Tue, 21 Aug 2007 04:59:27 +0000 (04:59 +0000)]
reimplement addition of complex numbers.

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

17 years agoAdd the ability to visit binary operators without having to
Chris Lattner [Tue, 21 Aug 2007 04:43:17 +0000 (04:43 +0000)]
Add the ability to visit binary operators without having to
match on binop then explicitly switching again.

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

17 years agoswitch aggregate expr codegen to use a visitor to localize most of the nasty
Chris Lattner [Tue, 21 Aug 2007 04:25:47 +0000 (04:25 +0000)]
switch aggregate expr codegen to use a visitor to localize most of the nasty
details in its own file.

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

17 years agoNow that the visitor is defined in one place, it is nice and easy to allow clients
Chris Lattner [Tue, 21 Aug 2007 04:06:29 +0000 (04:06 +0000)]
Now that the visitor is defined in one place, it is nice and easy to allow clients
to have visitors that return non-void.

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

17 years agoSwitch StmtVisitor from using dynamic to static dispatch. This makes it
Chris Lattner [Tue, 21 Aug 2007 04:04:25 +0000 (04:04 +0000)]
Switch StmtVisitor from using dynamic to static dispatch.  This makes it
significantly faster and actually reduces the amount of code in the system.
This also allows for future visitor changes.

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

17 years agowe now correctly emit:
Chris Lattner [Tue, 21 Aug 2007 01:19:46 +0000 (01:19 +0000)]
we now correctly emit:
unused-expr.c:8:6: warning: comparison of distinct pointer types ('int volatile *' and 'int *')
  VP == P;
  ~~ ^  ~

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

17 years agoImplement code generation for constant CFStrings.
Anders Carlsson [Tue, 21 Aug 2007 00:21:21 +0000 (00:21 +0000)]
Implement code generation for constant CFStrings.

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

17 years agoFix array->pointer decay. This unbreaks test/CodeGen/array.c
Chris Lattner [Mon, 20 Aug 2007 22:37:10 +0000 (22:37 +0000)]
Fix array->pointer decay.  This unbreaks test/CodeGen/array.c

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

17 years agoAdded Parser::ParseStructDeclaration() as a result of refactoring Parser::ParseStruct...
Steve Naroff [Mon, 20 Aug 2007 22:28:22 +0000 (22:28 +0000)]
Added Parser::ParseStructDeclaration() as a result of refactoring Parser::ParseStructUnionBody().

Motivation: Objective-C can now share this rule. It also makes Parser::ParseStructUnionBody()
a bit smaller/cleaner..

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

17 years agoStart parsing ObjC classes/categories!
Steve Naroff [Mon, 20 Aug 2007 21:31:48 +0000 (21:31 +0000)]
Start parsing ObjC classes/categories!

Next step, refactor Parser::ParseStructUnionBody() so that struct declarations can
be shared with Objective-C (for declaring instance variables).

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

17 years agoAdd support for code generation of builtins.
Anders Carlsson [Mon, 20 Aug 2007 18:05:56 +0000 (18:05 +0000)]
Add support for code generation of builtins.

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

17 years agoAdded test cases for the return-stack-address checker to test support
Ted Kremenek [Mon, 20 Aug 2007 16:28:05 +0000 (16:28 +0000)]
Added test cases for the return-stack-address checker to test support
for the following C++ casts: static_cast, reinterpret_cast, and const_cast.

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

17 years agoModified ArraySubscriptExpr to have accessors getLHS and getRHS in addition
Ted Kremenek [Mon, 20 Aug 2007 16:18:38 +0000 (16:18 +0000)]
Modified ArraySubscriptExpr to have accessors getLHS and getRHS in addition
to getBase and getIdx.  getBase and getIdx now return a "normalized" view
of the expression (e.g., always "A[4]" instead of possibly "4[A]").  getLHS
and getRHS return the expressions with syntactic fidelity to the original
source code.

Also modified client code of ArraySubscriptExpr, including the AST dumper
and pretty printer, the return-stack value checker, and the LLVM code
generator.

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

17 years agoFixed bug in VarDecl::hasAutoStorage: function parameters implicitly have
Ted Kremenek [Sat, 18 Aug 2007 04:59:12 +0000 (04:59 +0000)]
Fixed bug in VarDecl::hasAutoStorage: function parameters implicitly have
auto storage, but this routine would incorrectly return false.

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

17 years agoAdded extra test case to check proper handling of archaic array indexing: 4[A]
Ted Kremenek [Fri, 17 Aug 2007 22:17:23 +0000 (22:17 +0000)]
Added extra test case to check proper handling of archaic array indexing: 4[A]

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

17 years agoAdd preliminary support for converting struct types.
Anders Carlsson [Fri, 17 Aug 2007 22:00:32 +0000 (22:00 +0000)]
Add preliminary support for converting struct types.

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

17 years agoAdded extra semantic checking to do basic detection of
Ted Kremenek [Fri, 17 Aug 2007 16:46:58 +0000 (16:46 +0000)]
Added extra semantic checking to do basic detection of
"return of stack addresses."  ParseReturnStmt now calls CheckReturnStackAddr
to determine if the expression in the return statement evaluates to an
address of a stack variable.  If so, we issue a warning.

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

17 years agoReturn true in case of error, which is what other functions do.
Anders Carlsson [Fri, 17 Aug 2007 15:44:17 +0000 (15:44 +0000)]
Return true in case of error, which is what other functions do.

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

17 years agoAdd initial support for constant CFStrings.
Anders Carlsson [Fri, 17 Aug 2007 05:31:46 +0000 (05:31 +0000)]
Add initial support for constant CFStrings.

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

17 years agoFixed Sema::CheckEqualityOperands() and Sema::CheckRelationalOperands() to deal more
Steve Naroff [Thu, 16 Aug 2007 21:48:38 +0000 (21:48 +0000)]
Fixed Sema::CheckEqualityOperands() and Sema::CheckRelationalOperands() to deal more
thoughtfully with incompatible pointers. This includes:

- Emit a diagnostic when two pointers aren't compatible!
- Promote one of the pointers/integers so we maintain the invariant expected by the
code generator (i.e. that the left/right types match).
- Upgrade the pointer/integer comparison diagnostic to include the types.

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

17 years agoAdded a comment to ArraySubscriptExpr to note that the expressions like
Ted Kremenek [Wed, 15 Aug 2007 22:33:19 +0000 (22:33 +0000)]
Added a comment to ArraySubscriptExpr to note that the expressions like
"A[4]" are equivalent to "4[A]", and that a test that the expression
returned by "getBase()" has a pointer type is required to resolve which
subexpression is the "true" base expression of the array index.

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

17 years agoAdded the following utility methods to VarDecl that provide
Ted Kremenek [Wed, 15 Aug 2007 00:03:46 +0000 (00:03 +0000)]
Added the following utility methods to VarDecl that provide
canonicalized queries of a variable's storage:

  hasAutoStorage - Does a variable have (implicit) auto storage?

  hasStaticStorage - Does a variable have (implicit) static storage?

  hasLocalStorage - Is the variable a non-static local variable?

  hasGlobalStorage - Is the variable a global variable or a static
                     local variable?

Additional comments documenting these functions are included in the
source.

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

17 years agoRemoved dead variable "hadError" in ParseReturnStmt.
Ted Kremenek [Tue, 14 Aug 2007 18:14:14 +0000 (18:14 +0000)]
Removed dead variable "hadError" in ParseReturnStmt.

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

17 years agoAdded support for additional format string checking for the printf
Ted Kremenek [Tue, 14 Aug 2007 17:39:48 +0000 (17:39 +0000)]
Added support for additional format string checking for the printf
family of functions.  Previous functionality only included checking to
see if the format string was a string literal.  Now we check parse the
format string (if it is a literal) and perform the following checks:

(1) Warn if: number conversions (e.g. "%d") != number data arguments.

(2) Warn about missing format strings  (e.g., "printf()").

(3) Warn if the format string is not a string literal.

(4) Warn about the use se of '%n' conversion.  This conversion is
    discouraged for security reasons.

(5) Warn about malformed conversions.  For example '%;', '%v'; these
    are not valid.

(6) Warn about empty format strings; e.g. printf("").  Although these
    can be optimized away by the compiler, they can be indicative of
    broken programmer logic.  We may need to add additional support to
    see when such cases occur within macro expansion to avoid false
    positives.

(7) Warn if the string literal is wide; e.g. L"%d".

(8) Warn if we detect a '\0' character WITHIN the format string.

Test cases are included.

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

17 years agoAdded documentation to StringLiteral noting that the strings returned by
Ted Kremenek [Mon, 13 Aug 2007 22:26:47 +0000 (22:26 +0000)]
Added documentation to StringLiteral noting that the strings returned by
getStrData() are not null-terminated, and the lengths of these strings should
be determined using getByteLength().

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

17 years agoxfail this for now.
Chris Lattner [Sat, 11 Aug 2007 00:05:07 +0000 (00:05 +0000)]
xfail this for now.

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

17 years agostart splitting out aggregate value computation from EmitExpr into EmitAggExpr.
Chris Lattner [Sat, 11 Aug 2007 00:04:45 +0000 (00:04 +0000)]
start splitting out aggregate value computation from EmitExpr into EmitAggExpr.

aggregate value and scalar expression computation are very different, this
gets them away from each other.  This causes a temporary regression on some
complex number examples.

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

17 years agomake sure to add a newline at the end of the dump
Chris Lattner [Fri, 10 Aug 2007 21:51:12 +0000 (21:51 +0000)]
make sure to add a newline at the end of the dump

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

17 years agoAdded "id_idx" parameter to CheckPrintfArguments. This will be used
Ted Kremenek [Fri, 10 Aug 2007 21:21:05 +0000 (21:21 +0000)]
Added "id_idx" parameter to CheckPrintfArguments.  This will be used
by CheckPrintfArguments to determine if a given printf function
accepts a va_arg argument.

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

17 years agoMoved id_asprintf before id_vsnprintf in the enum used for indexing
Ted Kremenek [Fri, 10 Aug 2007 21:13:51 +0000 (21:13 +0000)]
Moved id_asprintf before id_vsnprintf in the enum used for indexing
KnownFunctionIDs.  This allows us to test for a printf-like function
that accepts a va_arg argument using a range comparison.

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

17 years agoadd support for a top-level __extension__ marker, implementing a todo.
Chris Lattner [Fri, 10 Aug 2007 20:57:02 +0000 (20:57 +0000)]
add support for a top-level __extension__ marker, implementing a todo.

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

17 years agoinitial support for checking format strings, patch by Ted Kremenek:
Chris Lattner [Fri, 10 Aug 2007 20:18:51 +0000 (20:18 +0000)]
initial support for checking format strings, patch by Ted Kremenek:

"I've coded up some support in clang to flag warnings for non-constant format strings used in calls to printf-like functions (all the functions listed in "man fprintf").  Non-constant format strings are a source of many security exploits in C/C++ programs, and I believe are currently detected by gcc using the flag -Wformat-nonliteral."

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

17 years agoNew file, just a placeholder for now.
Chris Lattner [Fri, 10 Aug 2007 20:13:28 +0000 (20:13 +0000)]
New file, just a placeholder for now.

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

17 years agoBuild ASTs before relexing the file. This avoids having comment finding mutate the
Chris Lattner [Fri, 10 Aug 2007 18:27:41 +0000 (18:27 +0000)]
Build ASTs before relexing the file.  This avoids having comment finding mutate the
preprocessor state, causing bogus diagnostics when the file is parsed for real.  This
implements Misc/diag-checker.c.  Thanks to Ted for noticing this.

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

17 years agoMake sure the arithmetic conversion are done for relation and equality operators.
Steve Naroff [Fri, 10 Aug 2007 18:26:40 +0000 (18:26 +0000)]
Make sure the arithmetic conversion are done for relation and equality operators.

This fixes the following...

eypedef short S;
int test(S X, long long Y) {
  return X < Y;
}

Before...

(CompoundStmt 0x2905d00
  (ReturnStmt 0x2905cf0
    (BinaryOperator 0x2905cd0 'int' '<'
      (ImplicitCastExpr 0x2905cc0 'int'
        (DeclRefExpr 0x2905c80 'S':'short' Decl='X' 0x2905c20))
      (DeclRefExpr 0x2905ca0 'long long' Decl='Y' 0x2905c50))))

After...

(CompoundStmt 0x2b05c30
  (ReturnStmt 0x2b05c20
    (BinaryOperator 0x2b05c00 'int' '<'
      (ImplicitCastExpr 0x2b05bf0 'long long'
        (DeclRefExpr 0x2b05bb0 'S':'short' Decl='X' 0x2b05b50))
      (DeclRefExpr 0x2b05bd0 'long long' Decl='Y' 0x2b05b80))))

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

17 years agofix this test to pass.
Chris Lattner [Fri, 10 Aug 2007 17:18:58 +0000 (17:18 +0000)]
fix this test to pass.

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

17 years agofix a codegen bug handling ocuvector element exprs.
Chris Lattner [Fri, 10 Aug 2007 17:10:08 +0000 (17:10 +0000)]
fix a codegen bug handling ocuvector element exprs.

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

17 years agomake this harder
Chris Lattner [Fri, 10 Aug 2007 17:02:59 +0000 (17:02 +0000)]
make this harder

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

17 years agoimplement initial codegen for aggregate return functions. This implements
Chris Lattner [Fri, 10 Aug 2007 17:02:28 +0000 (17:02 +0000)]
implement initial codegen for aggregate return functions.  This implements
codegen for:

_Complex double bar(int);
void test(_Complex double*);

void test2(int c) {
  _Complex double X;
  X = bar(1);
  test(&X);
}

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

17 years agoFix a bug handling function -> pointer decay and avoid emitting a noop
Chris Lattner [Fri, 10 Aug 2007 16:33:59 +0000 (16:33 +0000)]
Fix a bug handling function -> pointer decay and avoid emitting a noop
bitcast.

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

17 years agoimplement dumper support for declstmt's. The dumper is now "done".
Chris Lattner [Thu, 9 Aug 2007 18:03:18 +0000 (18:03 +0000)]
implement dumper support for declstmt's.  The dumper is now "done".

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

17 years agoimplement dumper support for the rest of expressions.
Chris Lattner [Thu, 9 Aug 2007 17:35:30 +0000 (17:35 +0000)]
implement dumper support for the rest of expressions.

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

17 years agomove a switch to common code.
Chris Lattner [Thu, 9 Aug 2007 17:34:19 +0000 (17:34 +0000)]
move a switch to common code.

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

17 years agominor fixes
Chris Lattner [Thu, 9 Aug 2007 17:33:55 +0000 (17:33 +0000)]
minor fixes

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

17 years agodump strings with escapes and other stuff in them nicely.
Chris Lattner [Thu, 9 Aug 2007 17:14:24 +0000 (17:14 +0000)]
dump strings with escapes and other stuff in them nicely.

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

17 years agominor cleanups
Chris Lattner [Thu, 9 Aug 2007 17:01:07 +0000 (17:01 +0000)]
minor cleanups

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

17 years ago__attribute__ starts a declspec.
Chris Lattner [Thu, 9 Aug 2007 16:40:21 +0000 (16:40 +0000)]
__attribute__ starts a declspec.

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

17 years agoadd dumping support for some new nodes
Chris Lattner [Thu, 9 Aug 2007 01:04:32 +0000 (01:04 +0000)]
add dumping support for some new nodes

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

17 years agoDump out types for expressions, and handle typedefs nicely.
Chris Lattner [Thu, 9 Aug 2007 00:36:22 +0000 (00:36 +0000)]
Dump out types for expressions, and handle typedefs nicely.
This allows us to dump:

typedef short S;
int test(S X, long long Y) {
  return X < ((100));
}

as:

typedef short S;

int test(S X, long long Y)
(CompoundStmt 0x2905d40
  (ReturnStmt 0x2905d30
    (BinaryOperator 0x2905d10 'int' '<'
      (ImplicitCastExpr 0x2905d00 'int'
        (DeclRefExpr 0x2905c80 'S':'short' Decl='X' 0x2905c20))
      (ParenExpr 0x2905ce0 'int'
        (ParenExpr 0x2905cc0 'int'
          (IntegerLiteral 0x2905ca0 'int' 100))))))

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

17 years agoadd a new AST dumper interface (E->dump()). This dumps out
Chris Lattner [Wed, 8 Aug 2007 22:51:59 +0000 (22:51 +0000)]
add a new AST dumper interface (E->dump()).  This dumps out
the AST in a structural, non-pretty, form useful for understanding
the AST.  It isn't quite done yet, but is already somewhat useful.

For this example:

int test(short X, long long Y) {
  return X < ((100));
}

we get (with -parse-ast-dump):

int test(short X, long long Y)
(CompoundStmt 0x2905ce0
  (ReturnStmt 0x2905cd0
    (BinaryOperator 0x2905cb0 '<'
      (ImplicitCastExpr 0x2905ca0
        (DeclRefExpr 0x2905c20 Decl='X' 0x2905bb0))
      (ParenExpr 0x2905c80
        (ParenExpr 0x2905c60
          (IntegerLiteral 0x2905c40 100))))))

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

17 years agoFinish implementing __builtin_classify_type()...
Steve Naroff [Wed, 8 Aug 2007 22:15:55 +0000 (22:15 +0000)]
Finish implementing __builtin_classify_type()...

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

17 years agonow that implicit conversions are explicit, we can eliminate
Chris Lattner [Wed, 8 Aug 2007 17:49:18 +0000 (17:49 +0000)]
now that implicit conversions are explicit, we can eliminate
EmitUsualArithmeticConversions.

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

17 years agoAdd support for __builtin_classify_type(). This builtin function isn't "public",...
Steve Naroff [Wed, 8 Aug 2007 17:48:34 +0000 (17:48 +0000)]
Add support for __builtin_classify_type(). This builtin function isn't "public", however
it is used by "tgmath.h" (so we need to support it). It might also come in handy when
developing the overloaded function macros for OpenCU.

Next check-in will make this an integer constant expression...

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

17 years agonow that implicit conversions are explicit, we can eliminate
Chris Lattner [Wed, 8 Aug 2007 17:43:05 +0000 (17:43 +0000)]
now that implicit conversions are explicit, we can eliminate
EmitExprWithUsualUnaryConversions.

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

17 years agoMove the function/array conversion for ParmVarDecl's from Sema::ParseIdentifierExpr()
Steve Naroff [Tue, 7 Aug 2007 22:44:21 +0000 (22:44 +0000)]
Move the function/array conversion for ParmVarDecl's from Sema::ParseIdentifierExpr()
to Sema::ParseParamDeclarator(). After discussing this with Chris, we decided this
approach has more immediate benefit (though we loose some information in the AST).
The comment below should describe more (if interested).

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

17 years agoadd some helpers
Chris Lattner [Tue, 7 Aug 2007 17:33:34 +0000 (17:33 +0000)]
add some helpers

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

17 years agoRemove a space from "typeof" printing. It was causing the following error...
Steve Naroff [Sun, 5 Aug 2007 03:24:45 +0000 (03:24 +0000)]
Remove a space from "typeof" printing. It was causing the following error...

[dylan:clang/test/Parser] admin% ../../../../Debug/bin/clang -parse-ast-check typeof.c
Warnings expected but not seen:
  Line 21: incompatible types assigning 'typeof(*pi) const' to 'int *'
Warnings seen but not expected:
  Line 21: incompatible types assigning 'typeof(*pi)  const' to 'int *'

Also corrected a typo from my previous commit.

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

17 years agoMake sure the good old "function/array conversion" is done to function parameters.
Steve Naroff [Sun, 5 Aug 2007 02:16:31 +0000 (02:16 +0000)]
Make sure the good old "function/array conversion" is done to function parameters.

This resulted in the following error...

[dylan:clang/test/Parser] admin% cat parmvardecl_conversion.c
// RUN: clang -parse-ast-check %s

void f (int p[]) { p++; }

[dylan:clang/test/Parser] admin% clang -parse-ast-check parmvardecl_conversion.c
Errors seen but not expected:
  Line 3: cannot modify value of type 'int []'

With this fix, the test case above succeeds.

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

17 years agoImplement codegen for __builtin_choose_expr. For example:
Chris Lattner [Sat, 4 Aug 2007 00:20:15 +0000 (00:20 +0000)]
Implement codegen for __builtin_choose_expr.  For example:

struct X { int A; };

void foo() {
  struct X s;
  int i;
  i = __builtin_choose_expr(0, s, i);
}

compiles to:

        %tmp = load i32* %i             ; <i32> [#uses=1]
        store i32 %tmp, i32* %i

wow :)

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

17 years agothe sse intrinsics are missing, leading to errors.
Chris Lattner [Sat, 4 Aug 2007 00:19:10 +0000 (00:19 +0000)]
the sse intrinsics are missing, leading to errors.

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

17 years agofix hang in testsuite
Chris Lattner [Sat, 4 Aug 2007 00:18:28 +0000 (00:18 +0000)]
fix hang in testsuite

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

17 years agofix constness issues.
Chris Lattner [Sat, 4 Aug 2007 00:14:36 +0000 (00:14 +0000)]
fix constness issues.

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

17 years agoRestrict vector component access (using "." and "[]") to variables.
Steve Naroff [Fri, 3 Aug 2007 22:40:33 +0000 (22:40 +0000)]
Restrict vector component access (using "." and "[]") to variables.
Chris suggested this, since it simplifies the code generator.
If this features is needed (and we don't think it is), we can revisit.

The following test case now produces an error.
[dylan:~/llvm/tools/clang] admin% cat t.c

typedef __attribute__(( ocu_vector_type(4) )) float float4;

static void test() {
    float4 vec4;

    vec4.rg.g;
    vec4.rg[1];
}
[dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang t.c
t.c:8:12: error: vector component access limited to variables
    vec4.rg.g;
           ^~
t.c:9:12: error: vector component access limited to variables
    vec4.rg[1];
           ^~~
2 diagnostics generated.

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

17 years agoImplement __builtin_choose_expr.
Steve Naroff [Fri, 3 Aug 2007 21:21:27 +0000 (21:21 +0000)]
Implement __builtin_choose_expr.

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

17 years agoAdd a test case to validate code gen for typeof/builtin_types_compatible.
Steve Naroff [Fri, 3 Aug 2007 18:38:22 +0000 (18:38 +0000)]
Add a test case to validate code gen for typeof/builtin_types_compatible.

This test case currently generates the following unexpected warnings (when compared with gcc).

[dylan:clang/test/Parser] admin% ../../../../Debug/bin/clang -parse-ast-check builtin_types_compatible.c
Warnings seen but not expected:
  Line 28: expression result unused
  Line 29: expression result unused
  Line 30: expression result unused
  Line 31: expression result unused
  Line 32: expression result unused
  Line 33: expression result unused

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