Commit Graph

4238 Commits

Author SHA1 Message Date
Ted Kremenek b0b7d28f67 Fixed horrid bug in LiveVariables analysis where we were only merging at
confluence points the liveness information for variables (Decls) and NOT
block-level expressions.

llvm-svn: 47506
2008-02-22 23:17:20 +00:00
Ted Kremenek c77f34daad Modified clang driver option -dump-live-variables to (optionally) use the
--analyze-function option to analyze specific functions.

llvm-svn: 47498
2008-02-22 20:13:09 +00:00
Ted Kremenek 88329bf0ea clang driver options --dump-cfg and --view-cfg now (optionally) use the
--analyze-function option to dump/view the CFGs of specific functions.

llvm-svn: 47497
2008-02-22 20:00:31 +00:00
Ted Kremenek 76c03b4a55 When running the GRSimpleVals analysis, skip functions that do not
appear in a file.

llvm-svn: 47491
2008-02-22 19:10:58 +00:00
Ted Kremenek 43638a87e5 Punt on unifying symbolic lvalues. This won't be needed for many checkers.
llvm-svn: 47489
2008-02-22 18:41:59 +00:00
Ted Kremenek cb507025d4 Added "assumption" logic for lval::FuncVal and lval::GotoLabel, and simplified
assumption logic for lval::DeclVal.

llvm-svn: 47466
2008-02-22 00:54:56 +00:00
Ted Kremenek 51017b5432 Bug fix: For transfer function for unary "!", compare the subexpression value
against '0' of the same bit-width.

llvm-svn: 47465
2008-02-22 00:42:36 +00:00
Ted Kremenek 20c91421fe Bug fix in liveness: Only compute liveness information for VarDecls.
llvm-svn: 47464
2008-02-22 00:34:10 +00:00
Ted Kremenek eb653882de Return "Unknown" when using the value of a function pointer whose value
is symbolic.

llvm-svn: 47463
2008-02-21 23:17:39 +00:00
Ted Kremenek 6d2bbd9467 Regression fix: Handle binary operators where both the left and right
operands are symbolic lvalues.

llvm-svn: 47459
2008-02-21 22:08:33 +00:00
Ted Kremenek 9f1ed12bc4 Added transfer function support for dispatching to functions we don't know
about.  The default logic is to invalidate the values of all values
passed-by-reference.

llvm-svn: 47456
2008-02-21 19:46:04 +00:00
Nate Begeman b16d53ea31 add a test case
llvm-svn: 47455
2008-02-21 19:44:16 +00:00
Nate Begeman d45d38d2b7 Handle __attribute__((annotate("string")))
llvm-svn: 47451
2008-02-21 19:30:49 +00:00
Ted Kremenek e82c7a44d6 RemoveDeadBindings should now check for UninitalizedVal, as it is a now
an error to cast it to LVal.

llvm-svn: 47450
2008-02-21 19:30:14 +00:00
Ted Kremenek 7328fa6ec8 Regression fix: Handle pointer arithmetic in unary ++/--.
llvm-svn: 47449
2008-02-21 19:29:23 +00:00
Ted Kremenek 7f8ebb73af Removed bogus assertions regard LValues binding to UnknownVal; they can
do so implicitly.

llvm-svn: 47447
2008-02-21 19:15:37 +00:00
Ted Kremenek d21429a8e7 Remove incorrect casts from UnknownVal to NonLVal.
llvm-svn: 47446
2008-02-21 19:10:12 +00:00
Ted Kremenek b1e3218125 FIX: Promote the correct operand.
llvm-svn: 47445
2008-02-21 18:46:24 +00:00
Ted Kremenek 7e4861b3c1 Simplified and generalized transfer function logic for casts, allowing
the transfer function to be invoked without an Expr* for the Cast operation.

Added implicit promotions to the transfer function logic for compound
assignments.

llvm-svn: 47444
2008-02-21 18:43:30 +00:00
Ted Kremenek d2332f9625 Added transfer function support for sizeof(void)
llvm-svn: 47443
2008-02-21 18:15:29 +00:00
Eli Friedman c62dd9d345 Some const initializer tests for stuff I just committed.
llvm-svn: 47442
2008-02-21 18:07:36 +00:00
Ted Kremenek 7f0639b039 Major cleanup of path-sensitive analysis engine and the current analysis
based on constant. prop. and limited symbolics.

- Renamed class: RValue -> RVal, LValue -> LVal, etc.
- Minor method renamings and interface cleanups.
- Tightened the RVal "type system" so that UninitializedVal and UnknownVal
  cannot be cast to LVal or NonLVal.  This forces these corner cases values
  to be explicitly handled early before being dispatched to plug-in transfer
  function logic.
- Major cleanup in the transfer function logic for binary and unary operators.
  Still fixing some regressions, but we now explicitly handle Uninitialized
  and Unknown values in a more rigorous way.

llvm-svn: 47441
2008-02-21 18:02:17 +00:00
Eli Friedman a243311f1d Clean up constant implicit cast emission; fixes a few edge cases
invlolving implicit casts that cause both a decay to pointer type and a 
type conversion.

llvm-svn: 47440
2008-02-21 17:57:49 +00:00
Eli Friedman 115e989985 Fix brace-enclosed string initializers for char arrays. From pr2079,
ahtough I had the fix in my tree previously.

llvm-svn: 47439
2008-02-21 17:45:41 +00:00
Gabor Greif 5c27a96967 Change variable name to Tq (from TQ)
because silly gcc 3.4.6 barfs on this
construct.
Type.h defines an "enum TQ", which makes
the parser to err.

llvm-svn: 47438
2008-02-21 17:40:55 +00:00
Gabor Greif 4999168309 Added classes SolarisTargetInfo and
SolarisSparcV8TargetInfo to be able
to handle "sparc-" triple prefixes.

Please be aware that this is a minimal
kludge, that pretty much duplicates
the features of DarwinPowerPCTargetInfo,
and also incorrectly uses stuff from
the PPC namespace.

But in result "make test" now passes
a lot of tests, the notable exceptions
being the objc rewrite tests and
mandel.c.

llvm-svn: 47436
2008-02-21 16:29:08 +00:00
Chris Lattner 3b418d8446 implement codegen support for sizeof(void), fixing PR2080.
llvm-svn: 47429
2008-02-21 05:45:29 +00:00
Chris Lattner a2417c9d8b add some semantic checks for address spaces.
llvm-svn: 47423
2008-02-21 01:42:41 +00:00
Chris Lattner 05d8cca8b6 add a fixme.
llvm-svn: 47421
2008-02-21 01:32:57 +00:00
Chris Lattner 788404f312 Collect and build and process type attributes on pointers. For
example, we can now correctly build the type for things like:
    _AS1 float * _AS2 *B;

llvm-svn: 47420
2008-02-21 01:32:26 +00:00
Chris Lattner ed71d60f4d move some code, no other change.
llvm-svn: 47419
2008-02-21 01:08:11 +00:00
Chris Lattner efedd9ec67 move type attribute processing into the creatively named ProcessTypeAttributes method.
llvm-svn: 47418
2008-02-21 01:07:18 +00:00
Chris Lattner ee0d271819 Correctly handle address space qualifiers in declspecs. This
allows us to correctly handle stuff like:

  _AS1 float *B;

and to reject stuff like:

  _AS1 _AS2* x;

llvm-svn: 47417
2008-02-21 00:48:22 +00:00
Chris Lattner 556676a20b move ConvertDeclSpecToType into Sema
llvm-svn: 47415
2008-02-20 23:53:49 +00:00
Chris Lattner dcee3a9630 rename some methods.
llvm-svn: 47414
2008-02-20 23:25:22 +00:00
Chris Lattner f179190206 Use getKind() in HandleDeclAttribute instead of decoding the string inline.
llvm-svn: 47413
2008-02-20 23:17:35 +00:00
Chris Lattner f18c743222 add a method to AttributeList that converts an identifier to an enum.
llvm-svn: 47412
2008-02-20 23:14:47 +00:00
Nate Begeman 7dd8e72de9 Tabs are the enemy
llvm-svn: 47410
2008-02-20 22:57:40 +00:00
Chris Lattner dba738e740 add some code that will be used to remove processed attrs from
declspec, it is currently nonfunctional though.

llvm-svn: 47405
2008-02-20 22:04:11 +00:00
Chris Lattner 19d8a38861 Change ConvertDeclSpecToType to break out of switch instead of
returning directly.  This allows us to factor handling of _Complex.

llvm-svn: 47404
2008-02-20 21:40:32 +00:00
Chris Lattner 445fcabff7 Alternate address spaces work:
rename QualType::getQualifiers to getCVRQualifiers.
Add some fixme's and clean up some code relevant to qualifiers.
Change ASQualType to contain a Type* instead of a QualType.  
Any CVR qualifiers should be on the outer qual type.

llvm-svn: 47398
2008-02-20 20:55:12 +00:00
Ted Kremenek 34e83b80fd Implemented transfer function logic for unary '+'
llvm-svn: 47357
2008-02-20 04:12:31 +00:00
Ted Kremenek b597bb9c4a Placed transfer function logic for dereferences in its own method, while at
the same time clearing up some logic of how the unary '*' operator is processed.

llvm-svn: 47356
2008-02-20 04:02:35 +00:00
Lauro Ramos Venancio ca0fd02cdd Improve non-const initializer implementation.
llvm-svn: 47347
2008-02-19 22:04:22 +00:00
Lauro Ramos Venancio 91fdb9ec43 Implement CodeGenModule::getMemSetFn method.
llvm-svn: 47346
2008-02-19 22:01:01 +00:00
Ted Kremenek 4ae9985285 Added missing case in constant propagation logic for handling the Xor of
two concrete integer values.

llvm-svn: 47341
2008-02-19 20:53:37 +00:00
Ted Kremenek 9c08512656 Added special handling for UninitializedVals for the transfer function logic
for pointer dereferences.

llvm-svn: 47340
2008-02-19 20:53:06 +00:00
Ted Kremenek 4baef06bbc Implemented "getType()" for symbolic values representing the "contents" of
another symbolic value.

llvm-svn: 47339
2008-02-19 20:51:40 +00:00
Lauro Ramos Venancio e2162c6549 Simplify aggregate initilizer implementation. Use the CodeGenModule::EmitConstantExpr method when
possible.
Fix mediabench/mpeg2/mpeg2dec test.

llvm-svn: 47336
2008-02-19 19:27:31 +00:00
Ted Kremenek 9fd2531b5e Fixed transfer function for casts to always evaluate the effects of the
cast's subexpression even if the cast itself has no effect.

llvm-svn: 47335
2008-02-19 18:52:54 +00:00
Ted Kremenek fe0b5740ce Added transfer function support for casting to "void".
llvm-svn: 47333
2008-02-19 18:47:04 +00:00
Chris Lattner d2a02fe840 fix the second half of PR2041: __restrict is ok in c90 mode, even if
restrict isn't.

llvm-svn: 47316
2008-02-19 06:46:10 +00:00
Ted Kremenek 86dc7ae58e Fixed bug classof() bug with RValues that could cause an UninitializedVal
or UnknownVal to be interpreted as an actual NonLValue/LValue.

llvm-svn: 47304
2008-02-19 02:34:18 +00:00
Ted Kremenek dbb1a3724c For now, --grsimple skips analyzing functions in header files.
llvm-svn: 47303
2008-02-19 02:33:31 +00:00
Ted Kremenek 8b51dc2754 Added back explicit state/node creation when visiting IntegerLiterals and
CharacterLiterals.  This may not be a permanent solution; it doesn't cost that
much, however, to create a few additional states, and solves a whole bunch
of edge cases when handling ?, ||, and &&.

llvm-svn: 47299
2008-02-19 02:01:16 +00:00
Ted Kremenek e0188e6ad7 Added boilerplate transfer function support for CallExprs.
llvm-svn: 47298
2008-02-19 01:44:53 +00:00
Nate Begeman 22011e90c9 Allow ArraySubscriptExpr to be a base node for vector dereference. This
allows you to do things like 
typedef __attribute__(( ocu_vector_type(4))) float float4;
float4 *x;
float y = x[0][2];

