Move some helpers from the global namespace into anonymous ones.

llvm-svn: 344468
This commit is contained in:
Benjamin Kramer 2018-10-13 22:18:22 +00:00
parent 7899ccbcca
commit c55e997556
9 changed files with 26 additions and 15 deletions

View File

@ -72,7 +72,8 @@ public:
} // namespace
// Returns callbacks that can be used to update the FileIndex with new ASTs.
std::unique_ptr<ParsingCallbacks> makeUpdateCallbacks(FileIndex *FIndex) {
static std::unique_ptr<ParsingCallbacks>
makeUpdateCallbacks(FileIndex *FIndex) {
struct CB : public ParsingCallbacks {
CB(FileIndex *FIndex) : FIndex(FIndex) {}
FileIndex *FIndex;

View File

@ -196,6 +196,7 @@ bool CallAndMessageChecker::uninitRefOrPointer(
return false;
}
namespace {
class FindUninitializedField {
public:
SmallVector<const FieldDecl *, 10> FieldChain;
@ -234,6 +235,7 @@ public:
return false;
}
};
} // namespace
bool CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
SVal V,

View File

@ -337,6 +337,7 @@ void ExprInspectionChecker::analyzerDenote(const CallExpr *CE,
C.addTransition(C.getState()->set<DenotedSymbols>(Sym, E));
}
namespace {
class SymbolExpressor
: public SymExprVisitor<SymbolExpressor, Optional<std::string>> {
ProgramStateRef State;
@ -369,6 +370,7 @@ public:
return None;
}
};
} // namespace
void ExprInspectionChecker::analyzerExpress(const CallExpr *CE,
CheckerContext &C) const {

View File

@ -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<ConstructedObjectKey, SVal>
ObjectsUnderConstructionMap;

View File

@ -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.

View File

@ -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 <typename T>
void setLocInfo(SmallVectorImpl<CCValAssign> &ArgLocs,
const SmallVectorImpl<T> &Arguments) {
static void setLocInfo(SmallVectorImpl<CCValAssign> &ArgLocs,
const SmallVectorImpl<T> &Arguments) {
for (unsigned i = 0; i < ArgLocs.size(); ++i) {
const CCValAssign &VA = ArgLocs[i];
CCValAssign::LocInfo LocInfo = determineLocInfo(

View File

@ -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<MachineBasicBlock *, 2> WL;
SmallPtrSet<MachineBasicBlock *, 2> Visited;

View File

@ -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.

View File

@ -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<typename K, typename S, typename M>
bool checkBias(K *Key, BranchProbability TrueProb, BranchProbability FalseProb,
S &TrueSet, S &FalseSet, M &BiasMap) {
template <typename K, typename S, typename M>
static bool checkBias(K *Key, BranchProbability TrueProb,
BranchProbability FalseProb, S &TrueSet, S &FalseSet,
M &BiasMap) {
BranchProbability Threshold = getCHRBiasThreshold();
if (TrueProb >= Threshold) {
TrueSet.insert(Key);