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

565 Коммитов

Автор SHA1 Сообщение Дата
Zhongxing Xu c3a0599bac Add support for symbolicating global structs and arrays in RegionStoreManager::getInitialStore().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59619 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 11:06:24 +00:00
Zhongxing Xu eabf776661 Add SymbolData for array elements and struct fields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59618 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 11:03:17 +00:00
Chris Lattner f4c8396577 rewrite FormatDiagnostic to be less gross and a lot more efficient.
This also makes it illegal to have bare '%'s in diagnostics.  If you
want a % in a diagnostic, use %%.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59596 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 06:51:40 +00:00
Ted Kremenek ab7b32b7d4 Fix warning about RegionStoreManager::Retrieve() not always returning a value.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59571 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 00:27:37 +00:00
Zhongxing Xu 9b6ceb1712 handle the case that the array element is of structure type when bind the whole array to a single value (for example, UnknownVal, UndefinedVal).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59521 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 13:11:04 +00:00
Chris Lattner 0a14eee528 This reworks some of the Diagnostic interfaces a bit to change how diagnostics
are formed.  In particular, a diagnostic with all its strings and ranges is now
packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a 
ton of random stuff.  This has the benefit of simplifying the interface, making
it more extensible, and allowing us to do more checking for things like access
past the end of the various arrays passed in.

In addition to introducing DiagnosticInfo, this also substantially changes how 
Diagnostic::Report works.  Instead of being passed in all of the info required
to issue a diagnostic, Report now takes only the required info (a location and 
ID) and returns a fresh DiagnosticInfo *by value*.  The caller is then free to
stuff strings and ranges into the DiagnosticInfo with the << operator.  When
the dtor runs on the DiagnosticInfo object (which should happen at the end of
the statement), the diagnostic is actually emitted with all of the accumulated
information.  This is a somewhat tricky dance, but it means that the 
accumulated DiagnosticInfo is allowed to keep pointers to other expression 
temporaries without those pointers getting invalidated.

This is just the minimal change to get this stuff working, but this will allow
us to eliminate the zillions of variant "Diag" methods scattered throughout
(e.g.) sema.  For example, instead of calling:

  Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
       SourceRange(BuiltinLoc, RParenLoc));

We will soon be able to just do:

  Diag(BuiltinLoc, diag::err_overload_no_match)
      << typeNames << SourceRange(BuiltinLoc, RParenLoc));

This scales better to support arbitrary types being passed in (not just 
strings) in a type-safe way.  Go operator overloading?!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59502 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 07:04:44 +00:00
Chris Lattner 470e5fc7b4 eliminate dependence of strange "Diagnostic::Report" method,
delete huge trailing whitespace to fit in 80 cols.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59497 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 06:07:40 +00:00
Chris Lattner 2383b7f6ae Change the diagnostics interface to take an array of pointers to
strings instead of array of strings.  This reduces string copying
in some not-very-important cases, but paves the way for future 
improvements.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59494 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 04:56:44 +00:00
Chris Lattner e837f931a8 cleanups and simplifications.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59491 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 04:44:58 +00:00
Ted Kremenek 34265e7133 Fold assertion into second valid else branch. This removes a compiler warning
where the control reaches the end of a non-void function and also allows the
compiler to generate better code.  When this assertion is false we can easily
add more else cases.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59468 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17 22:55:12 +00:00
Zhongxing Xu cb529b542a Enhance modularization: return a <state,loc> pair to let GRExprEngine modify the
environment.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59407 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 07:06:26 +00:00
Zhongxing Xu dc0a25d9bf Enhances SCA to process untyped region to typed region conversion.
- RegionView and RegionViewMap is introduced to assist back-mapping from
   super region to subregions.
 - GDM is used to carry RegionView information.
 - AnonTypedRegion is added to represent a typed region introduced by pointer
   casting. Later AnonTypedRegion can be used in other similar cases, e.g.,
   malloc()'ed region.
 - The specific conversion is delegated to store manager.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59382 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 04:07:26 +00:00