llvm-svn: 47295
2008-02-19 01:11:03 +00:00
Ted Kremenek 58cc30b64b Added FIXME for properly handling local arrays using symbolic LValues.
For now we just treat their values as "Unknown."

llvm-svn: 47294
2008-02-19 00:29:51 +00:00
Ted Kremenek 0f7130adc4 --grsimple now reports the number of nodes in the ExplodedGraph for
an analyzed function.

GRExprEngine now records stores to "uninitialized lvalues" (which are sinks in
the ExplodedGraph).

llvm-svn: 47293
2008-02-19 00:22:37 +00:00
Lauro Ramos Venancio c58fc4052e A global without initializer must be emitted as weak.
Fix Olden/bh test.

llvm-svn: 47292
2008-02-19 00:04:15 +00:00
Ted Kremenek a6f63d94a5 Added "size()" and "empty()" methods to ExplodedGraphImpl.
llvm-svn: 47289
2008-02-18 23:00:23 +00:00
Ted Kremenek 346169fa3d Added more assertions and checks in transfer function logic to check for
UninitializedVals and UnknownVals.

llvm-svn: 47288
2008-02-18 22:57:02 +00:00
Lauro Ramos Venancio dec89733a7 Implement multi-dimension array initalizer.
Fix McCat/08-main test.

llvm-svn: 47286
2008-02-18 22:44:02 +00:00
Ted Kremenek 86e793937a Running -grsimple now emits diagnostics about the time spent analyzing each function. Will
probably make this a separate command line option later.

Added "--analyze-function" option to the driver to (gradually) allow different
analyses to only be run on specific functions. Currently only --grsimple uses
this option.

llvm-svn: 47285
2008-02-18 21:21:23 +00:00
Ted Kremenek 3b1beb224b Temporary solution to push analysis through to analyzing PCRE.
We will implement symbol "unification" later.

llvm-svn: 47284
2008-02-18 21:19:49 +00:00
Anders Carlsson 196aa53300 Add more supported constraints.
llvm-svn: 47270
2008-02-18 17:00:25 +00:00
Steve Naroff f631ae2cf8 Tweak fix for http://llvm.org/bugs/show_bug.cgi?id=2000 to work across typedefs.
llvm-svn: 47269
2008-02-18 15:14:59 +00:00
Anders Carlsson 6b5b42be41 More bitfield improvements.
llvm-svn: 47260
2008-02-18 07:13:09 +00:00
Anders Carlsson 9195e08e5e Fix bug where we would report the wrong value for __alignof__ with an expr that is not a type.
llvm-svn: 47259
2008-02-18 07:10:45 +00:00
Nate Begeman d8c4156172 Turn handling of parameter attributes back on, fixing the ObjC breakage
llvm-svn: 47246
2008-02-17 21:20:31 +00:00
Nate Begeman d811e74786 Revert this temporarily, it's breaking objc :/
llvm-svn: 47245
2008-02-17 21:04:23 +00:00
Nate Begeman f0e4a52211 Handle parameter attributes
llvm-svn: 47243
2008-02-17 21:02:04 +00:00
Chris Lattner b080ed504e Fix PR2042. One remaining issue: we don't currently diagnose
int foobar(int);
 int foobar() {}

which requires ifdef'ing out a testcase in predefined-function.c.

llvm-svn: 47236
2008-02-17 19:31:09 +00:00
Anders Carlsson ffd0992247 Change alignment for doubles to 32 bits which is what X86 has.
llvm-svn: 47234
2008-02-17 03:40:02 +00:00
Eli Friedman f7e92acaba Implemnt isVariablyModifiedType correctly.
llvm-svn: 47233
2008-02-17 00:59:11 +00:00
Chris Lattner df53e20f2d implement codegen support for aggregates casted to void.
llvm-svn: 47226
2008-02-16 23:55:16 +00:00
Eli Friedman 1d88371663 A couple of msvc compile fixes from the ml; I haven't tested with msvc,
but the fixes are reasonable.

llvm-svn: 47224
2008-02-16 23:17:23 +00:00
Lauro Ramos Venancio bada8d4b5b Implement extern block var.
llvm-svn: 47223
2008-02-16 22:30:38 +00:00
Anders Carlsson f13b1efa75 Add more tests
llvm-svn: 47217
2008-02-16 19:51:36 +00:00
Anders Carlsson 6e3ace5205 Better handling of the aligned attribute.
llvm-svn: 47216
2008-02-16 19:51:27 +00:00
Anders Carlsson acea415ec5 More comments from Chris.
llvm-svn: 47210
2008-02-16 03:37:41 +00:00
Chris Lattner 27055194b7 Fix CheckEndOfDirective to diagnose lines that contain macros that expand to
zero tokens.  This fixes PR2045, thanks to Neil for finding another 
incredibly subtle corner case :)

llvm-svn: 47203
2008-02-16 01:20:36 +00:00
Anders Carlsson 3ea23a45d9 Make sizeof and __alignof work correctly with packed structs.
llvm-svn: 47202
2008-02-16 01:20:23 +00:00
Ted Kremenek 074965c5cb Further cleanup. Moved definitions for SymbolManager and ValueManager into
their own [.cpp;.h] files.

llvm-svn: 47201
2008-02-16 01:12:31 +00:00
Anders Carlsson 4b93979008 Fix typo
llvm-svn: 47199
2008-02-16 00:39:40 +00:00
Anders Carlsson 28e7108142 Handle packed attribute correctly
llvm-svn: 47197
2008-02-16 00:29:18 +00:00
Anders Carlsson 214260e04a Address comments from Chris.
llvm-svn: 47195
2008-02-16 00:24:09 +00:00
Anders Carlsson 8321a155a5 Store attributes in a global hash map instead.
llvm-svn: 47193
2008-02-15 23:57:38 +00:00
Anders Carlsson e5070069c8 Store attributes in a global hash map instead.
llvm-svn: 47191
2008-02-15 23:30:50 +00:00
Ted Kremenek 6698cb8aa3 Refactored code for transfer functions for binary operators involving two LValues.
Fixed bug in transfer functions for sizeof(*); we were incorrectly evaluating to
a value of the wrong type.

Fixed bug in transfer functions for compound assignments where we did not properly
handle assignments involving dereferences of symbolic values.

llvm-svn: 47190
2008-02-15 23:15:23 +00:00
Lauro Ramos Venancio 10984b2ee9 Set Ubuntu 7.10 c++ include path.
llvm-svn: 47186
2008-02-15 22:36:38 +00:00
Lauro Ramos Venancio ace55dac39 Add c++ to "inferlanguage"
llvm-svn: 47185
2008-02-15 22:35:25 +00:00
Ted Kremenek 8db4b110c3 Added transfer function support for conditional branches with a NULL condition (e.g., "for(;;)").
Fixed bug in transfer function for compound assignment operators when both operands where variables but had a non-pointer type (we fired an assertion).

llvm-svn: 47184
2008-02-15 22:29:00 +00:00
Ted Kremenek e81734b01c Simplified transfer function logic for ++/-- operators.
Added more boilerplate transfer function support for pointer arithmetic.
Added more pretty-printing support for symbolic constraints.
Added transfer function support for handling enum values.
Minor pointer types cleanup in ExplodedGraphImpl.

llvm-svn: 47183
2008-02-15 22:09:30 +00:00
Ted Kremenek c4bf7ef744 Added predicate function "UnaryOperator::isIncrementOp()".
llvm-svn: 47181
2008-02-15 22:04:52 +00:00
Eli Friedman 5c9490924c Don't call non-existent method... sorry about the spam; the fix seemed
trivial, but I forgot that method doesn't exist yet.

llvm-svn: 47175
2008-02-15 19:53:52 +00:00
Eli Friedman b26be3d053 Get rid of unused variable warning.
llvm-svn: 47174
2008-02-15 19:49:39 +00:00
Eli Friedman bd258284e0 Split out incomplete arrays from VariableArrayType into
IncompleteArrayType.  This should make code dealing with both incomplete 
and variable length arrays much more readable, plus it allows properly 
making the distinction between isVariableArrayType() and 
isVariablyModifiedType().  The patch is a little big, but it's 
strightforward. so I don't think there should be any issues.

llvm-svn: 47165
2008-02-15 18:16:39 +00:00
Chris Lattner 287c734075 Fix PR2041: restrict is not a keyword in c90.
llvm-svn: 47160
2008-02-15 18:02:59 +00:00
Eli Friedman 9e805b24fd Part of clearing up the whole VariableArrayType + incomplete arrays
thing.  Some cleanups that can be done independently of the fix.

llvm-svn: 47158
2008-02-15 12:53:51 +00:00
Eli Friedman 783a5c262b Remove unnecessary references to VariableArrayType from Analysis.
llvm-svn: 47157
2008-02-15 12:28:27 +00:00
Eli Friedman a682d39639 Remove useless parameter from isConstantSizeType.
llvm-svn: 47156
2008-02-15 12:20:59 +00:00
Anders Carlsson 1a84106117 Get rid of AttributeList in the AST and use the new Attr class instead
llvm-svn: 47155
2008-02-15 07:04:12 +00:00
Eli Friedman 78e47634b2 Get rid of outdated code that masks type errors. Fixes PR2036.
llvm-svn: 47154
2008-02-15 06:56:02 +00:00
Eli Friedman e9d0954c06 Nevermind, these tests work... I messed up my testing.
llvm-svn: 47153
2008-02-15 06:29:53 +00:00
Eli Friedman a01cfa75eb Partial fix for struct compatibility; there's still something messy
going on with mixing scopes, though.

llvm-svn: 47152
2008-02-15 06:03:44 +00:00
Ted Kremenek bc0ba39a1e Added boilerplate transfer function support for pointer arithmetic operations.
llvm-svn: 47147
2008-02-15 00:52:26 +00:00
Ted Kremenek e161afc4dd Added --grsimple-view option to clang driver; this is the same as
--grsimple except that it visualizes the ExplodedGraph using dot and
outputs the current function being analyzed.  --grsimple is now silent
except when it emits diagnostics.

llvm-svn: 47146
2008-02-15 00:35:38 +00:00
Ted Kremenek 8e6f6e05c3 Added "symbol iterators" for RValues, allowing easy iteration over the symbols
referenced by an RValue, instead of having to query the type of the RValue.

Modified ValueState::RemoveDeadBindings to also prune dead symbols.

llvm-svn: 47142
2008-02-14 23:25:54 +00:00
Ted Kremenek 5b70a22656 When visualizing ExplodedNodes created by GRExprEngine, color nodes with
null-dereferences or bad control-flow red.

llvm-svn: 47140
2008-02-14 22:54:53 +00:00
Ted Kremenek 5d8bab7ecd Don't analyze functions when we have parse errors.
llvm-svn: 47139
2008-02-14 22:54:17 +00:00
Ted Kremenek d3122cb83c Renamed GRConstants => GRSimpleVals.
Moved driver logic for --grsimple to GRSimpleVals.cpp.

llvm-svn: 47137
2008-02-14 22:36:46 +00:00
Ted Kremenek bd8957b6b2 #include cleanups in GRExprEngine.cpp/GRExprEngine.h. Moved GRExprEngine to
clang namespace.

llvm-svn: 47136
2008-02-14 22:16:04 +00:00
Ted Kremenek 64de207c52 Partitioned definition/implementation of GRExperEngine into .h and .cpp.
Still some cleanup to do, but this initial checkin compiles and runs correctly.

llvm-svn: 47135
2008-02-14 22:13:12 +00:00
Ted Kremenek cf7cf8e8b0 Migrated transfer functions for binary operators for simple value tracking
from RValues to GRTransferFuncs/GRSimpleVals.

