Commit Graph

1845 Commits

Author SHA1 Message Date
Ted Kremenek 3a5aa768c6 Added static method "CFG::hasImplicitControlFlow".
This method is used to determine if an expression contains implicit
control-flow, and thus appears in a distinct statement slot in the CFG.

For example:

  (1) x = ... ? ... ? ...

  logically becomes:

  (1) ... ? ... : ...  (a unique statement slot for the ternary ?)
  (2) x = [E1]         (where E1 is actually the ConditionalOperator*)

A client of the CFG, when walking the statement at (2), will encounter
E1.  In this case, hasImplicitControlFlow(E1) == true, and the client
will know that the expression E1 is explicitly placed into its own statement
slot to capture the implicit control-flow it has.

llvm-svn: 41868
2007-09-11 22:08:24 +00:00
Ted Kremenek 3dd952ba72 Fixed bug where ternary expressions and GCC-style conditional expressions
where not reversing the order of their subexpression blocks.

Added feature where CallExprs are placed in their own statement slot in
a CFGBlock.  Thus we have a designated "return site" within a CFGBlock when
reasoning about function calls.

llvm-svn: 41866
2007-09-11 21:29:43 +00:00
Steve Naroff f2fb4ad08e - Add an ObjcIvarDecl AST node (a subclass of FieldDecl).
- Instantiate the node in Sema::ParseField(), based on the type of the TagDecl.
- Add Sema::ObjcAddInstanceVariable(), responsible for adorning/adding the ObjcIvarDecl.

llvm-svn: 41864
2007-09-11 21:17:26 +00:00
Fariborz Jahanian cfc3e4d346 Change ObjcMethodDecl class derivation.
llvm-svn: 41860
2007-09-11 18:45:55 +00:00
Ted Kremenek 2f1a79d329 For looking at "dead stores" in declarations, we now check to see
if the assigned value is a constant expression, e.g.:

int x = 0;

We then check to see if "x" is ever reassigned later.  If so, we don't
emit a warning.  This is because programmers frequently use defensive
programming to make sure a variable has a defined value.

llvm-svn: 41853
2007-09-11 17:24:14 +00:00
Ted Kremenek ca6c2b750b Fixed potential NULL dereference when iterating over a chain of Decls.
llvm-svn: 41848
2007-09-11 17:00:40 +00:00
Gabor Greif 412af03cee get rid of ugly "warning: no newline at end of file"
warnings that some compilers diagnose

llvm-svn: 41847
2007-09-11 15:32:40 +00:00
Ted Kremenek ba3fdc9daf Fixed isFunctionPointerType to correctly handle typedefs.
llvm-svn: 41814
2007-09-10 22:54:34 +00:00
Steve Naroff 4292bde14f Fix the following bug submitted by Justin Handville.
int main(int argc, char* argv[])
{
  return 0;
}

After speaking briefly with Chris, we decided this should be a front-end fix.

The fix...have Sema::GetTypeForDeclarator() do the default function/array conversion, as
I outlined in the 9/9 email on this topic.

