Skip to content
  1. Feb 08, 2010
  2. Feb 05, 2010
  3. Jan 25, 2010
    • Ted Kremenek's avatar
      Split libAnalysis into two libraries: libAnalysis and libChecker. · d6b87086
      Ted Kremenek authored
      (1) libAnalysis is a generic analysis library that can be used by
          Sema.  It defines the CFG, basic dataflow analysis primitives, and
          inexpensive flow-sensitive analyses (e.g. LiveVariables).
      
      (2) libChecker contains the guts of the static analyzer, incuding the
          path-sensitive analysis engine and domain-specific checks.
      
      Now any clients that want to use the frontend to build their own tools
      don't need to link in the entire static analyzer.
      
      This change exposes various obvious cleanups that can be made to the
      layout of files and headers in libChecker.  More changes pending.  :)
      
      This change also exposed a layering violation between AnalysisContext
      and MemRegion.  BlockInvocationContext shouldn't explicitly know about
      BlockDataRegions.  For now I've removed the BlockDataRegion* from
      BlockInvocationContext (removing context-sensitivity; although this
      wasn't used yet).  We need to have a better way to extend
      BlockInvocationContext (and any LocationContext) to add
      context-sensitivty.
      
      llvm-svn: 94406
      d6b87086
  4. Jan 11, 2010
    • Ken Dyck's avatar
      Roll out ASTContext::getTypeSizeInChars(), replacing instances of · 40775003
      Ken Dyck authored
      "ASTContext::getTypeSize() / 8". Replace [u]int64_t variables with CharUnits
      ones as appropriate. 
      
      Also rename RawType, fromRaw(), and getRaw() in CharUnits to QuantityType, 
      fromQuantity(), and getQuantity() for clarity.
      
      llvm-svn: 93153
      40775003
    • Ted Kremenek's avatar
      Switch RegionStore over to using <BaseRegion+raw offset> to store · be909b5e
      Ted Kremenek authored
      value bindings.  Along with a small change to OSAtomicChecker, this
      resolves <rdar://problem/7527292> and resolves some long-standing
      issues with how values can be bound to the same physical address by
      not have the same "key".  This change is only a beginning; logically
      RegionStore needs to better handle loads from addresses where the
      stored value is larger/smaller/different type than the loaded value.
      We handle these cases in an approximate fashion now (via
      CastRetrievedVal and help in SimpleSValuator), but it could be made
      much smarter.
      
      llvm-svn: 93137
      be909b5e
  5. Jan 05, 2010
  6. Dec 17, 2009
  7. Dec 16, 2009
    • Zhongxing Xu's avatar
      Add a new kind of region: CXXObjectRegion. Currently it has only one · 6df9f54d
      Zhongxing Xu authored
      attribute: the object type. 
      Add initial support for visiting CXXThisExpr.
      Fix a bunch of 80-col violations.
      
      llvm-svn: 91535
      6df9f54d
    • Ted Kremenek's avatar
      Add (initial?) static analyzer support for handling C++ references. · 4cad5fc0
      Ted Kremenek authored
      This change was a lot bigger than I originally anticipated; among
      other things it requires us storing more information in the CFG to
      record what block-level expressions need to be evaluated as lvalues.
      
      The big change is that CFGBlocks no longer contain Stmt*'s by
      CFGElements.  Currently CFGElements just wrap Stmt*, but they also
      store a bit indicating whether the block-level expression should be
      evalauted as an lvalue.  DeclStmts involving the initialization of a
      reference require us treating the initialization expression as an
      lvalue, even though that information isn't recorded in the AST.
      Conceptually this change isn't that complicated, but it required
      bubbling up the data through the CFGBuilder, to GRCoreEngine, and
      eventually to GRExprEngine.
      
      The addition of CFGElement is also useful for when we want to handle
      more control-flow constructs or other data we want to keep in the CFG
      that isn't represented well with just a block of statements.
      
      In GRExprEngine, this patch introduces logic for evaluating the
      lvalues of references, which currently retrieves the internal "pointer
      value" that the reference represents.  EvalLoad does a two stage load
      to catch null dereferences involving an invalid reference (although
      this could possibly be caught earlier during the initialization of a
      reference).
      
      Symbols are currently symbolicated using the reference type, instead
      of a pointer type, and special handling is required creating
      ElementRegions that layer on SymbolicRegions (see the changes to
      RegionStoreManager).
      
      Along the way, the DeadStoresChecker also silences warnings involving
      dead stores to references.  This was the original change I introduced
      (which I wrote test cases for) that I realized caused GRExprEngine to
      crash.
      
      llvm-svn: 91501
      4cad5fc0
  8. Dec 11, 2009
  9. Dec 09, 2009
  10. Dec 07, 2009
    • Ted Kremenek's avatar
      Add analysis support for blocks. This includes a few key changes: · 04af9f20
      Ted Kremenek authored
      - Refactor the MemRegion hierarchy to distinguish between different StackSpaceRegions for locals and parameters.
      - VarRegions for "captured" variables now have the BlockDataRegion as their super region (except those passed by reference)
      - Add transfer function support to GRExprEngine for BlockDeclRefExprs.
      
      This change also supports analyzing blocks as an analysis entry point
      (top-of-the-stack), which required pushing more context-sensitivity
      around in the MemRegion hierarchy via the use of LocationContext
      objects.  Functionally almost everything is the same, except we track
      LocationContexts in a few more areas and StackSpaceRegions now refer
      to a StackFrameContext object.  In the future we will need to modify
      MemRegionManager to allow multiple StackSpaceRegions in flight at once
      (for the analysis of multiple stack frames).
      
      llvm-svn: 90809
      04af9f20
  11. Dec 03, 2009
  12. Nov 26, 2009
  13. Nov 25, 2009
  14. Nov 19, 2009
  15. Nov 16, 2009
    • Douglas Gregor's avatar
      First part of changes to eliminate problems with cv-qualifiers and · 1b8fe5b7
      Douglas Gregor authored
      sugared types. The basic problem is that our qualifier accessors
      (getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at
      the current QualType and not at any qualifiers that come from sugared
      types, meaning that we won't see these qualifiers through, e.g.,
      typedefs:
      
        typedef const int CInt;
        typedef CInt Self;
      
      Self.isConstQualified() currently returns false!
      
      Various bugs (e.g., PR5383) have cropped up all over the front end due
      to such problems. I'm addressing this problem by splitting each
      qualifier accessor into two versions: 
      
        - the "local" version only returns qualifiers on this particular
          QualType instance
        - the "normal" version that will eventually combine qualifiers from this
          QualType instance with the qualifiers on the canonical type to
          produce the full set of qualifiers.
      
      This commit adds the local versions and switches a few callers from
      the "normal" version (e.g., isConstQualified) over to the "local"
      version (e.g., isLocalConstQualified) when that is the right thing to
      do, e.g., because we're printing or serializing the qualifiers. Also,
      switch a bunch of
        
        Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType()
      
      expressions over to 
      
        Context.hasSameUnqualifiedType(T1, T2)
      
      llvm-svn: 88969
      1b8fe5b7
    • Zhongxing Xu's avatar
      * Do the same thing to the basicstore as in r84163. · 731f4626
      Zhongxing Xu authored
      * Add a load type to GRExprEngine::EvalLoad().
      * When retrieve from 'theValue' of OSAtomic funcitions, use the type of the 
        region instead of the argument expression as the load type.
      * Then we can convert CastRetrievedSVal to a pure assertion. In the future
        we can let all Retrieve() methods simply return SVal.
      
      llvm-svn: 88888
      731f4626
  16. Nov 10, 2009
  17. Oct 14, 2009
  18. Sep 09, 2009
  19. Aug 28, 2009
  20. Aug 25, 2009
  21. Aug 02, 2009
  22. Aug 01, 2009
    • Ted Kremenek's avatar
      This is a fairly large patch, which resulted from a cascade of changes · 1f22aa74
      Ted Kremenek authored
      made to RegionStore (and related classes) in order to handle some
      analyzer failures involving casts and manipulation of symbolic memory.
      
      The root of the change is in StoreManager::CastRegion().  Instead of
      using ad hoc heuristics to decide when to layer an ElementRegion on a
      casted MemRegion, we now always layer an ElementRegion when the cast
      type is different than the original type of the region.  This carries
      the current cast information associated with a region around without
      resorting to the error prone recording of "casted types" in GRState.
      
      Along with this new policy of layering ElementRegions, I added a new
      algorithm to strip away existing ElementRegions when they simply
      represented casts of a base memory object.  This algorithm computes
      the raw "byte offset" that an ElementRegion represents from the base
      region, and allows the new ElementRegion to be based off that offset.
      The added benefit is that this naturally handles a series of casts of
      a MemRegion without building up a set of redundant ElementRegions
      (thus canonicalizing the region view).
      
      Other related changes that cascaded from this one (as tests were
      failing in RegionStore):
      
      - Revamped RegionStoreManager::InvalidateRegion() to completely remove
        all bindings and default values from a region and all subregions.
        Now invalidated fields are not bound directly to new symbolic
        values; instead the base region has a "default" symbol value from
        which "derived symbols" can be created.  The main advantage of this
        approach is that it allows us to invalidate a region hierarchy and
        then lazily instantiate new values no matter how deep the hierarchy
        went (i.e., regardless of the number of field accesses,
        e.g. x->f->y->z->...).  The previous approach did not do this.
      
      - Slightly reworked RegionStoreManager::RemoveDeadBindings() to also
        incorporate live symbols and live regions that do not have direct
        bindings but also have "default values" used for lazy instantiation.
        The changes to 'InvalidateRegion' revealed that these were necessary
        in order to achieve lazy instantiation of values in the region store
        with those bindings being removed too early.
      
      - The changes to InvalidateRegion() and RemoveDeadBindings() revealed
        a serious bug in 'getSubRegionMap()' where not all region -> subregion
        relationships involved in actually bindings (explicit and implicit)
        were being recorded.  This has been fixed by using a worklist algorithm
        to iteratively fill in the region map.
      
      - Added special support to RegionStoreManager::Bind()/Retrieve() to handle
        OSAtomicCompareAndSwap in light of the new 'CastRegion' changes and the
        layering of ElementRegions.
      
      - Fixed a bug in SymbolReaper::isLive() where derived symbols were not
        being marked live if the symbol they were derived from was also live.
        This fix was critical for getting lazy instantiation in RegionStore
        to work.
      
      - Tidied up the implementation of ValueManager::getXXXSymbolVal() methods
        to use SymbolManager::canSymbolicate() to decide whether or not a
        symbol should be symbolicated.
      
      - 'test/Analysis/misc-ps-xfail.m' now passes; that test case has been
        moved to 'test/Analysis/misc-ps.m'.
      
      - Tweaked some pretty-printing of MemRegions, and implemented
        'ElementRegion::getRawOffset()' for use with the CastRegion changes.
      
      llvm-svn: 77782
      1f22aa74
  23. Jul 29, 2009
    • Ted Kremenek's avatar
      Change uses of: · c23c7e6a
      Ted Kremenek authored
        Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
        Type::getAsRecordType() -> Type::getAs<RecordType>()
        Type::getAsPointerType() -> Type::getAs<PointerType>()
        Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
        Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
        Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
        Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
        Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
        Type::getAsTagType() -> Type::getAs<TagType>()
        
      And remove Type::getAsReferenceType(), etc.
      
      This change is similar to one I made a couple weeks ago, but that was partly
      reverted pending some additional design discussion. With Doug's pending smart
      pointer changes for Types, it seemed natural to take this approach.
      
      llvm-svn: 77510
      c23c7e6a
    • Ted Kremenek's avatar
      Remove 'StoreManager::OldCastRegion()', TypedViewRegion (which only · 4301526e
      Ted Kremenek authored
      OldCastRegion used), and the associated command line option
      '-analyzer-store=old-basic-cast'.
      
      llvm-svn: 77509
      4301526e
    • Ted Kremenek's avatar
      Make StoreManager::InvalidateRegion() virtual, move the current implementation · bca70671
      Ted Kremenek authored
      in StoreManager to RegionStoreManager, and create a special, highly reduced
      version in BasicStoreManager.
      
      These changes are in preparation for future RegionStore-specific changes to
      InvalidateRegion.
      
      llvm-svn: 77483
      bca70671
  24. Jul 22, 2009
  25. Jul 18, 2009
  26. Jul 17, 2009
  27. Jul 16, 2009
    • Ted Kremenek's avatar
      Add member template 'Type::getAs<T>', which converts a Type* to a respective T*. · e3fb4b65
      Ted Kremenek authored
      This method is intended to eventually replace the individual
      Type::getAsXXXType<> methods.
      
      The motivation behind this change is twofold:
      
      1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
      them are basically copy-and-paste.
      
      2) By centralizing the implementation of the getAs<Type> logic we can more
      smoothly move over to Doug Gregor's proposed canonical type smart pointer
      scheme.
      
      Along with this patch:
      
      a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
      b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.
      
      llvm-svn: 76098
      e3fb4b65
    • Steve Naroff's avatar
      Remove ASTContext::isObjCObjectPointerType(). · 79d1215d
      Steve Naroff authored
      Convert all clients to use the new predicate on Type.
      
      llvm-svn: 76076
      79d1215d
  28. Jul 15, 2009
    • Zhongxing Xu's avatar
      rewrite the logic to make it follow the comments more closely. · a5da8d25
      Zhongxing Xu authored
      llvm-svn: 75750
      a5da8d25
    • Ted Kremenek's avatar
      More test cases revealed that the logic in StoreManager::InvalidateRegion()... · e6fea68c
      Ted Kremenek authored
      More test cases revealed that the logic in StoreManager::InvalidateRegion() needs more finesse when handling the invalidation of pointers.  Pointers that were invalidated as integers could later cause problems for clients using them as pointers.  It is easier for us to model a symbolic value as a pointer rather than modeling a non-symbolic value as a pointer.
      
      This patch causes:
      - StoreManager::InvalidateRegion() to not used the casted type of a region if
        it would cause a pointer type to be invalidated as a non-pointer type.
      - Pushes RegionStore::RetrieveElement() further by handling retrievals from
        symbolic arrays that have been invalidated.  This uses the new SymbolDerived
        construct that was recently introduced.
        
      The result is that the failing test in misc-ps-region-store-x86_64.m now passes.
      Both misc-ps-region-store-x86_64.m and misc-ps-region-store-i386.m contain a
      test case that motivated this change.
      
      llvm-svn: 75730
      e6fea68c
    • Ted Kremenek's avatar
      e5d2f798
  29. Jul 14, 2009
Loading