Граф коммитов

322 Коммитов

Автор SHA1 Сообщение Дата
Chris Lattner 8bcd723ea5 implement support for complex subscripts.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41240 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 18:03:58 +00:00
Chris Lattner 76e8033b82 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
2007-08-21 18:02:02 +00:00
Anders Carlsson 5508518a27 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
2007-08-21 17:43:55 +00:00
Chris Lattner 5083a53697 add a new builder ivar.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41237 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 17:39:38 +00:00
Chris Lattner 46d7d9fac9 move EmitLoadOfComplex/EmitStoreOfComplex into ComplexExprEmitter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41236 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 17:28:34 +00:00
Chris Lattner 756a4d8845 implement comma for complex.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41235 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 17:15:50 +00:00
Chris Lattner 4034edbf86 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
2007-08-21 17:12:50 +00:00
Chris Lattner 32e32e7782 simplify code slightly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41233 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 17:03:38 +00:00
Chris Lattner 3cbc38bd35 add sema support for complex integer types
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41232 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 17:02:28 +00:00
Chris Lattner 58dee10ed2 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
2007-08-21 16:57:55 +00:00
Chris Lattner c6fb90a724 add getAsComplexType() for consistency
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41229 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 16:54:08 +00:00
Chris Lattner 2d5049fcbb 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
2007-08-21 16:38:51 +00:00
Chris Lattner 2823c195ee reimplement complex mul
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41226 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 16:34:16 +00:00
Chris Lattner 2f9d5fe98e 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
2007-08-21 05:56:30 +00:00
Chris Lattner 05ba49cc45 update some comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41218 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 05:54:53 +00:00
Chris Lattner b6ef18a2b0 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
2007-08-21 05:54:00 +00:00
Chris Lattner c748f27f40 simplify this a bit to remove indirection
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41216 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 05:02:10 +00:00
Chris Lattner ee755f9118 reimplement addition of complex numbers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41215 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 04:59:27 +00:00
Chris Lattner 03d6fb9922 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
2007-08-21 04:43:17 +00:00
Chris Lattner 9c03356918 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
2007-08-21 04:25:47 +00:00
Chris Lattner e12b430182 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
2007-08-21 04:06:29 +00:00
Chris Lattner c5598cbc4c 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
2007-08-21 04:04:25 +00:00
Chris Lattner 2b8bac52b8 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
2007-08-21 01:19:46 +00:00
Anders Carlsson c9e2091efc Implement code generation for constant CFStrings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41206 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-21 00:21:21 +00:00
Chris Lattner 7016a706c9 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
2007-08-20 22:37:10 +00:00
Steve Naroff 28a7ca80da 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
2007-08-20 22:28:22 +00:00
Steve Naroff dac269b65e 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
2007-08-20 21:31:48 +00:00
Anders Carlsson 022012e6e5 Add support for code generation of builtins.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41188 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-20 18:05:56 +00:00
Ted Kremenek f8f9517d7d 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
2007-08-20 16:28:05 +00:00
Ted Kremenek 2324512285 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
2007-08-20 16:18:38 +00:00
Ted Kremenek 602f754796 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
2007-08-18 04:59:12 +00:00
Ted Kremenek 4774b4df07 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
2007-08-17 22:17:23 +00:00
Anders Carlsson 4e533287e6 Add preliminary support for converting struct types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41145 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-17 22:00:32 +00:00
Ted Kremenek 06de276fff 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
2007-08-17 16:46:58 +00:00
Anders Carlsson 9cdc4d3834 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
2007-08-17 15:44:17 +00:00
Anders Carlsson 71993dd85e Add initial support for constant CFStrings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41136 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-17 05:31:46 +00:00
Steve Naroff e77fd3c15c 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
2007-08-16 21:48:38 +00:00
Ted Kremenek fc4a1601a8 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
2007-08-15 22:33:19 +00:00
Ted Kremenek 87ce144920 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
2007-08-15 00:03:46 +00:00
Ted Kremenek 6a2394c4ea Removed dead variable "hadError" in ParseReturnStmt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41079 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-14 18:14:14 +00:00
Ted Kremenek 71895b9aa3 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
2007-08-14 17:39:48 +00:00
Ted Kremenek e6a82b2c29 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
2007-08-13 22:26:47 +00:00
Chris Lattner 954698cd84 xfail this for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41015 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-11 00:05:07 +00:00
Chris Lattner 883f6a7cc7 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
2007-08-11 00:04:45 +00:00
Chris Lattner ee41ce53f7 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
2007-08-10 21:51:12 +00:00
Ted Kremenek 820771033e 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
2007-08-10 21:21:05 +00:00
Ted Kremenek e0eb80aa7a 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
2007-08-10 21:13:51 +00:00
Chris Lattner c3018153a1 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
2007-08-10 20:57:02 +00:00
Chris Lattner 59907c4d8f 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
2007-08-10 20:18:51 +00:00
Chris Lattner af6f528b2b New file, just a placeholder for now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41002 91177308-0d34-0410-b5e6-96231b3b80d8
2007-08-10 20:13:28 +00:00