~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to clang/lib/StaticAnalyzer/Core/SVals.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
///
65
65
/// Implicit casts (ex: void* -> char*) can turn Symbolic region into Element
66
66
/// region. If that is the case, gets the underlining region.
67
 
SymbolRef SVal::getAsLocSymbol() const {
 
67
/// When IncludeBaseRegions is set to true and the SubRegion is non-symbolic,
 
68
/// the first symbolic parent region is returned.
 
69
SymbolRef SVal::getAsLocSymbol(bool IncludeBaseRegions) const {
68
70
  // FIXME: should we consider SymbolRef wrapped in CodeTextRegion?
69
71
  if (Optional<nonloc::LocAsInteger> X = getAs<nonloc::LocAsInteger>())
70
72
    return X->getLoc().getAsLocSymbol();
71
73
 
72
74
  if (Optional<loc::MemRegionVal> X = getAs<loc::MemRegionVal>()) {
73
 
    const MemRegion *R = X->stripCasts();
74
 
    if (const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(R))
 
75
    const MemRegion *R = X->getRegion();
 
76
    if (const SymbolicRegion *SymR = IncludeBaseRegions ?
 
77
                                      R->getSymbolicBase() :
 
78
                                      dyn_cast<SymbolicRegion>(R->StripCasts()))
75
79
      return SymR->getSymbol();
76
80
  }
77
81
  return 0;
99
103
// TODO: The next 3 functions have to be simplified.
100
104
 
101
105
/// \brief If this SVal wraps a symbol return that SymbolRef.
102
 
///  Otherwise return 0.
103
 
SymbolRef SVal::getAsSymbol() const {
 
106
/// Otherwise, return 0.
 
107
///
 
108
/// Casts are ignored during lookup.
 
109
/// \param IncludeBaseRegions The boolean that controls whether the search
 
110
/// should continue to the base regions if the region is not symbolic.
 
111
SymbolRef SVal::getAsSymbol(bool IncludeBaseRegion) const {
104
112
  // FIXME: should we consider SymbolRef wrapped in CodeTextRegion?
105
113
  if (Optional<nonloc::SymbolVal> X = getAs<nonloc::SymbolVal>())
106
114
    return X->getSymbol();
107
115
 
108
 
  return getAsLocSymbol();
 
116
  return getAsLocSymbol(IncludeBaseRegion);
109
117
}
110
118
 
111
119
/// getAsSymbolicExpression - If this Sval wraps a symbolic expression then