[llvm-commits] [llvm] r170653 - in /llvm/trunk: include/llvm/DataLayout.h lib/VMCore/DataLayout.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Wed Dec 19 20:02:58 PST 2012
Author: rsmith
Date: Wed Dec 19 22:02:58 2012
New Revision: 170653
URL: http://llvm.org/viewvc/llvm-project?rev=170653&view=rev
Log:
Don't use -1 as a value of an unsigned 7-bit enumeration; that has undefined
behavior and violates the !range constraints we put on loads of this enum.
Found by clang -fsanitize=enum.
Modified:
llvm/trunk/include/llvm/DataLayout.h
llvm/trunk/lib/VMCore/DataLayout.cpp
Modified: llvm/trunk/include/llvm/DataLayout.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DataLayout.h?rev=170653&r1=170652&r2=170653&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DataLayout.h (original)
+++ llvm/trunk/include/llvm/DataLayout.h Wed Dec 19 22:02:58 2012
@@ -39,6 +39,7 @@
/// Enum used to categorize the alignment types stored by LayoutAlignElem
enum AlignTypeEnum {
+ INVALID_ALIGN = 0, ///< An invalid alignment
INTEGER_ALIGN = 'i', ///< Integer type alignment
VECTOR_ALIGN = 'v', ///< Vector type alignment
FLOAT_ALIGN = 'f', ///< Floating point type alignment
Modified: llvm/trunk/lib/VMCore/DataLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DataLayout.cpp?rev=170653&r1=170652&r2=170653&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/DataLayout.cpp (original)
+++ llvm/trunk/lib/VMCore/DataLayout.cpp Wed Dec 19 22:02:58 2012
@@ -118,8 +118,7 @@
}
const LayoutAlignElem
-DataLayout::InvalidAlignmentElem =
- LayoutAlignElem::get((AlignTypeEnum) -1, 0, 0, 0);
+DataLayout::InvalidAlignmentElem = LayoutAlignElem::get(INVALID_ALIGN, 0, 0, 0);
//===----------------------------------------------------------------------===//
// PointerAlignElem, PointerAlign support
More information about the llvm-commits
mailing list