llvm-svn: 47131
2008-02-14 19:37:24 +00:00
Chris Lattner 99a59b6ba0 ParseCompoundStatementBody expects to only be called with { as the current
token.  Diagnose when the { is missing in objc @try blocks instead of aborting.

llvm-svn: 47130
2008-02-14 19:27:54 +00:00
Ted Kremenek 4bad8f7ad6 Migrated transfer functions for unary "~" and "-" to GRTransferFuncs/GRSimpleVals.
llvm-svn: 47126
2008-02-14 18:40:24 +00:00
Ted Kremenek 3ca942969e Started partitioning of transfer function logic (and thus the policy behind
these operations) into GRTransferFuncs and its subclasses.  Originally all
of this logic was handled by the class RValue, but in reality different
analyses will want more flexibility on how they evaluate different values.

Transfer functions migrated so far: "Cast"

llvm-svn: 47125
2008-02-14 18:28:23 +00:00
Ted Kremenek 747c777bde Moved Rvalues.h from "Analysis/" to "include/clang/Analysis/PathSensitive".
llvm-svn: 47123
2008-02-14 17:30:51 +00:00
Nate Begeman a338594236 Completed note
llvm-svn: 47120
2008-02-14 08:19:48 +00:00
Anders Carlsson b0aad621fd Address comments from Chris.
llvm-svn: 47118
2008-02-14 07:43:43 +00:00
Anders Carlsson b853a1a049 Add Attr.h which is an AST-level class for GCC attributes.
llvm-svn: 47112
2008-02-14 07:14:34 +00:00
Steve Naroff 2d868f2bcd Remove DeclSpec::Invalid, a recently added bool that allowed the parser to detect if the decl spec was invalid.
For now, we will stick with the original strategy - clients of Parse::ParseDeclarationSpecifiers() should never have to know this.

llvm-svn: 47104
2008-02-14 03:30:24 +00:00
Steve Naroff f631997cb5 A much better fix for http://llvm.org/bugs/show_bug.cgi?id=1987.
llvm-svn: 47103
2008-02-14 02:58:32 +00:00
Ted Kremenek 80ebc1d1c9 Added support to GRCoreEngine/GRExprEngine for processing control-flow
from switch...case...default statements.

llvm-svn: 47100
2008-02-13 23:08:21 +00:00
Dan Gohman 63705ecefd Adjust for APInt's isPositive being renamed to isNonNegative.
llvm-svn: 47091
2008-02-13 22:09:49 +00:00
Ted Kremenek 654c78fd2d When creating the CFGBlocks for a switch statement, we now have the "default"
branch ALWAYS be the last successor for a switch-terminated block. This allows
clients to distinguish cases like the following:

switch(...)
  case XXX:
    switch(...) {
      case YYY: ...
    }
    
  case ZZZ: ..
}

In this case, the block with "case ZZZ:" is the default block for the inner
switch statement, but that case is associated with the outer switch statement,
and not the inner one. Clients can test for this behavior by checking if a
successor block is the last one (and thus just assume that this is the "default"
case).

llvm-svn: 47088
2008-02-13 22:05:39 +00:00
Ted Kremenek 9682be18ae Fixed bug in CFG construction when processing switch statements that contain no
"default" case. In such cases, we now correctly add the CFGBlock representing
the code after the switch statement as a successor to the block terminated by
the switch statement.

llvm-svn: 47087
2008-02-13 21:46:34 +00:00
Ted Kremenek cd44b12f96 Fixed 80 col violations.
llvm-svn: 47076
2008-02-13 18:06:44 +00:00
Chris Lattner 7b7ace5537 avoid making implicit casts that just remove typedefs.
llvm-svn: 47074
2008-02-13 18:01:07 +00:00
Ted Kremenek 755d39b233 Unbreak the build.
llvm-svn: 47072
2008-02-13 17:45:18 +00:00
Ted Kremenek 1c16527774 Renamed files to match class renaming in r47070:
http://llvm.org/viewvc/llvm-project?rev=47070&view=rev

llvm-svn: 47071
2008-02-13 17:43:07 +00:00
Ted Kremenek f6c62f3459 Renamed class GREngine => GRCoreEngine.
Renamed class GRConstants => GRExprEngine.

This was done with a Perl script, and will result in 80 col. violations that
I will gradually fix up.

llvm-svn: 47070
2008-02-13 17:41:41 +00:00
Eli Friedman 2be9af9556 Fix a minor bug in isNullPointerConstant triggered by the linux
tgmath.h.

Note that there is another issue with tgmath.h, so mandel.c still 
doesn't work.

llvm-svn: 47069
2008-02-13 17:29:58 +00:00
Ted Kremenek 2bba901a36 Simplify GRIndirectGotoNodeBuilder.
llvm-svn: 47068
2008-02-13 17:27:37 +00:00
Ted Kremenek 632bcb82a7 Added GREngine support for "break" and "continue".
llvm-svn: 47064
2008-02-13 16:56:51 +00:00
Anders Carlsson 73cc507602 Use IgnoreParenCasts.
llvm-svn: 47041
2008-02-13 01:22:59 +00:00
Chris Lattner f26609686f Move IgnoreParenCasts to be a method on Expr.
llvm-svn: 47040
2008-02-13 01:02:39 +00:00
Ted Kremenek 7022efbe7b Added support to GREngine/GRConstants for handling computed gotos.
llvm-svn: 47038
2008-02-13 00:24:44 +00:00
Ted Kremenek 822f7370b2 Added GREngine support for GotoStmt.
llvm-svn: 47034
2008-02-12 21:51:20 +00:00
Dan Gohman 922096cc5e Adjust for the API change to APInt::getBitsSet.
People more familiar with clang than me, please review this.

llvm-svn: 47033
2008-02-12 21:49:34 +00:00
Ted Kremenek 736e441266 Added transfer function/value track logic for taking the address of a label.
llvm-svn: 47030
2008-02-12 21:37:56 +00:00
Ted Kremenek 1f3d4a73f5 Minor (cosmetic) reshuffling of code. Fixed a bug in "Assume" logic when
handling Non-Lvalues of the type nonlval::SymbolVal; we were accidentally
casting them to lval::SymbolVal.

llvm-svn: 47029
2008-02-12 21:37:25 +00:00
Ted Kremenek 002bf74fbc Added transfer function logic for sizeof(expr)/sizeof(type). This currently
doesn't support VLAs.

Reordered some cases in the switch statement of GRConstant::Visit() so
that they are ordered alphabetically based on AST node type.

llvm-svn: 47021
2008-02-12 19:49:57 +00:00
Ted Kremenek f225dffd4d Fixed misspelling in comment.
llvm-svn: 47016
2008-02-12 19:01:33 +00:00
Ted Kremenek fb9cc188af Renamed local variable.
Added transfer function support for CharacterLiteral.

llvm-svn: 47014
2008-02-12 18:50:32 +00:00
Ted Kremenek 07d65aa238 Moved class declaration for ObjCForCollectionStmt to be co-located with
the class declarations for the other ObjC***Stmt classes.

llvm-svn: 47013
2008-02-12 18:34:31 +00:00
Ted Kremenek 90ae68fe71 Added GRBlockCounter class, which tracks the number of times blocks
have been visited in a path.  Added GRBlockCounter as an item to be
enqueued to the worklist.

Modified "ProcessBranch" in GRConstants to prune branches with symbolic
conditions that have been already taken.

llvm-svn: 47010
2008-02-12 18:08:17 +00:00
Eli Friedman a7bf7ed476 Make typechecking for enum+int compatibility stricter.
llvm-svn: 47005
2008-02-12 08:46:17 +00:00
Eli Friedman 2b90b0d09e Add wchar_t type to ASTContext. Will be needed for wide strings, since
they are of type wchar_t[].

llvm-svn: 47004
2008-02-12 08:29:21 +00:00
Eli Friedman 16f909670e Fix type compatibility between constant and variable arrays.
llvm-svn: 47003
2008-02-12 08:23:06 +00:00
Steve Naroff ab468cb14b Allow the parser to detect invalid DeclSpec's. This fixes http://llvm.org/bugs/show_bug.cgi?id=1987.
This commit only "guards" the call to ParseDeclarationSpecifiers() in ParseDeclarationOrFunctionDefinition(). 

We could consider guarding all calls, however this is a bit radical (since it effectively stops parsing the declaration once we have a bad declspec). Will discuss with Chris tomorrow.

llvm-svn: 46984
2008-02-12 04:08:59 +00:00
Steve Naroff c1e22c7fa1 Fix unsafe static cast...
llvm-svn: 46980
2008-02-12 01:09:36 +00:00
Steve Naroff 69e8f9efab Several cleanups surrounding Parser::ParseAsmStatement() and Parser::FuzzyParseMicrosoftAsmStatement().
llvm-svn: 46977
2008-02-11 23:15:56 +00:00
Ted Kremenek 633654ffab Consolidated use of BumpPtrAllocator shared by various ImmutableSet/ImmutableMap
factories.

Fixed a horrible bug in lval:DeclVar::classof(RValue* V); we weren't checking
V was an LValue, allowing nonlval::ConcereteInts to match isa<lval::DeclVar>.

llvm-svn: 46976
2008-02-11 23:12:59 +00:00
Steve Naroff bff738543d Move policy on unnamed fields (a Microsoft extension) from Parser::ParseStructDeclaration() to the driver.
llvm-svn: 46974
2008-02-11 22:40:08 +00:00
Steve Naroff 5915777fca Move Microsoft __declspec hack from the parser to the preprocessor. Since we have no plans to actually implement this construct, it is cleaner to limit the change to the preprocessor.
llvm-svn: 46973
2008-02-11 22:29:58 +00:00
Steve Naroff 5a858df0b3 Fix http://llvm.org/bugs/show_bug.cgi?id=2013.
llvm-svn: 46972
2008-02-11 22:17:33 +00:00
Steve Naroff b5fc2551e4 After yesterday's discussion (http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-February/001044.html), decided not to change the semantics of Type::isIncompleteType().
This commit simply changes a couple comments to reflect this decision.

llvm-svn: 46970
2008-02-11 21:52:37 +00:00
Ted Kremenek ed3be17b6f Separate bindings for subexpressions to be in a separate map for
bindings for block-level expressions.

Moved pretty-printing logic (DOT) for ValueStates to ValueState.cpp.

llvm-svn: 46965
2008-02-11 19:21:59 +00:00
Anders Carlsson 6a8350b4f1 Get rid of bogus warnings when the second argument in va_start is either an implicit cast expr or a paren expr.
llvm-svn: 46950
2008-02-11 04:20:54 +00:00
Steve Naroff 4b32796d1c Add a comment/FIXME to an earlier change.
llvm-svn: 46947
2008-02-11 02:42:07 +00:00
Steve Naroff e78e2af754 Tweak test...
llvm-svn: 46946
2008-02-11 02:16:41 +00:00
Chris Lattner c9b96ae832 strings are arrays too
llvm-svn: 46945
2008-02-11 01:35:07 +00:00
Eli Friedman f54c4e5fea A couple of minor fixes to aggregate codegen, to stop asserting on some
edge cases.

llvm-svn: 46944
2008-02-11 01:09:17 +00:00
Eli Friedman a5b2023810 Make unsupported constant exprs fail with a warning instead of crashing
codegen.

llvm-svn: 46943
2008-02-11 00:23:10 +00:00
Steve Naroff 326389b8ce Fix http://llvm.org/bugs/show_bug.cgi?id=1988.
Sema::CheckInitializerListTypes() needs to ignore invalid structures.

llvm-svn: 46942
2008-02-11 00:06:17 +00:00
Chris Lattner 36fc8790b7 Fix PR1992 by computing the right type for string literals, which
is an array type not a pointer type.  This requires updating some
diags that change and updating the code generator to handle the
proper form of strings.

llvm-svn: 46941
2008-02-11 00:02:17 +00:00
Eli Friedman de4496bb9e Basic codegen test for conditional with void*.
llvm-svn: 46940
2008-02-10 23:18:23 +00:00
Eli Friedman fadc8462be Add a couple of sema tests for qualifiers with conditionals containing
void*.

llvm-svn: 46939
2008-02-10 23:14:16 +00:00
Chris Lattner 7b8134f5c6 Fix PR1999, by emitting a hard error only if an argument declarator is completely
missing.  Otherwise, it is an implicit int case, which is valid in c90 and invalid 
elsewhere, but accepted as an extension.

llvm-svn: 46938
2008-02-10 23:08:00 +00:00
Eli Friedman 15888c23f5 Fix the type of conditionals involving void* to be self-consistent and
spec-compliant.

I'll put together some testcases in a bit.

llvm-svn: 46937
2008-02-10 22:59:36 +00:00
Steve Naroff 15833ed168 Add a diagnostics helper to remove some redundant code.
llvm-svn: 46936
2008-02-10 21:38:56 +00:00
Chris Lattner 00c5b28923 long is 32-bit is on win32.
llvm-svn: 46935
2008-02-10 21:12:45 +00:00
Steve Naroff 1018ea35b7 Refine bug fix to Expr::isLvalue (commit r46917).
llvm-svn: 46919
2008-02-10 01:39:04 +00:00
Steve Naroff 43c50866f1 Change Expr::isLvalue() to allow the "void" type. This fixes bz2000 submitted by Neil Booth.
Neil, can you point me to the place in the C99 spec that says this is allowed? I thought Expr::isLvalue() conformed to the spec, which says "C99 6.3.2.1: an lvalue is an expression with an object type or an incomplete type other than void.". Please advise.

llvm-svn: 46917
2008-02-10 00:30:18 +00:00
Anders Carlsson c0b0e59643 Implement __builtin_va_copy
llvm-svn: 46911
2008-02-09 20:26:43 +00:00
Anders Carlsson 2e64d1a50f Behave correctly if a constraint expression is invalid.
llvm-svn: 46910
2008-02-09 19:57:29 +00:00
Steve Naroff 4cc387212a Fix spelling in comment.
llvm-svn: 46906
2008-02-09 17:25:18 +00:00
Steve Naroff 45173e0ac0 Fix <rdar://problem/5733511> clang doesn't emit error for const array.
llvm-svn: 46905
2008-02-09 16:59:44 +00:00
Eli Friedman a62f3e1352 Expose the logic for field address codegen; it is needed for aggregate
initializers, and I don't want to duplicate the bitfield-handling code.  
(I'll send a patch for aggregate initializers to the mailing 
list sometime soon.)

llvm-svn: 46904
2008-02-09 08:50:58 +00:00
Steve Naroff a369922449 A bunch-o changes to fix <rdar://problem/5716046> incomplete implementation of ObjC class warning is incomplete
As part of this fix, I made a low-level change to the text diagnostics machinery (to basically avoid printing duplicate source lines/carets when you have multiple diagnostics that refer to the same exact place). For now, this only happens with we don't have a source range (could be extended to support source ranges as well). 

llvm-svn: 46897
2008-02-08 22:06:17 +00:00
Ted Kremenek b54312d5a0 Split off expression-bindings in ValueState from variable-bindings.
llvm-svn: 46892
2008-02-08 21:10:02 +00:00
Ted Kremenek 4142cc834b Changed "GetValue" methods to take an
Expr* instead of a Stmt*, since we only
store bindings for Expr*.

llvm-svn: 46891
2008-02-08 20:29:23 +00:00
Lauro Ramos Venancio d74057fa87 Fix a bitfield regression. Reported by Anders Carlsson.
llvm-svn: 46889
2008-02-08 19:46:46 +00:00
Ted Kremenek 80ff44ff30 Moved implementation of "RemoveDeadBindings" from the main
GRConstants logic to ValueStateManager.

llvm-svn: 46888
2008-02-08 19:17:19 +00:00
Ted Kremenek 5d9073c776 Removed ability to create symbol bindings
in VarKey and VariableBindingsTy.

llvm-svn: 46887
2008-02-08 19:08:13 +00:00
Steve Naroff 8c099c3f03 Use getLogicalLineNumber() in FuzzyParseMicrosoftAsmStatement(), it's more general and simplifies the code.
llvm-svn: 46885
2008-02-08 18:01:27 +00:00
Ted Kremenek 09d6ba1496 Moved that clang doesn't depend on llvm-gcc above
the subsection of building clang with llvm.

llvm-svn: 46884
2008-02-08 07:32:26 +00:00
Ted Kremenek fd39e73b7a Implemented transfer functions for "<<" and ">>" when the RValues are
ConcreteInts.

llvm-svn: 46883
2008-02-08 07:14:58 +00:00
Eric Christopher 6aa87cbb63 Add instructions for building clang while building llvm.
llvm-svn: 46881
2008-02-08 07:10:48 +00:00
Ted Kremenek 707b07ccf9 Implemented transfer functions for Statement-Expressions and Commas.
Fixed bug in dispatching to the correct transfer function for |=, &=, and ^|.

llvm-svn: 46880
2008-02-08 07:05:39 +00:00
Eric Christopher 2dc30a5ac8 De-^Mify file.
llvm-svn: 46879
2008-02-08 06:45:49 +00:00
Steve Naroff db5f7d7699 Support fuzzy parsing MS line-oriented __asm's that originate from a macro (a case where we can't obtain source line info). As the test case indicates, we don't currently support line-oriented asm statements that mix file/macro body tokens.
llvm-svn: 46878
2008-02-08 03:36:19 +00:00
Ted Kremenek fd641f1056 More variable renamings.
llvm-svn: 46875
2008-02-08 03:02:48 +00:00
Ted Kremenek 173743da67 Renamed InvalidValue to UnknownVal.
Renamed UninitializedValue to UninitializedVal.

