Skip to content

Commit 7ca6921

Browse files
committed
llvm-profgen: Avoid "using namespace" in headers
(global) `using namespace` directives in headers are bad style.
1 parent 4a507b1 commit 7ca6921

File tree

9 files changed

+25
-37
lines changed

9 files changed

+25
-37
lines changed

llvm/tools/llvm-profgen/CSPreInliner.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
#include "llvm/Transforms/IPO/ProfiledCallGraph.h"
1717
#include "llvm/Transforms/IPO/SampleContextTracker.h"
1818

19-
using namespace llvm;
20-
using namespace sampleprof;
21-
2219
namespace llvm {
2320
namespace sampleprof {
2421

llvm/tools/llvm-profgen/ErrorHandling.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "llvm/Support/WithColor.h"
1717
#include <system_error>
1818

19-
using namespace llvm;
19+
namespace llvm {
2020

2121
[[noreturn]] inline void exitWithError(const Twine &Message,
2222
StringRef Whence = StringRef(),
@@ -53,4 +53,6 @@ inline void emitWarningSummary(uint64_t Num, uint64_t Total, StringRef Msg) {
5353
<< "%(" << Num << "/" << Total << ") " << Msg << "\n";
5454
}
5555

56+
} // end namespace llvm
57+
5658
#endif

llvm/tools/llvm-profgen/PerfReader.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#define DEBUG_TYPE "perf-reader"
1717

18+
using namespace llvm;
19+
1820
cl::opt<bool> SkipSymbolization("skip-symbolization",
1921
cl::desc("Dump the unsymbolized profile to the "
2022
"output file. It will show unwinder "
@@ -47,9 +49,6 @@ static cl::opt<int> CSProfMaxUnsymbolizedCtxDepth(
4749
cl::desc("Keep the last K contexts while merging unsymbolized profile. -1 "
4850
"means no depth limit."));
4951

50-
extern cl::opt<std::string> PerfTraceFilename;
51-
extern cl::opt<bool> ShowDisassemblyOnly;
52-
extern cl::opt<bool> ShowSourceLocations;
5352
extern cl::opt<std::string> OutputFilename;
5453

5554
namespace llvm {

llvm/tools/llvm-profgen/PerfReader.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
#include <fstream>
1818
#include <map>
1919

20-
using namespace llvm;
21-
using namespace sampleprof;
22-
2320
namespace llvm {
2421

2522
class CleanupInstaller;

llvm/tools/llvm-profgen/ProfileGenerator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include <unordered_set>
1818
#include <utility>
1919

20+
using namespace llvm;
21+
using namespace sampleprof;
22+
2023
cl::opt<std::string> OutputFilename("output", cl::value_desc("output"),
2124
cl::Required,
2225
cl::desc("Output profile file"));
@@ -104,9 +107,6 @@ cl::opt<bool> InferMissingFrames(
104107
"Infer missing call frames due to compiler tail call elimination."),
105108
llvm::cl::Optional);
106109

107-
using namespace llvm;
108-
using namespace sampleprof;
109-
110110
namespace llvm {
111111

112112
namespace sampleprof {

llvm/tools/llvm-profgen/ProfileGenerator.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
#include <memory>
1818
#include <unordered_set>
1919

20-
using namespace llvm;
21-
using namespace sampleprof;
22-
2320
namespace llvm {
2421
namespace sampleprof {
2522

llvm/tools/llvm-profgen/ProfiledBinary.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define DEBUG_TYPE "load-binary"
2626

2727
using namespace llvm;
28+
using namespace llvm::object;
2829
using namespace sampleprof;
2930

3031
cl::opt<bool> ShowDisassemblyOnly("show-disassembly-only",

llvm/tools/llvm-profgen/ProfiledBinary.h

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,10 @@
4242
#include <vector>
4343

4444
namespace llvm {
45+
4546
extern cl::opt<bool> EnableCSPreInliner;
4647
extern cl::opt<bool> UseContextCostForPreInliner;
47-
} // namespace llvm
48-
49-
using namespace llvm;
50-
using namespace sampleprof;
51-
using namespace llvm::object;
5248

53-
namespace llvm {
5449
namespace sampleprof {
5550

5651
class ProfiledBinary;
@@ -303,34 +298,34 @@ class ProfiledBinary {
303298

304299
bool IsCOFF = false;
305300

306-
void setPreferredTextSegmentAddresses(const ObjectFile *O);
301+
void setPreferredTextSegmentAddresses(const object::ObjectFile *O);
307302

308303
template <class ELFT>
309-
void setPreferredTextSegmentAddresses(const ELFFile<ELFT> &Obj,
304+
void setPreferredTextSegmentAddresses(const object::ELFFile<ELFT> &Obj,
310305
StringRef FileName);
311-
void setPreferredTextSegmentAddresses(const COFFObjectFile *Obj,
306+
void setPreferredTextSegmentAddresses(const object::COFFObjectFile *Obj,
312307
StringRef FileName);
313308

314-
void checkPseudoProbe(const ELFObjectFileBase *Obj);
309+
void checkPseudoProbe(const object::ELFObjectFileBase *Obj);
315310

316-
void decodePseudoProbe(const ELFObjectFileBase *Obj);
311+
void decodePseudoProbe(const object::ELFObjectFileBase *Obj);
317312

318313
void
319-
checkUseFSDiscriminator(const ObjectFile *Obj,
320-
std::map<SectionRef, SectionSymbolsTy> &AllSymbols);
314+
checkUseFSDiscriminator(const object::ObjectFile *Obj,
315+
std::map<object::SectionRef, SectionSymbolsTy> &AllSymbols);
321316

322317
// Set up disassembler and related components.
323-
void setUpDisassembler(const ObjectFile *Obj);
318+
void setUpDisassembler(const object::ObjectFile *Obj);
324319
symbolize::LLVMSymbolizer::Options getSymbolizerOpts() const;
325320

326321
// Load debug info of subprograms from DWARF section.
327-
void loadSymbolsFromDWARF(ObjectFile &Obj);
322+
void loadSymbolsFromDWARF(object::ObjectFile &Obj);
328323

329324
// Load debug info from DWARF unit.
330325
void loadSymbolsFromDWARFUnit(DWARFUnit &CompilationUnit);
331326

332327
// Create elf symbol to its start address mapping.
333-
void populateElfSymbolAddressList(const ELFObjectFileBase *O);
328+
void populateElfSymbolAddressList(const object::ELFObjectFileBase *O);
334329

335330
// A function may be spilt into multiple non-continuous address ranges. We use
336331
// this to set whether start a function range is the real entry of the
@@ -341,11 +336,11 @@ class ProfiledBinary {
341336
void warnNoFuncEntry();
342337

343338
/// Dissassemble the text section and build various address maps.
344-
void disassemble(const ObjectFile *O);
339+
void disassemble(const object::ObjectFile *O);
345340

346341
/// Helper function to dissassemble the symbol and extract info for unwinding
347342
bool dissassembleSymbol(std::size_t SI, ArrayRef<uint8_t> Bytes,
348-
SectionSymbolsTy &Symbols, const SectionRef &Section);
343+
SectionSymbolsTy &Symbols, const object::SectionRef &Section);
349344
/// Symbolize a given instruction pointer and return a full call context.
350345
SampleContextFrameVector symbolize(const InstructionPointer &IP,
351346
bool UseCanonicalFnName = false,

llvm/tools/llvm-profgen/llvm-profgen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include "llvm/Support/TargetSelect.h"
2222
#include "llvm/Support/VirtualFileSystem.h"
2323

24+
using namespace llvm;
25+
using namespace sampleprof;
26+
2427
static cl::OptionCategory ProfGenCategory("ProfGen Options");
2528

2629
static cl::opt<std::string> PerfScriptFilename(
@@ -71,9 +74,6 @@ extern cl::opt<bool> ShowDisassemblyOnly;
7174
extern cl::opt<bool> ShowSourceLocations;
7275
extern cl::opt<bool> SkipSymbolization;
7376

74-
using namespace llvm;
75-
using namespace sampleprof;
76-
7777
// Validate the command line input.
7878
static void validateCommandLine() {
7979
// Allow the missing perfscript if we only use to show binary disassembly.

0 commit comments

Comments
 (0)