From c55e9975566ca2491d377a33f1ac497ef12571a3 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 13 Oct 2018 22:18:22 +0000 Subject: [PATCH] Move some helpers from the global namespace into anonymous ones. llvm-svn: 344468 --- clang-tools-extra/clangd/ClangdServer.cpp | 3 ++- clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp | 2 ++ clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp | 2 ++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 4 +++- llvm/lib/Demangle/MicrosoftDemangle.cpp | 11 ++++++----- llvm/lib/Target/Mips/MipsCallLowering.cpp | 8 ++++---- llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp | 2 +- llvm/lib/Target/X86/X86CondBrFolding.cpp | 2 ++ .../lib/Transforms/Instrumentation/ControlHeightReduction.cpp | 7 ++++--- 9 files changed, 26 insertions(+), 15 deletions(-) diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index bdba66e..b870721 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -72,7 +72,8 @@ public: } // namespace // Returns callbacks that can be used to update the FileIndex with new ASTs. -std::unique_ptr makeUpdateCallbacks(FileIndex *FIndex) { +static std::unique_ptr +makeUpdateCallbacks(FileIndex *FIndex) { struct CB : public ParsingCallbacks { CB(FileIndex *FIndex) : FIndex(FIndex) {} FileIndex *FIndex; diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp index 1f9bdeb..3aa21b8 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -196,6 +196,7 @@ bool CallAndMessageChecker::uninitRefOrPointer( return false; } +namespace { class FindUninitializedField { public: SmallVector FieldChain; @@ -234,6 +235,7 @@ public: return false; } }; +} // namespace bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C, SVal V, diff --git a/clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp index 7c53b2d..0752dba 100644 --- a/clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp @@ -337,6 +337,7 @@ void ExprInspectionChecker::analyzerDenote(const CallExpr *CE, C.addTransition(C.getState()->set(Sym, E)); } +namespace { class SymbolExpressor : public SymExprVisitor> { ProgramStateRef State; @@ -369,6 +370,7 @@ public: return None; } }; +} // namespace void ExprInspectionChecker::analyzerExpress(const CallExpr *CE, CheckerContext &C) const { diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 151865f..c5edfad 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -98,11 +98,12 @@ STATISTIC(NumMaxBlockCountReachedInInlined, STATISTIC(NumTimesRetriedWithoutInlining, "The # of times we re-evaluated a call without inlining"); - //===----------------------------------------------------------------------===// // Internal program state traits. //===----------------------------------------------------------------------===// +namespace { + // When modeling a C++ constructor, for a variety of reasons we need to track // the location of the object for the duration of its ConstructionContext. // ObjectsUnderConstruction maps statements within the construction context @@ -164,6 +165,7 @@ public: return Impl < RHS.Impl; } }; +} // namespace typedef llvm::ImmutableMap ObjectsUnderConstructionMap; diff --git a/llvm/lib/Demangle/MicrosoftDemangle.cpp b/llvm/lib/Demangle/MicrosoftDemangle.cpp index 9f60eb2..59fb7c9 100644 --- a/llvm/lib/Demangle/MicrosoftDemangle.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangle.cpp @@ -652,7 +652,7 @@ Demangler::demangleLiteralOperatorIdentifier(StringView &MangledName) { return N; } -IntrinsicFunctionKind +static IntrinsicFunctionKind translateIntrinsicFunctionCode(char CH, FunctionIdentifierCodeGroup Group) { // Not all ? identifiers are intrinsics *functions*. This function only maps // operator codes for the special functions, all others are handled elsewhere, @@ -1220,7 +1220,7 @@ static void outputEscapedChar(OutputStream &OS, unsigned C) { outputHex(OS, C); } -unsigned countTrailingNullBytes(const uint8_t *StringBytes, int Length) { +static unsigned countTrailingNullBytes(const uint8_t *StringBytes, int Length) { const uint8_t *End = StringBytes + Length - 1; unsigned Count = 0; while (Length > 0 && *End == 0) { @@ -1231,7 +1231,8 @@ unsigned countTrailingNullBytes(const uint8_t *StringBytes, int Length) { return Count; } -unsigned countEmbeddedNulls(const uint8_t *StringBytes, unsigned Length) { +static unsigned countEmbeddedNulls(const uint8_t *StringBytes, + unsigned Length) { unsigned Result = 0; for (unsigned I = 0; I < Length; ++I) { if (*StringBytes++ == 0) @@ -1240,8 +1241,8 @@ unsigned countEmbeddedNulls(const uint8_t *StringBytes, unsigned Length) { return Result; } -unsigned guessCharByteSize(const uint8_t *StringBytes, unsigned NumChars, - unsigned NumBytes) { +static unsigned guessCharByteSize(const uint8_t *StringBytes, unsigned NumChars, + unsigned NumBytes) { assert(NumBytes > 0); // If the number of bytes is odd, this is guaranteed to be a char string. diff --git a/llvm/lib/Target/Mips/MipsCallLowering.cpp b/llvm/lib/Target/Mips/MipsCallLowering.cpp index 8babdbf..4d070f9 100644 --- a/llvm/lib/Target/Mips/MipsCallLowering.cpp +++ b/llvm/lib/Target/Mips/MipsCallLowering.cpp @@ -298,8 +298,8 @@ static bool isSupportedType(Type *T) { return false; } -CCValAssign::LocInfo determineLocInfo(const MVT RegisterVT, const EVT VT, - const ISD::ArgFlagsTy &Flags) { +static CCValAssign::LocInfo determineLocInfo(const MVT RegisterVT, const EVT VT, + const ISD::ArgFlagsTy &Flags) { // > does not mean loss of information as type RegisterVT can't hold type VT, // it means that type VT is split into multiple registers of type RegisterVT if (VT.getSizeInBits() >= RegisterVT.getSizeInBits()) @@ -312,8 +312,8 @@ CCValAssign::LocInfo determineLocInfo(const MVT RegisterVT, const EVT VT, } template -void setLocInfo(SmallVectorImpl &ArgLocs, - const SmallVectorImpl &Arguments) { +static void setLocInfo(SmallVectorImpl &ArgLocs, + const SmallVectorImpl &Arguments) { for (unsigned i = 0; i < ArgLocs.size(); ++i) { const CCValAssign &VA = ArgLocs[i]; CCValAssign::LocInfo LocInfo = determineLocInfo( diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp index 936b801..98953f0 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp @@ -59,7 +59,7 @@ FunctionPass *llvm::createWebAssemblyLateEHPrepare() { // possible search paths should be the same. // Returns nullptr in case it does not find any EH pad in the search, or finds // multiple different EH pads. -MachineBasicBlock *GetMatchingEHPad(MachineInstr *MI) { +static MachineBasicBlock *GetMatchingEHPad(MachineInstr *MI) { MachineFunction *MF = MI->getParent()->getParent(); SmallVector WL; SmallPtrSet Visited; diff --git a/llvm/lib/Target/X86/X86CondBrFolding.cpp b/llvm/lib/Target/X86/X86CondBrFolding.cpp index 8b9ef20..1d22193 100644 --- a/llvm/lib/Target/X86/X86CondBrFolding.cpp +++ b/llvm/lib/Target/X86/X86CondBrFolding.cpp @@ -84,6 +84,7 @@ FunctionPass *llvm::createX86CondBrFolding() { return new X86CondBrFoldingPass(); } +namespace { // A class the stores the auxiliary information for each MBB. struct TargetMBBInfo { MachineBasicBlock *TBB; @@ -129,6 +130,7 @@ private: return MBBInfos[MBB->getNumber()].get(); } }; +} // namespace // Find a valid path that we can reuse the CondCode. // The resulted path (if return true) is stored in BranchPath. diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index 2c0721f..8f4159d 100644 --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -621,9 +621,10 @@ static BranchProbability getCHRBiasThreshold() { // CHRBiasThreshold, put Key into TrueSet and return true. If FalseProb >= // CHRBiasThreshold, put Key into FalseSet and return true. Otherwise, return // false. -template -bool checkBias(K *Key, BranchProbability TrueProb, BranchProbability FalseProb, - S &TrueSet, S &FalseSet, M &BiasMap) { +template +static bool checkBias(K *Key, BranchProbability TrueProb, + BranchProbability FalseProb, S &TrueSet, S &FalseSet, + M &BiasMap) { BranchProbability Threshold = getCHRBiasThreshold(); if (TrueProb >= Threshold) { TrueSet.insert(Key); -- 2.7.4