Zhongxing Xu 0adfbf6e72 Use the allocator of ExplodedGraph. The whole static analysis module uses it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59359 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-15 08:19:58 +00:00
Zhongxing Xu a09300a9db Improve zero value generation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59356 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-15 05:18:50 +00:00
Ted Kremenek 0fb7c61b14 Reduce permissiveness of assertion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59354 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-15 05:00:27 +00:00
Ted Kremenek 60595dab8b Reverted part of r59335: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20081110/009243.html
In that patch I added a bogus type promotion for unary '!'.

The real bug was more fallout from edges cases with compound assignments and conjured symbolic values.  Now the conjured value has the type of the LHS expression, and we do a promotion to the computation type.  We also now correctly do a conversion from the computation type back to the LHS type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59349 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-15 04:01:56 +00:00
Ted Kremenek 5631a73dbb Re-enable an assertion that I mistakenly removed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59348 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-15 02:35:08 +00:00
Ted Kremenek d291c8cd1f Use the correct QualType when creating the '0' constant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59343 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-15 00:40:08 +00:00
Ted Kremenek e04a5cb9af Implement FIXME in GRExprEngine::VisitUnaryOperator() to handle implicit conversions caused by the '!' operator. This required adding some logic to GRSimpleVals to reason about nonloc::LocAsInteger SVals. This code appears to work fine, but it should eventually be cleaned up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59335 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-15 00:20:05 +00:00
Ted Kremenek 96cbfd45c9 Flush llvm::errs() when printing out SVals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59334 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-15 00:16:53 +00:00
Ted Kremenek 06529aeadf Minor tweaks to liveness analysis:
- Block-expression for 'ObjCForCollectionStmt' is not alive before it occurs
- Recursively visit 'element' expression for ObjCForCollectionStmt to get liveness for referenced block-level expressions and variables.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59316 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 21:07:14 +00:00
Ted Kremenek 06fb99fb40 Second attempt at implementation transfer function support for ObjCForCollectionStmt. We now assume that the 'element' expression can be any lvalue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59313 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 19:47:18 +00:00
Ted Kremenek c2813f77ba Flow-sensitive uninitialized values analysis: properly handle the 'element' expression of ObjCForCollectionStmt (can be anything).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59312 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 18:21:25 +00:00
Douglas Gregor b4609806e9 Add a new expression node, CXXOperatorCallExpr, which expresses a
function call created in response to the use of operator syntax that
resolves to an overloaded operator in C++, e.g., "str1 +
str2" that resolves to std::operator+(str1, str2)". We now build a
CXXOperatorCallExpr in C++ when we pick an overloaded operator. (But
only for binary operators, where we actually implement overloading)

