[llvm-commits] CVS: llvm/lib/VMCore/Type.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Mar 1 19:54:59 PST 2005
Changes in directory llvm/lib/VMCore:
Type.cpp updated: 1.121 -> 1.122
---
Log message:
Fix a nasty order of evaluation bug that Gabor Greif ran into. Here's an
explanation from IRC:
|sabre| I think it's an order of evaluation thing
|sabre| for me, the RHS of the assignment is evaluated first
|sabre| getTypeDescription checks to see if ConcreteTypeDescription[Ty] contains anything
|sabre| since it doesn't, it computes and returns the value
|sabre| this gets put into the map.
|sabre| For you, the LHS is evaluated first.
|sabre| Map[Ty] (aka ConcreteTypeDescriptions[Ty]) inserts an empty string into the map, returning a reference
|sabre| getTypeDesc then sees the empty string in the map
|sabre| and returns it
|sabre| bork :)
---
Diffs of the changes: (+2 -1)
Type.cpp | 3 ++-
1 files changed, 2 insertions(+), 1 deletion(-)
Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.121 llvm/lib/VMCore/Type.cpp:1.122
--- llvm/lib/VMCore/Type.cpp:1.121 Sat Jan 8 14:19:51 2005
+++ llvm/lib/VMCore/Type.cpp Tue Mar 1 21:54:43 2005
@@ -291,7 +291,8 @@
if (I != Map.end()) return I->second;
std::vector<const Type *> TypeStack;
- return Map[Ty] = getTypeDescription(Ty, TypeStack);
+ std::string Result = getTypeDescription(Ty, TypeStack);
+ return Map[Ty] = Result;
}
More information about the llvm-commits
mailing list