Skip to content

Commit 1f47f3f

Browse files
committed
Merge from '"main"' to '"sycl-web"' (5 commits)
CONFLICT (content): Merge conflict in clang/lib/Driver/Driver.cpp
2 parents b450017 + 98ab43a commit 1f47f3f

File tree

327 files changed

+5803
-6114
lines changed

Some content is hidden

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

327 files changed

+5803
-6114
lines changed

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ void RenamerClangTidyCheck::checkMacro(SourceManager &SourceMgr,
486486
NamingCheckFailure &Failure = NamingCheckFailures[ID];
487487
SourceRange Range(MacroNameTok.getLocation(), MacroNameTok.getEndLoc());
488488

489+
if (!isValidAsciiIdentifier(Info.Fixup))
490+
Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
491+
489492
Failure.Info = std::move(Info);
490493
addUsage(ID, Range);
491494
}

clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ bool ExpandAutoType::prepare(const Selection& Inputs) {
9696
if (auto *Node = Inputs.ASTSelection.commonAncestor()) {
9797
if (auto *TypeNode = Node->ASTNode.get<TypeLoc>()) {
9898
if (const AutoTypeLoc Result = TypeNode->getAs<AutoTypeLoc>()) {
99-
if (!isStructuredBindingType(Node) &&
99+
// Code in apply() does handle 'decltype(auto)' yet.
100+
if (!Result.getTypePtr()->isDecltypeAuto() &&
101+
!isStructuredBindingType(Node) &&
100102
!isDeducedAsLambda(Node, Result.getBeginLoc()) &&
101103
!isTemplateParam(Node))
102104
CachedLocation = Result;

clang-tools-extra/clangd/unittests/SelectionTests.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@ TEST(SelectionTest, CommonAncestor) {
391391
)cpp",
392392
"DeclRefExpr"},
393393
{"[[decltype^(1)]] b;", "DecltypeTypeLoc"}, // Not the VarDecl.
394-
// decltype(auto) is an AutoTypeLoc!
395-
{"[[de^cltype(a^uto)]] a = 1;", "AutoTypeLoc"},
396394

397395
// Objective-C nullability attributes.
398396
{

clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ TEST_F(ExpandAutoTypeTest, Test) {
7171
apply("void ns::Func() { au^to x = new ns::Class::Nested{}; }"),
7272
"void ns::Func() { ns::Class::Nested * x = new ns::Class::Nested{}; }");
7373

74-
EXPECT_EQ(apply("dec^ltype(auto) x = 10;"), "int x = 10;");
75-
EXPECT_EQ(apply("decltype(au^to) x = 10;"), "int x = 10;");
74+
EXPECT_UNAVAILABLE("dec^ltype(au^to) x = 10;");
7675
// expanding types in structured bindings is syntactically invalid.
7776
EXPECT_UNAVAILABLE("const ^auto &[x,y] = (int[]){1,2};");
7877

clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ int _;
171171
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration uses identifier '_', which is reserved in the global namespace; cannot be fixed automatically [bugprone-reserved-identifier]
172172
// CHECK-FIXES: {{^}}int _;{{$}}
173173

174+
// https://github.com/llvm/llvm-project/issues/52895
175+
#define _5_kmph_rpm 459
176+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration uses identifier '_5_kmph_rpm', which is reserved in the global namespace; cannot be fixed automatically [bugprone-reserved-identifier]
177+
// CHECK-FIXES: {{^}}#define _5_kmph_rpm 459{{$}}
178+
174179
// these should pass
175180
#define MACRO(m) int m = 0
176181

clang/include/clang/AST/ASTConcept.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ class ConceptReference {
131131
NamedConcept(NamedConcept), ArgsAsWritten(ArgsAsWritten) {}
132132

133133
ConceptReference()
134-
: FoundDecl(nullptr), NamedConcept(nullptr), ArgsAsWritten(nullptr) {}
134+
: TemplateKWLoc(), FoundDecl(nullptr), NamedConcept(nullptr),
135+
ArgsAsWritten(nullptr) {}
135136

136137
const NestedNameSpecifierLoc &getNestedNameSpecifierLoc() const {
137138
return NestedNameSpec;

clang/include/clang/AST/TypeLoc.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,9 +2081,6 @@ struct AutoTypeLocInfo : TypeSpecLocInfo {
20812081
NamedDecl *FoundDecl;
20822082
SourceLocation LAngleLoc;
20832083
SourceLocation RAngleLoc;
2084-
2085-
// For decltype(auto).
2086-
SourceLocation RParenLoc;
20872084
};
20882085

20892086
class AutoTypeLoc
@@ -2096,10 +2093,6 @@ class AutoTypeLoc
20962093
return getTypePtr()->getKeyword();
20972094
}
20982095

2099-
bool isDecltypeAuto() const { return getTypePtr()->isDecltypeAuto(); }
2100-
SourceLocation getRParenLoc() const { return getLocalData()->RParenLoc; }
2101-
void setRParenLoc(SourceLocation Loc) { getLocalData()->RParenLoc = Loc; }
2102-
21032096
bool isConstrained() const {
21042097
return getTypePtr()->isConstrained();
21052098
}
@@ -2180,13 +2173,16 @@ class AutoTypeLoc
21802173
}
21812174

21822175
SourceRange getLocalSourceRange() const {
2183-
return {isConstrained()
2184-
? (getNestedNameSpecifierLoc()
2185-
? getNestedNameSpecifierLoc().getBeginLoc()
2186-
: (getTemplateKWLoc().isValid() ? getTemplateKWLoc()
2187-
: getConceptNameLoc()))
2188-
: getNameLoc(),
2189-
isDecltypeAuto() ? getRParenLoc() : getNameLoc()};
2176+
return{
2177+
isConstrained()
2178+
? (getNestedNameSpecifierLoc()
2179+
? getNestedNameSpecifierLoc().getBeginLoc()
2180+
: (getTemplateKWLoc().isValid()
2181+
? getTemplateKWLoc()
2182+
: getConceptNameLoc()))
2183+
: getNameLoc(),
2184+
getNameLoc()
2185+
};
21902186
}
21912187

21922188
void copy(AutoTypeLoc Loc) {

clang/include/clang/ASTMatchers/Dynamic/Diagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct SourceRange {
4040

4141
/// A VariantValue instance annotated with its parser context.
4242
struct ParserValue {
43-
ParserValue() {}
43+
ParserValue() : Range() {}
4444
StringRef Text;
4545
SourceRange Range;
4646
VariantValue Value;

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ namespace dataflow {
3939
/// must provide the following public members:
4040
/// * `LatticeT initialElement()` - returns a lattice element that models the
4141
/// initial state of a basic block;
42-
/// * `LatticeT transfer(const Stmt *, const LatticeT &, Environment &)` -
43-
/// applies the analysis transfer function for a given statement and lattice
44-
/// element.
42+
/// * `void transfer(const Stmt *, LatticeT &, Environment &)` - applies the
43+
/// analysis transfer function for a given statement and lattice element.
4544
///
4645
/// `LatticeT` is a bounded join-semilattice that is used by `Derived` and must
4746
/// provide the following public members:
@@ -79,11 +78,10 @@ class DataflowAnalysis : public TypeErasedDataflowAnalysis {
7978
return L1 == L2;
8079
}
8180

82-
TypeErasedLattice transferTypeErased(const Stmt *Stmt,
83-
const TypeErasedLattice &E,
84-
Environment &Env) final {
85-
const Lattice &L = llvm::any_cast<const Lattice &>(E.Value);
86-
return {static_cast<Derived *>(this)->transfer(Stmt, L, Env)};
81+
void transferTypeErased(const Stmt *Stmt, TypeErasedLattice &E,
82+
Environment &Env) final {
83+
Lattice &L = llvm::any_cast<Lattice &>(E.Value);
84+
static_cast<Derived *>(this)->transfer(Stmt, L, Env);
8785
}
8886

8987
private:

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_DATAFLOWANALYSISCONTEXT_H
1717

1818
#include "clang/AST/Decl.h"
19+
#include "clang/AST/Expr.h"
1920
#include "clang/Analysis/FlowSensitive/StorageLocation.h"
2021
#include "clang/Analysis/FlowSensitive/Value.h"
2122
#include "llvm/ADT/DenseMap.h"
@@ -70,6 +71,23 @@ class DataflowAnalysisContext {
7071
return It == DeclToLoc.end() ? nullptr : It->second;
7172
}
7273

74+
/// Assigns `Loc` as the storage location of `E`.
75+
///
76+
/// Requirements:
77+
///
78+
/// `E` must not be assigned a storage location.
79+
void setStorageLocation(const Expr &E, StorageLocation &Loc) {
80+
assert(ExprToLoc.find(&E) == ExprToLoc.end());
81+
ExprToLoc[&E] = &Loc;
82+
}
83+
84+
/// Returns the storage location assigned to `E` or null if `E` has no
85+
/// assigned storage location.
86+
StorageLocation *getStorageLocation(const Expr &E) const {
87+
auto It = ExprToLoc.find(&E);
88+
return It == ExprToLoc.end() ? nullptr : It->second;
89+
}
90+
7391
private:
7492
// Storage for the state of a program.
7593
std::vector<std::unique_ptr<StorageLocation>> Locs;
@@ -81,7 +99,7 @@ class DataflowAnalysisContext {
8199
// basic blocks are evaluated multiple times. The storage locations that are
82100
// in scope for a particular basic block are stored in `Environment`.
83101
llvm::DenseMap<const ValueDecl *, StorageLocation *> DeclToLoc;
84-
// FIXME: Add `Expr` to `StorageLocation` map.
102+
llvm::DenseMap<const Expr *, StorageLocation *> ExprToLoc;
85103

86104
// FIXME: Add `StorageLocation` for `this`.
87105

0 commit comments

Comments
 (0)