[llvm-commits] [dragonegg] r127487 - in /dragonegg/trunk: Constants.cpp Constants.h

Duncan Sands baldrick at free.fr
Fri Mar 11 12:33:58 PST 2011


Author: baldrick
Date: Fri Mar 11 14:33:58 2011
New Revision: 127487

URL: http://llvm.org/viewvc/llvm-project?rev=127487&view=rev
Log:
Add a comment describing AddressOf, and tighten a check which forgot to
verify that we were returning a pointer type when the GCC tree having
its address taken had void type.

Modified:
    dragonegg/trunk/Constants.cpp
    dragonegg/trunk/Constants.h

Modified: dragonegg/trunk/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=127487&r1=127486&r2=127487&view=diff
==============================================================================
--- dragonegg/trunk/Constants.cpp (original)
+++ dragonegg/trunk/Constants.cpp Fri Mar 11 14:33:58 2011
@@ -1221,9 +1221,10 @@
   // Check that the type of the lvalue is indeed that of a pointer to the tree
   // node.  Since LLVM has no void* type, don't insist that void* be converted
   // to a specific LLVM type.
-  assert((VOID_TYPE_P(TREE_TYPE(exp)) ||
-          LV->getType() == ConvertType(TREE_TYPE(exp))->getPointerTo()) &&
-         "LValue of constant has wrong type!");
+  assert(isa<PointerType>(LV->getType()) &&
+         (VOID_TYPE_P(TREE_TYPE(exp)) ||
+          cast<PointerType>(LV->getType())->getElementType() ==
+          ConvertType(TREE_TYPE(exp))) && "Constant LValue has wrong type!");
 
   return LV;
 }

Modified: dragonegg/trunk/Constants.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.h?rev=127487&r1=127486&r2=127487&view=diff
==============================================================================
--- dragonegg/trunk/Constants.h (original)
+++ dragonegg/trunk/Constants.h Fri Mar 11 14:33:58 2011
@@ -33,7 +33,11 @@
 // Constant Expressions
 extern llvm::Constant *ConvertConstant(tree_node *exp);
 
-// Constant Expression l-values.
+/// AddressOf - Given an expression with a constant address such as a constant,
+/// a global variable or a label, returns the address.  The type of the returned
+/// is always a pointer type and, as long as 'exp' does not have void type, the
+/// type of the pointee is the memory type that corresponds to the type of exp
+/// (see ConvertType).
 extern llvm::Constant *AddressOf(tree_node *exp);
 
 #endif /* DRAGONEGG_CONSTANTS_H */





More information about the llvm-commits mailing list