Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
bad4149dfc
!149 remove duplicate files and add Requires
From: @znzjugod 
Reviewed-by: @hubin95, @wangqiang95 
Signed-off-by: @hubin95, @wangqiang95
2024-11-06 05:52:10 +00:00
znzjugod
f6378debba remove duplicate files and add Requires 2024-11-05 16:26:21 +08:00
openeuler-ci-bot
8dcd305989
!140 [backport][Clang] Defer the instantiation of explicit-specifier until constraint checking completes
From: @mmzzmm 
Reviewed-by: @liyunfei33 
Signed-off-by: @liyunfei33
2024-09-05 11:50:11 +00:00
Zhao Mengmeng
0ce7317523 Clang: Defer the instantiation of explicit-specifier until constraint checking completes
Backport upstream commit
128b3b61fe
to fix an build failure.

[resolve docs/ReleaseNotes.rst conflicts]
Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
(cherry picked from commit dda395ae46a3d5a93b618dd5375f2881addd40fa)
2024-09-05 14:44:33 +08:00
openeuler-ci-bot
9e17571196
!127 Handling of option -Wall and -Werror=format=2 override -Wno
From: @wangqiang95 
Reviewed-by: @cf-zhao 
Signed-off-by: @cf-zhao
2024-08-02 03:59:34 +00:00
wangqiang
f8691f01f0 Handling of option -Wall and -Werror=format=2 override -Wno 2024-07-22 15:30:25 +08:00
openeuler-ci-bot
8e77bfe6cc
!116 [sync] PR-115: Revert "Support stack clash protection"
From: @openeuler-sync-bot 
Reviewed-by: @liyunfei33 
Signed-off-by: @liyunfei33
2024-05-20 03:07:10 +00:00
cf-zhao
034173015e Revert "Support stack clash protection"
This reverts commit 5b938d7d6a6fcc9aa87a12cfe6fde223ed765bd3.

(cherry picked from commit 7be2e4982661c3184196af8c1ca31ad55b8f3496)
2024-05-20 09:06:27 +08:00
openeuler-ci-bot
64db5b62ea
!113 [sync] PR-106: Support stack clash protection
From: @openeuler-sync-bot 
Reviewed-by: @cf-zhao 
Signed-off-by: @cf-zhao
2024-05-16 12:31:35 +00:00
rickyleung
f72a4fc6ae Support stack clash protection
(cherry picked from commit 5b938d7d6a6fcc9aa87a12cfe6fde223ed765bd3)
2024-05-16 10:11:26 +08:00
4 changed files with 509 additions and 3 deletions

View File