llvm-svn: 46874
2008-02-08 02:57:34 +00:00
Eli Friedman 113eed5cff Fix indentation.
llvm-svn: 46873
2008-02-08 01:24:30 +00:00
Eli Friedman 1974e5321a Detabify SemaExpr. My text editor defaults to 8 spaces per tab, so it
gets kind of annoying.

llvm-svn: 46872
2008-02-08 01:19:44 +00:00
Eli Friedman 4297826cac Improve diagnostic for illegal array initialization.
llvm-svn: 46869
2008-02-08 00:48:24 +00:00
Anders Carlsson 5c6c05956e Put back the top-level asm code; all tests pass now.
llvm-svn: 46868
2008-02-08 00:33:21 +00:00
Anders Carlsson 0fae4f56df Back out 46855 for now, it causes test failures on Darwin.
llvm-svn: 46867
2008-02-08 00:23:11 +00:00
Steve Naroff 4e79d340bd - Add support for fuzzy parsing line-oriented __asm's (yuck).
- Change handling of __w64 to a built-in macro.

llvm-svn: 46864
2008-02-07 23:24:32 +00:00
Lauro Ramos Venancio 9eff02d9f8 Simplify bitfield codegen.
Fix codegen of struct { short a[3]; int b:15; }.

llvm-svn: 46859
2008-02-07 19:29:53 +00:00
Lauro Ramos Venancio 0f166de892 Fix codegen of
struct {
  char a[3];
  unsigned char b:1;
};

Fix PR1990.

llvm-svn: 46856
2008-02-07 18:18:58 +00:00
Anders Carlsson bcc3a4bf64 Handle top-level asm declarations.
llvm-svn: 46855
2008-02-07 17:19:11 +00:00
Steve Naroff 6936a08704 Minor cleanup from yesterday's -fms-extension commit. Move __int* MS keywords to predefined macros. This removes some of the MS-madness from Parser::ParseDeclarationSpecifiers().
llvm-svn: 46852
2008-02-07 15:26:07 +00:00
Ted Kremenek e187d0511f Added some more opcode pretty-printing.
Minor cleanups with generating nodes for NULL-pointer dereferences.

llvm-svn: 46851
2008-02-07 15:20:13 +00:00
Ted Kremenek d74da0838f Added proof-of-concept NULL pointer diagnostics to GRConstants.
Modified the driver to pass the Diagnostic object to GRConstants.

llvm-svn: 46847
2008-02-07 06:33:19 +00:00
Ted Kremenek 149512c013 Added support to distinguish between both implicit and explicit null dereferences.
llvm-svn: 46846
2008-02-07 06:04:18 +00:00
Chris Lattner 3b5054dda0 Implement support for the extremely atrocious MS /##/ extension,
which pastes together a comment.  This is only enabled with 
-fms-extensions of course.

llvm-svn: 46845
2008-02-07 06:03:59 +00:00
Chris Lattner f96e8d0925 these aren't tokens.
llvm-svn: 46844
2008-02-07 05:57:50 +00:00
Ted Kremenek e324704e62 Added recording of "implicit" NULL dereferences of symbolic pointers.
llvm-svn: 46843
2008-02-07 05:48:01 +00:00
Eli Friedman 69d56cff31 Add a FIXME for alternate address spaces.
llvm-svn: 46841
2008-02-07 05:24:51 +00:00
Chris Lattner 6bd4c7f94f get the tree building again
llvm-svn: 46840
2008-02-07 05:01:42 +00:00
Ted Kremenek 88da1de048 Added several guards in transfer functions for "InvalidValues".
Fixed bug in RemoveDeadBindings by implementing a simple "mark-and-sweep"
cleaner over the bindings, starting from the Decls and block-level expressions
that are considered "live" by the Liveness analysis.

Fixed bug in isa<> implementation for class LValue.

Added "VisitDeclRefExpr" to GRConstants so that we explicitly bind the current
value of variable to the Block-level Expression (i.e., when the DeclRefExpr is
at the CFGBlock level).

llvm-svn: 46839
2008-02-07 04:16:04 +00:00
Steve Naroff b2c80c7c7b Implement -fms-extensions. This allows us to fuzzy parse non-standard MS constructs used in "windows.h".
llvm-svn: 46838
2008-02-07 03:50:06 +00:00
Ted Kremenek a56c08a2e4 Fixed bug in LiveVariables analysis where Block-level exprs appearing
as the initializers for DeclStmts were not being registered as being
live at the start of the DeclStmt.

llvm-svn: 46837
2008-02-07 02:38:55 +00:00
Ted Kremenek 43523e0fe8 Added transfer function logic for ReturnStmts.
Fixed insidious bug in handling dereferences.

llvm-svn: 46835
2008-02-07 01:08:27 +00:00
Ted Kremenek 4aa77cee11 Minor reordering of the serialization of the fields of MemberExpr to result
in a smaller encoding on disk.

llvm-svn: 46832
2008-02-06 23:03:14 +00:00
Ted Kremenek cdd0be1dc1 Major code refactoring/cleanup with transfer function logic. Now the
code structure is more suitable for additional symbolic analysis.

llvm-svn: 46831
2008-02-06 22:50:25 +00:00
Eli Friedman 1242fff6ec Make sure to propagate qualifiers through the member operator.
llvm-svn: 46830
2008-02-06 22:48:16 +00:00
Chris Lattner 871e0ceffb explicitly document that return statement argument does not necessarily follow the result type of the function. Add testcase.
llvm-svn: 46823
2008-02-06 21:20:34 +00:00
Anders Carlsson 377ad02de5 Use the subprocess module instead of os.system. Patch by Sam Bishop.
llvm-svn: 46819
2008-02-06 19:03:27 +00:00
Ted Kremenek afa5f492e5 Added main transfer function support for unary operator "!".
llvm-svn: 46815
2008-02-06 17:56:00 +00:00
Ted Kremenek 17b65b557b Added assumption logic for symbolic non-lvalues when used in conditions such as
"if(x)". On the true branch we know the value is != 0, and on the false branch
we know it is 0.

