Skip to content

Commit 8ee3f31

Browse files
aartbikcommit-bot@chromium.org
authored andcommitted
[vm/gardening] clang tidy fixes
#38196 Change-Id: I0a61eae20d8cfc1c2ada8d6a607d437d02136d33 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115609 Reviewed-by: Ben Konyi <[email protected]> Reviewed-by: Martin Kustermann <[email protected]> Commit-Queue: Aart Bik <[email protected]>
1 parent 89ad636 commit 8ee3f31

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

runtime/tools/run_clang_tidy.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ final pool = new Pool(max(1, Platform.numberOfProcessors ~/ 2));
3838
// TODO(dartbug.com/38196): Ensure all VM sources are clang-tidy clean.
3939
final Set<String> migratedFiles = Set<String>.from([
4040
'runtime/vm/native_api_impl.cc',
41+
'runtime/vm/compiler/backend/constant_propagator.cc',
42+
'runtime/vm/compiler/backend/flow_graph.cc',
43+
'runtime/vm/compiler/backend/flow_graph_checker.cc',
44+
'runtime/vm/compiler/backend/il.cc',
45+
'runtime/vm/compiler/backend/inliner.cc',
46+
'runtime/vm/compiler/backend/linearscan.cc',
47+
'runtime/vm/compiler/backend/loops.cc',
48+
'runtime/vm/compiler/backend/loops_test.cc',
49+
'runtime/vm/compiler/backend/range_analysis.cc',
4150
]);
4251

4352
main(List<String> files) async {

runtime/vm/compiler/backend/inliner.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,7 @@ TargetEntryInstr* PolymorphicInliner::BuildDecisionGraph() {
18951895
// Unshared. Graft the normal entry on after the check class
18961896
// instruction.
18971897
auto target = callee_entry->AsGraphEntry()->normal_entry();
1898+
ASSERT(cursor != nullptr);
18981899
cursor->LinkTo(target->next());
18991900
target->ReplaceAsPredecessorWith(current_block);
19001901
// Unuse all inputs of the graph entry and the normal entry. They are
@@ -1955,6 +1956,7 @@ TargetEntryInstr* PolymorphicInliner::BuildDecisionGraph() {
19551956
new TargetEntryInstr(AllocateBlockId(), try_idx, DeoptId::kNone);
19561957
below_target->InheritDeoptTarget(zone(), call_);
19571958
current_block->AddDominatedBlock(below_target);
1959+
ASSERT(cursor != nullptr); // read before overwrite
19581960
cursor = current_block = below_target;
19591961
*branch_top->true_successor_address() = below_target;
19601962

@@ -1972,9 +1974,9 @@ TargetEntryInstr* PolymorphicInliner::BuildDecisionGraph() {
19721974
}
19731975

19741976
branch->InheritDeoptTarget(zone(), call_);
1975-
cursor = AppendInstruction(cursor, branch);
1977+
AppendInstruction(cursor, branch);
1978+
cursor = nullptr;
19761979
current_block->set_last_instruction(branch);
1977-
cursor = NULL;
19781980

19791981
// 2. Handle a match by linking to the inlined body. There are three
19801982
// cases (unshared, shared first predecessor, and shared subsequent
@@ -3369,7 +3371,7 @@ bool FlowGraphInliner::TryReplaceInstanceCallWithInline(
33693371
}
33703372
// Replace all uses of this definition with the result.
33713373
if (call->HasUses()) {
3372-
ASSERT(result->HasSSATemp());
3374+
ASSERT(result != nullptr && result->HasSSATemp());
33733375
call->ReplaceUsesWith(result);
33743376
}
33753377
// Finally insert the sequence other definition in place of this one in the

runtime/vm/compiler/backend/linearscan.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ void FlowGraphAllocator::BuildLiveRanges() {
603603

604604
// Check if any values live into the loop can be spilled for free.
605605
if (block->IsLoopHeader()) {
606-
current_interference_set = NULL;
606+
ASSERT(loop_info != nullptr);
607+
current_interference_set = nullptr;
607608
for (BitVector::Iterator it(liveness_.GetLiveInSetAt(i)); !it.Done();
608609
it.Advance()) {
609610
LiveRange* range = GetLiveRange(it.Current());

runtime/vm/object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7395,8 +7395,8 @@ class Smi : public Integer {
73957395
static intptr_t InstanceSize() { return 0; }
73967396

73977397
static RawSmi* New(intptr_t value) {
7398-
RawSmi* raw_smi =
7399-
reinterpret_cast<RawSmi*>((value << kSmiTagShift) | kSmiTag);
7398+
RawSmi* raw_smi = reinterpret_cast<RawSmi*>(
7399+
(static_cast<uintptr_t>(value) << kSmiTagShift) | kSmiTag);
74007400
ASSERT(ValueFromRawSmi(raw_smi) == value);
74017401
return raw_smi;
74027402
}

runtime/vm/zone.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class Zone {
119119
void Free(ElementType* old_array, intptr_t len) {
120120
#ifdef DEBUG
121121
if (len > 0) {
122+
ASSERT(old_array != nullptr);
122123
memset(old_array, kZapUninitializedByte, len * sizeof(ElementType));
123124
}
124125
#endif

0 commit comments

Comments
 (0)