@ -0,0 +1,128 @@
From 001e7941bc936847b07da2fdb4b19a8adcba7718 Mon Sep 17 00:00:00 2001
From: liyunfei <liyunfei33@huawei.com>
Date: Fri, 19 Jul 2024 10:44:49 +0800
Subject: [PATCH 1/2] Complete -fgcc-compatible option scope
Complete -fgcc-compatible option scope to Langopts and Diagopts
(cherry picked from commit 8881224782ade2afaab4860f3462e44b7d5c2601)
Signed-off-by: wangqiang <wangqiang1@kylinos.cn>
---
clang/include/clang/Basic/DiagnosticOptions.def | 4 ++++
clang/include/clang/Basic/LangOptions.def | 4 ++++
clang/include/clang/Driver/Options.td | 6 ++++--
clang/lib/Driver/ToolChains/Clang.cpp | 2 ++
clang/lib/Frontend/CompilerInvocation.cpp | 15 +++++++++++++--
5 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/clang/include/clang/Basic/DiagnosticOptions.def b/clang/include/clang/Basic/DiagnosticOptions.def
index 6d0c1b14acc1..5253e951d403 100644
--- a/clang/include/clang/Basic/DiagnosticOptions.def
+++ b/clang/include/clang/Basic/DiagnosticOptions.def
@@ -99,6 +99,10 @@ VALUE_DIAGOPT(MessageLength, 32, 0)
DIAGOPT(ShowSafeBufferUsageSuggestions, 1, 0)
+#ifdef BUILD_FOR_OPENEULER
+DIAGOPT(GccCompatible, 1, 0) /// -fgcc-compatible
+#endif
+
#undef DIAGOPT
#undef ENUM_DIAGOPT
#undef VALUE_DIAGOPT
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index f7ec0406f33e..eb62a4951c65 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -468,6 +468,10 @@ LANGOPT(IncrementalExtensions, 1, 0, " True if we want to process statements"
BENIGN_LANGOPT(CheckNew, 1, 0, "Do not assume C++ operator new may not return NULL")
+#ifdef BUILD_FOR_OPENEULER
+LANGOPT(GccCompatible, 1, 0, "Enable gcc compatibility for openEuler.")
+#endif
+
#undef LANGOPT
#undef COMPATIBLE_LANGOPT
#undef BENIGN_LANGOPT
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 71d6ed66ab96..344c8bd49da7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1810,9 +1810,11 @@ def fautotune_rank : Flag<["-"], "fautotune-rank">, Group<f_Group>,
MarshallingInfoString<CodeGenOpts<"MemoryProfileUsePath">>;
#ifdef BUILD_FOR_OPENEULER
-def fgcc_compatible : Flag<["-"], "fgcc-compatible">, Group<f_Group>,
+def fgcc_compatible : Flag<["-"], "fgcc-compatible">,
+ Flags<[CC1Option]>,
+ MarshallingInfoFlag<DiagnosticOpts<"GccCompatible">>,
HelpText<"Enable gcc compatibility for openEuler.">;
-def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Group<f_Group>;
+def fno_gcc_compatible : Flag<["-"], "fno-gcc-compatible">, Flags<[CC1Option]>;
#endif
// Begin sanitizer flags. These should all be core options exposed in all driver
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index c49cb43ff19c..fac4f03d6193 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4725,6 +4725,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-Wno-error=varargs");
CmdArgs.push_back("-Wno-error=unused-value");
CmdArgs.push_back("-Wno-error=format-nonliteral");
+
+ CmdArgs.push_back("-fgcc-compatible");
}
#endif
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 1fba91bed041..d7b609ef276c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -818,8 +818,9 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
std::vector<std::string> &Diagnostics) {
for (auto *A : Args.filtered(Group)) {
if (A->getOption().getKind() == Option::FlagClass) {
- // The argument is a pure flag (such as OPT_Wall or OPT_Wdeprecated). Add
- // its name (minus the "W" or "R" at the beginning) to the diagnostics.
+ // The argument is a pure flag (such as OPT_Wall or
+ // OPT_Wdeprecated). Add its name (minus the "W" or "R" at the
+ // beginning) to the diagnostics.
Diagnostics.push_back(
std::string(A->getOption().getName().drop_front(1)));
} else if (A->getOption().matches(GroupWithValue)) {
@@ -829,6 +830,7 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
std::string(A->getOption().getName().drop_front(1).rtrim("=-")));
} else {
// Otherwise, add its value (for OPT_W_Joined and similar).
+
Diagnostics.push_back(A->getValue());
}
}
@@ -3522,6 +3524,11 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
if (!Opts.RandstructSeed.empty())
GenerateArg(Args, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed, SA);
+
+#ifdef BUILD_FOR_OPENEULER
+ if (Opts.GccCompatible)
+ GenerateArg(Args, OPT_fgcc_compatible, SA);
+#endif
}
bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
@@ -4073,6 +4080,10 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
Diags.Report(diag::err_drv_hlsl_unsupported_target) << T.str();
}
+#ifdef BUILD_FOR_OPENEULER
+ Opts.GccCompatible = Args.hasArg(options::OPT_fgcc_compatible);
+#endif
+
return Diags.getNumErrors() == NumErrorsBefore;
}
--
2.33.0

View File