llvm-svn: 46814
2008-02-06 17:32:17 +00:00
Anders Carlsson d3b06cda3c Add pointer + int (and vice versa) to the constant emitter.
llvm-svn: 46812
2008-02-06 07:23:14 +00:00
Anders Carlsson 093f1a099f Generate code for the various __builtin_ctz functions.
llvm-svn: 46811
2008-02-06 07:19:27 +00:00
Chris Lattner b818af539f now that ConvertTagDeclType is nice and simple, use it from UpdateCompletedType.
llvm-svn: 46809
2008-02-06 06:06:49 +00:00
Chris Lattner d11482ea22 simplify and speed up type refinement logic. No functionality change.
llvm-svn: 46808
2008-02-06 06:03:51 +00:00
Chris Lattner a64dde6b48 only convert the type name once, not each type it is refined.
llvm-svn: 46807
2008-02-06 05:48:29 +00:00
Eli Friedman 220ee41011 Fix the codegen of structs with flexible array members.
llvm-svn: 46806
2008-02-06 05:33:51 +00:00
Chris Lattner 3340b92582 simplify a bunch of code.
llvm-svn: 46805
2008-02-06 05:29:46 +00:00
Chris Lattner 56096f3020 rename TypeHolderMap to TypeCache, which more aptly describes what it is.
llvm-svn: 46804
2008-02-06 05:21:55 +00:00
Chris Lattner ee9fafd533 split tagged decl layout into its own method.
llvm-svn: 46803
2008-02-06 05:18:32 +00:00
Chris Lattner f6e3669eb2 only update the llvm type for a struct when we used the struct
previously in an opaque context.  If we didn't do this, 
computing its layout could be wasted: just be lazy.

llvm-svn: 46802
2008-02-06 05:12:09 +00:00
Chris Lattner 68be60694e sink more of the type related code into CodeGenTypes.
llvm-svn: 46801
2008-02-06 05:08:19 +00:00
Chris Lattner 8b945ee058 codegen static variables in a function into a different namespace from
static variables outside functions.

llvm-svn: 46800
2008-02-06 04:54:32 +00:00
Eli Friedman d49a720d52 Be a bit stricter about array type compatibility.
llvm-svn: 46799
2008-02-06 04:53:22 +00:00
Chris Lattner a5e4d30942 Finish off the refactoring of type handling stuff. Now we recompile every
tag decl after it has been completed

llvm-svn: 46798
2008-02-06 04:51:19 +00:00
Ted Kremenek 73451846a7 Fixed bug in '=' transfer function: RHS does not have to be a non-LValue.
llvm-svn: 46797
2008-02-06 04:41:14 +00:00
Ted Kremenek d17f05435a Fixed signedness bug in cast transfer function when casting integers to pointers.
Removed lval::SymIntConstraintVal; wrappers for symbolic constraints are not lvalues (only integers that evaluate to !0 or 0).

llvm-svn: 46796
2008-02-06 04:31:33 +00:00
Ted Kremenek b2652827e6 Modified state pretty-printing to include the '!=' and '==' constraints on
symbols (for constant integers).

llvm-svn: 46795
2008-02-06 03:56:15 +00:00
Ted Kremenek 0ea8fea0ba Disabled operator= for ValueStateImpl.
ValueState no longer inherits FoldingSetNode (not needed).
Removed redundant operator= implementation for ValueState (it simply did the default behavior).

llvm-svn: 46794
2008-02-06 02:50:36 +00:00
Ted Kremenek 4ff4e7ce9f Fixed bug when allocating a ValueStateImpl object in getPersistentState()
using the bump-pointer allocator and a placed new; we accidentally allocated
a ValueStateImpl* instead, causing an overrun when we did a placed new().

llvm-svn: 46793
2008-02-06 02:45:20 +00:00
Chris Lattner adf1f51fc5 move the codegen ASTConsumer out of the driver into libcodegen,
eliminating a bunch of forwarding methods and generally 
simplifying things.

llvm-svn: 46792
2008-02-06 02:01:47 +00:00
Chris Lattner b5eda6253b pull .ll and .bc writing out of the ASTConsumer destructors into some top
level code in clang.  This is a cleanup, but does implement "-o" for 
-emit-llvm.  One effect of this is that "clang foo.c -emit-llvm" will now
emit into foo.ll instead of stdout.  Use "clang foo.c -emit-llvm -o -" or 
"clang < foo.c -emit-llvm" to get the old behavior.

llvm-svn: 46791
2008-02-06 01:42:25 +00:00
Ted Kremenek 03e7b55f22 Added some skeleton code for performing "assume" on symbols: e.g. assume($0 != 0).
This action will add constraints to the possible values of a symbol.
Still needs to be debugged.

llvm-svn: 46789
2008-02-06 00:54:14 +00:00
Chris Lattner 622c193a32 inform astconsumer about tagdecls as they are defined.
llvm-svn: 46788
2008-02-06 00:51:33 +00:00
Chris Lattner fe0e0af434 pass the astconsumer into Sema's ctor, clean up some stuff in
Sema::ActOnTranslationUnitScope.  The various ObjC pieces at the top
of Sema.cpp should be moved into SemaObjC or something.

llvm-svn: 46787
2008-02-06 00:46:58 +00:00
Chris Lattner 8082d870bd rename ASTSTreamer.{h|cpp} -> ParseAST.{h|cpp}
llvm-svn: 46786
2008-02-06 00:23:21 +00:00
Chris Lattner 4afeded499 kill the ASTStreamer class, inlining it into its only client: clang::ParseAST
llvm-svn: 46785
2008-02-06 00:15:02 +00:00
Anders Carlsson 3ed4aea198 Even more inline asm codegen fixes.
llvm-svn: 46784
2008-02-06 00:11:32 +00:00
Nate Begeman 3399bb424c simple implementation of __builtin_alloca
llvm-svn: 46783
2008-02-06 00:02:50 +00:00
Steve Naroff 2352150043 Add a FIXME to clarify previous commit/experiment.
llvm-svn: 46782
2008-02-05 23:59:27 +00:00
Anders Carlsson 487e527fcf Handle the memory clobber.
llvm-svn: 46780
2008-02-05 23:30:20 +00:00
Anders Carlsson b737b6247f Improvements to inline asm code generation.
llvm-svn: 46779
2008-02-05 23:18:57 +00:00
Ted Kremenek 38b32e976c Added pretty-printing support for lval::SymIntConstraintVal and
nonlval::SymIntConstraintVal.

Reworked transfer function for '==' and '!=' for LValues to return
SymIntConstraintVal when comparing a symbol with a constant.

llvm-svn: 46778
2008-02-05 23:08:41 +00:00
Anders Carlsson 19fe116fc0 Handle simple asm statements correctly.
llvm-svn: 46777
2008-02-05 23:03:50 +00:00
Chris Lattner 9413a016f4 simplify some code.
llvm-svn: 46774
2008-02-05 22:40:55 +00:00
Ted Kremenek 8f6dcfaa30 Moved implementation of cast<> for SymbolData closer to SymbolData's definition.
llvm-svn: 46772
2008-02-05 22:21:54 +00:00
Ted Kremenek 1ee50cd9c1 Added new "NonLValue" class: SymIntConstraintVal. This class represents a binary
contraint between a symbol and an integer constant.

llvm-svn: 46771
2008-02-05 22:10:48 +00:00
Ted Kremenek 1e3fa134de Moved subclasses of LValue and NonLValue into their own namespaces.
This noticeably cleans up the naming of these classes.

llvm-svn: 46770
2008-02-05 21:52:21 +00:00
Ted Kremenek a4aa95bd9d Added "SymIntConstraint", a utility class to represent intermediate values for
transfer function evaluation that represent constraints between symbolic values
and constant integers.

llvm-svn: 46769
2008-02-05 21:32:43 +00:00
Steve Naroff e6016798bf Fix Parser::ParseObjCTryStmt() to allow for trailing @-keyword statements/expressions.
This bug fix is the result of not having 2-token lookahead to recognize specific @-keywords.

llvm-svn: 46768
2008-02-05 21:27:35 +00:00
Anders Carlsson fcbb11a86f Add some binops.
llvm-svn: 46766
2008-02-05 20:54:21 +00:00
Anders Carlsson b170d0cf7e More improvements to inline asm CG.
llvm-svn: 46762
2008-02-05 20:01:53 +00:00
Ted Kremenek e1bbf8e549 Added "batch" processing versions of Nodify and SetValue. Created typedefs
for buffers for RValues and States.

llvm-svn: 46759
2008-02-05 19:35:18 +00:00
Ted Kremenek 1cc95f6cd3 Added a "ConstantNotEq" map to ValueState (and added necessary typedefs and factory objects to ValueStateManager).
llvm-svn: 46758
2008-02-05 18:51:06 +00:00
Ted Kremenek 961ec7bc22 Added some comments.
llvm-svn: 46756
2008-02-05 18:24:17 +00:00
Ted Kremenek db814b5415 Renamed typedef "iterator" in ValueState to "vb_iterator" (for "VariableBindings").
llvm-svn: 46755
2008-02-05 18:19:15 +00:00
Ted Kremenek 17e5b5c99e Reordered fields/methods in ValueState to make it more aesthetically pleasing.
llvm-svn: 46754
2008-02-05 18:17:58 +00:00
Anders Carlsson 063ab86775 Use correct flag value.
llvm-svn: 46752
2008-02-05 17:26:36 +00:00
Anders Carlsson d0cd0d89a0 Append input argument to args vector.
llvm-svn: 46751
2008-02-05 16:57:38 +00:00
Anders Carlsson 952a99592f Add code generation for inline asm statements.
llvm-svn: 46750
2008-02-05 16:35:33 +00:00
Chris Lattner b1537ebdd4 rewrite some of the type refinement code to eliminate dangling pointers
simplify the code and generally make it more robust.

llvm-svn: 46745
2008-02-05 08:06:13 +00:00
Ted Kremenek d8902e06ba Overhauling of "ValueState" so that it represents its own functional data
structure that can contain several maps, not just one.

llvm-svn: 46744
2008-02-05 07:17:49 +00:00
Chris Lattner 86964a9653 Change the key of CGRecordLayouts from being an llvm type* to being a decl*. LLVM
Type*'s can change as types are refined, so we can't use them as a stable key in
the map.  Decls don't change, so use them instead.

This patch was written by Anders, but he's too shy to commit it himself :)

llvm-svn: 46743
2008-02-05 06:55:31 +00:00
Chris Lattner b977b6a59b Relax an assertion, fixing PR1968
llvm-svn: 46742
2008-02-05 06:37:34 +00:00
Ted Kremenek 0a04690fda ValueManager now uses the BumpPtrAllocator owned by the ExplodedGraph.
llvm-svn: 46740
2008-02-05 05:15:51 +00:00
Devang Patel 6c037da51c Update outdated comment.
llvm-svn: 46737
2008-02-05 03:17:42 +00:00
Devang Patel a703a67384 Cleanup InitListExpr code generation code.
Handle padding fields while initializing struct (fix PR 1962)

llvm-svn: 46736
2008-02-05 02:39:50 +00:00
Eli Friedman 26a6dd0877 Fix memory corruption from the type map being modified while a reference
to a cell is being held.

llvm-svn: 46735
2008-02-05 02:18:07 +00:00
Devang Patel 86e7166522 Keep track of padding fields.
llvm-svn: 46734
2008-02-05 01:40:48 +00:00
Ted Kremenek 4894c56ba7 Simplified transfer functions for '++' and '--'
llvm-svn: 46732
2008-02-05 00:43:43 +00:00
Ted Kremenek 3f2f1ade4c Implemented initial transfer function support for '&&', '||', '?', and
__builtin_choose.

llvm-svn: 46731
2008-02-05 00:26:40 +00:00
Ted Kremenek 7746a6279b Added file that should have been in my previous commit.
llvm-svn: 46722
2008-02-04 21:59:22 +00:00
Ted Kremenek 723fe3f863 Created ValueStateManager, a full-blown class to manage the states
created for GRConstants.  Moved instances of ValueManager and SymbolManager
inside this class.  The goal is to gradually separate more of the state
management from the state transformation.

