[llvm-commits] [dragonegg] r154662 - in /dragonegg/trunk: include/dragonegg/Trees.h src/Trees.cpp
Duncan Sands
baldrick at free.fr
Fri Apr 13 04:12:11 PDT 2012
Author: baldrick
Date: Fri Apr 13 06:12:11 2012
New Revision: 154662
URL: http://llvm.org/viewvc/llvm-project?rev=154662&view=rev
Log:
Document how the bitwidth of returned APInts is determined. Explicitly
check for wrong attempts to extract an APInt from a GCC tree rather than
relying on GCC's checking.
Modified:
dragonegg/trunk/include/dragonegg/Trees.h
dragonegg/trunk/src/Trees.cpp
Modified: dragonegg/trunk/include/dragonegg/Trees.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Trees.h?rev=154662&r1=154661&r2=154662&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Trees.h (original)
+++ dragonegg/trunk/include/dragonegg/Trees.h Fri Apr 13 06:12:11 2012
@@ -61,7 +61,8 @@
return !TYPE_UNSIGNED(type) && TYPE_OVERFLOW_UNDEFINED(type);
}
-/// getIntegerValue - Return the specified INTEGER_CST as an APInt.
+/// getIntegerValue - Return the specified INTEGER_CST as an APInt (the bitwidth
+/// is the precision of the constant's type, aka TYPE_PRECISION).
llvm::APInt getIntegerValue(const_tree exp);
/// isInt64 - Return true if t is an INTEGER_CST that fits in a 64 bit integer.
Modified: dragonegg/trunk/src/Trees.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Trees.cpp?rev=154662&r1=154661&r2=154662&view=diff
==============================================================================
--- dragonegg/trunk/src/Trees.cpp (original)
+++ dragonegg/trunk/src/Trees.cpp Fri Apr 13 06:12:11 2012
@@ -133,6 +133,7 @@
/// getIntegerValue - Return the specified INTEGER_CST as an APInt.
APInt getIntegerValue(const_tree exp) {
+ assert(TREE_CODE(exp) == INTEGER_CST && "Expected an integer constant!");
double_int val = tree_to_double_int(exp);
unsigned NumBits = TYPE_PRECISION(TREE_TYPE(exp));
More information about the llvm-commits
mailing list