<br><br><div class="gmail_quote">On Thu, Nov 20, 2008 at 2:01 AM, Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com">kremenek@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Zhongxing,<br>
<br>
Great progress!  This looks fine for now, but in the future we should think about how symbols that are specific to a given combination of StoreManager/ConstraintManager should be factored out of the the base implementation of StoreManager.</blockquote>
<div> </div><div>Do you mean "..out of the base implementation of SymbolicManager"?                                                                           <br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
It's definitely something we should *not* worry about right now, as I think we are still trying to factor apart the main pieces of the analysis engine (i.e., GRTransferFuncs needs to be overhauled into probably a few big pieces similar to StoreManager and ConstraintManager).<br>
<font color="#888888">
<br>
Ted</font><div><div></div><div class="Wj3C7c"><br>
<br>
On Nov 19, 2008, at 3:03 AM, Zhongxing Xu wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Author: zhongxingxu<br>
Date: Wed Nov 19 05:03:17 2008<br>
New Revision: 59618<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=59618&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=59618&view=rev</a><br>
Log:<br>
Add SymbolData for array elements and struct fields.<br>
<br>
Modified:<br>
   cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h<br>
   cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h<br>
   cfe/trunk/lib/Analysis/SVals.cpp<br>
   cfe/trunk/lib/Analysis/SymbolManager.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?rev=59618&r1=59617&r2=59618&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?rev=59618&r1=59617&r2=59618&view=diff</a><br>

<br>
==============================================================================<br>
--- cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (original)<br>
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Wed Nov 19 05:03:17 2008<br>
@@ -73,6 +73,10 @@<br>
  }<br>
<br>
  static SVal GetSymbolValue(SymbolManager& SymMgr, VarDecl *D);<br>