llvm-svn: 46721
2008-02-04 21:59:01 +00:00
Ted Kremenek 2cdfd6670e Implemented transfer function for unary '~'.
llvm-svn: 46708
2008-02-04 16:58:30 +00:00
Christopher Lamb da8e5d979e Add ending newline to test.
llvm-svn: 46692
2008-02-04 02:35:11 +00:00
Christopher Lamb 025b5fb883 Add experimental support for address space qualified types. Address space
qualifiers use the __attribute__((address_space(id))) syntax.

llvm-svn: 46691
2008-02-04 02:31:56 +00:00
Bill Wendling e5b8b7db4a - ccc creates output objects in same directory as the source file, and
not in the current directory. This doesn't work with VPATH builds in
  autotooled builds.
- ccc now creates object files without an extension.
- Return exit code 1 if code > 255.

Patch by Torok!

llvm-svn: 46689
2008-02-03 21:27:46 +00:00
Chris Lattner 3ac9699c44 Fix PR1966 by ignoring non-error diagnostics from system headers even if they are
*mapped* onto errors.

llvm-svn: 46686
2008-02-03 09:00:04 +00:00
Chris Lattner 15e4ad81c3 the macro start and macro end bits in source location are dead, remove them.
llvm-svn: 46685
2008-02-03 08:24:13 +00:00
Seo Sanghyeon 66de08bfb4 Make ccc work with older Python versions. Patch by Sam Bishop.
llvm-svn: 46675
2008-02-03 03:40:41 +00:00
Chris Lattner c43926fe67 Implement support for __extension__ which silences extwarnings in its
scope.  This is part of the fix for PR1966

llvm-svn: 46669
2008-02-02 20:20:10 +00:00
Chris Lattner 6cba8e9d66 minor tweak to anders patch: (only) ocu vectors support splatting, but
ocu vectors should not treat bitcasts from int <-> vector as a splat
unless it is of the element type.

llvm-svn: 46664
2008-02-02 04:51:41 +00:00
Anders Carlsson 6fa0813186 Add RUN line.
llvm-svn: 46663
2008-02-02 04:49:12 +00:00
Chris Lattner bfc2d8acd9 testcase for previous patch.
llvm-svn: 46662
2008-02-02 04:45:42 +00:00
Chris Lattner ce6ae5cb06 fix codegen on static variables which have multiple decl nodes. These
should be merged just like normal globals.  This fixes this testcase
that Anders provided:

static struct s a;
static struct s *ap1 = &a;
static struct s a =  { 10 };

llvm-svn: 46661
2008-02-02 04:43:11 +00:00
Steve Naroff 72df405dc5 Cleanup previous patch (based on feedback from Ted).
Since this behavior is useful for most classes, we might consider adding a simple 3 method class that implements the behavior. Ted said that Boost has such a class.

llvm-svn: 46654
2008-02-02 00:10:46 +00:00
Steve Naroff f7fe5b372f Make sure SourceManager/HeaderSearch don't support default copy constructors (since they result in bad runtime behavior).
I'm sure there are other classes that might need this "guard", however I was bitten by these 2 recently (so I thought I'd fix them).

llvm-svn: 46653
2008-02-01 23:31:13 +00:00
Anders Carlsson 53fef5d9d6 Add trailing newline.
llvm-svn: 46652
2008-02-01 23:27:51 +00:00
Anders Carlsson 0b05d041f2 Only OCU vectors can be splatted.
llvm-svn: 46651
2008-02-01 23:17:55 +00:00
Steve Naroff 0dffa442ea Rename diagnostic to reflect it's role...
llvm-svn: 46650
2008-02-01 22:44:48 +00:00
Steve Naroff e6b7ffd073 Minor API cleanup...
llvm-svn: 46649
2008-02-01 22:08:12 +00:00
Steve Naroff d9dc63f2c5 Remove temporary workaround (thanks to Ted for fixing ObjCAtCatchStmt so quickly:-).
llvm-svn: 46648
2008-02-01 21:51:39 +00:00
Ted Kremenek a496584c82 For ObjCAtCatchStmt, removed field 'NextAtCatchStmt' (which referenced the next @catch)
and put the the next ObjcAtCatchStmt* as part of SubExprs.  This fixes a bug with
iterating over the children of ObjcAtCatch, where the next @catch was not
properly being iterated over as a child.

Altered serialization of ObjCAtCatchStmt to reflect this new layout of
its subexpressions, and fixed an ownership issue with the next @catch not
being serialized as an owned pointer.

llvm-svn: 46647
2008-02-01 21:28:59 +00:00
Steve Naroff edb5bc6f09 Fix two rewriter bugs with @catch.
- Support @catch(...), rather than crash:-)
- Make sure all catch bodies get rewritten. This "fix" is really a workaround until the iterator for the "try" AST is fixed. Will fix this in a separate commit.

llvm-svn: 46644
2008-02-01 20:02:07 +00:00
Ted Kremenek e9a709a0c5 Moved "Rewriter" tests from test/Sema to test/Rewriter.
llvm-svn: 46640
2008-02-01 17:05:54 +00:00
Anders Carlsson f4f3679eea Generate correct code for __builtin_huge_val
llvm-svn: 46639
2008-02-01 16:06:34 +00:00
Anders Carlsson 59435b2f9a getPrimaryDecl can return null.
llvm-svn: 46638
2008-02-01 16:01:31 +00:00
Anders Carlsson 806700f973 It is allowed to get the address of an array subscript, even if the array has the register qualifier, if the array is really a pointer.
llvm-svn: 46634
2008-02-01 07:15:58 +00:00
Chris Lattner a347834869 make some diagnostics more terse, update testcases.
Fix Sema::ActOnInstanceMessage to correctly do things in terms of canonical 
types, fixing bogus errors like:

NSDistantObject.m:10383:120: error: bad receiver type 'typeof((id<NSMutableCopying>)self)'
    id mess = ({ id __inv__ = ((void *)0); id __mb__ = _NSMessageBuilder((id <NSMutableCopying>)self, &__inv__); (void)[(__typeof__((id <NSMutableCopying>)self))__mb__ mutableCopyWithZone:((void *)0)]; if (!objc_collecting_enabled()) object_dispose(__mb__); __inv__; });

llvm-svn: 46633
2008-02-01 06:57:39 +00:00
Chris Lattner 617bfc39ff Sema::ActOnInstanceMessage is generally doing bad things with typedefs, but
here I fix just one.  The loop that rips through pointers should use
getAsPointerType() not static_cast<PointerType*> to get the pointee.  This
fixes a crash on a large testcase.

llvm-svn: 46632
2008-02-01 06:43:02 +00:00
Ted Kremenek 81f0550cdd Added back 'CodeGen' to test suite (accidentally removed in my last patch).
llvm-svn: 46631
2008-02-01 06:37:46 +00:00
Ted Kremenek effdafa62a Implemented casts for ConcreteInt and ConcreteIntLValue.
Implemented '==' and '!=' for ConcreteIntLValue.

llvm-svn: 46630
2008-02-01 06:36:40 +00:00
Chris Lattner 1226188e0a Fix PR1969. stdin has no FileEntry.
llvm-svn: 46629
2008-02-01 05:34:02 +00:00
Anders Carlsson b49fdfb5f0 Implement __builtin_huge_val.
llvm-svn: 46627
2008-02-01 00:44:41 +00:00
Anders Carlsson 3d149daf50 Don't try to compile .a files.
llvm-svn: 46626
2008-01-31 23:48:19 +00:00
Ted Kremenek 2820b9c893 Added skeleton for new LValue class ConcereteIntLValue.
llvm-svn: 46624
2008-01-31 22:17:03 +00:00
Chris Lattner 9cc55f5b1f add some helper methods for removing and replacing text, this makes the
rewriter more robust.

llvm-svn: 46622
2008-01-31 19:51:04 +00:00
Chris Lattner 1780a85602 Add a new InsertText method that does the check to see if the insertion was valid. This
fixes crashes where the insertion point was in a macro.  Instead of crashing, we want
to emit a warning.

llvm-svn: 46621
2008-01-31 19:42:41 +00:00
Chris Lattner 187f626a7c move a large method out of line
llvm-svn: 46620
2008-01-31 19:38:44 +00:00
Chris Lattner 2e0d2600a2 Make rewriter::inserttext return a bool to indicate if it failed.
Add a RewriteTest::ReplaceStmt method to factor the 'checking for
rewrite failed + emitting diagnostic if so' code.

llvm-svn: 46619
2008-01-31 19:37:57 +00:00
Ted Kremenek 2838799859 Moved RValue code in GRConstants.cpp to RValue.[h,cpp].
Moved ValueKey/ValueMap declaration to ValueState.h.

llvm-svn: 46618
2008-01-31 19:34:24 +00:00
Steve Naroff e97c4ab30c Fix http://llvm.org/bugs/show_bug.cgi?id=1967.
llvm-svn: 46616
2008-01-31 18:29:10 +00:00
Lauro Ramos Venancio bb733a2bdc Implement review feedback. Use getAsPointerType instead of cast<PointerType>.
llvm-svn: 46613
2008-01-31 15:19:04 +00:00
Ted Kremenek 6f4a9ef4b6 Fixed misspelling of "LLVM" due to some editor+Ted madness.
llvm-svn: 46604
2008-01-31 06:49:09 +00:00
Chris Lattner 7f024fe0c6 Fix PR1965: missing diagnostics for parameters that are missing
type specifiers.  This required updating some (buggy) tests, and the
testcase was previously accidentally committed.

llvm-svn: 46603
2008-01-31 06:10:07 +00:00
Chris Lattner 4973fb9273 Fix a bogus test
llvm-svn: 46602
2008-01-31 06:06:29 +00:00
Nate Begeman 4cd6689d1f Remainder of the __builtin_overload feedback
llvm-svn: 46601
2008-01-31 05:38:29 +00:00
Chris Lattner a779d69029 Fix a rewriter crash when the whole body of a foreach is itself
rewritten, as in Sema/rewrite-foreach-6.m.  Fariborz/Steve,
please review this to see if it is sane.

llvm-svn: 46600
2008-01-31 05:10:40 +00:00
Chris Lattner a94035bbb8 Fix PR1921 by promoting negative indices to intptrty.
llvm-svn: 46599
2008-01-31 04:12:50 +00:00
Ted Kremenek a0be8264b5 Added transfer function support for unary '&' and '*', providing basic
(local) aliasing support.

Modified ExplodedGraph pretty-printer (for GRConstants) to also print out the
pointer value of the state associated with a node.  This way one can easily
see that two states are identical.

llvm-svn: 46595
2008-01-31 02:35:41 +00:00
Anders Carlsson fbcf676a65 Make CallExpr::isBuiltinConstantExpr slightly more efficient.
llvm-svn: 46594
2008-01-31 02:13:57 +00:00
Steve Naroff f6e3b32964 Add support for CallExpr::isBuiltinConstantExpr(). For now, this hook is used to support CFConstantStrings. Can be extended to support other built-in functions.
This allows the following code to compile without error...

#include <CoreFoundation/CoreFoundation.h>

#define CONST_STRING_DECL(S, V) const CFStringRef S = (const CFStringRef)__builtin___CFStringMakeConstantString(V);

CONST_STRING_DECL(kCFTimeZoneSystemTimeZoneDidChangeNotification, "kCFTimeZoneSystemTimeZoneDidChangeNotification")

llvm-svn: 46592
2008-01-31 01:07:12 +00:00
Ted Kremenek b5474fc529 Added 'SymbolicLValue' class to represent LValues whose value is symbolic.
Improved pretty-printing of LValues.
Parameters whose values are pointers/references are now assigned SymbolicLValues.

llvm-svn: 46584
2008-01-31 00:09:56 +00:00
Steve Naroff e101f9548e Hack Sema::MergeTypeDefDecl() to silently ignore duplicate typedef's in system headers files.
A bizarre, non-standard hook that many compilers appear to implement (sigh:-).

llvm-svn: 46583
2008-01-30 23:46:05 +00:00
Ted Kremenek 2531fce319 We now delay adding nodes created by GRBranchNodeBuilder to the analysis
worklist until the dstor of GRBranchNodeBuilderImpl. This way clients can mark
creates nodes as "sinks" before they are added to the worklist.

