Commit Graph

3405 Commits

Author SHA1 Message Date
Fariborz Jahanian 386699515b Computed length of a __func__ identifier used in an objective-c method correctly,
when creating its type.

llvm-svn: 46109
2008-01-17 01:36:09 +00:00
Seo Sanghyeon 15051b4caf Ignore --param
llvm-svn: 46107
2008-01-17 01:08:43 +00:00
Ted Kremenek e780f408b1 Added some experimental optimizations to remove dead values from the
state.

llvm-svn: 46106
2008-01-17 00:52:48 +00:00
Steve Naroff 1aa1941889 Declarator::clear(): Null out variable after it's been deleted.
This avoids a double free (which is good:-)

Bug submitted by Eli.

llvm-svn: 46105
2008-01-17 00:36:28 +00:00
Steve Naroff d8583eb993 Simplify comment.
llvm-svn: 46103
2008-01-16 23:56:32 +00:00
Steve Naroff 8a0abea999 Type::isArithmeticType(): disallow incomplete enum decls.
Bug submitted by Eli.

llvm-svn: 46102
2008-01-16 23:54:22 +00:00
Ted Kremenek 506e507508 Changed sorting criteria for DSPtr to put sub-expressions first in the value
map. This will allow us to quickly prune them from maps without searching the
entire map.

llvm-svn: 46101
2008-01-16 23:35:31 +00:00
Ted Kremenek 692b01b0be Changed sorting criteria for DSPtr to sort Decl* before Expr*, and
to sort sub-expressions before Block-level expressions.

llvm-svn: 46100
2008-01-16 23:33:44 +00:00
Ted Kremenek a14396d51d IntegerLiterals are no longer evaluated to create separate nodes; their
values are determined when evaluating the parent expression.

llvm-svn: 46096
2008-01-16 22:28:08 +00:00
Ted Kremenek 493444fc19 Fixed bug where we performed addition instead of subtraction during
constant propagation.

llvm-svn: 46095
2008-01-16 22:20:36 +00:00
Ted Kremenek e914bb8183 Fixed iterator bug in ExplodedNodeImpl::NodeGroup::end(); we would improperly
handle the case where the number of nodes was 0.

Fixed bug in GREngineImpl where we did not proceed to the next statement
when processing a PostStmt location.

llvm-svn: 46093
2008-01-16 22:13:19 +00:00
Ted Kremenek ac886cb835 Added initial graph visualization support for the GRConstants analysis.
llvm-svn: 46092
2008-01-16 21:46:15 +00:00
Ted Kremenek 873bbd53a4 Fixed invalid typedefs in the root and eop iterators for ExplodedGraph.
llvm-svn: 46091
2008-01-16 21:45:54 +00:00
Ted Kremenek 88d5909bed Added support from retrieving stored values to variables.
llvm-svn: 46087
2008-01-16 19:47:19 +00:00
Ted Kremenek 47b62c1a5f Added support for assignments in GRConstants.
llvm-svn: 46086
2008-01-16 19:42:59 +00:00
Ted Kremenek 7e7070b594 Fixed bug where GRConstants::AddBindings() did not check for values
that were "not a constant."

llvm-svn: 46085
2008-01-16 19:28:16 +00:00
Ted Kremenek deac51943a Fixed bug in cleanup of nodes in ExplodedNodeImpl where we should directly
call the dstor instead of using delete.

llvm-svn: 46084
2008-01-16 19:27:42 +00:00
Chris Lattner a65e1f3b31 Move promoteExprToType from being a static method in SemaExpr.cpp to being
a method named ImpCastExprToType in Sema.

Use this method to insert implicit casts for case statements from their 
operand type to the condition type of the switch.  This fixes a crash on
test/CodeGen/statements.c, reported by Eli Friedman.

llvm-svn: 46083
2008-01-16 19:17:22 +00:00
Chris Lattner 45b985c664 add accessors to switchstmt.
llvm-svn: 46082
2008-01-16 19:16:00 +00:00
Ted Kremenek 334139f58e Fixed broken bitmasking in the ctor of ProgramPoint.
llvm-svn: 46081
2008-01-16 19:11:06 +00:00
Ted Kremenek 29a9d00a56 Added missing call to the checker's Initialize() method in the alternate
ctor for GREngine.

