diff --git a/llvm/include/llvm/XRay/BlockIndexer.h b/llvm/include/llvm/XRay/BlockIndexer.h index e9782dafed618..155e6bd6fb12a 100644 --- a/llvm/include/llvm/XRay/BlockIndexer.h +++ b/llvm/include/llvm/XRay/BlockIndexer.h @@ -19,8 +19,7 @@ #include #include -namespace llvm { -namespace xray { +namespace llvm::xray { // The BlockIndexer will gather all related records associated with a // process+thread and group them by 'Block'. @@ -63,7 +62,6 @@ class LLVM_ABI BlockIndexer : public RecordVisitor { Error flush(); }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_BLOCKINDEXER_H diff --git a/llvm/include/llvm/XRay/BlockPrinter.h b/llvm/include/llvm/XRay/BlockPrinter.h index caf78c5c4a5a6..81944a5d05bf5 100644 --- a/llvm/include/llvm/XRay/BlockPrinter.h +++ b/llvm/include/llvm/XRay/BlockPrinter.h @@ -18,8 +18,7 @@ #include "llvm/XRay/FDRRecords.h" #include "llvm/XRay/RecordPrinter.h" -namespace llvm { -namespace xray { +namespace llvm::xray { class LLVM_ABI BlockPrinter : public RecordVisitor { enum class State { @@ -55,7 +54,6 @@ class LLVM_ABI BlockPrinter : public RecordVisitor { void reset() { CurrentState = State::Start; } }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_BLOCKPRINTER_H diff --git a/llvm/include/llvm/XRay/BlockVerifier.h b/llvm/include/llvm/XRay/BlockVerifier.h index b88785c393e37..5e7b25cc4d0d3 100644 --- a/llvm/include/llvm/XRay/BlockVerifier.h +++ b/llvm/include/llvm/XRay/BlockVerifier.h @@ -16,8 +16,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/XRay/FDRRecords.h" -namespace llvm { -namespace xray { +namespace llvm::xray { class LLVM_ABI BlockVerifier : public RecordVisitor { public: @@ -64,7 +63,6 @@ class LLVM_ABI BlockVerifier : public RecordVisitor { void reset(); }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_BLOCKVERIFIER_H diff --git a/llvm/include/llvm/XRay/FDRLogBuilder.h b/llvm/include/llvm/XRay/FDRLogBuilder.h index f07c446ce1e59..5f7b815f4c2a3 100644 --- a/llvm/include/llvm/XRay/FDRLogBuilder.h +++ b/llvm/include/llvm/XRay/FDRLogBuilder.h @@ -10,8 +10,7 @@ #include "llvm/XRay/FDRRecords.h" -namespace llvm { -namespace xray { +namespace llvm::xray { /// The LogBuilder class allows for creating ad-hoc collections of records /// through the `add<...>(...)` function. An example use of this API is in @@ -34,7 +33,6 @@ class LogBuilder { std::vector> consume() { return std::move(Records); } }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_FDRLOGBUILDER_H diff --git a/llvm/include/llvm/XRay/FDRRecordConsumer.h b/llvm/include/llvm/XRay/FDRRecordConsumer.h index 473777f0e04f2..13bb711328fdc 100644 --- a/llvm/include/llvm/XRay/FDRRecordConsumer.h +++ b/llvm/include/llvm/XRay/FDRRecordConsumer.h @@ -15,8 +15,7 @@ #include #include -namespace llvm { -namespace xray { +namespace llvm::xray { class RecordConsumer { public: @@ -48,7 +47,6 @@ class LLVM_ABI PipelineConsumer : public RecordConsumer { Error consume(std::unique_ptr R) override; }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_FDRRECORDCONSUMER_H diff --git a/llvm/include/llvm/XRay/FDRRecordProducer.h b/llvm/include/llvm/XRay/FDRRecordProducer.h index 083b57139d397..b953f62f4eca7 100644 --- a/llvm/include/llvm/XRay/FDRRecordProducer.h +++ b/llvm/include/llvm/XRay/FDRRecordProducer.h @@ -14,8 +14,7 @@ #include "llvm/XRay/XRayRecord.h" #include -namespace llvm { -namespace xray { +namespace llvm::xray { class RecordProducer { public: @@ -45,7 +44,6 @@ class LLVM_ABI FileBasedRecordProducer : public RecordProducer { Expected> produce() override; }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_FDRRECORDPRODUCER_H diff --git a/llvm/include/llvm/XRay/FDRRecords.h b/llvm/include/llvm/XRay/FDRRecords.h index 7ee8db61b2106..91689cae935b1 100644 --- a/llvm/include/llvm/XRay/FDRRecords.h +++ b/llvm/include/llvm/XRay/FDRRecords.h @@ -23,8 +23,7 @@ #include "llvm/Support/Error.h" #include "llvm/XRay/XRayRecord.h" -namespace llvm { -namespace xray { +namespace llvm::xray { class RecordVisitor; class RecordInitializer; @@ -444,7 +443,6 @@ class LLVM_ABI RecordInitializer : public RecordVisitor { Error visit(TypedEventRecord &) override; }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_FDRRECORDS_H diff --git a/llvm/include/llvm/XRay/FDRTraceExpander.h b/llvm/include/llvm/XRay/FDRTraceExpander.h index 197c123fff1e3..ca400c9c567cb 100644 --- a/llvm/include/llvm/XRay/FDRTraceExpander.h +++ b/llvm/include/llvm/XRay/FDRTraceExpander.h @@ -17,8 +17,7 @@ #include "llvm/XRay/FDRRecords.h" #include "llvm/XRay/XRayRecord.h" -namespace llvm { -namespace xray { +namespace llvm::xray { class TraceExpander : public RecordVisitor { // Type-erased callback for handling individual XRayRecord instances. @@ -56,7 +55,6 @@ class TraceExpander : public RecordVisitor { Error flush(); }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_FDRTRACEEXPANDER_H diff --git a/llvm/include/llvm/XRay/FDRTraceWriter.h b/llvm/include/llvm/XRay/FDRTraceWriter.h index a3dc58e03333e..957039d478f3f 100644 --- a/llvm/include/llvm/XRay/FDRTraceWriter.h +++ b/llvm/include/llvm/XRay/FDRTraceWriter.h @@ -18,8 +18,7 @@ #include "llvm/XRay/FDRRecords.h" #include "llvm/XRay/XRayRecord.h" -namespace llvm { -namespace xray { +namespace llvm::xray { /// The FDRTraceWriter allows us to hand-craft an XRay Flight Data Recorder /// (FDR) mode log file. This is used primarily for testing, generating @@ -50,7 +49,6 @@ class LLVM_ABI FDRTraceWriter : public RecordVisitor { support::endian::Writer OS; }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_FDRTRACEWRITER_H diff --git a/llvm/include/llvm/XRay/FileHeaderReader.h b/llvm/include/llvm/XRay/FileHeaderReader.h index ecdb975a30661..758ca294263b6 100644 --- a/llvm/include/llvm/XRay/FileHeaderReader.h +++ b/llvm/include/llvm/XRay/FileHeaderReader.h @@ -19,15 +19,13 @@ #include "llvm/XRay/XRayRecord.h" #include -namespace llvm { -namespace xray { +namespace llvm::xray { /// Convenience function for loading the file header given a data extractor at a /// specified offset. LLVM_ABI Expected readBinaryFormatHeader(DataExtractor &HeaderExtractor, uint64_t &OffsetPtr); -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_FILEHEADERREADER_H diff --git a/llvm/include/llvm/XRay/Graph.h b/llvm/include/llvm/XRay/Graph.h index 07b418b8cb640..8521e09c33208 100644 --- a/llvm/include/llvm/XRay/Graph.h +++ b/llvm/include/llvm/XRay/Graph.h @@ -23,8 +23,7 @@ #include "llvm/ADT/iterator.h" #include "llvm/Support/Error.h" -namespace llvm { -namespace xray { +namespace llvm::xray { /// A Graph object represents a Directed Graph and is used in XRay to compute /// and store function call graphs and associated statistical information. @@ -485,6 +484,6 @@ class Graph { return p; } }; -} -} +} // namespace llvm::xray + #endif diff --git a/llvm/include/llvm/XRay/InstrumentationMap.h b/llvm/include/llvm/XRay/InstrumentationMap.h index b5371478680ef..c5e7ebff0e2c1 100644 --- a/llvm/include/llvm/XRay/InstrumentationMap.h +++ b/llvm/include/llvm/XRay/InstrumentationMap.h @@ -23,9 +23,7 @@ #include #include -namespace llvm { - -namespace xray { +namespace llvm::xray { // Forward declare to make a friend. class InstrumentationMap; @@ -102,11 +100,11 @@ class InstrumentationMap { const SledContainer &sleds() const { return Sleds; }; }; -} // end namespace xray - -namespace yaml { +} // end namespace llvm::xray -template <> struct ScalarEnumerationTraits { +namespace llvm { +template <> +struct yaml::ScalarEnumerationTraits { static void enumeration(IO &IO, xray::SledEntry::FunctionKinds &Kind) { IO.enumCase(Kind, "function-enter", xray::SledEntry::FunctionKinds::ENTRY); IO.enumCase(Kind, "function-exit", xray::SledEntry::FunctionKinds::EXIT); @@ -118,7 +116,7 @@ template <> struct ScalarEnumerationTraits { } }; -template <> struct MappingTraits { +template <> struct yaml::MappingTraits { static void mapping(IO &IO, xray::YAMLXRaySledEntry &Entry) { IO.mapRequired("id", Entry.FuncId); IO.mapRequired("address", Entry.Address); @@ -131,10 +129,7 @@ template <> struct MappingTraits { static constexpr bool flow = true; }; - -} // end namespace yaml - -} // end namespace llvm +} // namespace llvm LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRaySledEntry) diff --git a/llvm/include/llvm/XRay/Profile.h b/llvm/include/llvm/XRay/Profile.h index e30c01e489d33..b5b8dd24d1ee4 100644 --- a/llvm/include/llvm/XRay/Profile.h +++ b/llvm/include/llvm/XRay/Profile.h @@ -22,8 +22,7 @@ #include #include -namespace llvm { -namespace xray { +namespace llvm::xray { class Profile; @@ -144,7 +143,6 @@ class Profile { bool empty() const { return Blocks.empty(); } }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif diff --git a/llvm/include/llvm/XRay/RecordPrinter.h b/llvm/include/llvm/XRay/RecordPrinter.h index 5d2c27757255a..3281221d5c294 100644 --- a/llvm/include/llvm/XRay/RecordPrinter.h +++ b/llvm/include/llvm/XRay/RecordPrinter.h @@ -17,8 +17,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/XRay/FDRRecords.h" -namespace llvm { -namespace xray { +namespace llvm::xray { class LLVM_ABI RecordPrinter : public RecordVisitor { raw_ostream &OS; @@ -44,7 +43,6 @@ class LLVM_ABI RecordPrinter : public RecordVisitor { Error visit(TypedEventRecord &) override; }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_RECORDPRINTER_H diff --git a/llvm/include/llvm/XRay/Trace.h b/llvm/include/llvm/XRay/Trace.h index 5e4e40aa7ca90..13ada22150d91 100644 --- a/llvm/include/llvm/XRay/Trace.h +++ b/llvm/include/llvm/XRay/Trace.h @@ -21,8 +21,7 @@ #include "llvm/Support/Error.h" #include "llvm/XRay/XRayRecord.h" -namespace llvm { -namespace xray { +namespace llvm::xray { /// A Trace object represents the records that have been loaded from XRay /// log files generated by instrumented binaries. We encapsulate the logic of @@ -76,7 +75,6 @@ LLVM_ABI Expected loadTraceFile(StringRef Filename, bool Sort = false); LLVM_ABI Expected loadTrace(const DataExtractor &Extractor, bool Sort = false); -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_TRACE_H diff --git a/llvm/include/llvm/XRay/XRayRecord.h b/llvm/include/llvm/XRay/XRayRecord.h index 238bf3daf6ea5..8f3440c8d81f9 100644 --- a/llvm/include/llvm/XRay/XRayRecord.h +++ b/llvm/include/llvm/XRay/XRayRecord.h @@ -18,8 +18,7 @@ #include #include -namespace llvm { -namespace xray { +namespace llvm::xray { /// XRay traces all have a header providing some top-matter information useful /// to help tools determine how to interpret the information available in the @@ -98,7 +97,6 @@ struct XRayRecord { std::string Data; }; -} // namespace xray -} // namespace llvm +} // namespace llvm::xray #endif // LLVM_XRAY_XRAYRECORD_H diff --git a/llvm/include/llvm/XRay/YAMLXRayRecord.h b/llvm/include/llvm/XRay/YAMLXRayRecord.h index 606260693fc4f..6bf4f1d1ae082 100644 --- a/llvm/include/llvm/XRay/YAMLXRayRecord.h +++ b/llvm/include/llvm/XRay/YAMLXRayRecord.h @@ -17,8 +17,7 @@ #include "llvm/Support/YAMLTraits.h" #include "llvm/XRay/XRayRecord.h" -namespace llvm { -namespace xray { +namespace llvm::xray { struct YAMLXRayFileHeader { uint16_t Version; @@ -46,13 +45,12 @@ struct YAMLXRayTrace { std::vector Records; }; -} // namespace xray - -namespace yaml { +} // namespace llvm::xray +namespace llvm { // YAML Traits // ----------- -template <> struct ScalarEnumerationTraits { +template <> struct yaml::ScalarEnumerationTraits { static void enumeration(IO &IO, xray::RecordTypes &Type) { IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER); IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT); @@ -63,7 +61,7 @@ template <> struct ScalarEnumerationTraits { } }; -template <> struct MappingTraits { +template <> struct yaml::MappingTraits { static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) { IO.mapRequired("version", Header.Version); IO.mapRequired("type", Header.Type); @@ -73,7 +71,7 @@ template <> struct MappingTraits { } }; -template <> struct MappingTraits { +template <> struct yaml::MappingTraits { static void mapping(IO &IO, xray::YAMLXRayRecord &Record) { IO.mapRequired("type", Record.RecordType); IO.mapOptional("func-id", Record.FuncId); @@ -90,7 +88,7 @@ template <> struct MappingTraits { static constexpr bool flow = true; }; -template <> struct MappingTraits { +template <> struct yaml::MappingTraits { static void mapping(IO &IO, xray::YAMLXRayTrace &Trace) { // A trace file contains two parts, the header and the list of all the // trace records. @@ -98,8 +96,6 @@ template <> struct MappingTraits { IO.mapRequired("records", Trace.Records); } }; - -} // namespace yaml } // namespace llvm LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord) diff --git a/llvm/lib/XRay/BlockIndexer.cpp b/llvm/lib/XRay/BlockIndexer.cpp index f4ba0eb5bda9c..d0c68539e8180 100644 --- a/llvm/lib/XRay/BlockIndexer.cpp +++ b/llvm/lib/XRay/BlockIndexer.cpp @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #include "llvm/XRay/BlockIndexer.h" -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; Error BlockIndexer::visit(BufferExtents &) { return Error::success(); } @@ -89,6 +89,3 @@ Error BlockIndexer::flush() { CurrentBlock.WallclockTime = nullptr; return Error::success(); } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/BlockPrinter.cpp b/llvm/lib/XRay/BlockPrinter.cpp index 63a60c3c56a38..d85be5bc664d2 100644 --- a/llvm/lib/XRay/BlockPrinter.cpp +++ b/llvm/lib/XRay/BlockPrinter.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "llvm/XRay/BlockPrinter.h" -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; Error BlockPrinter::visit(BufferExtents &R) { OS << "\n[New Block]\n"; @@ -108,6 +108,3 @@ Error BlockPrinter::visit(EndBufferRecord &R) { auto E = RP.visit(R); return E; } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/BlockVerifier.cpp b/llvm/lib/XRay/BlockVerifier.cpp index 99f255ea66887..e39f6b6f44b6f 100644 --- a/llvm/lib/XRay/BlockVerifier.cpp +++ b/llvm/lib/XRay/BlockVerifier.cpp @@ -10,19 +10,18 @@ #include -namespace llvm { -namespace xray { -namespace { +using namespace llvm; +using namespace llvm::xray; -constexpr unsigned long long mask(BlockVerifier::State S) { +static constexpr unsigned long long mask(BlockVerifier::State S) { return 1uLL << static_cast(S); } -constexpr std::size_t number(BlockVerifier::State S) { +static constexpr std::size_t number(BlockVerifier::State S) { return static_cast(S); } -StringRef recordToString(BlockVerifier::State R) { +static StringRef recordToString(BlockVerifier::State R) { switch (R) { case BlockVerifier::State::BufferExtents: return "BufferExtents"; @@ -53,6 +52,8 @@ StringRef recordToString(BlockVerifier::State R) { llvm_unreachable("Unkown state!"); } +namespace { + struct Transition { BlockVerifier::State From; std::bitset ToStates; @@ -133,7 +134,7 @@ Error BlockVerifier::transition(State To) { CurrentRecord = To; return Error::success(); -} // namespace xray +} Error BlockVerifier::visit(BufferExtents &) { return transition(State::BufferExtents); @@ -201,6 +202,3 @@ Error BlockVerifier::verify() { } void BlockVerifier::reset() { CurrentRecord = State::Unknown; } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/FDRRecordProducer.cpp b/llvm/lib/XRay/FDRRecordProducer.cpp index 479b710444be8..0f4eed13525e8 100644 --- a/llvm/lib/XRay/FDRRecordProducer.cpp +++ b/llvm/lib/XRay/FDRRecordProducer.cpp @@ -10,8 +10,8 @@ #include -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; namespace { @@ -31,8 +31,9 @@ enum MetadataRecordKinds : uint8_t { // This is an end marker, used to identify the upper bound for this enum. EnumEndMarker, }; +} // namespace -Expected> +static Expected> metadataRecordType(const XRayFileHeader &Header, uint8_t T) { if (T >= static_cast(MetadataRecordKinds::EnumEndMarker)) @@ -72,12 +73,10 @@ metadataRecordType(const XRayFileHeader &Header, uint8_t T) { llvm_unreachable("Unhandled MetadataRecordKinds enum value"); } -constexpr bool isMetadataIntroducer(uint8_t FirstByte) { +static constexpr bool isMetadataIntroducer(uint8_t FirstByte) { return FirstByte & 0x01u; } -} // namespace - Expected> FileBasedRecordProducer::findNextBufferExtent() { // We seek one byte at a time until we find a suitable buffer extents metadata @@ -193,6 +192,3 @@ Expected> FileBasedRecordProducer::produce() { assert(R != nullptr); return std::move(R); } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/FDRRecords.cpp b/llvm/lib/XRay/FDRRecords.cpp index ff315d35417d6..a18f733ef73bf 100644 --- a/llvm/lib/XRay/FDRRecords.cpp +++ b/llvm/lib/XRay/FDRRecords.cpp @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #include "llvm/XRay/FDRRecords.h" -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; Error BufferExtents::apply(RecordVisitor &V) { return V.visit(*this); } Error WallclockRecord::apply(RecordVisitor &V) { return V.visit(*this); } @@ -61,6 +61,3 @@ StringRef Record::kindToString(RecordKind K) { } return "Unknown"; } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/FDRTraceExpander.cpp b/llvm/lib/XRay/FDRTraceExpander.cpp index b68e997fe7063..991e6e5127aa0 100644 --- a/llvm/lib/XRay/FDRTraceExpander.cpp +++ b/llvm/lib/XRay/FDRTraceExpander.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "llvm/XRay/FDRTraceExpander.h" -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; void TraceExpander::resetCurrentRecord() { if (BuildingRecord) @@ -126,6 +126,3 @@ Error TraceExpander::flush() { resetCurrentRecord(); return Error::success(); } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/FDRTraceWriter.cpp b/llvm/lib/XRay/FDRTraceWriter.cpp index fb591252ffa3e..3e320a64da9fd 100644 --- a/llvm/lib/XRay/FDRTraceWriter.cpp +++ b/llvm/lib/XRay/FDRTraceWriter.cpp @@ -12,8 +12,8 @@ #include "llvm/XRay/FDRTraceWriter.h" #include -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; namespace { @@ -37,9 +37,10 @@ template struct IndexedWriter { return 0; } }; +} // namespace template -Error writeMetadata(support::endian::Writer &OS, Values &&... Ds) { +static Error writeMetadata(support::endian::Writer &OS, Values &&...Ds) { // The first bit in the first byte of metadata records is always set to 1, so // we ensure this is the case when we write out the first byte of the record. uint8_t FirstByte = (static_cast(Kind) << 1) | uint8_t{0x01u}; @@ -54,8 +55,6 @@ Error writeMetadata(support::endian::Writer &OS, Values &&... Ds) { return Error::success(); } -} // namespace - FDRTraceWriter::FDRTraceWriter(raw_ostream &O, const XRayFileHeader &H) : OS(O, llvm::endianness::native) { // We need to re-construct a header, by writing the fields we care about for @@ -146,6 +145,3 @@ Error FDRTraceWriter::visit(FunctionRecord &R) { OS.write(R.delta()); return Error::success(); } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/FileHeaderReader.cpp b/llvm/lib/XRay/FileHeaderReader.cpp index 6b6daf9deba59..681cef7122f30 100644 --- a/llvm/lib/XRay/FileHeaderReader.cpp +++ b/llvm/lib/XRay/FileHeaderReader.cpp @@ -7,12 +7,13 @@ //===----------------------------------------------------------------------===// #include "llvm/XRay/FileHeaderReader.h" -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; // Populates the FileHeader reference by reading the first 32 bytes of the file. -Expected readBinaryFormatHeader(DataExtractor &HeaderExtractor, - uint64_t &OffsetPtr) { +Expected +xray::readBinaryFormatHeader(DataExtractor &HeaderExtractor, + uint64_t &OffsetPtr) { // FIXME: Maybe deduce whether the data is little or big-endian using some // magic bytes in the beginning of the file? @@ -68,6 +69,3 @@ Expected readBinaryFormatHeader(DataExtractor &HeaderExtractor, OffsetPtr += 16; return std::move(FileHeader); } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/LogBuilderConsumer.cpp b/llvm/lib/XRay/LogBuilderConsumer.cpp index ffb49f9eb4e98..f0fc3360b28e4 100644 --- a/llvm/lib/XRay/LogBuilderConsumer.cpp +++ b/llvm/lib/XRay/LogBuilderConsumer.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "llvm/XRay/FDRRecordConsumer.h" -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; Error LogBuilderConsumer::consume(std::unique_ptr R) { if (!R) @@ -32,6 +32,3 @@ Error PipelineConsumer::consume(std::unique_ptr R) { Result = joinErrors(std::move(Result), R->apply(*V)); return Result; } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/Profile.cpp b/llvm/lib/XRay/Profile.cpp index 1b340e54c9dbb..ecb767bfc2c2a 100644 --- a/llvm/lib/XRay/Profile.cpp +++ b/llvm/lib/XRay/Profile.cpp @@ -18,8 +18,8 @@ #include "llvm/XRay/Trace.h" #include -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; Profile::Profile(const Profile &O) { // We need to re-create all the tries from the original (O), into the current @@ -46,6 +46,7 @@ struct BlockHeader { uint32_t Number; uint64_t Thread; }; +} // namespace static Expected readBlockHeader(DataExtractor &Extractor, uint64_t &Offset) { @@ -115,8 +116,6 @@ static Expected readData(DataExtractor &Extractor, return D; } -} // namespace - Error Profile::addBlock(Block &&B) { if (B.PathData.empty()) return make_error( @@ -189,7 +188,7 @@ Profile::PathID Profile::internPath(ArrayRef P) { return Node->ID; } -Profile mergeProfilesByThread(const Profile &L, const Profile &R) { +Profile xray::mergeProfilesByThread(const Profile &L, const Profile &R) { Profile Merged; using PathDataMap = DenseMap; using PathDataMapPtr = std::unique_ptr; @@ -228,7 +227,7 @@ Profile mergeProfilesByThread(const Profile &L, const Profile &R) { return Merged; } -Profile mergeProfilesByStack(const Profile &L, const Profile &R) { +Profile xray::mergeProfilesByStack(const Profile &L, const Profile &R) { Profile Merged; using PathDataMap = DenseMap; PathDataMap PathData; @@ -258,7 +257,7 @@ Profile mergeProfilesByStack(const Profile &L, const Profile &R) { return Merged; } -Expected loadProfile(StringRef Filename) { +Expected xray::loadProfile(StringRef Filename) { Expected FdOrErr = sys::fs::openNativeFileForRead(Filename); if (!FdOrErr) return FdOrErr.takeError(); @@ -322,7 +321,7 @@ struct StackEntry { } // namespace -Expected profileFromTrace(const Trace &T) { +Expected xray::profileFromTrace(const Trace &T) { Profile P; // The implementation of the algorithm re-creates the execution of @@ -397,6 +396,3 @@ Expected profileFromTrace(const Trace &T) { return P; } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/RecordInitializer.cpp b/llvm/lib/XRay/RecordInitializer.cpp index 68ab3db06208d..83d5f14b10504 100644 --- a/llvm/lib/XRay/RecordInitializer.cpp +++ b/llvm/lib/XRay/RecordInitializer.cpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #include "llvm/XRay/FDRRecords.h" -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; Error RecordInitializer::visit(BufferExtents &R) { if (!E.isValidOffsetForDataOfSize(OffsetPtr, sizeof(uint64_t))) @@ -426,6 +426,3 @@ Error RecordInitializer::visit(FunctionRecord &R) { assert(FunctionRecord::kFunctionRecordSize == (OffsetPtr - BeginOffset)); return Error::success(); } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/RecordPrinter.cpp b/llvm/lib/XRay/RecordPrinter.cpp index 32d42104db95c..b9b7a16501591 100644 --- a/llvm/lib/XRay/RecordPrinter.cpp +++ b/llvm/lib/XRay/RecordPrinter.cpp @@ -9,8 +9,8 @@ #include "llvm/Support/FormatVariadic.h" -namespace llvm { -namespace xray { +using namespace llvm; +using namespace llvm::xray; Error RecordPrinter::visit(BufferExtents &R) { OS << formatv("", R.size()) << Delim; @@ -103,6 +103,3 @@ Error RecordPrinter::visit(FunctionRecord &R) { OS << Delim; return Error::success(); } - -} // namespace xray -} // namespace llvm diff --git a/llvm/lib/XRay/Trace.cpp b/llvm/lib/XRay/Trace.cpp index 74515b16417da..14a3f01be66bd 100644 --- a/llvm/lib/XRay/Trace.cpp +++ b/llvm/lib/XRay/Trace.cpp @@ -29,11 +29,9 @@ using namespace llvm; using namespace llvm::xray; using llvm::yaml::Input; -namespace { - -Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian, - XRayFileHeader &FileHeader, - std::vector &Records) { +static Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian, + XRayFileHeader &FileHeader, + std::vector &Records) { if (Data.size() < 32) return make_error( "Not enough bytes for an XRay log.", @@ -265,8 +263,9 @@ Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian, /// what FunctionRecord instances use, and we no longer need to include the CPU /// id in the CustomEventRecord. /// -Error loadFDRLog(StringRef Data, bool IsLittleEndian, - XRayFileHeader &FileHeader, std::vector &Records) { +static Error loadFDRLog(StringRef Data, bool IsLittleEndian, + XRayFileHeader &FileHeader, + std::vector &Records) { if (Data.size() < 32) return createStringError(std::make_error_code(std::errc::invalid_argument), @@ -348,8 +347,8 @@ Error loadFDRLog(StringRef Data, bool IsLittleEndian, return Error::success(); } -Error loadYAMLLog(StringRef Data, XRayFileHeader &FileHeader, - std::vector &Records) { +static Error loadYAMLLog(StringRef Data, XRayFileHeader &FileHeader, + std::vector &Records) { YAMLXRayTrace Trace; Input In(Data); In >> Trace; @@ -376,7 +375,6 @@ Error loadYAMLLog(StringRef Data, XRayFileHeader &FileHeader, }); return Error::success(); } -} // namespace Expected llvm::xray::loadTraceFile(StringRef Filename, bool Sort) { Expected FdOrErr = sys::fs::openNativeFileForRead(Filename);