llvm-svn: 46582
2008-01-30 23:24:39 +00:00
Ted Kremenek a50d98565f Implemented some branch pruning in GRConstants using != and == for
constant integers.

llvm-svn: 46581
2008-01-30 23:03:39 +00:00
Ted Kremenek 1564763b8e Added method "printTerminator" to CFGBlock so that external clients can
pretty-print a block's terminator.

When building CFGs, for IfStmts ('if'), we no longer add the ParenExpr
that is the subexpression of the IfStmt to the CFG; instead we add its
first descendant subexpression that is not a ParenExpr.

llvm-svn: 46580
2008-01-30 23:02:42 +00:00
Steve Naroff 2a2c5b98ee Fix test case and add a FIXME.
llvm-svn: 46577
2008-01-30 21:50:43 +00:00
Lauro Ramos Venancio 86b99c1b79 getLLVMFieldNo can't be called before emitting the base value.
llvm-svn: 46576
2008-01-30 21:23:20 +00:00
Lauro Ramos Venancio f5291d2871 A pointer to an opaque type is an "opaque type definition".
llvm-svn: 46575
2008-01-30 21:21:08 +00:00
Chris Lattner 8f39876ac3 On an unexpected @foo keyword, return failure instead of a 'successful' null AST. This fixes a segfault
on things like @foo.

llvm-svn: 46574
2008-01-30 21:20:25 +00:00
Nate Begeman 936b207407 Implement first round of feedback on __builtin_overload
llvm-svn: 46572
2008-01-30 20:50:20 +00:00
Fariborz Jahanian ca2565ce9a Typo.
llvm-svn: 46570
2008-01-30 20:03:29 +00:00
Steve Naroff 7b3579b8de Abolish a bunch of Xcode inserted tabs.
llvm-svn: 46566
2008-01-30 19:17:43 +00:00
Ted Kremenek 90962af0e8 Minor cosmetic cleanups: replaced some integer literals with constants and
more cleanups with pretty-printing of analysis results.

llvm-svn: 46564
2008-01-30 18:54:06 +00:00
Devang Patel 57412cacb6 Add TODO marker so that it is easier to search.
llvm-svn: 46561
2008-01-30 18:00:07 +00:00
Eli Friedman 3780d35306 Ignore __aligned__ with zero arguments in addition to __aligned__ with
one argument.  Lets stuff using pthread.h compile.

llvm-svn: 46559
2008-01-30 17:38:42 +00:00
Fariborz Jahanian 049fa58d0d Fixed misc. issues raised by Chris L. on @synchronized implementation.
llvm-svn: 46558
2008-01-30 17:38:29 +00:00
Eli Friedman 1bc0fed9a5 Fix codegen for conditionals with incommpatible pointer types. Code
that causes this isn't really correct, but if we're going to accept 
this, it should come up with a consistent AST.

llvm-svn: 46557
2008-01-30 17:02:03 +00:00
Chris Lattner 05ba4cbe17 fix a problem reported by Eli, caused by not keeping bool as i1
when in a register.

llvm-svn: 46552
2008-01-30 07:01:17 +00:00
Chris Lattner e850fa2452 make this pass by adding an expected error, add some tests.
llvm-svn: 46551
2008-01-30 06:46:30 +00:00
Chris Lattner dd830b9c8b Eli points out this can only happen for scalar elements.
llvm-svn: 46550
2008-01-30 06:08:20 +00:00
Chris Lattner 6ebd38deae Be more explicit about what flavors of initlistexpr's we can see. I don't
know if all of this is exactly right, but it seems like the right thing to
aim for.  Steve, please review.

llvm-svn: 46549
2008-01-30 05:53:56 +00:00
Chris Lattner 86f5e13224 move some constructors out of line and fix indentation in ObjCAtThrowStmt::getSourceRange.
llvm-svn: 46547
2008-01-30 05:01:46 +00:00
Eli Friedman 9d92ce8b3a Make sure to emit all the arguments to a function call. This fixes the
codegen of calls to functions without a prototype and varargs functions, 
including printf.

llvm-svn: 46543
2008-01-30 01:32:06 +00:00
Steve Naroff 1e7873642b Many refinements to Sema::MergeVarDecl(). This routine still needs some re-work to fully handle tentative decls.
This includes a fix to bz1908.

llvm-svn: 46540
2008-01-30 00:44:01 +00:00
Ted Kremenek 162bb8060e Added method "markInfeasible" to GRBranchNodeBuilder to disable the
auto-propagation of state along a branch.

llvm-svn: 46537
2008-01-29 23:36:02 +00:00
Ted Kremenek 7ff1893f86 Implemented more boilerplate in GREngine for processing branches. Now
we automatically generate a new successor node along an edge if the checker
did not explicitly do so (i.e., we just propagate the current state).

llvm-svn: 46536
2008-01-29 23:32:35 +00:00
Ted Kremenek ee2d5a540c Fixed bit-setting bug for ExplodedNodeImpl::NodeGroup.
llvm-svn: 46535
2008-01-29 23:31:09 +00:00
Devang Patel 45a65d2ee1 Handle incomplete struct initializer.
llvm-svn: 46534
2008-01-29 23:23:18 +00:00
Fariborz Jahanian 284011b462 Rewriting of @synchronized. This has one FIXME in it. But this should allow @sychronized to be rewritten.
llvm-svn: 46533
2008-01-29 22:59:37 +00:00
Ted Kremenek 9b4211d25d Added boilerplate logic in GREngine for processing branches.
llvm-svn: 46532
2008-01-29 22:56:11 +00:00
Ted Kremenek b2cad31aae Renamed GRNodeBuilder to GRStmtNodeBuilder.
llvm-svn: 46531
2008-01-29 22:11:49 +00:00
Ted Kremenek 71b49503d8 Minor fix in transfer function of '!=' where a 'false' literal should
have been 'true'.

llvm-svn: 46530
2008-01-29 21:27:49 +00:00
Ted Kremenek 15ad4cf46b - Hooked up deserialization of ObjCAtSynchronizedStmt Stmt::Create().
- Some minor optimizations of the encoding format for ObjCAtSynchronizedStmt.
- Reordered methods so that the deserialization methods for 
  ObjCAtSynchronizedStmt appear in alphabetical order with the corresponding
  methods of the other AST nodes.

llvm-svn: 46529
2008-01-29 21:21:30 +00:00
Ted Kremenek 8d5bfe5844 Added preliminary transfer function support for '==' and '!='.
Made some internal API cleanups with creating ConcreteInt values, which lead to
some code reduction in implementing "++", "--".

llvm-svn: 46528
2008-01-29 19:43:15 +00:00
Fariborz Jahanian 48085b86ae AST for @synchronized.
llvm-svn: 46524
2008-01-29 19:14:59 +00:00
Steve Naroff ddb1dd8c5f Tighten up ASTContext::typesAreCompatible()...it needs to make sure the qualifiers match. The comment and C99 citation for this routine were correct...the code needed to conform to the comment/spec. This fixes the test added below.
Tightening up this routine forced tweaks to Sema::CheckSubtractionOperands() and Sema::CheckCompareOperands(). For example, they both need to operate on the unqualified pointee...

llvm-svn: 46522
2008-01-29 18:58:14 +00:00
Fariborz Jahanian f89ca383d7 Bunch of type defs, etc. for @synchronized.
llvm-svn: 46520
2008-01-29 18:21:32 +00:00
Eli Friedman 7031d734ed Fix a bug where CodeGen would attempt to erase an instruction that was
already used.

llvm-svn: 46519
2008-01-29 18:13:51 +00:00
Ted Kremenek b6056cfea4 Added "SymbolManager", which manages the set of symbolic values used
for analyzing a function.

The initial state for GRConstants now assigns symbolic values to parameters.

llvm-svn: 46517
2008-01-29 17:27:31 +00:00
Anders Carlsson a8dc3e6b52 Implement __builtin_offsetof.
llvm-svn: 46515
2008-01-29 15:56:48 +00:00
Chris Lattner f6df8e9702 fix comment typo
llvm-svn: 46505
2008-01-29 07:59:54 +00:00
Chris Lattner 5440b94ccf add diagnostic
llvm-svn: 46504
2008-01-29 07:59:42 +00:00
Chris Lattner 0c8a1edb8b Fix a bug where we would incorrectly emit a "cannot paste" error
message when handling the GNU ", ## __VA_ARGS__" extension.  While
I'm at it, flag uses of this as extensions.

llvm-svn: 46503
2008-01-29 07:54:23 +00:00
Eli Friedman 361de6164d Use the canonical type when comparing array types so the comparison
doesn't get confused by typedefs.

llvm-svn: 46502
2008-01-29 07:51:12 +00:00
Anders Carlsson d7d5e4ce00 Improvements to ccc. Patch by Shantonu Sen.
llvm-svn: 46501
2008-01-29 07:21:34 +00:00
Ted Kremenek 75bc4cd620 Fixed bug where not all dead subexpressions were being pruned from the analysis
state.

llvm-svn: 46491
2008-01-29 05:25:31 +00:00
Ted Kremenek 8ff7705a6c Modified LiveVariables to perform all of its base initialization in the ctor,
and now we require a FunctionDecl* object so that we can also keep track of
all of the ParmDecls.

Modified clients of LiveVariables to conform to the new interface.

llvm-svn: 46490
2008-01-29 05:13:23 +00:00
Steve Naroff 31daee11be Tweak Sema::DefaultArgumentPromotion() to call UsualUnaryConversions(). This makes sure function calls that don't have a prototype get the default function/array conversion.
Patch by Eli Friedman!

llvm-svn: 46489
2008-01-29 02:42:22 +00:00
Anders Carlsson ce0740e1f5 Handle binary or in constant expressions.
llvm-svn: 46482
2008-01-29 01:33:32 +00:00
Anders Carlsson 0674a7417f Correctly handle constants that refer to enums.
llvm-svn: 46481
2008-01-29 01:28:48 +00:00
Anders Carlsson 6f2a10e8c9 Correctly handle scalars in braces.
llvm-svn: 46480
2008-01-29 01:15:48 +00:00
Ted Kremenek e3d965f4b1 Added skeleton code for tracking the values of function parameters.
llvm-svn: 46477
2008-01-29 00:43:03 +00:00
Ted Kremenek 997d872375 Driver now passes the top-level FunctionDecl* to GRConstants.
Refactoring: for GREngine and GRConstants, pushed references to CFG, ASTContext,
and the top-level FunctionDecl into ExplodedGraphImpl.

llvm-svn: 46475
2008-01-29 00:33:40 +00:00
Steve Naroff f06b5ba047 Fix bz1950. ASTContext::functionTypesAreCompatible() needs to operate on the unqualified parameter types (per C99 6.7.5.3p15).
llvm-svn: 46472
2008-01-29 00:15:50 +00:00
Ted Kremenek 64d9524dcb Added RValue class "UninitializedValue".
llvm-svn: 46471
2008-01-28 22:51:57 +00:00
Ted Kremenek fe9cf4f38b Added transfer function logic for "%=" operator.
llvm-svn: 46470
2008-01-28 22:28:54 +00:00
Ted Kremenek 7e67036f2f Added transfer function hookups for "modulo" operator.
llvm-svn: 46468
2008-01-28 22:26:15 +00:00
Ted Kremenek 5b8cd80897 Minor tweaking with hierarchy of NonLValue objects: SymbolValue is
now SymbolicNonLValue.

Cleaned up some casts.

llvm-svn: 46467
2008-01-28 22:25:21 +00:00
Ted Kremenek 17a739681c Some additional cleanups with method names.
Renamed ExprValue to RValue, as all expression values are RValues, and this
keeps with the C terminology (renamed old "RValue" class to "NonLValue").

Introduced "ConcreteInt", a class that represents a concrete, integer
constant as an RValue.

Temporarily removed classes to represent set of possible constants and set of !=
constants. Will replace with a more general class representing a set of
constraints.

