Move some helpers from the global namespace into anonymous ones.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 13 Oct 2018 22:18:22 +0000 (22:18 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 13 Oct 2018 22:18:22 +0000 (22:18 +0000)
llvm-svn: 344468

clang-tools-extra/clangd/ClangdServer.cpp
clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
llvm/lib/Demangle/MicrosoftDemangle.cpp
llvm/lib/Target/Mips/MipsCallLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
llvm/lib/Target/X86/X86CondBrFolding.cpp
llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp

index bdba66e..b870721 100644 (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;
index 1f9bdeb..3aa21b8 100644 (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,
index 7c53b2d..0752dba 100644 (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 {
index 151865f..c5edfad 100644 (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;
index 9f60eb2..59fb7c9 100644 (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.
index 8babdbf..4d070f9 100644 (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(
index 936b801..98953f0 100644 (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;
index 8b9ef20..1d22193 100644 (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.
index 2c0721f..8f4159d 100644 (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);