llvm-svn: 46080
2008-01-16 18:59:52 +00:00
Ted Kremenek 34eb8bb3bd Added missing ctor to ExplodedGraph.
llvm-svn: 46079
2008-01-16 18:59:09 +00:00
Ted Kremenek f81d2c9a06 Fixed incorrect pointer mask.
llvm-svn: 46078
2008-01-16 18:58:48 +00:00
Ted Kremenek db0b651de9 Shortened driver option for running the GR-constants analysis to --grconstants.
llvm-svn: 46076
2008-01-16 18:21:49 +00:00
Ted Kremenek 7773c4fafd Add missing header file for GRConstants analysis.
llvm-svn: 46075
2008-01-16 18:19:20 +00:00
Ted Kremenek 2e12c2e790 Hooked up the GRConstants analysis to the driver.
Fixed some compilation errors with GREngine that showed up during
template instantiation.

llvm-svn: 46074
2008-01-16 18:18:48 +00:00
Ted Kremenek 2d700ed2ba More cleanups in DoStmt. The NodeSets are now vectors instead of sets, since
node caching in GREngine will guarantee that we do not insert a node twice into
a nodeset.

llvm-svn: 46071
2008-01-16 17:56:25 +00:00
Steve Naroff 17832a48f8 Sema::MergeFunctionDecl()...make sure diagnostic is accurate (wrt function declarations/definitions). Patch by Carl Lewis!
llvm-svn: 46070
2008-01-16 15:01:34 +00:00
Ted Kremenek 73e5f2bb17 Adjusted DSPtr::Profile method again, since my last patch broke the build.
llvm-svn: 46051
2008-01-16 05:51:13 +00:00
Ted Kremenek 29185f17e9 Changed 'Profile' method for DSPtr to incorporate the flags from the
variant type, and not just the pointer value.

llvm-svn: 46049
2008-01-16 05:49:09 +00:00
Ted Kremenek fb55354fc9 Renamed some internal classes for the GR-Constant Propagation analysis.
Cleaned up GRConstants::AddBinding to not directly reference the
predecessor node.  Now we just manipulate the current state, and a driver
function creates nodes as needed.

llvm-svn: 46040
2008-01-16 00:53:15 +00:00
Fariborz Jahanian 19d42bf0a5 Typo.
llvm-svn: 46038
2008-01-16 00:09:11 +00:00
Fariborz Jahanian b860cbf052 Added support for rewriting of continue/break statements inside ObjC2's foreach-stmt.
llvm-svn: 46037
2008-01-15 23:58:23 +00:00
Ted Kremenek de8d62b132 Added skeleton implementation of new constant-prop. analysis using
the graph reachability engine.

llvm-svn: 46036
2008-01-15 23:55:06 +00:00
Ted Kremenek 03bc2afa65 Added ctor to GRNodeBuilder.
llvm-svn: 46035
2008-01-15 23:54:22 +00:00
Steve Naroff abefc391dd Finish up handling all permutations of "complex int" (in Sema::UsualArithmeticConversions()).
A FIXME remains to verify the conversion rules are consistent with GCC.

Thanks to Eli for the new/improved test case...

llvm-svn: 46022
2008-01-15 22:21:49 +00:00
Steve Naroff 6fcfd0581d - Change Type::isComplexType() to exlude GCC's complex integer extension. In general, we will keep the lowest level Type predicates "pure" (i.e. true to the C99 spec).
- Modify Sema::UsualArithmeticConversions() to work with the new definition of Type::isComplexType().

