[clang] [C2y] Add stdcountof.h (PR #140890)
via cfe-commits
cfe-commits at lists.llvm.org
Wed May 21 06:36:50 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions c,h,cpp,inc -- clang/lib/Headers/stdcountof.h clang/lib/Lex/ModuleMap.cpp clang/lib/Lex/PPDirectives.cpp clang/lib/Tooling/Inclusions/Stdlib/CSymbolMap.inc clang/test/C/C2y/n3469.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index be9cab8af..aea71808f 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -253,19 +253,19 @@ OptionalFileEntryRef ModuleMap::findHeader(
/// headers.
static bool isBuiltinHeaderName(StringRef FileName) {
return llvm::StringSwitch<bool>(FileName)
- .Case("float.h", true)
- .Case("iso646.h", true)
- .Case("limits.h", true)
- .Case("stdalign.h", true)
- .Case("stdarg.h", true)
- .Case("stdatomic.h", true)
- .Case("stdbool.h", true)
- .Case("stdcountof.h", true)
- .Case("stddef.h", true)
- .Case("stdint.h", true)
- .Case("tgmath.h", true)
- .Case("unwind.h", true)
- .Default(false);
+ .Case("float.h", true)
+ .Case("iso646.h", true)
+ .Case("limits.h", true)
+ .Case("stdalign.h", true)
+ .Case("stdarg.h", true)
+ .Case("stdatomic.h", true)
+ .Case("stdbool.h", true)
+ .Case("stdcountof.h", true)
+ .Case("stddef.h", true)
+ .Case("stdint.h", true)
+ .Case("tgmath.h", true)
+ .Case("unwind.h", true)
+ .Default(false);
}
/// Determine whether the given module name is the name of a builtin
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 68f9ca9cb..502dd015a 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -248,50 +248,58 @@ static bool warnByDefaultOnWrongCase(StringRef Include) {
// The standard C/C++ and Posix headers
return llvm::StringSwitch<bool>(LowerInclude)
- // C library headers
- .Cases("assert.h", "complex.h", "ctype.h", "errno.h", "fenv.h", true)
- .Cases("float.h", "inttypes.h", "iso646.h", "limits.h", "locale.h", true)
- .Cases("math.h", "setjmp.h", "signal.h", "stdalign.h", "stdarg.h", true)
- .Cases("stdatomic.h", "stdbool.h", "stdckdint.h", "stdcountof.h", true)
- .Cases("stddef.h", "stdint.h", "stdio.h", "stdlib.h", "stdnoreturn.h", true)
- .Cases("string.h", "tgmath.h", "threads.h", "time.h", "uchar.h", true)
- .Cases("wchar.h", "wctype.h", true)
-
- // C++ headers for C library facilities
- .Cases("cassert", "ccomplex", "cctype", "cerrno", "cfenv", true)
- .Cases("cfloat", "cinttypes", "ciso646", "climits", "clocale", true)
- .Cases("cmath", "csetjmp", "csignal", "cstdalign", "cstdarg", true)
- .Cases("cstdbool", "cstddef", "cstdint", "cstdio", "cstdlib", true)
- .Cases("cstring", "ctgmath", "ctime", "cuchar", "cwchar", true)
- .Case("cwctype", true)
-
- // C++ library headers
- .Cases("algorithm", "fstream", "list", "regex", "thread", true)
- .Cases("array", "functional", "locale", "scoped_allocator", "tuple", true)
- .Cases("atomic", "future", "map", "set", "type_traits", true)
- .Cases("bitset", "initializer_list", "memory", "shared_mutex", "typeindex", true)
- .Cases("chrono", "iomanip", "mutex", "sstream", "typeinfo", true)
- .Cases("codecvt", "ios", "new", "stack", "unordered_map", true)
- .Cases("complex", "iosfwd", "numeric", "stdexcept", "unordered_set", true)
- .Cases("condition_variable", "iostream", "ostream", "streambuf", "utility", true)
- .Cases("deque", "istream", "queue", "string", "valarray", true)
- .Cases("exception", "iterator", "random", "strstream", "vector", true)
- .Cases("forward_list", "limits", "ratio", "system_error", true)
-
- // POSIX headers (which aren't also C headers)
- .Cases("aio.h", "arpa/inet.h", "cpio.h", "dirent.h", "dlfcn.h", true)
- .Cases("fcntl.h", "fmtmsg.h", "fnmatch.h", "ftw.h", "glob.h", true)
- .Cases("grp.h", "iconv.h", "langinfo.h", "libgen.h", "monetary.h", true)
- .Cases("mqueue.h", "ndbm.h", "net/if.h", "netdb.h", "netinet/in.h", true)
- .Cases("netinet/tcp.h", "nl_types.h", "poll.h", "pthread.h", "pwd.h", true)
- .Cases("regex.h", "sched.h", "search.h", "semaphore.h", "spawn.h", true)
- .Cases("strings.h", "stropts.h", "sys/ipc.h", "sys/mman.h", "sys/msg.h", true)
- .Cases("sys/resource.h", "sys/select.h", "sys/sem.h", "sys/shm.h", "sys/socket.h", true)
- .Cases("sys/stat.h", "sys/statvfs.h", "sys/time.h", "sys/times.h", "sys/types.h", true)
- .Cases("sys/uio.h", "sys/un.h", "sys/utsname.h", "sys/wait.h", "syslog.h", true)
- .Cases("tar.h", "termios.h", "trace.h", "ulimit.h", true)
- .Cases("unistd.h", "utime.h", "utmpx.h", "wordexp.h", true)
- .Default(false);
+ // C library headers
+ .Cases("assert.h", "complex.h", "ctype.h", "errno.h", "fenv.h", true)
+ .Cases("float.h", "inttypes.h", "iso646.h", "limits.h", "locale.h", true)
+ .Cases("math.h", "setjmp.h", "signal.h", "stdalign.h", "stdarg.h", true)
+ .Cases("stdatomic.h", "stdbool.h", "stdckdint.h", "stdcountof.h", true)
+ .Cases("stddef.h", "stdint.h", "stdio.h", "stdlib.h", "stdnoreturn.h",
+ true)
+ .Cases("string.h", "tgmath.h", "threads.h", "time.h", "uchar.h", true)
+ .Cases("wchar.h", "wctype.h", true)
+
+ // C++ headers for C library facilities
+ .Cases("cassert", "ccomplex", "cctype", "cerrno", "cfenv", true)
+ .Cases("cfloat", "cinttypes", "ciso646", "climits", "clocale", true)
+ .Cases("cmath", "csetjmp", "csignal", "cstdalign", "cstdarg", true)
+ .Cases("cstdbool", "cstddef", "cstdint", "cstdio", "cstdlib", true)
+ .Cases("cstring", "ctgmath", "ctime", "cuchar", "cwchar", true)
+ .Case("cwctype", true)
+
+ // C++ library headers
+ .Cases("algorithm", "fstream", "list", "regex", "thread", true)
+ .Cases("array", "functional", "locale", "scoped_allocator", "tuple", true)
+ .Cases("atomic", "future", "map", "set", "type_traits", true)
+ .Cases("bitset", "initializer_list", "memory", "shared_mutex",
+ "typeindex", true)
+ .Cases("chrono", "iomanip", "mutex", "sstream", "typeinfo", true)
+ .Cases("codecvt", "ios", "new", "stack", "unordered_map", true)
+ .Cases("complex", "iosfwd", "numeric", "stdexcept", "unordered_set", true)
+ .Cases("condition_variable", "iostream", "ostream", "streambuf",
+ "utility", true)
+ .Cases("deque", "istream", "queue", "string", "valarray", true)
+ .Cases("exception", "iterator", "random", "strstream", "vector", true)
+ .Cases("forward_list", "limits", "ratio", "system_error", true)
+
+ // POSIX headers (which aren't also C headers)
+ .Cases("aio.h", "arpa/inet.h", "cpio.h", "dirent.h", "dlfcn.h", true)
+ .Cases("fcntl.h", "fmtmsg.h", "fnmatch.h", "ftw.h", "glob.h", true)
+ .Cases("grp.h", "iconv.h", "langinfo.h", "libgen.h", "monetary.h", true)
+ .Cases("mqueue.h", "ndbm.h", "net/if.h", "netdb.h", "netinet/in.h", true)
+ .Cases("netinet/tcp.h", "nl_types.h", "poll.h", "pthread.h", "pwd.h",
+ true)
+ .Cases("regex.h", "sched.h", "search.h", "semaphore.h", "spawn.h", true)
+ .Cases("strings.h", "stropts.h", "sys/ipc.h", "sys/mman.h", "sys/msg.h",
+ true)
+ .Cases("sys/resource.h", "sys/select.h", "sys/sem.h", "sys/shm.h",
+ "sys/socket.h", true)
+ .Cases("sys/stat.h", "sys/statvfs.h", "sys/time.h", "sys/times.h",
+ "sys/types.h", true)
+ .Cases("sys/uio.h", "sys/un.h", "sys/utsname.h", "sys/wait.h", "syslog.h",
+ true)
+ .Cases("tar.h", "termios.h", "trace.h", "ulimit.h", true)
+ .Cases("unistd.h", "utime.h", "utmpx.h", "wordexp.h", true)
+ .Default(false);
}
/// Find a similar string in `Candidates`.
``````````
</details>
https://github.com/llvm/llvm-project/pull/140890
More information about the cfe-commits
mailing list