Skip to content

llvm-profgen: Avoid "using namespace" in headers #147631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions llvm/tools/llvm-profgen/CSPreInliner.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#include "llvm/Transforms/IPO/ProfiledCallGraph.h"
#include "llvm/Transforms/IPO/SampleContextTracker.h"

using namespace llvm;
using namespace sampleprof;

namespace llvm {
namespace sampleprof {

Expand Down
4 changes: 3 additions & 1 deletion llvm/tools/llvm-profgen/ErrorHandling.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "llvm/Support/WithColor.h"
#include <system_error>

using namespace llvm;
namespace llvm {

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

} // end namespace llvm

#endif
5 changes: 2 additions & 3 deletions llvm/tools/llvm-profgen/PerfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#define DEBUG_TYPE "perf-reader"

using namespace llvm;

cl::opt<bool> SkipSymbolization("skip-symbolization",
cl::desc("Dump the unsymbolized profile to the "
"output file. It will show unwinder "
Expand Down Expand Up @@ -47,9 +49,6 @@ static cl::opt<int> CSProfMaxUnsymbolizedCtxDepth(
cl::desc("Keep the last K contexts while merging unsymbolized profile. -1 "
"means no depth limit."));

extern cl::opt<std::string> PerfTraceFilename;
extern cl::opt<bool> ShowDisassemblyOnly;
extern cl::opt<bool> ShowSourceLocations;
extern cl::opt<std::string> OutputFilename;

namespace llvm {
Expand Down
3 changes: 0 additions & 3 deletions llvm/tools/llvm-profgen/PerfReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#include <fstream>
#include <map>

using namespace llvm;
using namespace sampleprof;

namespace llvm {

class CleanupInstaller;
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-profgen/ProfileGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include <unordered_set>
#include <utility>

using namespace llvm;
using namespace sampleprof;

cl::opt<std::string> OutputFilename("output", cl::value_desc("output"),
cl::Required,
cl::desc("Output profile file"));
Expand Down Expand Up @@ -104,9 +107,6 @@ cl::opt<bool> InferMissingFrames(
"Infer missing call frames due to compiler tail call elimination."),
llvm::cl::Optional);

using namespace llvm;
using namespace sampleprof;

namespace llvm {

namespace sampleprof {
Expand Down
3 changes: 0 additions & 3 deletions llvm/tools/llvm-profgen/ProfileGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#include <memory>
#include <unordered_set>

using namespace llvm;
using namespace sampleprof;

namespace llvm {
namespace sampleprof {

Expand Down
1 change: 1 addition & 0 deletions llvm/tools/llvm-profgen/ProfiledBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define DEBUG_TYPE "load-binary"

using namespace llvm;
using namespace llvm::object;
using namespace sampleprof;

cl::opt<bool> ShowDisassemblyOnly("show-disassembly-only",
Expand Down
34 changes: 15 additions & 19 deletions llvm/tools/llvm-profgen/ProfiledBinary.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,10 @@
#include <vector>

namespace llvm {

extern cl::opt<bool> EnableCSPreInliner;
extern cl::opt<bool> UseContextCostForPreInliner;
} // namespace llvm

using namespace llvm;
using namespace sampleprof;
using namespace llvm::object;

namespace llvm {
namespace sampleprof {

class ProfiledBinary;
Expand Down Expand Up @@ -303,34 +298,34 @@ class ProfiledBinary {

bool IsCOFF = false;

void setPreferredTextSegmentAddresses(const ObjectFile *O);
void setPreferredTextSegmentAddresses(const object::ObjectFile *O);

template <class ELFT>
void setPreferredTextSegmentAddresses(const ELFFile<ELFT> &Obj,
void setPreferredTextSegmentAddresses(const object::ELFFile<ELFT> &Obj,
StringRef FileName);
void setPreferredTextSegmentAddresses(const COFFObjectFile *Obj,
void setPreferredTextSegmentAddresses(const object::COFFObjectFile *Obj,
StringRef FileName);

void checkPseudoProbe(const ELFObjectFileBase *Obj);
void checkPseudoProbe(const object::ELFObjectFileBase *Obj);

void decodePseudoProbe(const ELFObjectFileBase *Obj);
void decodePseudoProbe(const object::ELFObjectFileBase *Obj);

void
checkUseFSDiscriminator(const ObjectFile *Obj,
std::map<SectionRef, SectionSymbolsTy> &AllSymbols);
void checkUseFSDiscriminator(
const object::ObjectFile *Obj,
std::map<object::SectionRef, SectionSymbolsTy> &AllSymbols);

// Set up disassembler and related components.
void setUpDisassembler(const ObjectFile *Obj);
void setUpDisassembler(const object::ObjectFile *Obj);
symbolize::LLVMSymbolizer::Options getSymbolizerOpts() const;

// Load debug info of subprograms from DWARF section.
void loadSymbolsFromDWARF(ObjectFile &Obj);
void loadSymbolsFromDWARF(object::ObjectFile &Obj);

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

// Create elf symbol to its start address mapping.
void populateElfSymbolAddressList(const ELFObjectFileBase *O);
void populateElfSymbolAddressList(const object::ELFObjectFileBase *O);

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

/// Dissassemble the text section and build various address maps.
void disassemble(const ObjectFile *O);
void disassemble(const object::ObjectFile *O);

/// Helper function to dissassemble the symbol and extract info for unwinding
bool dissassembleSymbol(std::size_t SI, ArrayRef<uint8_t> Bytes,
SectionSymbolsTy &Symbols, const SectionRef &Section);
SectionSymbolsTy &Symbols,
const object::SectionRef &Section);
/// Symbolize a given instruction pointer and return a full call context.
SampleContextFrameVector symbolize(const InstructionPointer &IP,
bool UseCanonicalFnName = false,
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-profgen/llvm-profgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/VirtualFileSystem.h"

using namespace llvm;
using namespace sampleprof;

static cl::OptionCategory ProfGenCategory("ProfGen Options");

static cl::opt<std::string> PerfScriptFilename(
Expand Down Expand Up @@ -71,9 +74,6 @@ extern cl::opt<bool> ShowDisassemblyOnly;
extern cl::opt<bool> ShowSourceLocations;
extern cl::opt<bool> SkipSymbolization;

using namespace llvm;
using namespace sampleprof;

// Validate the command line input.
static void validateCommandLine() {
// Allow the missing perfscript if we only use to show binary disassembly.
Expand Down