[cfe-commits] r110116 - /cfe/trunk/lib/Frontend/InitPreprocessor.cpp
Chris Lattner
sabre at nondot.org
Tue Aug 3 09:48:42 PDT 2010
Author: lattner
Date: Tue Aug 3 11:48:42 2010
New Revision: 110116
URL: http://llvm.org/viewvc/llvm-project?rev=110116&view=rev
Log:
fix some undefined behavior, PR7779.
Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=110116&r1=110115&r2=110116&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Aug 3 11:48:42 2010
@@ -169,9 +169,10 @@
llvm::StringRef ValSuffix, bool isSigned,
MacroBuilder& Builder) {
long long MaxVal;
- if (isSigned)
- MaxVal = (1LL << (TypeWidth - 1)) - 1;
- else
+ if (isSigned) {
+ assert(TypeWidth != 1);
+ MaxVal = ~0ULL >> (65-TypeWidth);
+ } else
MaxVal = ~0LL >> (64-TypeWidth);
Builder.defineMacro(MacroName, llvm::Twine(MaxVal) + ValSuffix);
More information about the cfe-commits
mailing list