I decided *not* to refactor the current CallExpr to make it abstract
(with FunctionCallExpr and CXXOperatorCallExpr as derived
classes). Doing so would allow us to make CXXOperatorCallExpr a little
bit smaller, at the cost of making the argument and callee accessors
virtual. We won't know if this is going to be a win until we can parse
lots of C++ code to determine how much memory we'll save by making
this change vs. the performance penalty due to the extra virtual
calls.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59306 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 16:09:21 +00:00
Zhongxing Xu 37d682ac04 Improve comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59294 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 09:23:38 +00:00
Ted Kremenek 8f646002d8 Handle the case where 'element' in ObjCforCollectionstmt is not a DeclStmt or DeclRefExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59290 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 01:58:12 +00:00
Ted Kremenek 8d798c75b8 Rename header file.
Update include files.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59284 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-14 01:14:18 +00:00
Ted Kremenek 82bd99f4db - Revert r59229 and r59232: AllocRegion should be immutable.
- Temporarily disabled test Analysis/array-struct.c for region store.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59245 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 15:42:31 +00:00
Zhongxing Xu e4d139374c Process array base expression of any type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59240 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 09:48:44 +00:00
Zhongxing Xu cc0d0ec3a8 Array index might be unsigned. We have to generate a temporary signed value for
it to be evaluated by APSInt::operators.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59238 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 09:15:14 +00:00
Zhongxing Xu a4f28ffac7 Incomplete struct pointer can be used as a function argument.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59235 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 08:41:36 +00:00
Zhongxing Xu 6d82f9d338 Lift the pointer to alloca'ed region to the pointer to its first element.
This is required by some operations, e.g., *p = 1; p[0] = 1;.
Also set the AllocaRegion's type during the cast.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59232 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 07:58:20 +00:00
Zhongxing Xu 56af977305 Change AllocaRegion to subclass TypedRegion. We need to know ElementRegion's
type when assigning to it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59229 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 07:30:58 +00:00
Ted Kremenek 062e2f9a0e GRExprEngine/CFRefCount/GRSimpleVals: We don't do any special handling (yet) of vector types. Add explicit checks that when we process integers that they really are scalars.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59225 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 06:10:40 +00:00
Ted Kremenek f8cce1d83e Fix uninitialized variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59222 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 05:26:15 +00:00
Ted Kremenek 76dba7b67a GRExprEngine::VisitInitListExpr:
- Don't crash on vector types.
- Handle typedefs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59220 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-13 05:05:34 +00:00
Ted Kremenek bfcb712627 Update CFGStmtVisitor to recognize that ObjCForCollectionStmts are special block-level "expressions".
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59176 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 21:58:46 +00:00
Ted Kremenek 116ed0aba3 Shore up transfer function for ObjCForCollectionStmt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59162 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 21:12:46 +00:00
Ted Kremenek 8ded8d8e47 Use Stmt* instead of Expr* for block-level expression.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59161 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 21:12:18 +00:00
Ted Kremenek af3374187c Add (preliminary) transfer function support for ObjCForCollectionStmt. Still need to flesh out some logic.
When processing DeclStmt, use the new interface to StateManager::BindDecl.  Conjuring of symbols is now done in VisitDeclStmt.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59155 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 19:24:17 +00:00
Ted Kremenek b5abb429e7 Conjured symbols now bind to Stmt* instead of Expr*.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59154 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 19:22:47 +00:00
Ted Kremenek a441b7e913 Update method names involving GRStateRef. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59153 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 19:22:09 +00:00
Ted Kremenek d493163294 GRStateRef:
- Rename SetSVal to BindLoc
- Add BindDecl
- Add BindExpr

GRState:
- Environment now binds to Stmt* instead of Expr*.  This is needed for processing ObjCForCollectionStmt (essentially the declaration of the the 'element' variable can have an SVal attached to it).
- BindDecl no longer accepts Expr* for the initialization value; use SVal* instead.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59152 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 19:21:30 +00:00
Ted Kremenek 42577d145e StoreManager::BindDecl now takes an SVal* for the initialization value instead of an Expr* (which can be null). Lazy symbolication of conjured symbols is now the sole responsibility of GRExprEngine.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59151 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-12 19:18:35 +00:00
Ted Kremenek e219b8a9c0 Flow-sensitive uninitialized values analysis:
- Added support for ObjCForCollectionStmt
- Fixed bug where expression values would be always set to uninitialized when loops were involved


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59076 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 19:41:42 +00:00
Ted Kremenek e97d9db35c Accesses to a collection within a fast enumeration 'for' statement constitute a 'use'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59075 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 19:40:47 +00:00
Sebastian Redl 0518999d3a Introduce a single AST node SizeOfAlignOfExpr for all sizeof and alignof expressions, both of values and types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59057 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 17:56:53 +00:00
Ted Kremenek 8f5aab6961 Add transfer function support for ObjCForCollectionStmt to LiveVariables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59053 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 17:42:10 +00:00
Zhongxing Xu d2f016f8f2 Fix StringLiteral print bug.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59015 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 01:36:32 +00:00
Zhongxing Xu cc128b3242 Add pretty printing to StringRegion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58985 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-10 13:05:26 +00:00