Skip to content

Commit 6aa8230

Browse files
authored
Merge branch 'main' into covariant
2 parents 027a985 + e018f55 commit 6aa8230

File tree

349 files changed

+8040
-3397
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

349 files changed

+8040
-3397
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ function keep-modified-projects() {
191191
}
192192

193193
function check-targets() {
194+
# Do not use "check-all" here because if there is "check-all" plus a
195+
# project specific target like "check-clang", that project's tests
196+
# will be run twice.
194197
projects=${@}
195198
for project in ${projects}; do
196199
case ${project} in
@@ -216,7 +219,7 @@ function check-targets() {
216219
echo "check-lldb"
217220
;;
218221
pstl)
219-
echo "check-all"
222+
# Currently we do not run pstl tests in CI.
220223
;;
221224
libclc)
222225
# Currently there is no testing for libclc.

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,8 @@ groupReplacements(const TUReplacements &TUs, const TUDiagnostics &TUDs,
148148

149149
if (auto Entry = SM.getFileManager().getOptionalFileRef(Path)) {
150150
if (SourceTU) {
151-
auto &Replaces = DiagReplacements[*Entry];
152-
auto It = Replaces.find(R);
153-
if (It == Replaces.end())
154-
Replaces.emplace(R, SourceTU);
155-
else if (It->second != SourceTU)
151+
auto [It, Inserted] = DiagReplacements[*Entry].try_emplace(R, SourceTU);
152+
if (!Inserted && It->second != SourceTU)
156153
// This replacement is a duplicate of one suggested by another TU.
157154
return;
158155
}

clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,8 @@ void ChangeNamespaceTool::run(
606606
Result.Nodes.getNodeAs<DeclRefExpr>("func_ref")) {
607607
// If this reference has been processed as a function call, we do not
608608
// process it again.
609-
if (ProcessedFuncRefs.count(FuncRef))
609+
if (!ProcessedFuncRefs.insert(FuncRef).second)
610610
return;
611-
ProcessedFuncRefs.insert(FuncRef);
612611
const auto *Func = Result.Nodes.getNodeAs<FunctionDecl>("func_decl");
613612
assert(Func);
614613
const auto *Context = Result.Nodes.getNodeAs<Decl>("dc");

clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ void ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit() {
146146
}
147147
// Check if a definition in another namespace exists.
148148
const auto DeclName = CurDecl->getName();
149-
if (!DeclNameToDefinitions.contains(DeclName)) {
149+
auto It = DeclNameToDefinitions.find(DeclName);
150+
if (It == DeclNameToDefinitions.end()) {
150151
continue; // No definition in this translation unit, we can skip it.
151152
}
152153
// Make a warning for each definition with the same name (in other
153154
// namespaces).
154-
const auto &Definitions = DeclNameToDefinitions[DeclName];
155+
const auto &Definitions = It->second;
155156
for (const auto *Def : Definitions) {
156157
diag(CurDecl->getLocation(),
157158
"no definition found for %0, but a definition with "

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ C++23 Feature Support
171171
^^^^^^^^^^^^^^^^^^^^^
172172
- Removed the restriction to literal types in constexpr functions in C++23 mode.
173173

174+
- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully
175+
supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
176+
174177
C++20 Feature Support
175178
^^^^^^^^^^^^^^^^^^^^^
176179

clang/include/clang/AST/Attr.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,23 @@ class InheritableParamAttr : public InheritableAttr {
197197
}
198198
};
199199

200+
class InheritableParamOrStmtAttr : public InheritableParamAttr {
201+
protected:
202+
InheritableParamOrStmtAttr(ASTContext &Context,
203+
const AttributeCommonInfo &CommonInfo,
204+
attr::Kind AK, bool IsLateParsed,
205+
bool InheritEvenIfAlreadyPresent)
206+
: InheritableParamAttr(Context, CommonInfo, AK, IsLateParsed,
207+
InheritEvenIfAlreadyPresent) {}
208+
209+
public:
210+
// Implement isa/cast/dyncast/etc.
211+
static bool classof(const Attr *A) {
212+
return A->getKind() >= attr::FirstInheritableParamOrStmtAttr &&
213+
A->getKind() <= attr::LastInheritableParamOrStmtAttr;
214+
}
215+
};
216+
200217
class HLSLAnnotationAttr : public InheritableAttr {
201218
protected:
202219
HLSLAnnotationAttr(ASTContext &Context, const AttributeCommonInfo &CommonInfo,

clang/include/clang/Basic/Attr.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,11 @@ class TargetSpecificAttr<TargetSpec target> {
759759
/// redeclarations, even when it's written on a parameter.
760760
class InheritableParamAttr : InheritableAttr;
761761

762+
/// A attribute that is either a declaration attribute or a statement attribute,
763+
/// and if used as a declaration attribute, is inherited by later
764+
/// redeclarations, even when it's written on a parameter.
765+
class InheritableParamOrStmtAttr : InheritableParamAttr;
766+
762767
/// An attribute which changes the ABI rules for a specific parameter.
763768
class ParameterABIAttr : InheritableParamAttr {
764769
let Subjects = SubjectList<[ParmVar]>;
@@ -928,7 +933,7 @@ def AnalyzerNoReturn : InheritableAttr {
928933
let Documentation = [Undocumented];
929934
}
930935

931-
def Annotate : InheritableParamAttr {
936+
def Annotate : InheritableParamOrStmtAttr {
932937
let Spellings = [Clang<"annotate">];
933938
let Args = [StringArgument<"Annotation">, VariadicExprArgument<"Args">];
934939
// Ensure that the annotate attribute can be used with

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4745,6 +4745,12 @@ def HLSLCross: LangBuiltin<"HLSL_LANG"> {
47454745
let Prototype = "void(...)";
47464746
}
47474747

4748+
def HLSLDegrees : LangBuiltin<"HLSL_LANG"> {
4749+
let Spellings = ["__builtin_hlsl_elementwise_degrees"];
4750+
let Attributes = [NoThrow, Const];
4751+
let Prototype = "void(...)";
4752+
}
4753+
47484754
def HLSLDotProduct : LangBuiltin<"HLSL_LANG"> {
47494755
let Spellings = ["__builtin_hlsl_dot"];
47504756
let Attributes = [NoThrow, Const];

clang/include/clang/Sema/Sema.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,9 +4528,10 @@ class Sema final : public SemaBase {
45284528
/// declaration.
45294529
void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E);
45304530

4531-
/// AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
4532-
void AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI,
4533-
StringRef Annot, MutableArrayRef<Expr *> Args);
4531+
/// CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
4532+
Attr *CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot,
4533+
MutableArrayRef<Expr *> Args);
4534+
Attr *CreateAnnotationAttr(const ParsedAttr &AL);
45344535

45354536
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range,
45364537
bool BestCase,

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6006,6 +6006,9 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
60066006

60076007
return this->emitGetPtrParam(It->second.Offset, E);
60086008
}
6009+
6010+
if (D->getType()->isReferenceType())
6011+
return false; // FIXME: Do we need to emit InvalidDeclRef?
60096012
}
60106013

60116014
// In case we need to re-visit a declaration.
@@ -6042,9 +6045,7 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
60426045
const auto typeShouldBeVisited = [&](QualType T) -> bool {
60436046
if (T.isConstant(Ctx.getASTContext()))
60446047
return true;
6045-
if (const auto *RT = T->getAs<ReferenceType>())
6046-
return RT->getPointeeType().isConstQualified();
6047-
return false;
6048+
return T->isReferenceType();
60486049
};
60496050

60506051
// DecompositionDecls are just proxies for us.
@@ -6060,9 +6061,12 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
60606061
// other words, we're evaluating the initializer, just to know if we can
60616062
// evaluate the initializer.
60626063
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
6063-
VD->getInit() && !VD->getInit()->isValueDependent() &&
6064-
VD->evaluateValue())
6065-
return revisit(VD);
6064+
VD->getInit() && !VD->getInit()->isValueDependent()) {
6065+
6066+
if (VD->evaluateValue())
6067+
return revisit(VD);
6068+
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E), E);
6069+
}
60666070
}
60676071
} else {
60686072
if (const auto *VD = dyn_cast<VarDecl>(D);

0 commit comments

Comments
 (0)