@ -0,0 +1,96 @@
From c6f76aa5cdb02c376df17aafadf2dd7cf41fe5b1 Mon Sep 17 00:00:00 2001
From: wangqiang <wangqiang1@kylinos.cn>
Date: Fri, 19 Jul 2024 11:01:22 +0800
Subject: [PATCH 2/2] Handling of option `-Wall` and `-Werror=format=2`
override `-Wno`
Fix nfs-utils build issue
Signed-off-by: wangqiang <wangqiang1@kylinos.cn>
---
clang/lib/Frontend/CompilerInvocation.cpp | 32 ++++++++++++++++++++++-
clang/test/Driver/test-warnning.c | 15 +++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
create mode 100644 clang/test/Driver/test-warnning.c
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index d7b609ef276c..cbb122cc6eeb 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -817,10 +817,40 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
OptSpecifier GroupWithValue,
std::vector<std::string> &Diagnostics) {
for (auto *A : Args.filtered(Group)) {
+#ifdef BUILD_FOR_OPENEULER
+ bool GccCompatible = Args.hasFlag(options::OPT_fgcc_compatible,
+ options::OPT_fno_gcc_compatible, false);
if (A->getOption().getKind() == Option::FlagClass) {
// The argument is a pure flag (such as OPT_Wall or
// OPT_Wdeprecated). Add its name (minus the "W" or "R" at the
// beginning) to the diagnostics.
+ if (A->getOption().getName() == "Wall" && GccCompatible) {
+ // Avoid -Wall and -Werror=format=2 override -Wno-xxx
+ Diagnostics.insert(
+ Diagnostics.begin(),
+ std::string(A->getOption().getName().drop_front(1)));
+ } else {
+ Diagnostics.push_back(
+ std::string(A->getOption().getName().drop_front(1)));
+ }
+ } else if (A->getOption().matches(GroupWithValue)) {
+ // This is -Wfoo= or -Rfoo=, where foo is the name of the diagnostic
+ // group. Add only the group name to the diagnostics.
+ Diagnostics.push_back(std::string(
+ A->getOption().getName().drop_front(1).rtrim("=-")));
+ } else {
+ // Otherwise, add its value (for OPT_W_Joined and similar).
+ if (std::string(A->getValue()) == "error=format=2" && GccCompatible) {
+ // Avoid -Werror=format=2 override -Wno-xxx
+ Diagnostics.insert(Diagnostics.begin(), A->getValue());
+ } else {
+ Diagnostics.push_back(A->getValue());
+ }
+ }
+#else
+ if (A->getOption().getKind() == Option::FlagClass) {
+ // The argument is a pure flag (such as OPT_Wall or OPT_Wdeprecated). Add
+ // its name (minus the "W" or "R" at the beginning) to the diagnostics.
Diagnostics.push_back(
std::string(A->getOption().getName().drop_front(1)));
} else if (A->getOption().matches(GroupWithValue)) {
@@ -830,9 +860,9 @@ static void addDiagnosticArgs(ArgList &Args, OptSpecifier Group,
std::string(A->getOption().getName().drop_front(1).rtrim("=-")));
} else {
// Otherwise, add its value (for OPT_W_Joined and similar).
-
Diagnostics.push_back(A->getValue());
}
+#endif
}
}
diff --git a/clang/test/Driver/test-warnning.c b/clang/test/Driver/test-warnning.c
new file mode 100644
index 000000000000..641f9e3512d5
--- /dev/null
+++ b/clang/test/Driver/test-warnning.c
@@ -0,0 +1,15 @@
+// REQUIRES: build_for_openeuler
+
+// RUN: %clang -v -fgcc-compatible -Wno-format-security -Werror=format=2 -Wall %s
+// RUN: %clang -v -Wall %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// CHECK-ERROR: warning: format string is not a string literal (potentially insecure)
+// RUN: %clang -v -Wno-format-security -Werror=format=2 -Wall %s 2>&1 | FileCheck -check-prefix=CHECK-ERROR %s
+// CHECK-ERROR: error: format string is not a string literal (potentially insecure)
+
+#include <stdio.h>
+
+int main() {
+ char *str = "llvm-project";
+ printf(str);
+ return 0;
+}
\ No newline at end of file
--
2.33.0

View File

