Skip to content

Commit 2ad206f

Browse files
Merge branch 'main' into main
2 parents b1b5286 + 837b89f commit 2ad206f

File tree

186 files changed

+5875
-5106
lines changed

Some content is hidden

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

186 files changed

+5875
-5106
lines changed

clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ void IncludeModernizePPCallbacks::InclusionDirective(
199199
// 2. Insert `using namespace std;` to the beginning of TU.
200200
// 3. Do nothing and let the user deal with the migration himself.
201201
SourceLocation DiagLoc = FilenameRange.getBegin();
202-
if (CStyledHeaderToCxx.count(FileName) != 0) {
203-
IncludesToBeProcessed.emplace_back(
204-
IncludeMarker{CStyledHeaderToCxx[FileName], FileName,
205-
FilenameRange.getAsRange(), DiagLoc});
202+
if (auto It = CStyledHeaderToCxx.find(FileName);
203+
It != CStyledHeaderToCxx.end()) {
204+
IncludesToBeProcessed.emplace_back(IncludeMarker{
205+
It->second, FileName, FilenameRange.getAsRange(), DiagLoc});
206206
} else if (DeleteHeaders.count(FileName) != 0) {
207207
IncludesToBeProcessed.emplace_back(
208208
// NOLINTNEXTLINE(modernize-use-emplace) - false-positive

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace interp {
2929
template <class Emitter> class DeclScope final : public LocalScope<Emitter> {
3030
public:
3131
DeclScope(Compiler<Emitter> *Ctx, const ValueDecl *VD)
32-
: LocalScope<Emitter>(Ctx, VD), Scope(Ctx->P, VD),
32+
: LocalScope<Emitter>(Ctx, VD), Scope(Ctx->P),
3333
OldInitializingDecl(Ctx->InitializingDecl) {
3434
Ctx->InitializingDecl = VD;
3535
Ctx->InitStack.push_back(InitLink::Decl(VD));

clang/lib/AST/ByteCode/Program.h

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,22 @@ class Program final {
132132
/// Context to manage declaration lifetimes.
133133
class DeclScope {
134134
public:
135-
DeclScope(Program &P, const ValueDecl *VD) : P(P) {
136-
P.startDeclaration(VD);
135+
DeclScope(Program &P) : P(P), PrevDecl(P.CurrentDeclaration) {
136+
++P.LastDeclaration;
137+
P.CurrentDeclaration = P.LastDeclaration;
137138
}
138-
~DeclScope() { P.endDeclaration(); }
139+
~DeclScope() { P.CurrentDeclaration = PrevDecl; }
139140

140141
private:
141142
Program &P;
143+
unsigned PrevDecl;
142144
};
143145

144146
/// Returns the current declaration ID.
145147
std::optional<unsigned> getCurrentDecl() const {
146148
if (CurrentDeclaration == NoDeclaration)
147-
return std::optional<unsigned>{};
148-
return LastDeclaration;
149+
return std::nullopt;
150+
return CurrentDeclaration;
149151
}
150152

151153
private:
@@ -218,21 +220,12 @@ class Program final {
218220
}
219221

220222
/// No declaration ID.
221-
static constexpr unsigned NoDeclaration = (unsigned)-1;
223+
static constexpr unsigned NoDeclaration = ~0u;
222224
/// Last declaration ID.
223225
unsigned LastDeclaration = 0;
224226
/// Current declaration ID.
225227
unsigned CurrentDeclaration = NoDeclaration;
226228

227-
/// Starts evaluating a declaration.
228-
void startDeclaration(const ValueDecl *Decl) {
229-
LastDeclaration += 1;
230-
CurrentDeclaration = LastDeclaration;
231-
}
232-
233-
/// Ends a global declaration.
234-
void endDeclaration() { CurrentDeclaration = NoDeclaration; }
235-
236229
public:
237230
/// Dumps the disassembled bytecode to \c llvm::errs().
238231
void dump() const;

clang/lib/Analysis/LiveVariables.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,18 +664,18 @@ void LiveVariables::dumpExprLiveness(const SourceManager &M) {
664664
}
665665

666666
void LiveVariablesImpl::dumpExprLiveness(const SourceManager &M) {
667-
auto ByBeginLoc = [&M](const Expr *L, const Expr *R) {
668-
return M.isBeforeInTranslationUnit(L->getBeginLoc(), R->getBeginLoc());
667+
const ASTContext &Ctx = analysisContext.getASTContext();
668+
auto ByIDs = [&Ctx](const Expr *L, const Expr *R) {
669+
return L->getID(Ctx) < R->getID(Ctx);
669670
};
670671

671672
// Don't iterate over blockEndsToLiveness directly because it's not sorted.
672673
for (const CFGBlock *B : *analysisContext.getCFG()) {
673-
674674
llvm::errs() << "\n[ B" << B->getBlockID()
675675
<< " (live expressions at block exit) ]\n";
676676
std::vector<const Expr *> LiveExprs;
677677
llvm::append_range(LiveExprs, blocksEndToLiveness[B].liveExprs);
678-
llvm::sort(LiveExprs, ByBeginLoc);
678+
llvm::sort(LiveExprs, ByIDs);
679679
for (const Expr *E : LiveExprs) {
680680
llvm::errs() << "\n";
681681
E->dump();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_cc1 -std=c++2c -fexperimental-new-constant-interpreter -verify=expected,both %s
2+
// RUN: %clang_cc1 -std=c++2c -verify=ref,both %s
3+
4+
// both-no-diagnostics
5+
6+
namespace std {
7+
constexpr int
8+
midpoint(int __a, int ) {
9+
constexpr unsigned __half_diff = 0;
10+
return __half_diff;
11+
}
12+
}
13+
struct Tuple {
14+
int min;
15+
int mid;
16+
constexpr Tuple() {
17+
min = 0;
18+
mid = std::midpoint(min, min);
19+
}
20+
};
21+
constexpr Tuple tup;
22+

clang/test/Analysis/live-stmts.cpp

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Disabling this flaky test, see https://github.com/llvm/llvm-project/pull/126913#issuecomment-2655850766
2-
// UNSUPPORTED: true
3-
41
// RUN: %clang_analyze_cc1 -w -analyzer-checker=debug.DumpLiveExprs %s 2>&1\
52
// RUN: | FileCheck %s
63

@@ -29,36 +26,36 @@ int testThatDumperWorks(int x, int y, int z) {
2926
// CHECK-EMPTY:
3027
// CHECK: [ B2 (live expressions at block exit) ]
3128
// CHECK-EMPTY:
32-
// CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
33-
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
34-
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
35-
// CHECK-EMPTY:
3629
// CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
3730
// CHECK-EMPTY:
3831
// CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
3932
// CHECK-EMPTY:
40-
// CHECK-EMPTY:
41-
// CHECK: [ B3 (live expressions at block exit) ]
42-
// CHECK-EMPTY:
4333
// CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
4434
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
4535
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
4636
// CHECK-EMPTY:
47-
// CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
4837
// CHECK-EMPTY:
49-
// CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
38+
// CHECK: [ B3 (live expressions at block exit) ]
5039
// CHECK-EMPTY:
40+
// CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
5141
// CHECK-EMPTY:
52-
// CHECK: [ B4 (live expressions at block exit) ]
42+
// CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
5343
// CHECK-EMPTY:
5444
// CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
5545
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
5646
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
5747
// CHECK-EMPTY:
48+
// CHECK-EMPTY:
49+
// CHECK: [ B4 (live expressions at block exit) ]
50+
// CHECK-EMPTY:
5851
// CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
5952
// CHECK-EMPTY:
6053
// CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
6154
// CHECK-EMPTY:
55+
// CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
56+
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
57+
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
58+
// CHECK-EMPTY:
6259
// CHECK-EMPTY:
6360
// CHECK: [ B5 (live expressions at block exit) ]
6461
// CHECK-EMPTY:
@@ -228,15 +225,15 @@ int logicalOpInTernary(bool b) {
228225
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
229226
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
230227
// CHECK-EMPTY:
228+
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
229+
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
230+
// CHECK-EMPTY:
231231
// CHECK: BinaryOperator {{.*}} '_Bool' '||'
232232
// CHECK: |-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
233233
// CHECK: | `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
234234
// CHECK: `-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
235235
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
236236
// CHECK-EMPTY:
237-
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
238-
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
239-
// CHECK-EMPTY:
240237
// CHECK: IntegerLiteral {{.*}} 'int' 0
241238
// CHECK-EMPTY:
242239
// CHECK: IntegerLiteral {{.*}} 'int' 1
@@ -247,15 +244,15 @@ int logicalOpInTernary(bool b) {
247244
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
248245
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
249246
// CHECK-EMPTY:
247+
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
248+
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
249+
// CHECK-EMPTY:
250250
// CHECK: BinaryOperator {{.*}} '_Bool' '||'
251251
// CHECK: |-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
252252
// CHECK: | `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
253253
// CHECK: `-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
254254
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
255255
// CHECK-EMPTY:
256-
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
257-
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
258-
// CHECK-EMPTY:
259256
// CHECK: IntegerLiteral {{.*}} 'int' 0
260257
// CHECK-EMPTY:
261258
// CHECK: IntegerLiteral {{.*}} 'int' 1
@@ -266,15 +263,15 @@ int logicalOpInTernary(bool b) {
266263
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
267264
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
268265
// CHECK-EMPTY:
266+
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
267+
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
268+
// CHECK-EMPTY:
269269
// CHECK: BinaryOperator {{.*}} '_Bool' '||'
270270
// CHECK: |-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
271271
// CHECK: | `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
272272
// CHECK: `-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
273273
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
274274
// CHECK-EMPTY:
275-
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
276-
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
277-
// CHECK-EMPTY:
278275
// CHECK: IntegerLiteral {{.*}} 'int' 0
279276
// CHECK-EMPTY:
280277
// CHECK: IntegerLiteral {{.*}} 'int' 1
@@ -285,15 +282,15 @@ int logicalOpInTernary(bool b) {
285282
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
286283
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
287284
// CHECK-EMPTY:
285+
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
286+
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
287+
// CHECK-EMPTY:
288288
// CHECK: BinaryOperator {{.*}} '_Bool' '||'
289289
// CHECK: |-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
290290
// CHECK: | `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
291291
// CHECK: `-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
292292
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
293293
// CHECK-EMPTY:
294-
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
295-
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
296-
// CHECK-EMPTY:
297294
// CHECK: IntegerLiteral {{.*}} 'int' 0
298295
// CHECK-EMPTY:
299296
// CHECK: IntegerLiteral {{.*}} 'int' 1

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,9 @@ Expected<bool> getSymbolsFromBitcode(MemoryBufferRef Buffer, OffloadKind Kind,
10601060
if (Sym.isFormatSpecific() || !Sym.isGlobal())
10611061
continue;
10621062

1063-
bool NewSymbol = Syms.count(Sym.getName()) == 0;
1064-
auto OldSym = NewSymbol ? Sym_None : Syms[Sym.getName()];
1063+
auto It = Syms.find(Sym.getName());
1064+
bool NewSymbol = It == Syms.end();
1065+
auto OldSym = NewSymbol ? Sym_None : It->second;
10651066

10661067
// We will extract if it defines a currenlty undefined non-weak
10671068
// symbol.

flang/include/flang/Optimizer/Support/InitFIR.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ inline void registerMLIRPassesForFortranTools() {
112112
mlir::affine::registerAffineLoopTilingPass();
113113
mlir::affine::registerAffineDataCopyGenerationPass();
114114

115-
mlir::registerConvertAffineToStandardPass();
115+
mlir::registerLowerAffinePass();
116116
}
117117

118118
/// Register the interfaces needed to lower to LLVM IR.

flang/lib/Optimizer/Passes/Pipelines.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm,
205205
pm, fir::createStackReclaim);
206206
// convert control flow to CFG form
207207
fir::addCfgConversionPass(pm, pc);
208-
pm.addPass(mlir::createConvertSCFToCFPass());
208+
pm.addPass(mlir::createSCFToControlFlowPass());
209209

210210
pm.addPass(mlir::createCanonicalizerPass(config));
211211
pm.addPass(fir::createSimplifyRegionLite());

lld/ELF/Arch/ARM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,12 +663,12 @@ void ARM::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
663663
case R_ARM_THM_JUMP8:
664664
// We do a 9 bit check because val is right-shifted by 1 bit.
665665
checkInt(ctx, loc, val, 9, rel);
666-
write16(ctx, loc, (read32(ctx, loc) & 0xff00) | ((val >> 1) & 0x00ff));
666+
write16(ctx, loc, (read16(ctx, loc) & 0xff00) | ((val >> 1) & 0x00ff));
667667
break;
668668
case R_ARM_THM_JUMP11:
669669
// We do a 12 bit check because val is right-shifted by 1 bit.
670670
checkInt(ctx, loc, val, 12, rel);
671-
write16(ctx, loc, (read32(ctx, loc) & 0xf800) | ((val >> 1) & 0x07ff));
671+
write16(ctx, loc, (read16(ctx, loc) & 0xf800) | ((val >> 1) & 0x07ff));
672672
break;
673673
case R_ARM_THM_JUMP19:
674674
// Encoding T3: Val = S:J2:J1:imm6:imm11:0

0 commit comments

Comments
 (0)