Added some foundational code to track "symbolic" values, which are used to
accrue constraints on an abstract value that is shared between multiple
variables.  e.g:

   x = y;      // at this point "x" and "y" share the same "value"
   if (x > 1) 
     ...       // at this point, the value shared by "x" and "y" is "> 1".

llvm-svn: 46466
2008-01-28 22:09:13 +00:00
Steve Naroff 1f7f6929f4 Implement "private extern" on function decls!
llvm-svn: 46464
2008-01-28 21:57:15 +00:00
Steve Naroff 909651a6ed Add -Wno-rewrite-macros to silence the following warning when using -rewrite-test:
xx.m:10:3: warning: rewriting sub-expression within a macro (may not be correct)

llvm-svn: 46462
2008-01-28 21:34:52 +00:00
Steve Naroff aeb6b30f64 Fix a bug with struct initializers (in Sema::CheckInitializerListTypes()).
Test case included from bz1948 (thanks Neil!).
Also fixed an 80 column violation...

llvm-svn: 46430
2008-01-28 02:00:41 +00:00
Chris Lattner 02bf44436f Make -o work with -E, patch contributed by Shantonu Sen!
llvm-svn: 46426
2008-01-27 23:55:11 +00:00
Anders Carlsson 8a88c3815a Tweaks to EmitLValue in CGExprConstant. Patch by Eli Friedman.
llvm-svn: 46389
2008-01-26 04:30:23 +00:00
Anders Carlsson a413911373 Add CodeGen for AddrOf in constant initializers. Original patch by Eli Friedman.
llvm-svn: 46388
2008-01-26 02:08:50 +00:00
Anders Carlsson 610ee7134e Factor out the constant generation into its own file.
llvm-svn: 46386
2008-01-26 01:36:00 +00:00
Ted Kremenek 95a123c0ec Added back logic in patch r46361 (http://llvm.org/viewvc/llvm-project?rev=46361&view=rev) with the addition of
some previously missing NULL pointer checks.

Modified the UninitializedValues analysis to not expect that every Expr* at the
block-level is a block-level expression (we probably need to change the name of
such expressions to something truer to their meaning).

llvm-svn: 46380
2008-01-26 00:03:27 +00:00
Ted Kremenek 5588c9e9ce Implemented transfer function for '/='.
llvm-svn: 46379
2008-01-25 23:45:34 +00:00
Ted Kremenek 2b8a7c80b8 Further refactoring of transfer functions by having APSIntSetOp take
a template-template parameter.

llvm-svn: 46378
2008-01-25 23:43:12 +00:00
Ted Kremenek 0cb1ba2c5e Reverting r46361 (http://llvm.org/viewvc/llvm-project?rev=46361&view=rev) until
I diagnose the source of the failures it causes in the test suite.

llvm-svn: 46376
2008-01-25 23:22:27 +00:00
Ted Kremenek ec5a444de6 Renamed RValueDisjunctiveEqual to RValEqualityORSet.
Renamed RValueConjunctiveUnequal to RValInequalityANDSet.

Refactored add/subtract/multiple (and now divide) operations for
RValEqualityORSet to be based on a single template function.

llvm-svn: 46374
2008-01-25 22:55:56 +00:00
Steve Naroff fda820970a Add more support for Apple's "private extern" extension...
llvm-svn: 46371
2008-01-25 22:14:40 +00:00
Ted Kremenek 109e362fbd Fixed 80 col. violation.
llvm-svn: 46370
2008-01-25 22:07:26 +00:00
Ted Kremenek 555855c779 Renamed RValueMayEqualSet to RValueDisjunctiveEqual.
llvm-svn: 46368
2008-01-25 22:06:07 +00:00
Chris Lattner 77927cc33c Add support for dispatching an objc message to a variable
in an initializer list.

llvm-svn: 46367
2008-01-25 19:43:26 +00:00
Chris Lattner 8917c5ace2 First half of a fix for the "objc message send in initializer" bug. This only
handles message sends with typenames to start with.

llvm-svn: 46366
2008-01-25 19:37:24 +00:00
Chris Lattner e10c6da41e Factor a complex predicate out to a helper method.
llvm-svn: 46365
2008-01-25 19:25:00 +00:00
Chris Lattner de001c186e fix isIntegerConstantExpr evaluation of unary !.
llvm-svn: 46364
2008-01-25 19:16:19 +00:00
Chris Lattner 8f6970663a split the second half of ParseObjCMessageExpression into a new
ParseObjCMessageExpressionBody method.

llvm-svn: 46363
2008-01-25 18:59:06 +00:00
Chris Lattner b241a1ba4c remove an implemented todo
llvm-svn: 46362
2008-01-25 18:58:06 +00:00
Ted Kremenek 463b726698 When adding assignment expressions to the set of block-level expressions, only
include the assignment expressions whose result (as in the value of the
expression) is used by other expressions.

llvm-svn: 46361
2008-01-25 18:28:28 +00:00
Fariborz Jahanian cc9c5452d1 Diagnose bad receiver type.
llvm-svn: 46358
2008-01-25 17:43:39 +00:00
Seo Sanghyeon d145ac0b34 Implement -print-prog-name. Patch by Nuno Lopes.
llvm-svn: 46353
2008-01-25 14:57:54 +00:00
Nate Begeman 43eec490fb Support checking and codegen of constant vector globals
llvm-svn: 46343
2008-01-25 05:34:48 +00:00
Steve Naroff 78c6cdf95e Replace Sema::CheckVariableInitList, CheckConstantInitList, and CheckForCharArrayInitializer with CheckInitializerListTypes. The new routine now supports struct/union initializers.
This is a modified version of a patch by Eli Friedman. This version passes all of the clang tests and supports vectors:-)

Note that Eli and I are still unsatisfied the implementation of CheckInitializerListTypes(). We'd like to find a more elegant implementation. Nevertheless, this is a complex part of the standard (and may be hard to simplify). Since the complexity is localized to this routine, we can iterate without too much disruption:-)

llvm-svn: 46339
2008-01-25 00:51:06 +00:00
Chris Lattner 3efff5472b Fix a bug recovering from broken code with a goto that Eli reported.
llvm-svn: 46336
2008-01-25 00:01:10 +00:00
Chris Lattner 9046dc1080 Change the location we return for the EOF token to actually be on the last
line of the file, in the common case where a file ends with a newline.

llvm-svn: 46335
2008-01-25 00:00:30 +00:00
Chris Lattner 01b322cb02 Don't add an extra line to the end of the buffer, it doesn't really exist.
llvm-svn: 46330
2008-01-24 23:25:53 +00:00
Ted Kremenek 8a025806a4 Some minor restructuring around LValue and RValue types. The value "kind"
information is not separated into a "base" and "sub" type. Eventually the
value-tracking logic will know about LValues and RValues, but not about
specialized LValues and RValues; separating the "kind" information into bits
indicating whether an ExprValue is an LValue or an RValue from the bits that
specify the actual value type makes this separation easier.

llvm-svn: 46329
2008-01-24 23:19:54 +00:00
Steve Naroff d9d581fc7b Exclude vectors from Type::isScalar() predicate.
llvm-svn: 46328
2008-01-24 22:55:05 +00:00
Ted Kremenek f3d6d668b6 enum value name change.
llvm-svn: 46327
2008-01-24 22:44:24 +00:00
Ted Kremenek 3e742f9184 More cleanups to pretty-printing of states in GraphViz output.
llvm-svn: 46326
2008-01-24 22:27:20 +00:00
Ted Kremenek 053527478b Added transfer function for DeclStmt.
llvm-svn: 46323
2008-01-24 20:55:43 +00:00
Ted Kremenek 1fba169ce0 Adjusted storage of values for Stmt* so that we need only query if
a Stmt* is a block-level expression when we INSERT a value into the map, and
not also when we QUERY a value.

llvm-svn: 46321
2008-01-24 19:43:37 +00:00
Ted Kremenek fa8062c162 Fixed a bug where the values of block-level expressions were being recorded in
the value map as if the expressions were non-block-level expressions.

llvm-svn: 46319
2008-01-24 19:28:01 +00:00
Ted Kremenek 286f030911 Minor tweaks in the transfer functions for pre- and post- ++/-- where
we falsely constructed an APInt to represent the constant '1' instead of
using an APSInt (which has a sign).

llvm-svn: 46317
2008-01-24 19:00:57 +00:00
Ted Kremenek c9052ff8fd Added support for unary operator '-' for equality sets.
Added some workarounds for loss of signess information on some APSInt
operations. Considering the best route to integrate these into APSInt directly.
(FIXME's in GRConstants.cpp).

llvm-svn: 46310
2008-01-24 08:20:02 +00:00
Ted Kremenek 1c91a67086 Added transfer functions for pre- and post- increment/decrement operators.
llvm-svn: 46300
2008-01-24 02:28:56 +00:00
Ted Kremenek 33d8285b8d Added passing "ASTContext" to both GREngine and GRConstants.
Added initial support for integer casting operations to GRConstants.

llvm-svn: 46298
2008-01-24 02:02:54 +00:00
Ted Kremenek 4f1da522ca Minor tweak in GetValue to avoid an extra check for ParenExprs.
llvm-svn: 46294
2008-01-24 00:50:08 +00:00
Ted Kremenek 2517423c3c Implemented value tracking support for '*' and '*='.
Added "multiplication" support for equality sets.

llvm-svn: 46289
2008-01-23 23:42:27 +00:00
Ted Kremenek 5e02dc1b46 Implemented value tracking support for '+=' and '-='.
llvm-svn: 46288
2008-01-23 23:38:00 +00:00
Chris Lattner 2dd606839d add some assertions so that the rewriter dies violently with a useful
error instead of subtly with a mysterious one.

llvm-svn: 46287
2008-01-23 23:37:15 +00:00
Ted Kremenek cefae084a3 Removed extra GraphViz node attributes for GRConstants, as some of them were
causing problems with Dot.

llvm-svn: 46285
2008-01-23 22:54:57 +00:00
Ted Kremenek 930191c011 some prettying of the GraphViz visualization of GRConstants analysis results.
llvm-svn: 46284
2008-01-23 22:30:44 +00:00
Fariborz Jahanian 60a901621f Fixed a nasty bug which took a while to come up with a test case,
diagnose, and took even longer to fix. It has to do with rewriting of a message
receiver which is an 'ivar' reference. Fix, however, is to remove a code which
was not doing the right thing and no longer needed.

llvm-svn: 46279
2008-01-23 20:34:40 +00:00
Ted Kremenek 0a8d3767a3 Major "architectural" changes to the GRConstants analysis. We now reason about
abstract "L-values" and "R-values" when doing value tracking, and expanding
constant tracking to encompass tracking disjunctive sets of possible constants.
Further, the tree-walking is more efficient, as we don't blindly recurse the
tree if we won't generate new states.

llvm-svn: 46278
2008-01-23 19:59:44 +00:00
Chris Lattner 7238225c28 add support for -Wundef.
llvm-svn: 46274
2008-01-23 17:19:46 +00:00
Fariborz Jahanian 54e42318c0 Missing ObjC stuff. Patch by Mike Stump.
llvm-svn: 46268
2008-01-23 01:34:33 +00:00
Fariborz Jahanian 0a71ad2e07 Problem with ObjC's type-encoding of nested structs causing infinit recursion.
llvm-svn: 46260
2008-01-22 22:44:46 +00:00
Lauro Ramos Venancio db449040aa Fix a typo.
llvm-svn: 46259
2008-01-22 22:38:35 +00:00
Lauro Ramos Venancio 09af71c2a6 Implement bitfield write.
llvm-svn: 46258
2008-01-22 22:36:45 +00:00
Lauro Ramos Venancio 2ddcb25a3b Implement bitfield read.
llvm-svn: 46257
2008-01-22 20:17:04 +00:00
Chris Lattner 97ff7763dc Fix PR1936, a crash on malformed #if. Thanks to Neil for
noticing this!

llvm-svn: 46256
2008-01-22 19:34:51 +00:00