Skip to content

Commit 20e9c36

Browse files
committed
Internalize functions from various tools. NFC
And internalize some classes if I noticed them:)
1 parent 6f24774 commit 20e9c36

File tree

16 files changed

+58
-61
lines changed

16 files changed

+58
-61
lines changed

lld/MachO/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void MachOOptTable::printHelp(const char *argv0, bool showHidden) const {
8888
lld::outs() << "\n";
8989
}
9090

91-
HeaderFileType getOutputType(const opt::InputArgList &args) {
91+
static HeaderFileType getOutputType(const opt::InputArgList &args) {
9292
// TODO: -r, -dylinker, -preload...
9393
opt::Arg *outputArg = args.getLastArg(OPT_bundle, OPT_dylib, OPT_execute);
9494
if (outputArg == nullptr)

llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static bool canSafelyConvertTo16Bit(Value &V) {
8383
}
8484

8585
// Convert a value to 16-bit.
86-
Value *convertTo16Bit(Value &V, InstCombiner::BuilderTy &Builder) {
86+
static Value *convertTo16Bit(Value &V, InstCombiner::BuilderTy &Builder) {
8787
Type *VTy = V.getType();
8888
if (isa<FPExtInst>(&V) || isa<SExtInst>(&V) || isa<ZExtInst>(&V))
8989
return cast<Instruction>(&V)->getOperand(0);

llvm/tools/llvm-ar/llvm-ar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ USAGE: llvm-ar [options] [-]<operation>[modifiers] [relpos] [count] <archive> [f
125125
[V] - display the version and exit
126126
)";
127127

128-
void printHelpMessage() {
128+
static void printHelpMessage() {
129129
if (Stem.contains_lower("ranlib"))
130130
outs() << RanlibHelp;
131131
else if (Stem.contains_lower("ar"))

llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ cl::opt<bool> Summarize("summarize", cl::desc("Print the summary only."),
6060

6161
ExitOnError ExitOnErr;
6262

63-
void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
63+
static void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
6464
auto FileOrErr = MemoryBuffer::getFile(LineInfo.FileName);
6565
if (!FileOrErr) {
6666
errs() << "Could not open file: " << LineInfo.FileName << "\n";
@@ -84,10 +84,10 @@ void printBlameContext(const DILineInfo &LineInfo, unsigned Context) {
8484
}
8585
}
8686

87-
void printInstructionInformation(const FileAnalysis &Analysis,
88-
const Instr &InstrMeta,
89-
const GraphResult &Graph,
90-
CFIProtectionStatus ProtectionStatus) {
87+
static void printInstructionInformation(const FileAnalysis &Analysis,
88+
const Instr &InstrMeta,
89+
const GraphResult &Graph,
90+
CFIProtectionStatus ProtectionStatus) {
9191
outs() << "Instruction: " << format_hex(InstrMeta.VMAddress, 2) << " ("
9292
<< stringCFIProtectionStatus(ProtectionStatus) << "): ";
9393
Analysis.printInstruction(InstrMeta, outs());
@@ -97,8 +97,8 @@ void printInstructionInformation(const FileAnalysis &Analysis,
9797
Graph.printToDOT(Analysis, outs());
9898
}
9999

100-
void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
101-
const DILineInfo &LineInfo) {
100+
static void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
101+
const DILineInfo &LineInfo) {
102102
if (BlameLine) {
103103
outs() << "Blacklist Match: " << BlacklistFilename << ":" << BlameLine
104104
<< "\n";
@@ -122,8 +122,9 @@ void printInstructionStatus(unsigned BlameLine, bool CFIProtected,
122122
}
123123
}
124124

125-
void printIndirectCFInstructions(FileAnalysis &Analysis,
126-
const SpecialCaseList *SpecialCaseList) {
125+
static void
126+
printIndirectCFInstructions(FileAnalysis &Analysis,
127+
const SpecialCaseList *SpecialCaseList) {
127128
uint64_t ExpectedProtected = 0;
128129
uint64_t UnexpectedProtected = 0;
129130
uint64_t ExpectedUnprotected = 0;

llvm/tools/llvm-cvtres/llvm-cvtres.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class CvtResOptTable : public opt::OptTable {
6767
};
6868
}
6969

70-
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
70+
static LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
7171
errs() << Msg;
7272
exit(1);
7373
}
@@ -76,13 +76,7 @@ static void reportError(StringRef Input, std::error_code EC) {
7676
reportError(Twine(Input) + ": " + EC.message() + ".\n");
7777
}
7878

79-
void error(std::error_code EC) {
80-
if (!EC)
81-
return;
82-
reportError(EC.message() + ".\n");
83-
}
84-
85-
void error(Error EC) {
79+
static void error(Error EC) {
8680
if (!EC)
8781
return;
8882
handleAllErrors(std::move(EC),

llvm/tools/llvm-dwp/llvm-dwp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ writeIndex(MCStreamer &Out, MCSection *Section,
377377
&DWARFUnitIndex::Entry::SectionContribution::Length);
378378
}
379379

380-
std::string buildDWODescription(StringRef Name, StringRef DWPName, StringRef DWOName) {
380+
static std::string buildDWODescription(StringRef Name, StringRef DWPName,
381+
StringRef DWOName) {
381382
std::string Text = "\'";
382383
Text += Name;
383384
Text += '\'';

llvm/tools/llvm-ifs/llvm-ifs.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ enum class IFSSymbolType {
6262
Unknown = 16,
6363
};
6464

65-
std::string getTypeName(IFSSymbolType Type) {
65+
static std::string getTypeName(IFSSymbolType Type) {
6666
switch (Type) {
6767
case IFSSymbolType::NoType:
6868
return "NoType";
@@ -213,8 +213,8 @@ static Expected<std::unique_ptr<IFSStub>> readInputFile(StringRef FilePath) {
213213
return std::move(Stub);
214214
}
215215

216-
int writeTbdStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
217-
const StringRef Format, raw_ostream &Out) {
216+
static int writeTbdStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
217+
const StringRef Format, raw_ostream &Out) {
218218

219219
auto PlatformKindOrError =
220220
[](const llvm::Triple &T) -> llvm::Expected<llvm::MachO::PlatformKind> {
@@ -275,8 +275,8 @@ int writeTbdStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
275275
return 0;
276276
}
277277

278-
int writeElfStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
279-
const StringRef Format, raw_ostream &Out) {
278+
static int writeElfStub(const Triple &T, const std::vector<IFSSymbol> &Symbols,
279+
const StringRef Format, raw_ostream &Out) {
280280
SmallString<0> Storage;
281281
Storage.clear();
282282
raw_svector_ostream OS(Storage);
@@ -358,7 +358,7 @@ int writeElfStub(const llvm::Triple &T, const std::vector<IFSSymbol> &Symbols,
358358
return convertYAML(YIn, Out, ErrHandler) ? 0 : 1;
359359
}
360360

361-
int writeIfso(const IFSStub &Stub, bool IsWriteIfs, raw_ostream &Out) {
361+
static int writeIfso(const IFSStub &Stub, bool IsWriteIfs, raw_ostream &Out) {
362362
if (IsWriteIfs) {
363363
yaml::Output YamlOut(Out, NULL, /*WrapColumn =*/0);
364364
YamlOut << const_cast<IFSStub &>(Stub);

llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ Session::findSymbolInfo(StringRef SymbolName, Twine ErrorMsgStem) {
770770

771771
} // end namespace llvm
772772

773-
Triple getFirstFileTriple() {
773+
static Triple getFirstFileTriple() {
774774
assert(!InputFiles.empty() && "InputFiles can not be empty");
775775
auto ObjBuffer =
776776
ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(InputFiles.front())));
@@ -779,7 +779,7 @@ Triple getFirstFileTriple() {
779779
return Obj->makeTriple();
780780
}
781781

782-
Error sanitizeArguments(const Session &S) {
782+
static Error sanitizeArguments(const Session &S) {
783783
if (EntryPointName.empty()) {
784784
if (S.TPC->getTargetTriple().getObjectFormat() == Triple::MachO)
785785
EntryPointName = "_main";
@@ -801,7 +801,7 @@ Error sanitizeArguments(const Session &S) {
801801
return Error::success();
802802
}
803803

804-
Error loadProcessSymbols(Session &S) {
804+
static Error loadProcessSymbols(Session &S) {
805805
auto InternedEntryPointName = S.ES.intern(EntryPointName);
806806
auto FilterMainEntryPoint = [InternedEntryPointName](SymbolStringPtr Name) {
807807
return Name != InternedEntryPointName;
@@ -813,7 +813,7 @@ Error loadProcessSymbols(Session &S) {
813813
return Error::success();
814814
}
815815

816-
Error loadDylibs() {
816+
static Error loadDylibs() {
817817
// FIXME: This should all be handled inside DynamicLibrary.
818818
for (const auto &Dylib : Dylibs) {
819819
if (!sys::fs::is_regular_file(Dylib))
@@ -827,12 +827,11 @@ Error loadDylibs() {
827827
return Error::success();
828828
}
829829

830-
void addPhonyExternalsGenerator(Session &S) {
830+
static void addPhonyExternalsGenerator(Session &S) {
831831
S.MainJD->addGenerator(std::make_unique<PhonyExternalsGenerator>());
832832
}
833833

834-
Error loadObjects(Session &S) {
835-
834+
static Error loadObjects(Session &S) {
836835
std::map<unsigned, JITDylib *> IdxToJLD;
837836

838837
// First, set up JITDylibs.
@@ -941,7 +940,7 @@ Error loadObjects(Session &S) {
941940
return Error::success();
942941
}
943942

944-
Error runChecks(Session &S) {
943+
static Error runChecks(Session &S) {
945944

946945
auto TripleName = S.TPC->getTargetTriple().str();
947946
std::string ErrorStr;
@@ -1036,12 +1035,14 @@ static Expected<JITEvaluatedSymbol> getMainEntryPoint(Session &S) {
10361035
return S.ES.lookup(S.JDSearchOrder, EntryPointName);
10371036
}
10381037

1038+
namespace {
10391039
struct JITLinkTimers {
10401040
TimerGroup JITLinkTG{"llvm-jitlink timers", "timers for llvm-jitlink phases"};
10411041
Timer LoadObjectsTimer{"load", "time to load/add object files", JITLinkTG};
10421042
Timer LinkTimer{"link", "time to link object files", JITLinkTG};
10431043
Timer RunTimer{"run", "time to execute jitlink'd code", JITLinkTG};
10441044
};
1045+
} // namespace
10451046

10461047
int main(int argc, char *argv[]) {
10471048
InitLLVM X(argc, argv);

llvm/tools/llvm-lto/llvm-lto.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ getLocalLTOModule(StringRef Path, std::unique_ptr<MemoryBuffer> &Buffer,
337337
}
338338

339339
/// Print some statistics on the index for each input files.
340-
void printIndexStats() {
340+
static void printIndexStats() {
341341
for (auto &Filename : InputFilenames) {
342342
ExitOnError ExitOnErr("llvm-lto: error loading file '" + Filename + "': ");
343343
std::unique_ptr<ModuleSummaryIndex> Index =

llvm/tools/llvm-mt/llvm-mt.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CvtResOptTable : public opt::OptTable {
6464
};
6565
} // namespace
6666

67-
LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
67+
LLVM_ATTRIBUTE_NORETURN static void reportError(Twine Msg) {
6868
WithColor::error(errs(), "llvm-mt") << Msg << '\n';
6969
exit(1);
7070
}
@@ -73,12 +73,7 @@ static void reportError(StringRef Input, std::error_code EC) {
7373
reportError(Twine(Input) + ": " + EC.message());
7474
}
7575

76-
void error(std::error_code EC) {
77-
if (EC)
78-
reportError(EC.message());
79-
}
80-
81-
void error(Error EC) {
76+
static void error(Error EC) {
8277
if (EC)
8378
handleAllErrors(std::move(EC), [&](const ErrorInfoBase &EI) {
8479
reportError(EI.message());

0 commit comments

Comments
 (0)