This is a nice cleanup and also fixes a bug submitted by Eli (which I've added to the test suite).

llvm-svn: 46005
2008-01-15 19:36:10 +00:00
Chris Lattner 15346fae70 avoid pasting L + "foo" into L"foo".
llvm-svn: 46000
2008-01-15 05:22:14 +00:00
Chris Lattner 877ca77420 avoid token pasting between identifiers and wide strings:
abc+L"foo" -> abc L"foo", not abcL"foo"

llvm-svn: 45999
2008-01-15 05:14:19 +00:00
Steve Naroff 8115902d6c Add a comment...
llvm-svn: 45993
2008-01-15 02:05:07 +00:00
Steve Naroff 7f988889ef Rework commit r45976, which was incorrect.
- Add Type::isComplexIntegerType(), Type::getAsComplexIntegerType().
- Don't inlude complex types with Type::isIntegerType(), which is too general.
- Use the new predicates in Sema::UsualArithmeticConversions() to recognize/convert the types.

llvm-svn: 45992
2008-01-15 01:41:59 +00:00
Ted Kremenek e584359716 Removed implicit transitions to a "BlockExit" location; we now handle
the end of the block by processing empty blocks (at BlockEntrance) or
when we have just processed the last statement in a block (at PostStmt).

llvm-svn: 45991
2008-01-15 00:24:08 +00:00
Ted Kremenek 619bd1a8a0 Removed mutation of CFGBlock through operator[]. For now the underlying ASTs,
however, can still be manipulated through the returned Stmt*.

llvm-svn: 45990
2008-01-15 00:18:01 +00:00
Steve Naroff d8c7d484af Make sure Sema::GetTypeForDeclarator() deals with abstract declarators when diagnosing incorrect code.
Bug submitted by Eli.

llvm-svn: 45989
2008-01-14 23:33:18 +00:00
Ted Kremenek 3e743661c5 Added prototype implementation of path-sens. analysis core engine.
llvm-svn: 45986
2008-01-14 23:24:37 +00:00
Ted Kremenek 50fd838140 Added operator[] for CFGBlock. This provides random access to the statements
of a block.

llvm-svn: 45984
2008-01-14 23:18:55 +00:00
Chris Lattner 49f980c334 Fix build issue on cygwin, patch by Sam Bishop
llvm-svn: 45977
2008-01-14 21:47:29 +00:00
Steve Naroff c28f46c6b4 Teach Type::isIntegerType() about GCC's __complex__ integer extensions...
Bug submitted by Eli.

llvm-svn: 45976
2008-01-14 21:38:57 +00:00
Steve Naroff 012484d6c8 Fix crasher when redefining functions. Not 100% pleased with this solution, but it is clearly an improvement. Will discuss with Chris later.
llvm-svn: 45975
2008-01-14 20:51:29 +00:00
Ted Kremenek cb994b6a72 Cleaned up comment.
llvm-svn: 45970
2008-01-14 18:42:38 +00:00
Ted Kremenek 94acc6ac9a Cleaned up comment.
llvm-svn: 45969
2008-01-14 18:41:42 +00:00
Ted Kremenek a018a2c0f4 When serializing CompoundLiteralExpr, serialize out the file scope flag before
serializing the subexpression (Init), as this results in a more efficient
encoding in the bitstream.

llvm-svn: 45967
2008-01-14 18:29:39 +00:00
Steve Naroff d32419de0d Record if a compound literal expression is @ file scope. This allows us to implement C99 6.5.2.5p6. This could have been done without modifying the AST (by checking the decl type and passing the info down to isContextExpr), however we concluded this is more desirable.
Bug/patch by Eli Friedman!

llvm-svn: 45966
2008-01-14 18:19:28 +00:00
Ted Kremenek d065a790d9 Removed 'inline' keywords from methods now defined in ExplodedGraph.cpp.
llvm-svn: 45965
2008-01-14 18:11:35 +00:00
Ted Kremenek a0a3e9bb07 Change uses of std::cerr/std::cout to llvm::Lcerr/llvm::cout, and remove
#include<iostream>.

Patch provided by Sam Bishop.

llvm-svn: 45962
2008-01-14 16:44:48 +00:00
Steve Naroff 4871fe0b8f Revert r45951, Chris says it violates the C99 spec.
llvm-svn: 45961
2008-01-14 16:10:57 +00:00
Anders Carlsson a1afcab6f9 _asm is another valid alias for asm.
llvm-svn: 45957
2008-01-14 07:46:40 +00:00
Anders Carlsson 1ba25ca171 Add codegen upport for implicit casts to aggregate exprs.
llvm-svn: 45954
2008-01-14 06:28:57 +00:00
Chris Lattner f14ba63620 add a note
llvm-svn: 45953
2008-01-14 06:27:57 +00:00
Chris Lattner fd65291aa3 Fix ASTContext::typesAreCompatible when analyzing a function type with
proto and function type without proto.  It would never call 
'functionTypesAreCompatible' because they have different type classes.

llvm-svn: 45952
2008-01-14 05:45:46 +00:00
Steve Naroff 090353191c Rewrite Expr::isNullPointerConstant() to deal with multiple levels of explicit casts.
Now, isNullPointerConstant() will return true for the following: "(void*)(double*)0"

llvm-svn: 45951
2008-01-14 02:53:34 +00:00
Steve Naroff 826e91ae04 Change Sema::CheckAddressOfOperation() to respect C99-only addressof rules.
Remove diagnostics from Sema::CheckIndirectionOperand(). C89/C99 allow dereferencing an incomplete type. clang appears to be emulating some incorrect gcc behavior (see below).

void
foo (void)
{
 struct b;
 struct b* x = 0;
 struct b* y = &*x; // gcc produces an error ("dereferencing pointer to incomplete type")
}

With this patch, the above is now allowed.

Bug/Patch by Eli Friedman!

llvm-svn: 45933
2008-01-13 17:10:08 +00:00
Ted Kremenek d122bbdb06 Moved destructor logic of templated class ExplodedGraph to non-templated
parent class ExplodedGraphImpl.

llvm-svn: 45930
2008-01-13 05:33:04 +00:00
Ted Kremenek 6d7aee6edd Added node cleanup to dstor of ExplodedGraph.
llvm-svn: 45929
2008-01-13 05:03:01 +00:00
Ted Kremenek eb370bc386 Created ExplodedGraph.cpp and moved most method implementations of
ExplodedNodeImpl::NodeGroup from being defined inline to being defined
"out-of-line" in ExplodedGraph.cpp. This removes a dependence on including
<vector> in ExplodedGraph.h, and will hopefully result in smaller generated code
with negligible performance impact.

llvm-svn: 45928
2008-01-13 04:56:13 +00:00
Ted Kremenek 49bbee0b1d Moved 'ExplodedNodeGroup' into class 'ExplodedNode' as the nested class
'NodeGroup.'

llvm-svn: 45927
2008-01-13 04:20:10 +00:00
Ted Kremenek 39dfeadd93 Fixed lines preventing compilation.
llvm-svn: 45926
2008-01-13 04:18:40 +00:00
Ted Kremenek 2ae51a5d27 Now include "CFG.h" because the inline methods of "BlockEntrance" accessor
the methods of CFGBlock.

llvm-svn: 45925
2008-01-13 04:08:45 +00:00
Ted Kremenek 990d7d5205 Fixed some comments.
llvm-svn: 45924
2008-01-13 04:03:38 +00:00
Ted Kremenek 76245f3ed0 Removed ExplodedNode.h, since its contents are now in ExplodedGraph.h
llvm-svn: 45923
2008-01-13 04:00:44 +00:00
Ted Kremenek 8f13ec74c4 Merged ExplodedNode.h into ExplodedGraph.h, since the ExplodedNode class will
only be used in the context of the ExplodedGraph class.

llvm-svn: 45922
2008-01-13 04:00:16 +00:00
Ted Kremenek cfe8235fa1 Changed implementation of successor and predecessor sets for ExplodedNode
to optimize for the common case of having a single predecessor and a single
successor.

llvm-svn: 45921
2008-01-13 03:55:50 +00:00
Chris Lattner 0a8c2325fc allow __func__ in objc methods.
llvm-svn: 45915
2008-01-12 19:32:28 +00:00
Chris Lattner 317e6ba07f Tighten up handling of __func__ and friends: it should be an array
of const char, and it should error if it occurs outside a function.

Is it valid in an objc method?  If so we should handle that too.

llvm-svn: 45910
2008-01-12 18:39:25 +00:00
Chris Lattner a81a0279cc Fix the type of predefined identifiers like __func__. Patch by
Eli Friedman!

llvm-svn: 45906
2008-01-12 08:14:25 +00:00
Chris Lattner 65531e8fb7 Fix a fixme, by only parsing extern "C" in C++ mode.
llvm-svn: 45905
2008-01-12 07:08:43 +00:00
Chris Lattner 38376f1595 Add first pieces of support for parsing and representing
extern "C" in C++ mode.  Patch by Mike Stump!

llvm-svn: 45904
2008-01-12 07:05:38 +00:00
Chris Lattner 177977ac19 When forming the squigly underline for a diagnostic, make sure to
verify that the source range corresponds to the current file, not
just the current line.  This allows us to emit:

a.c:1:44: error: invalid operands to binary expression ('double' and 'int *')
double a; int *b; void f(void) { int c = a +
                                         ~ ^

instead of:

a.c:1:44: error: invalid operands to binary expression ('double' and 'int *')
double a; int *b; void f(void) { int c = a +
~                                        ~ ^

for PR1906 (note the leading ~).

Thanks to Neil for noticing this.

llvm-svn: 45901
2008-01-12 06:43:35 +00:00
Ted Kremenek 8d71e25590 Fix misspelling of "existent".
Do not use std::cerr; use llvm::cerr instead.

Patch provided by Sam Bishop!

llvm-svn: 45880
2008-01-11 20:42:05 +00:00
Ted Kremenek 5906b9e79a Added ProgramPoint.cpp, which implements several methods of the subclasses
of ProgramPoint.

llvm-svn: 45866
2008-01-11 16:36:20 +00:00
Ted Kremenek b1dec454bb Renamed ProgramEdge.h to ProgramPoint.h
llvm-svn: 45847
2008-01-11 00:43:12 +00:00
Ted Kremenek e5ccf9a96c Renamed ProgramEdge to ProgramPoint and changed subclasses of ProgramEdge
to have a much simpler, cleaner interpretation of what is a "location"
in a function (as encoded by a CFG).

llvm-svn: 45846
2008-01-11 00:40:29 +00:00
Ted Kremenek d7a7abed62 Fixed 80-col violation.
llvm-svn: 45845
2008-01-11 00:18:40 +00:00
Fariborz Jahanian af5d80cba5 Avoid redefinition of __objcFastEnumerationState
llvm-svn: 45842
2008-01-10 23:04:06 +00:00
Steve Naroff 98f7203680 - Teach Expr::isConstantExpr() about InitListExpr's (and offsetof, since I noticed it was missing).
- Rename CheckInitializer() to CheckInitializerTypes().
- Removed the isStatic argument to CheckInitializerTypes() and all of it's subroutines. Checking for constant expressions is now done separately.
- Added CheckForConstantInitializer().

llvm-svn: 45840
2008-01-10 22:15:12 +00:00
Fariborz Jahanian 939776756f Recover from user typo not having proper @interface decl and a bad foreach decl.
llvm-svn: 45839
2008-01-10 20:33:58 +00:00
Fariborz Jahanian 2de9a0be09 Remove non-ascii chaaracter from diagnostic
llvm-svn: 45836
2008-01-10 18:10:31 +00:00
Ted Kremenek e67952fcd9 Fixed non-ASCII quote.
llvm-svn: 45835
2008-01-10 18:08:55 +00:00
Fariborz Jahanian c644ee4992 Warn (as gcc does) when @end does not close anything.
llvm-svn: 45834
2008-01-10 17:58:07 +00:00
Ted Kremenek aa8c904dfc Added some text about the ccc script provided by Sanghyeon Seo.
llvm-svn: 45820
2008-01-10 04:59:05 +00:00
Chris Lattner 2cbf2f39ee add support for the GCC -include option.
llvm-svn: 45810
2008-01-10 01:53:41 +00:00
Seo Sanghyeon 77133e6d30 Compiler driver
llvm-svn: 45809
2008-01-10 01:43:47 +00:00
Chris Lattner bceeefdc9c Fix some 80 col violations
llvm-svn: 45808
2008-01-10 01:43:14 +00:00
Chris Lattner d2cdb97747 Ted apparently likes crazy whitespace at the end of line. Crush his spirit by
removing them, fitting the file into 80 columns. :)

llvm-svn: 45807
2008-01-10 01:41:55 +00:00
Fariborz Jahanian 7262fca0a6 Put return type of synthesize method on same line as method declaration, space after method declaration header.
llvm-svn: 45806
2008-01-10 01:39:52 +00:00
Ted Kremenek 3d55c84c99 Added "InfeasibleEdge" to represent an infeasible state transition.
llvm-svn: 45802
2008-01-10 00:58:25 +00:00
Fariborz Jahanian db701b47d2 Pass rewritten output to 'clang' for verification.
llvm-svn: 45794
2008-01-10 00:30:24 +00:00
Fariborz Jahanian 82ae0152a7 Allow messaging expression as foreach's collection expression.
llvm-svn: 45793
2008-01-10 00:24:29 +00:00
Steve Naroff a385fb8c2e Add a FIXME to commit r45784. Thanks mrs!
llvm-svn: 45790
2008-01-09 23:44:05 +00:00
Steve Naroff e6b0ec8b5e Fix Sema::ActOnDeclarator() to call MergeFunctionDecl for function decls that aren't in scope. Since C functions are in a flat namespace, we need to give them special treatment (when compared with variables and typedefs).
llvm-svn: 45789
2008-01-09 23:34:55 +00:00