diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2016-04-13 13:55:58 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2016-04-13 13:55:58 +0000 |
commit | 9c7fd406fcd23502fc5746b7ff03711ed81c90bd (patch) | |
tree | 61c71047c78af362111701fc50b296471e0b94b0 /include | |
parent | ebcac979c82e51235cd0a9c4ab16e605ef2a3aae (diff) | |
download | clang-9c7fd406fcd23502fc5746b7ff03711ed81c90bd.tar.gz |
Add functions declared in ctype.h to builtin function database. All functions are annotated with nothrow and pure attribute, which enables better optimization.
Patch by Taewook Oh.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266199 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/Basic/Builtins.def | 17 | ||||
-rw-r--r-- | include/clang/Basic/Builtins.h | 9 |
2 files changed, 24 insertions, 2 deletions
diff --git a/include/clang/Basic/Builtins.def b/include/clang/Basic/Builtins.def index 7a440cc708..53e77cf35b 100644 --- a/include/clang/Basic/Builtins.def +++ b/include/clang/Basic/Builtins.def @@ -67,6 +67,7 @@ // Builtin::Context class. Currently we have: // n -> nothrow // r -> noreturn +// U -> pure // c -> const // t -> signature is meaningless, use custom typechecking // F -> this is a libc/libm function with a '__builtin_' prefix added. @@ -773,6 +774,22 @@ LIBBUILTIN(sscanf, "icC*RcC*R.", "fs:1:", "stdio.h", ALL_LANGUAGES) LIBBUILTIN(vscanf, "icC*Ra", "fS:0:", "stdio.h", ALL_LANGUAGES) LIBBUILTIN(vfscanf, "iP*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES) LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES) +// C99 ctype.h +LIBBUILTIN(isalnum, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(isalpha, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(isblank, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(iscntrl, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(isdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(isgraph, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(islower, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(isprint, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(ispunct, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(isspace, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(isupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(isxdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(tolower, "ii", "fnU", "ctype.h", ALL_LANGUAGES) +LIBBUILTIN(toupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES) + // C99 // In some systems setjmp is a macro that expands to _setjmp. We undefine // it here to avoid having two identical LIBBUILTIN entries. diff --git a/include/clang/Basic/Builtins.h b/include/clang/Basic/Builtins.h index 5917843f29..8938e191bb 100644 --- a/include/clang/Basic/Builtins.h +++ b/include/clang/Basic/Builtins.h @@ -89,11 +89,16 @@ public: return getRecord(ID).Type; } - /// \brief Return true if this function is a target-specific builtin + /// \brief Return true if this function is a target-specific builtin. bool isTSBuiltin(unsigned ID) const { return ID >= Builtin::FirstTSBuiltin; } + /// \brief Return true if this function has no side effects. + bool isPure(unsigned ID) const { + return strchr(getRecord(ID).Attributes, 'U') != nullptr; + } + /// \brief Return true if this function has no side effects and doesn't /// read memory. bool isConst(unsigned ID) const { @@ -155,7 +160,7 @@ public: /// \brief Completely forget that the given ID was ever considered a builtin, /// e.g., because the user provided a conflicting signature. void forgetBuiltin(unsigned ID, IdentifierTable &Table); - + /// \brief If this is a library function that comes from a specific /// header, retrieve that header name. const char *getHeaderName(unsigned ID) const { |