Since this conversion is done before Sema::ParseParamDeclarator(), I thought I could
remove the conversion from Sema::ParseParamDeclarator(). Unfortunately, this didn't work.
The conversion apparently needs to be done in both places (which doesn't make sense to me).

Will investigate.

llvm-svn: 41811
2007-09-10 22:17:00 +00:00
Steve Naroff acb1e7478f Some small tweaks to the recent Objc support...
llvm-svn: 41803
2007-09-10 20:51:04 +00:00
Fariborz Jahanian 33d037441e Early patch to collect objective-c methods inserts them in
class object.

llvm-svn: 41801
2007-09-10 20:33:04 +00:00
Ted Kremenek bd9cc5ca89 Fixed LiveVariables to no longer track the liveness of function pointers
that refer to direct function calls.

Modified interface of LiveVariables to only track liveness of VarDecls.
This cleans up a bunch of edge cases, and removed the bug just mentioned.

llvm-svn: 41797
2007-09-10 17:36:42 +00:00
Ted Kremenek 5f64ca8ec5 Modified dumping of Decl information to including the Decl type.
llvm-svn: 41796
2007-09-10 17:32:55 +00:00
Ted Kremenek 0319fc07fc Added "isFunctionPointerType()" so that we can readily see if a DeclRefExpr
refers to a function.

llvm-svn: 41795
2007-09-10 17:20:54 +00:00
Ted Kremenek cfe207c112 Renaming of the LiveVariablesAuditor interface. Changed "Auditor" and
"Audit" to "Observer" and "Observe"

llvm-svn: 41794
2007-09-10 15:56:38 +00:00
Chris Lattner f8a3dadd40 Don't rely on ADL to find this member, patch by Justin Handville
llvm-svn: 41783
2007-09-08 01:29:20 +00:00
Ted Kremenek 35fff1e656 -check-dead-stores now no longer prints out the function declarations
for each function.  This was the behavior prior to the following patch:

http://llvm.org/viewvc/llvm-project?view=rev&revision=41779

llvm-svn: 41780
2007-09-07 23:54:15 +00:00
Ted Kremenek 45c9e96c2b Refactored driver options that perform analyses/work over CFGs to use
"CFGVisitor", which now handles all the boilerplate for iterating over
the function definitions in a translation unit and building the CFGs.
This logic was previously replicated for each driver option that used
CFGs.

The options -dump-cfg, -view-cfg, -check-dead-stores, and
-dump-live-variables now use this refactored code.

llvm-svn: 41779
2007-09-07 23:47:56 +00:00
Hartmut Kaiser ec7531c9f6 Fixed compilation on Windows.
Silenced a couple of warnings.
Added *.vcproj file for new clangAnalysis library.
Renamed Basic to clangBasic projects.

llvm-svn: 41767
2007-09-07 14:34:20 +00:00
Ted Kremenek 3ce57c6baf Added more checking in "dead stores" for values that are initialized
but never used.

Fix a bug in LiveVariables where uses on the LHS of self-assign
operators (e.g +=, *=, etc) would not be properly recorded in the
liveness state of the variable.

llvm-svn: 41757
2007-09-06 23:39:53 +00:00
Ted Kremenek 10e7870746 Minor bug fixes to corner cases where LiveVariables would crash on some CFGs
that contained no declarations, or when a variable is declared but never used.

llvm-svn: 41756
2007-09-06 23:25:10 +00:00
Ted Kremenek 1bb9f2596f Forgot to check in the actual "dead stores" checker in the last commit!
llvm-svn: 41755
2007-09-06 23:01:46 +00:00
Ted Kremenek 6dc7b11d32 Added "Dead Stores", a flow-sensitive checker that checks for stores
to variables that are no longer live.  This analysis is built on top
of CFGs and the LiveVariables analysis.

changes to driver:
 added driver option "-check-dead-stores" to run the analysis

llvm-svn: 41754
2007-09-06 23:00:42 +00:00
Ted Kremenek 3f8ed2653c LiveVariables:
- Finished 99% of analysis logic.  Probably a few bugs.
 - Added querying functions to query liveness.
 - Added better pretty printing of liveness.
 - Added better bookkeeping of per-variable liveness information.
 - Added LiveVariablesAuditor interface, which allows "lazy" querying
   of intra-basic block liveness information.

Driver:
 - Minor cleanups involved in dumping liveness information.

llvm-svn: 41753
2007-09-06 21:26:58 +00:00
Steve Naroff 09bf815f89 The goal of this commit is to get just enough Sema support to recognize Objective-C classes
as types. That said, the AST nodes ObjcInterfaceDecl, ObjcInterfaceType, and ObjcClassDecl are *very*
preliminary.

The good news is we no longer need -parse-noop (aka MinimalActions) to parse cocoa.m.

llvm-svn: 41752
2007-09-06 21:24:23 +00:00
Ted Kremenek 73c18e0362 Added LabelLoc to GotoStmt to record the source location of the label token
in the actual GotoStmt.

Fixed bug where GotoStmt::getSourceRange incorrectly used the target LabelStmt
to compute its extent.

llvm-svn: 41745
2007-09-06 17:11:52 +00:00
Ted Kremenek e80505643d Added libClangAnalysis
llvm-svn: 41742
2007-09-06 15:58:13 +00:00
Ted Kremenek b56a990955 Added an early implementation of Live-Variables analysis built on
source-level CFGs.  This code may change significantly in the near
future as we explore different means to implement dataflow analyses.

Added a driver option, -dump-live-variables, to view the output of
live variable analysis.  This output is very ALPHA; it will be improved shortly.

llvm-svn: 41737
2007-09-06 00:17:54 +00:00
Chris Lattner 542a440062 remove the FATAL classifier.
llvm-svn: 41736
2007-09-06 00:16:35 +00:00
Chris Lattner aa4b29c52b remove sorry.
llvm-svn: 41734
2007-09-06 00:14:09 +00:00
Steve Naroff ca85d1dc07 Start implementing Actions interface for ObjC classes, instance variables, and methods.
Lot's of small changes to the parser.

llvm-svn: 41732
2007-09-05 23:30:30 +00:00
Fariborz Jahanian bd25f7d4a5 Patch for parsing objective-c style method calls.
llvm-svn: 41731
2007-09-05 23:08:20 +00:00
Ted Kremenek 813dd67a34 Moved tracking of CFG block IDs into the CFG class.
Added CFG::getNumBlockIDs() to query the number of distinct block ids created.

llvm-svn: 41724
2007-09-05 20:02:05 +00:00
Fariborz Jahanian 7db004df78 1. Fix parsing of method prototype involving c-style argument declarations.
2. Fixes all allowable key-words used as selectors.
3. Template to do the messaging parse.
4. A test case for all allowable selector names.

llvm-svn: 41723
2007-09-05 19:52:07 +00:00
Fariborz Jahanian 7eccba3b8e Fixed a typo pointed out by Anders Calrsson.
llvm-svn: 41716
2007-09-04 21:42:12 +00:00
Steve Naroff 67ae443954 Simplified initializer semantic analysis by adding the following 2 methods:
- ArrayType::getBaseType(), and 
- ConstantArrayType::getMaximumElements().

Wanted to do this cleanup before adding structure support, which will add more complexity.

llvm-svn: 41715
2007-09-04 21:13:33 +00:00
Fariborz Jahanian d8e12d3df3 Patch to parse objective-c's @compatibility_alias directive.
llvm-svn: 41709
2007-09-04 19:26:51 +00:00
Hartmut Kaiser db48641837 Updated VC8 project files.
llvm-svn: 41707
2007-09-04 19:06:30 +00:00
Ted Kremenek c81587d240 Updated calls to CreateGEP to new interface in LLVM mainline.
llvm-svn: 41704
2007-09-04 17:20:08 +00:00
Chris Lattner 73ab7fa9c6 disable this for now.
llvm-svn: 41701
2007-09-04 16:49:09 +00:00
Steve Naroff 77b97002e9 Make sure initializer type promotions get propagated.
This fixes a recent regression with Codegen/mandel.c.

llvm-svn: 41696
2007-09-04 14:36:54 +00:00
Chris Lattner 7717c56b4f updates (?) to the vc++ files, patch by Hartmut Kaiser
llvm-svn: 41695
2007-09-04 02:46:31 +00:00
Chris Lattner 0dc165b5f1 silence VC++ warnings, patch by Hartmut Kaiser
llvm-svn: 41694
2007-09-04 02:46:00 +00:00
Chris Lattner 9cf21c5a2c Silence VC++ warnings, patch by Hartmut Kaiser
llvm-svn: 41693
2007-09-04 02:45:27 +00:00
Chris Lattner fb2eb6941a eliminate some VC++ warnings, patch contributed by Hartmut Kaiser
llvm-svn: 41692
2007-09-04 02:34:27 +00:00
Chris Lattner e15fa6c89c add a VC++ solution file, contributed by Hartmut Kaiser
llvm-svn: 41691
2007-09-04 02:31:11 +00:00
Steve Naroff ac074b4df4 More fun with initializers!
- Fixed many bugs, enhanced test case considerably, added a diagnostic, etc.
- Refactored CheckInitList() into CheckVariableInitList()/CheckConstantInitList().
- Added CheckInitExpr().
- Support for multi-dimensional arrays looking good.

llvm-svn: 41690
2007-09-04 02:20:04 +00:00
Chris Lattner ff3fa8b624 VC++ doesn't define S_ISDIR
llvm-svn: 41688
2007-09-03 18:37:14 +00:00
Chris Lattner 1463cca1cc Add a method required by the VC++ STL, patch by Hartmut Kaiser!
llvm-svn: 41687
2007-09-03 18:31:57 +00:00
Chris Lattner a263393d11 Add #include required on win32.
llvm-svn: 41686
2007-09-03 18:30:32 +00:00