aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Lex
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-24 15:11:41 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-08 19:04:38 +0000
commitfcaf7f8644a9988098ac6be2165bce3ea4786e91 (patch)
tree08a554363df16b968a623d651c09d82a5a0b1c65 /contrib/llvm-project/clang/lib/Lex
parent753f127f3ace09432b2baeffd71a308760641a62 (diff)
parent4b4fe385e49bd883fd183b5f21c1ea486c722e61 (diff)
Diffstat (limited to 'contrib/llvm-project/clang/lib/Lex')
-rw-r--r--contrib/llvm-project/clang/lib/Lex/Lexer.cpp6
-rw-r--r--contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp6
-rw-r--r--contrib/llvm-project/clang/lib/Lex/PPDirectives.cpp29
3 files changed, 18 insertions, 23 deletions
diff --git a/contrib/llvm-project/clang/lib/Lex/Lexer.cpp b/contrib/llvm-project/clang/lib/Lex/Lexer.cpp
index b3aac9df6546..a4cff403e739 100644
--- a/contrib/llvm-project/clang/lib/Lex/Lexer.cpp
+++ b/contrib/llvm-project/clang/lib/Lex/Lexer.cpp
@@ -1462,11 +1462,11 @@ static bool isAllowedIDChar(uint32_t C, const LangOptions &LangOpts) {
return false;
} else if (LangOpts.DollarIdents && '$' == C) {
return true;
- } else if (LangOpts.CPlusPlus) {
+ } else if (LangOpts.CPlusPlus || LangOpts.C2x) {
// A non-leading codepoint must have the XID_Continue property.
// XIDContinueRanges doesn't contains characters also in XIDStartRanges,
// so we need to check both tables.
- // '_' doesn't have the XID_Continue property but is allowed in C++.
+ // '_' doesn't have the XID_Continue property but is allowed in C and C++.
static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
static const llvm::sys::UnicodeCharSet XIDContinueChars(XIDContinueRanges);
return C == '_' || XIDStartChars.contains(C) ||
@@ -1486,7 +1486,7 @@ static bool isAllowedInitiallyIDChar(uint32_t C, const LangOptions &LangOpts) {
if (LangOpts.AsmPreprocessor) {
return false;
}
- if (LangOpts.CPlusPlus) {
+ if (LangOpts.CPlusPlus || LangOpts.C2x) {
static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
// '_' doesn't have the XID_Start property but is allowed in C++.
return C == '_' || XIDStartChars.contains(C);
diff --git a/contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp b/contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp
index 57e344622f25..47d6f5893e97 100644
--- a/contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp
+++ b/contrib/llvm-project/clang/lib/Lex/ModuleMap.cpp
@@ -456,10 +456,8 @@ static bool violatesPrivateInclude(Module *RequestingModule,
&Header.getModule()->Headers[Module::HK_Private],
&Header.getModule()->Headers[Module::HK_PrivateTextual]};
for (auto *Hs : HeaderList)
- IsPrivate |=
- std::find_if(Hs->begin(), Hs->end(), [&](const Module::Header &H) {
- return H.Entry == IncFileEnt;
- }) != Hs->end();
+ IsPrivate |= llvm::any_of(
+ *Hs, [&](const Module::Header &H) { return H.Entry == IncFileEnt; });
assert(IsPrivate && "inconsistent headers and roles");
}
#endif
diff --git a/contrib/llvm-project/clang/lib/Lex/PPDirectives.cpp b/contrib/llvm-project/clang/lib/Lex/PPDirectives.cpp
index 352e1f217819..9a8fd4391b41 100644
--- a/contrib/llvm-project/clang/lib/Lex/PPDirectives.cpp
+++ b/contrib/llvm-project/clang/lib/Lex/PPDirectives.cpp
@@ -1261,7 +1261,16 @@ void Preprocessor::HandleDirective(Token &Result) {
return HandleIncludeNextDirective(SavedHash.getLocation(), Result);
case tok::pp_warning:
- Diag(Result, diag::ext_pp_warning_directive);
+ if (LangOpts.CPlusPlus)
+ Diag(Result, LangOpts.CPlusPlus2b
+ ? diag::warn_cxx2b_compat_warning_directive
+ : diag::ext_pp_warning_directive)
+ << /*C++2b*/ 1;
+ else
+ Diag(Result, LangOpts.C2x ? diag::warn_c2x_compat_warning_directive
+ : diag::ext_pp_warning_directive)
+ << /*C2x*/ 0;
+
return HandleUserDiagnosticDirective(Result, true);
case tok::pp_ident:
return HandleIdentSCCSDirective(Result);
@@ -1806,22 +1815,14 @@ static void diagnoseAutoModuleImport(
Preprocessor &PP, SourceLocation HashLoc, Token &IncludeTok,
ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> Path,
SourceLocation PathEnd) {
- StringRef ImportKeyword;
- if (PP.getLangOpts().ObjC)
- ImportKeyword = "@import";
- else if (PP.getLangOpts().ModulesTS || PP.getLangOpts().CPlusPlusModules)
- ImportKeyword = "import";
- else
- return; // no import syntax available
-
SmallString<128> PathString;
for (size_t I = 0, N = Path.size(); I != N; ++I) {
if (I)
PathString += '.';
PathString += Path[I].first->getName();
}
- int IncludeKind = 0;
+ int IncludeKind = 0;
switch (IncludeTok.getIdentifierInfo()->getPPKeywordID()) {
case tok::pp_include:
IncludeKind = 0;
@@ -1843,12 +1844,8 @@ static void diagnoseAutoModuleImport(
llvm_unreachable("unknown include directive kind");
}
- CharSourceRange ReplaceRange(SourceRange(HashLoc, PathEnd),
- /*IsTokenRange=*/false);
- PP.Diag(HashLoc, diag::warn_auto_module_import)
- << IncludeKind << PathString
- << FixItHint::CreateReplacement(
- ReplaceRange, (ImportKeyword + " " + PathString + ";").str());
+ PP.Diag(HashLoc, diag::remark_pp_include_directive_modular_translation)
+ << IncludeKind << PathString;
}
// Given a vector of path components and a string containing the real