aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp113
1 files changed, 65 insertions, 48 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 5c6ecdb..6a5e5d4 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -248,50 +248,67 @@ 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`.
@@ -3648,14 +3665,14 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) {
std::pair<tok::TokenKind, SourceLocation> Matches) {
Diag(CurTok, diag::err_expected) << Expected;
Diag(Matches.second, diag::note_matching) << Matches.first;
- if (CurTok.isNot(tok::eod))
+ if (CurTok.isNot(EndTokenKind))
DiscardUntilEndOfDirective(CurTok);
};
auto ExpectOrDiagAndSkipToEOD = [&](tok::TokenKind Kind) {
if (CurTok.isNot(Kind)) {
Diag(CurTok, diag::err_expected) << Kind;
- if (CurTok.isNot(tok::eod))
+ if (CurTok.isNot(EndTokenKind))
DiscardUntilEndOfDirective(CurTok);
return false;
}
@@ -3746,7 +3763,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) {
if (Result.isNegative()) {
Diag(CurTok, diag::err_requires_positive_value)
<< toString(Result, 10) << /*positive*/ 0;
- if (CurTok.isNot(tok::eod))
+ if (CurTok.isNot(EndTokenKind))
DiscardUntilEndOfDirective(CurTok);
return std::nullopt;
}
@@ -3889,7 +3906,7 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool ForHasEmbed) {
}
if (!ForHasEmbed) {
Diag(ParamStartLoc, diag::err_pp_unknown_parameter) << 1 << Parameter;
- if (CurTok.isNot(tok::eod))
+ if (CurTok.isNot(EndTokenKind))
DiscardUntilEndOfDirective(CurTok);
return std::nullopt;
}