Added PersistentMap, an ADT that implements a map data structure that
is persistent. Adds/removals to a PersistentMap do not result in
a map being modified, but a new map being created. This will be useful
for path-sensitive analyses.
The current implementation mainly makes copies to implement this
functionality. If the map turns out to be extensively used, this
implementation will be replaced with a more efficient one that uses
data sharing (see comments in PersistentMap.h for more information).
Added smart pointer class "IntrusiveSPtr" that handles reference
counted objects that maintain their own internal reference count.
This smart pointer implementation is compatible with LLVM-style
down-casting (see in llvm: include/llvm/Support/Casting.h).
Implemented "RefCounted", a base class that objects that wish to be
managed using IntrusiveSPtrs can subclass.
Reference counted objects are being targeted for use in path-sensitive
dataflow analyses where managing many live objects becomes difficult.
This patch adds to new things to clang:
1. Handles saving and checking on protocols used in an @interface declaration
2. Checks and saves class's super class.
3. Adds semantic check to category declarations.
Match to do some semantic analysis on objective-c class decl.
1. Detect used of undeclared/forward declared super class.
2. Detect duplicate definition of a class.
Moved GraphTraits<Stmt*> to StmtGraphTraits.h. This allows consumers of Stmt.h not to have to pay the cost
of parsing the GraphTraits templates if they don't need that functionality.
Defined nodes_iterator for GraphTraits<Stmt*> to be based on llvm::df_iterator.
Added two new visitors that extend CFGStmtVisitor: CFGRecStmtVisitor and CFGRecStmtDeclVisitor.
The extended functionality of these visitors is that they automatically visit all statements in
an AST (no explicit recursion is required from subclasses), and the for the latter, decls are visited
as well.
Steve Naroff [Wed, 19 Sep 2007 16:18:46 +0000 (16:18 +0000)]
Remove SelectorTable/SelectorInfo, simply store all selectors in the central IdentifierTable.
Rationale:
We currently have a separate table to unique ObjC selectors. Since I don't need all the instance data in IdentifierInfo, I thought this would save space (and make more sense conceptually).
It turns out the cost of having duplicate entries for unary selectors (i.e. names without colons) outweighs the cost difference between the IdentifierInfo & SelectorInfo structures. Here is the data:
DataflowSolver now acccepts an "_Equal" template parameter that allows the user
to specify how two dataflow values should be compared for equality. The default
is to use std::equal_to.
Modified DataFlowValues and DataflowSolver to associate dataflow value
with CFG *edges* instead of blocks. This will fascilitate dataflow
analyses that are sensitive to block terminators, and also simplifies
some reasoning.
Updated UninitializedValues to comply to this new interface.
Bug fix to merging of data flow values (merge incorrectly made values
too "conservative").
Several revisions to UninitializedValues checker after testing. We
now appear to be working correctly (probably some bugs still, but main
functionality appears to be there). Implemented careful emitting of
warnings so that we wouldn't get a cascade of warnings for simply not
defining a single variable and using it everywhere. This way the
warnings point closer to the root cause rather than "symptoms" from
using values derived from uninitialized variables.
Hartmut Kaiser [Mon, 17 Sep 2007 21:11:08 +0000 (21:11 +0000)]
Fixed a VC++ issue related to bitmasks. As it turns out the compiler fills the unused bits of the word a bitmask is stored in with '1' (or randomly, I can't tell, I've seen '1' so far only), which creates wrong results in certain cases.
Steve Naroff [Mon, 17 Sep 2007 20:25:27 +0000 (20:25 +0000)]
- Refactored ObjcKeywordInfo into ObjcKeywordInfo, ObjcKeywordDecl, and ObjcKeywordMessage.
- Removed helper ObjcGetSelectorInfo(), moving the code directly into ObjcBuildMethodDeclaration().
- Many refinements to ParseObjCMessageExpression().
- Add ActOnMessageExpression().
Next step, finish the message actions and (finally) create/instantiate an ObjcMessageExpr AST.
Removed "ObserverTy" from core DataflowValues types. The observer
mechanism can be implemented simply by affixing the Observer to an
analysis meta data, so it doesn't need to be a required type. This
also permits analyses not to implement an Observer if it doesn't make
sense.
Changed "DataflowValues::MetaDataTy" to
"DataflowValues::AnalysisDataTy" to reflect that the type
enscapsulated the data associated with analyzing a given CFG.
Changed CFGStmtVisitor::BlockStmt_VisitImplicitControlFlowStmt(Stmt*)
to ...VisitImplicitControlFlowExpr(Expr*). The type narrowing is more
precise and more useful to clients.
Added CFGStmtVisitor::BlockStmt_VisitExpr to reflect the visitation of
expressions at the block statement level. This captures all implicit
control-flow statements as well as other expressions that are hoisted
to the block level (such as conditions for terminators and function
calls). This is especially useful for dataflow analysis.
When building CFGs we now (unconditionally) add an empty CFGBlock to the CFG
to serve as the entry block. An empty entry block (just as with an
empty exit block, which we already have) simplifies building analyses on top
of CFGs with very little extra overhead.
Steve Naroff [Mon, 17 Sep 2007 14:16:13 +0000 (14:16 +0000)]
Add support for ObjC keyword selectors.
- Add SelectorInfo/SelectorTable classes, modeled after IdentifierInfo/IdentifierTable.
- Add SelectorTable instance to ASTContext, created lazily through ASTContext::getSelectorInfo().
- Add SelectorInfo slot to ObjcMethodDecl.
- Add helper function to derive a SelectorInfo from ObjcKeywordInfo.
Misc: Got the Decl stats stuff up and running again...it was missing support for ObjC AST's.
Chris Lattner [Sun, 16 Sep 2007 19:27:16 +0000 (19:27 +0000)]
From Justin Handville:
"The ExpectedStr search was starting at the end of the comment string.
This patch starts the search at the beginning of the comment string.
After applying this patch, clang -parse-ast-check on negative test
case source files worked as expected."
Steve Naroff [Sun, 16 Sep 2007 16:16:00 +0000 (16:16 +0000)]
Fixes/tweaks that prevent "defaults-i.m" from compiling.
- Allow classnames as the receiver (removing a FIXME from ParseObjCMessageExpression).
- Added a FIXME to ParseObjCMessageExpression()...we need to return a message expr AST node!
Chris Lattner [Sat, 15 Sep 2007 23:21:08 +0000 (23:21 +0000)]
switch the various CFG-based stuff over to using ASTConsumer interface,
this eliminates their dependence on the preprocessor and eliminates some
duplicated code.
Steve Naroff [Sat, 15 Sep 2007 18:49:24 +0000 (18:49 +0000)]
Start converting Action methods from Parse-prefix to ActOn-prefix.
The previous naming scheme was confusing, since it resulted in both the Parser and Action modules having methods with the same name. In addition, the Action module never does any parsing...
Steve Naroff [Fri, 14 Sep 2007 23:09:53 +0000 (23:09 +0000)]
Rename Action::ParseRecordBody() to ProcessFieldDecls(), and add a visibility argument.
Remove Action::ObjcAddVisibilityToIvars(). No need for an extra API when it is trivial to add this info to the previous hook.
In general, I want to start migrating away from having Actions prefixed with "Parse" (which is confusing, since the Action API doesn't do any parsing, per se).
Steve Naroff [Fri, 14 Sep 2007 22:20:54 +0000 (22:20 +0000)]
Several improvement to Sema::ParseRecordBody()...
- Adding a safer prologue. The previous prologue would accept a null and therefore assume we had an interface (which was incorrect).
- Fixed FieldDecl's classof method. This allowed me to simplify some unnecessary casting.
- When diagnosing errors, make sure the FieldDecl/EnclosingDecl are marked as invalid. In addition, don't delete the field...rather, add all fields to the enclosing decl. Memory management can/should be done elsewhere. This code was never "upgraded" to the recently added invalid decl strategy.