diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-02-24 06:54:56 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-02-24 06:54:56 +0000 |
| commit | d767a0300effd3ff2d2b90f9dc95408f064ea7c3 (patch) | |
| tree | 4af99c1d12b0543a5cce151336a8851b1b040e3d /clang/lib/Frontend/InitPreprocessor.cpp | |
| parent | 190aa10fe6778de4454e1e12a995de9af04fa3cc (diff) | |
| download | bcm5719-llvm-d767a0300effd3ff2d2b90f9dc95408f064ea7c3.tar.gz bcm5719-llvm-d767a0300effd3ff2d2b90f9dc95408f064ea7c3.zip | |
Reimplement DefineTypeSize in terms of APInt. This eliminates some
magic integer arithmetic and allows it to work with types larger
than 64 bits.
llvm-svn: 126365
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
| -rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 90ca65746d5..91b5280a87e 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -174,15 +174,10 @@ static void DefineFloatMacros(MacroBuilder &Builder, llvm::StringRef Prefix, /// signedness of 'isSigned' and with a value suffix of 'ValSuffix' (e.g. LL). static void DefineTypeSize(llvm::StringRef MacroName, unsigned TypeWidth, llvm::StringRef ValSuffix, bool isSigned, - MacroBuilder& Builder) { - long long MaxVal; - if (isSigned) { - assert(TypeWidth != 1); - MaxVal = ~0ULL >> (65-TypeWidth); - } else - MaxVal = ~0ULL >> (64-TypeWidth); - - Builder.defineMacro(MacroName, llvm::Twine(MaxVal) + ValSuffix); + MacroBuilder &Builder) { + llvm::APInt MaxVal = isSigned ? llvm::APInt::getSignedMaxValue(TypeWidth) + : llvm::APInt::getMaxValue(TypeWidth); + Builder.defineMacro(MacroName, MaxVal.toString(10, isSigned) + ValSuffix); } /// DefineTypeSize - An overloaded helper that uses TargetInfo to determine |

