[PATCH] Pull Lexer's CharInfo table out for general use throughout Clang

Jordan Rose jordan_rose at apple.com
Fri Feb 1 16:36:32 PST 2013


Hi rsmith, bkramer, gribozavr, joerg,

Rewriting the same predicates over and over again is bad for code size and code maintainence. Using the functions in <ctype.h> is generally unsafe unless they are specified to be locale-independent (i.e. only isdigit and isxdigit).

The motivation behind this is that MSVC uses a signed char, which gets sign-extended when passed to <ctype.h> functions, which trips an assert for not fitting in one byte. See http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130128/072920.html

We discussed the performance implications of this a bit on IRC and decided that it //should// be acceptable -- we were most likely not getting CPU-relative addressing before, or if we were we still will after LTO. ...I think.

The next commit will try to clean up uses of <ctype.h> functions within Clang.

http://llvm-reviews.chandlerc.com/D363

Files:
  include/clang/Basic/CharInfo.h
  lib/Basic/CMakeLists.txt
  lib/Basic/CharInfo.cpp
  lib/Lex/Lexer.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D363.1.patch
Type: text/x-patch
Size: 18713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130201/4001f666/attachment.bin>


More information about the cfe-commits mailing list