+  static SVal getSymbolValue(SymbolManager& SymMgr, const MemRegion* R,<br>
+                             const llvm::APSInt* Idx, QualType T);<br>
+  static SVal getSymbolValue(SymbolManager& SymMgr, const MemRegion* R,<br>
+                             const FieldDecl* FD, QualType T);<br>
<br>
  inline bool isUnknown() const {<br>
    return getRawKind() == UnknownKind;<br>
<br>
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h?rev=59618&r1=59617&r2=59618&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h?rev=59618&r1=59617&r2=59618&view=diff</a><br>

<br>
==============================================================================<br>
--- cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h (original)<br>
+++ cfe/trunk/include/clang/Analysis/PathSensitive/SymbolManager.h Wed Nov 19 05:03:17 2008<br>
@@ -24,7 +24,7 @@<br>
<br>
namespace clang {<br>
<br>
-<br>
+class MemRegion;<br>
class SymbolManager;<br>
<br>
class SymbolID {<br>
@@ -69,7 +69,8 @@<br>
<br>
class SymbolData : public llvm::FoldingSetNode {<br>
public:<br>
-  enum Kind { UndefKind, ParmKind, GlobalKind, ContentsOfKind, ConjuredKind };<br>
+  enum Kind { UndefKind, ParmKind, GlobalKind, ElementKind, FieldKind,<br>
+              ContentsOfKind, ConjuredKind };<br>
<br>
private:<br>
  Kind K;<br>
@@ -141,6 +142,52 @@<br>
  }<br>
};<br>
<br>
+class SymbolDataElement : public SymbolData {<br>
+  const MemRegion* R;<br>
+  const llvm::APSInt* Idx;<br>
+<br>
+public:<br>
+  SymbolDataElement(SymbolID MySym, const MemRegion* r, const llvm::APSInt* idx)<br>
+    : SymbolData(ElementKind, MySym), R(r), Idx(idx) {}<br>
+<br>
+  static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* R,<br>
+                      const llvm::APSInt* Idx) {<br>
+    profile.AddPointer(R);<br>
+    profile.AddPointer(Idx);<br>
+  }<br>
+<br>
+  void Profile(llvm::FoldingSetNodeID& profile) {<br>
+    Profile(profile, R, Idx);<br>
+  }<br>
+<br>
+  static bool classof(const SymbolData* D) {<br>
+    return D->getKind() == ElementKind;<br>
+  }<br>
+};<br>
+<br>
+class SymbolDataField : public SymbolData {<br>
+  const MemRegion* R;<br>
+  const FieldDecl* D;<br>
+<br>
+public:<br>
+  SymbolDataField(SymbolID MySym, const MemRegion* r, const FieldDecl* d)<br>
+    : SymbolData(FieldKind, MySym), R(r), D(d) {}<br>
+<br>
+  static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* R,<br>
+                      const FieldDecl* D) {<br>
+    profile.AddPointer(R);<br>
+    profile.AddPointer(D);<br>
+  }<br>
+<br>
+  void Profile(llvm::FoldingSetNodeID& profile) {<br>
+    Profile(profile, R, D);<br>
+  }<br>
+<br>
+  static bool classof(const SymbolData* D) {<br>
+    return D->getKind() == FieldKind;<br>
+  }<br>
+};<br>
+<br>
class SymbolDataContentsOf : public SymbolData {<br>
  SymbolID Sym;<br>
<br>
@@ -245,6 +292,8 @@<br>
  ~SymbolManager();<br>
<br>
  SymbolID getSymbol(VarDecl* D);<br>
+  SymbolID getElementSymbol(const MemRegion* R, const llvm::APSInt* Idx);<br>
+  SymbolID getFieldSymbol(const MemRegion* R, const FieldDecl* D);<br>
  SymbolID getContentsOfSymbol(SymbolID sym);<br>
  SymbolID getConjuredSymbol(Stmt* E, QualType T, unsigned VisitCount);<br>
  SymbolID getConjuredSymbol(Expr* E, unsigned VisitCount) {<br>
<br>
Modified: cfe/trunk/lib/Analysis/SVals.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SVals.cpp?rev=59618&r1=59617&r2=59618&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SVals.cpp?rev=59618&r1=59617&r2=59618&view=diff</a><br>

<br>
==============================================================================<br>
--- cfe/trunk/lib/Analysis/SVals.cpp (original)<br>
+++ cfe/trunk/lib/Analysis/SVals.cpp Wed Nov 19 05:03:17 2008<br>
@@ -272,6 +272,22 @@<br>
  return nonloc::SymbolVal(SymMgr.getSymbol(D));<br>
}<br>
<br>
+SVal SVal::getSymbolValue(SymbolManager& SymMgr, const MemRegion* R,<br>
+                          const llvm::APSInt* Idx, QualType T) {<br>
+  if (Loc::IsLocType(T))<br>
+    return loc::SymbolVal(SymMgr.getElementSymbol(R, Idx));<br>
+  else<br>
+    return nonloc::SymbolVal(SymMgr.getElementSymbol(R, Idx));<br>
+}<br>
+<br>
+SVal SVal::getSymbolValue(SymbolManager& SymMgr, const MemRegion* R,<br>
+                          const FieldDecl* FD, QualType T) {<br>
+  if (Loc::IsLocType(T))<br>
+    return loc::SymbolVal(SymMgr.getFieldSymbol(R, FD));<br>
+  else<br>
+    return nonloc::SymbolVal(SymMgr.getFieldSymbol(R, FD));<br>
+}<br>
+<br>
nonloc::LocAsInteger nonloc::LocAsInteger::Make(BasicValueFactory& Vals, Loc V,<br>
                                                unsigned Bits) {<br>
  return LocAsInteger(Vals.getPersistentSValWithData(V, Bits));<br>
<br>
Modified: cfe/trunk/lib/Analysis/SymbolManager.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SymbolManager.cpp?rev=59618&r1=59617&r2=59618&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/SymbolManager.cpp?rev=59618&r1=59617&r2=59618&view=diff</a><br>

<br>
==============================================================================<br>
--- cfe/trunk/lib/Analysis/SymbolManager.cpp (original)<br>
+++ cfe/trunk/lib/Analysis/SymbolManager.cpp Wed Nov 19 05:03:17 2008<br>
@@ -51,6 +51,41 @@<br>
  DataMap[SymbolCounter] = SD;<br>
  return SymbolCounter++;<br>
}<br>
+<br>
+SymbolID SymbolManager::getElementSymbol(const MemRegion* R,<br>
+                                         const llvm::APSInt* Idx){<br>
+  llvm::FoldingSetNodeID ID;<br>
+  SymbolDataElement::Profile(ID, R, Idx);<br>
+  void* InsertPos;<br>
+  SymbolData* SD = DataSet.FindNodeOrInsertPos(ID, InsertPos);<br>
+<br>
+  if (SD)<br>
+    return SD->getSymbol();<br>
+<br>
+  SD = (SymbolData*) BPAlloc.Allocate<SymbolDataElement>();<br>
+  new (SD) SymbolDataElement(SymbolCounter, R, Idx);<br>
+<br>
+  DataSet.InsertNode(SD, InsertPos);<br>
+  DataMap[SymbolCounter] = SD;<br>
+  return SymbolCounter++;<br>
+}<br>
+<br>
+SymbolID SymbolManager::getFieldSymbol(const MemRegion* R, const FieldDecl* D) {<br>
+  llvm::FoldingSetNodeID ID;<br>
+  SymbolDataField::Profile(ID, R, D);<br>
+  void* InsertPos;<br>
+  SymbolData* SD = DataSet.FindNodeOrInsertPos(ID, InsertPos);<br>
+<br>
+  if (SD)<br>
+    return SD->getSymbol();<br>
+<br>
+  SD = (SymbolData*) BPAlloc.Allocate<SymbolDataField>();<br>
+  new (SD) SymbolDataField(SymbolCounter, R, D);<br>
+<br>
+  DataSet.InsertNode(SD, InsertPos);<br>
+  DataMap[SymbolCounter] = SD;<br>
+  return SymbolCounter++;<br>
+}<br>
<br>
SymbolID SymbolManager::getContentsOfSymbol(SymbolID sym) {<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote>
<br>
</div></div></blockquote></div><br>