Skip to content

Commit 624e89b

Browse files
[memprof] Use namespace scopes in unit tests (NFC) (#119176)
This patch uses namespace scopes to remove memprof:: in MemProfUseTest.cpp as in MemProfTest.cpp. While I am at it, this patch removes a stale comment about IndexedAllocationInfo::CallStack, which has been removed.
1 parent 1708519 commit 624e89b

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

llvm/unittests/Transforms/Instrumentation/MemProfUseTest.cpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#include "gmock/gmock.h"
2222
#include "gtest/gtest.h"
2323

24+
namespace llvm {
25+
namespace memprof {
2426
namespace {
25-
using namespace llvm;
26-
using namespace llvm::memprof;
2727
using testing::Contains;
2828
using testing::ElementsAre;
2929
using testing::Pair;
@@ -315,15 +315,12 @@ MemInfoBlock makePartialMIB() {
315315
}
316316

317317
IndexedMemProfRecord
318-
makeRecordV2(std::initializer_list<::llvm::memprof::CallStackId> AllocFrames,
319-
std::initializer_list<::llvm::memprof::CallStackId> CallSiteFrames,
320-
const MemInfoBlock &Block, const memprof::MemProfSchema &Schema) {
321-
llvm::memprof::IndexedMemProfRecord MR;
322-
for (const auto &CSId : AllocFrames) {
323-
// We don't populate IndexedAllocationInfo::CallStack because we use it only
324-
// in Version1.
318+
makeRecordV2(std::initializer_list<CallStackId> AllocFrames,
319+
std::initializer_list<CallStackId> CallSiteFrames,
320+
const MemInfoBlock &Block, const MemProfSchema &Schema) {
321+
IndexedMemProfRecord MR;
322+
for (const auto &CSId : AllocFrames)
325323
MR.AllocSites.emplace_back(CSId, Block, Schema);
326-
}
327324
for (const auto &CSId : CallSiteFrames)
328325
MR.CallSiteIds.push_back(CSId);
329326
return MR;
@@ -427,17 +424,17 @@ attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "t
427424

428425
const MemInfoBlock MIB = makePartialMIB();
429426

430-
Writer.setMemProfVersionRequested(memprof::Version3);
427+
Writer.setMemProfVersionRequested(Version3);
431428
Writer.setMemProfFullSchema(false);
432429

433430
ASSERT_THAT_ERROR(Writer.mergeProfileKind(InstrProfKind::MemProf),
434431
Succeeded());
435432

436433
const IndexedMemProfRecord IndexedMR = makeRecordV2(
437434
/*AllocFrames=*/{0x111, 0x222, 0x333},
438-
/*CallSiteFrames=*/{}, MIB, memprof::getHotColdSchema());
435+
/*CallSiteFrames=*/{}, MIB, getHotColdSchema());
439436

440-
memprof::IndexedMemProfData MemProfData;
437+
IndexedMemProfData MemProfData;
441438
// The call sites within foo.
442439
MemProfData.Frames.try_emplace(0, GUIDFoo, 1, 8, false);
443440
MemProfData.Frames.try_emplace(1, GUIDFoo, 2, 3, false);
@@ -447,14 +444,11 @@ attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "t
447444
MemProfData.Frames.try_emplace(4, GUIDZzz, 9, 9, false);
448445
MemProfData.Frames.try_emplace(5, GUIDBaz, 9, 9, false);
449446
MemProfData.CallStacks.try_emplace(
450-
0x111,
451-
std::initializer_list<memprof::FrameId>{3, 0}); // bar called by foo
447+
0x111, std::initializer_list<FrameId>{3, 0}); // bar called by foo
452448
MemProfData.CallStacks.try_emplace(
453-
0x222,
454-
std::initializer_list<memprof::FrameId>{4, 1}); // zzz called by foo
449+
0x222, std::initializer_list<FrameId>{4, 1}); // zzz called by foo
455450
MemProfData.CallStacks.try_emplace(
456-
0x333,
457-
std::initializer_list<memprof::FrameId>{5, 2}); // baz called by foo
451+
0x333, std::initializer_list<FrameId>{5, 2}); // baz called by foo
458452
MemProfData.Records.try_emplace(0x9999, IndexedMR);
459453
Writer.addMemProfData(MemProfData, Err);
460454

@@ -488,3 +482,5 @@ attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "t
488482
Pair(LineLocation(3, 3), LineLocation(2, 8))))));
489483
}
490484
} // namespace
485+
} // namespace memprof
486+
} // namespace llvm

0 commit comments

Comments
 (0)