[PATCH] D16309: Use getCharWidth() instead of magic number

Daniel Marjamäki via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 18 23:52:49 PST 2016


danielmarjamaki created this revision.
danielmarjamaki added a subscriber: cfe-commits.

Use getCharWidth() instead of magic number to handle arbitrary char widths.

no change in logical behaviour is intended when getCharWidth() is 8.


http://reviews.llvm.org/D16309

Files:
  lib/Frontend/InitPreprocessor.cpp

Index: lib/Frontend/InitPreprocessor.cpp
===================================================================
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -644,7 +644,7 @@
 
   // Define type sizing macros based on the target properties.
   assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far");
-  Builder.defineMacro("__CHAR_BIT__", "8");
+  Builder.defineMacro("__CHAR_BIT__", Twine(TI.getCharWidth()));
 
   DefineTypeSize("__SCHAR_MAX__", TargetInfo::SignedChar, TI, Builder);
   DefineTypeSize("__SHRT_MAX__", TargetInfo::SignedShort, TI, Builder);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16309.45231.patch
Type: text/x-patch
Size: 601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160119/f0b9aebf/attachment.bin>


More information about the cfe-commits mailing list