@ -0,0 +1,259 @@
From c2668403868559918b54671d3d31527fb2f04486 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=88=98=E9=9B=A8=E5=9F=B9?= <liuyupei951018@hotmail.com>
Date: Wed, 1 Nov 2023 21:45:48 +0800
Subject: [PATCH] Defer the instantiation of explicit-specifier until
constraint checking completes (#70548)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Modifications:
- Skip the instantiation of the explicit-specifier during Decl
substitution if we are deducing template arguments and the
explicit-specifier is value dependent.
- Instantiate the explicit-specifier after the constraint checking
completes.
- Make `instantiateExplicitSpecifier` a member function in order to
instantiate the explicit-specifier in different stages.
This PR doesnt defer the instantiation of the explicit specifier for
deduction guides, because Im not familiar with deduction guides yet.
Ill dig into it after this PR.
According to my local test, GCC 13 tuple works with this PR.
Fixes #59827.
---------
Co-authored-by: Erich Keane <ekeane@nvidia.com>
---
docs/ReleaseNotes.rst | 4 ++
include/clang/Sema/Sema.h | 3 ++
lib/Sema/SemaTemplateDeduction.cpp | 53 +++++++++++++++++++
lib/Sema/SemaTemplateInstantiateDecl.cpp | 40 +++++++++-----
test/SemaCXX/cxx2a-explicit-bool-deferred.cpp | 31 +++++++++++
5 files changed, 117 insertions(+), 14 deletions(-)
create mode 100644 test/SemaCXX/cxx2a-explicit-bool-deferred.cpp
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5086a56e..05dad41c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -860,6 +860,10 @@ Bug Fixes to C++ Support
(`#64172 <https://github.com/llvm/llvm-project/issues/64172>`_) and
(`#64723 <https://github.com/llvm/llvm-project/issues/64723>`_).
+- Clang now defers the instantiation of explicit specifier until constraint checking
+ completes (except deduction guides). Fixes:
+ (`#59827 <https://github.com/llvm/llvm-project/issues/59827>`_)
+
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3752a23f..b2ab6d0f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10293,6 +10293,9 @@ public:
const CXXConstructorDecl *Tmpl,
const MultiLevelTemplateArgumentList &TemplateArgs);
+ ExplicitSpecifier instantiateExplicitSpecifier(
+ const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES);
+
NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
const MultiLevelTemplateArgumentList &TemplateArgs,
bool FindingInstantiatedContext = false);
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 31ea7be2..58dd1b78 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3546,6 +3546,48 @@ static unsigned getPackIndexForParam(Sema &S,
llvm_unreachable("parameter index would not be produced from template");
}
+// if `Specialization` is a `CXXConstructorDecl` or `CXXConversionDecl`,
+// we'll try to instantiate and update its explicit specifier after constraint
+// checking.
+static Sema::TemplateDeductionResult instantiateExplicitSpecifierDeferred(
+ Sema &S, FunctionDecl *Specialization,
+ const MultiLevelTemplateArgumentList &SubstArgs,
+ TemplateDeductionInfo &Info, FunctionTemplateDecl *FunctionTemplate,
+ ArrayRef<TemplateArgument> DeducedArgs) {
+ auto GetExplicitSpecifier = [](FunctionDecl *D) {
+ return isa<CXXConstructorDecl>(D)
+ ? cast<CXXConstructorDecl>(D)->getExplicitSpecifier()
+ : cast<CXXConversionDecl>(D)->getExplicitSpecifier();
+ };
+ auto SetExplicitSpecifier = [](FunctionDecl *D, ExplicitSpecifier ES) {
+ isa<CXXConstructorDecl>(D)
+ ? cast<CXXConstructorDecl>(D)->setExplicitSpecifier(ES)
+ : cast<CXXConversionDecl>(D)->setExplicitSpecifier(ES);
+ };
+
+ ExplicitSpecifier ES = GetExplicitSpecifier(Specialization);
+ Expr *ExplicitExpr = ES.getExpr();
+ if (!ExplicitExpr)
+ return Sema::TDK_Success;
+ if (!ExplicitExpr->isValueDependent())
+ return Sema::TDK_Success;
+
+ Sema::InstantiatingTemplate Inst(
+ S, Info.getLocation(), FunctionTemplate, DeducedArgs,
+ Sema::CodeSynthesisContext::DeducedTemplateArgumentSubstitution, Info);
+ if (Inst.isInvalid())
+ return Sema::TDK_InstantiationDepth;
+ Sema::SFINAETrap Trap(S);
+ const ExplicitSpecifier InstantiatedES =
+ S.instantiateExplicitSpecifier(SubstArgs, ES);
+ if (InstantiatedES.isInvalid() || Trap.hasErrorOccurred()) {
+ Specialization->setInvalidDecl(true);
+ return Sema::TDK_SubstitutionFailure;
+ }
+ SetExplicitSpecifier(Specialization, InstantiatedES);
+ return Sema::TDK_Success;
+}
+
/// Finish template argument deduction for a function template,
/// checking the deduced template arguments for completeness and forming
/// the function template specialization.
@@ -3675,6 +3717,17 @@ Sema::TemplateDeductionResult Sema::FinishTemplateArgumentDeduction(
}
}
+ // We skipped the instantiation of the explicit-specifier during the
+ // substitution of `FD` before. So, we try to instantiate it back if
+ // `Specialization` is either a constructor or a conversion function.
+ if (isa<CXXConstructorDecl, CXXConversionDecl>(Specialization)) {
+ if (TDK_Success != instantiateExplicitSpecifierDeferred(
+ *this, Specialization, SubstArgs, Info,
+ FunctionTemplate, DeducedArgs)) {
+ return TDK_SubstitutionFailure;
+ }
+ }
+
if (OriginalCallArgs) {
// C++ [temp.deduct.call]p4:
// In general, the deduction process attempts to find template argument
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index f78d46f5..a40510ce 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -555,18 +555,16 @@ static void instantiateDependentAMDGPUFlatWorkGroupSizeAttr(
S.addAMDGPUFlatWorkGroupSizeAttr(New, Attr, MinExpr, MaxExpr);
}
-static ExplicitSpecifier
-instantiateExplicitSpecifier(Sema &S,
- const MultiLevelTemplateArgumentList &TemplateArgs,
- ExplicitSpecifier ES, FunctionDecl *New) {
+ExplicitSpecifier Sema::instantiateExplicitSpecifier(
+ const MultiLevelTemplateArgumentList &TemplateArgs, ExplicitSpecifier ES) {
if (!ES.getExpr())
return ES;
Expr *OldCond = ES.getExpr();
Expr *Cond = nullptr;
{
EnterExpressionEvaluationContext Unevaluated(
- S, Sema::ExpressionEvaluationContext::ConstantEvaluated);
- ExprResult SubstResult = S.SubstExpr(OldCond, TemplateArgs);
+ *this, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+ ExprResult SubstResult = SubstExpr(OldCond, TemplateArgs);
if (SubstResult.isInvalid()) {
return ExplicitSpecifier::Invalid();
}
@@ -574,7 +572,7 @@ instantiateExplicitSpecifier(Sema &S,
}
ExplicitSpecifier Result(Cond, ES.getKind());
if (!Cond->isTypeDependent())
- S.tryResolveExplicitSpecifier(Result);
+ tryResolveExplicitSpecifier(Result);
return Result;
}
@@ -2065,8 +2063,8 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
ExplicitSpecifier InstantiatedExplicitSpecifier;
if (auto *DGuide = dyn_cast<CXXDeductionGuideDecl>(D)) {
- InstantiatedExplicitSpecifier = instantiateExplicitSpecifier(
- SemaRef, TemplateArgs, DGuide->getExplicitSpecifier(), DGuide);
+ InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier(
+ TemplateArgs, DGuide->getExplicitSpecifier());
if (InstantiatedExplicitSpecifier.isInvalid())
return nullptr;
}
@@ -2440,11 +2438,25 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(
}
}
- ExplicitSpecifier InstantiatedExplicitSpecifier =
- instantiateExplicitSpecifier(SemaRef, TemplateArgs,
- ExplicitSpecifier::getFromDecl(D), D);
- if (InstantiatedExplicitSpecifier.isInvalid())
- return nullptr;
+ auto InstantiatedExplicitSpecifier = ExplicitSpecifier::getFromDecl(D);
+ // deduction guides need this
+ const bool CouldInstantiate =
+ InstantiatedExplicitSpecifier.getExpr() == nullptr ||
+ !InstantiatedExplicitSpecifier.getExpr()->isValueDependent();
+
+ // Delay the instantiation of the explicit-specifier until after the
+ // constraints are checked during template argument deduction.
+ if (CouldInstantiate ||
+ SemaRef.CodeSynthesisContexts.back().Kind !=
+ Sema::CodeSynthesisContext::DeducedTemplateArgumentSubstitution) {
+ InstantiatedExplicitSpecifier = SemaRef.instantiateExplicitSpecifier(
+ TemplateArgs, InstantiatedExplicitSpecifier);
+
+ if (InstantiatedExplicitSpecifier.isInvalid())
+ return nullptr;
+ } else {
+ InstantiatedExplicitSpecifier.setKind(ExplicitSpecKind::Unresolved);
+ }
// Implicit destructors/constructors created for local classes in
// DeclareImplicit* (see SemaDeclCXX.cpp) might not have an associated TSI.
diff --git a/clang/test/SemaCXX/cxx2a-explicit-bool-deferred.cpp b/clang/test/SemaCXX/cxx2a-explicit-bool-deferred.cpp
new file mode 100644
index 00000000..4d667008
--- /dev/null
+++ b/clang/test/SemaCXX/cxx2a-explicit-bool-deferred.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s
+
+template <typename T1, typename T2> struct is_same {
+ static constexpr bool value = false;
+};
+
+template <typename T> struct is_same<T, T> {
+ static constexpr bool value = true;
+};
+
+template <class T, class U>
+concept SameHelper = is_same<T, U>::value;
+template <class T, class U>
+concept same_as = SameHelper<T, U> && SameHelper<U, T>;
+
+namespace deferred_instantiation {
+template <class X> constexpr X do_not_instantiate() { return nullptr; }
+
+struct T {
+ template <same_as<float> X> explicit(do_not_instantiate<X>()) T(X) {}
+
+ T(int) {}
+};
+
+T t(5);
+// expected-error@17{{cannot initialize}}
+// expected-note@20{{in instantiation of function template specialization}}
+// expected-note@30{{while substituting deduced template arguments}}
+// expected-note@30{{in instantiation of function template specialization}}
+T t2(5.0f);
+} // namespace deferred_instantiation
--
2.33.0

View File

@ -37,7 +37,7 @@
Name: %{pkg_name}
Version: %{clang_version}
Release: 16
Release: 19
Summary: A C language family front-end for LLVM
License: NCSA
@ -60,6 +60,9 @@ Patch11: 0011-Add-the-support-for-classic-flang.patch
Patch12: 0012-Fix-declaration-definition-mismatch-for-classic-flang.patch
Patch13: 0013-Ignored-option-Wa-generate-missing-build-notes.patch
Patch14: 0014-Update-llvm-lit-config-to-support-build_for_openeule.patch
Patch15: 0015-Complete-fgcc-compatible-option-scope.patch
Patch16: 0016-Handling-of-option-Wall-and-Werror-format-2-override.patch
Patch17: 0017-Backport-Defer-the-instantiation-of-explicit-specifier-until-.patch
# Patches for clang-tools-extra
# See https://reviews.llvm.org/D120301
@ -109,6 +112,7 @@ BuildRequires: perl(Text::ParseWords)
BuildRequires: perl(Sys::Hostname)
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
Requires: %{name}-tools-extra%{?_isa} = %{version}-%{release}
Requires: libstdc++-devel
# Require gcc libs installed during rumtime
@ -158,6 +162,12 @@ Provides: %{name}-resource-filesystem(major) = %{maj_ver}
%description resource-filesystem
This package owns the clang resouce directory: $libdir/clang/$version/
%package help
Summary: Help manual for %{name}
%description help
The %{name}-help package contains mannual etc
%package analyzer
Summary: A source code analysis framework
@ -303,7 +313,6 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build
%{install_bindir}/clang-%{maj_ver}
%{install_bindir}/clang-cl
%{install_bindir}/clang-cpp
%{install_prefix}/share/man/man1/*
%if %{with classic_flang}
%{install_bindir}/flang
%endif
@ -327,6 +336,10 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build
%dir %{install_libdir}/clang/%{maj_ver}/share/
%dir %{install_libdir}/clang/
%files help
%{_mandir}/man1/clang.1.gz
%{_mandir}/man1/diagtool.1.gz
%files analyzer
%{install_libexecdir}/ccc-analyzer
%{install_libexecdir}/c++-analyzer
@ -339,7 +352,7 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build
%{install_bindir}/analyze-build
%{install_bindir}/intercept-build
%{install_bindir}/scan-build-py
%{install_prefix}/share/man/man1/*
%{_mandir}/man1/scan-build.1.*
%{install_libdir}/libear
%{install_libdir}/libscanbuild
%{install_sharedir}/scan-view
@ -394,6 +407,16 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build
%{install_bindir}/git-clang-format
%changelog
* Tue Nov 05 2024 zhangnan <zhangnan134@huawei.com> - 17.0.6-19
- remove duplicate files and add Requires and add help package
* Thu Sep 05 2024 Zhao Mengmeng <zhaomengmeng@kylinos.cn> - 17.0.6-18
- Fix the too-early instantiation of conditional "explict" by applying the patch
of https://github.com/llvm/llvm-project/commit/128b3b61fe6768c724975fd1df2be0abec848cf6
* Mon Jul 22 2024 wangqiang <wangqiang1@kylinos.cn> - 17.0.6-17
- Complete -fgcc-compatible option scope to Langopts and Diagopts, and handling of option `-Wall` and `-Werror=format=2` override `-Wno`
* Mon Apr 29 2024 wangqiang <wangqiang1@kylinos.cn> - 17.0.6-16
- Ignored the `-Wa,--generate-missing-build-notes=` option, update llvm-lit config to support macro `build_for_openeuler`