[clang] 65c3617 - [clang][analysis][NFC]add static for internal linkage function (#117481)

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 26 05:50:40 PST 2024


Author: Congcong Cai
Date: 2024-11-26T21:50:35+08:00
New Revision: 65c36179be68dda0d1cc5d7e5c5b312a6b52cc0e

URL: https://github.com/llvm/llvm-project/commit/65c36179be68dda0d1cc5d7e5c5b312a6b52cc0e
DIFF: https://github.com/llvm/llvm-project/commit/65c36179be68dda0d1cc5d7e5c5b312a6b52cc0e.diff

LOG: [clang][analysis][NFC]add static for internal linkage function (#117481)

Detected by misc-use-internal-linkage

Added: 
    

Modified: 
    clang/lib/Analysis/FlowSensitive/Arena.cpp
    clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
    clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
    clang/lib/Analysis/IntervalPartition.cpp
    clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Analysis/FlowSensitive/Arena.cpp b/clang/lib/Analysis/FlowSensitive/Arena.cpp
index 81137e8088e330..7542a137c735e0 100644
--- a/clang/lib/Analysis/FlowSensitive/Arena.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Arena.cpp
@@ -23,8 +23,8 @@ canonicalFormulaPair(const Formula &LHS, const Formula &RHS) {
 }
 
 template <class Key, class ComputeFunc>
-const Formula &cached(llvm::DenseMap<Key, const Formula *> &Cache, Key K,
-                      ComputeFunc &&Compute) {
+static const Formula &cached(llvm::DenseMap<Key, const Formula *> &Cache, Key K,
+                             ComputeFunc &&Compute) {
   auto [It, Inserted] = Cache.try_emplace(std::forward<Key>(K));
   if (Inserted)
     It->second = Compute();

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index c5c6e900b79766..693313b322af1b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -64,7 +64,8 @@ static llvm::DenseMap<const ValueDecl *, StorageLocation *> intersectDeclToLoc(
 // expression must map to the same location / value. This is the case if we are
 // performing a join for control flow within a full-expression (which is the
 // only case when this function should be used).
-template <typename MapT> MapT joinExprMaps(const MapT &Map1, const MapT &Map2) {
+template <typename MapT>
+static MapT joinExprMaps(const MapT &Map1, const MapT &Map2) {
   MapT Result = Map1;
 
   for (const auto &Entry : Map2) {
@@ -204,10 +205,11 @@ static WidenResult widenDistinctValues(QualType Type, Value &Prev,
 // Returns whether the values in `Map1` and `Map2` compare equal for those
 // keys that `Map1` and `Map2` have in common.
 template <typename Key>
-bool compareKeyToValueMaps(const llvm::MapVector<Key, Value *> &Map1,
-                           const llvm::MapVector<Key, Value *> &Map2,
-                           const Environment &Env1, const Environment &Env2,
-                           Environment::ValueModel &Model) {
+static bool compareKeyToValueMaps(const llvm::MapVector<Key, Value *> &Map1,
+                                  const llvm::MapVector<Key, Value *> &Map2,
+                                  const Environment &Env1,
+                                  const Environment &Env2,
+                                  Environment::ValueModel &Model) {
   for (auto &Entry : Map1) {
     Key K = Entry.first;
     assert(K != nullptr);
@@ -260,7 +262,7 @@ joinLocToVal(const llvm::MapVector<const StorageLocation *, Value *> &LocToVal,
 // Perform widening on either `LocToVal` or `ExprToVal`. `Key` must be either
 // `const StorageLocation *` or `const Expr *`.
 template <typename Key>
-llvm::MapVector<Key, Value *>
+static llvm::MapVector<Key, Value *>
 widenKeyToValueMap(const llvm::MapVector<Key, Value *> &CurMap,
                    const llvm::MapVector<Key, Value *> &PrevMap,
                    Environment &CurEnv, const Environment &PrevEnv,

diff  --git a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
index 77d817dafe8378..02fd73754f01be 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
@@ -16,8 +16,9 @@ namespace dataflow {
 
 /// Determines whether `D` is one of the methods used to implement Chromium's
 /// `CHECK` macros. Populates `CheckDecls`, if empty.
-bool isCheckLikeMethod(llvm::SmallDenseSet<const CXXMethodDecl *> &CheckDecls,
-                       const CXXMethodDecl &D) {
+static bool
+isCheckLikeMethod(llvm::SmallDenseSet<const CXXMethodDecl *> &CheckDecls,
+                  const CXXMethodDecl &D) {
   // All of the methods of interest are static, so avoid any lookup for
   // non-static methods (the common case).
   if (!D.isStatic())

diff  --git a/clang/lib/Analysis/IntervalPartition.cpp b/clang/lib/Analysis/IntervalPartition.cpp
index 5f06606ec132e9..41199f358c5b97 100644
--- a/clang/lib/Analysis/IntervalPartition.cpp
+++ b/clang/lib/Analysis/IntervalPartition.cpp
@@ -36,8 +36,8 @@ static unsigned getID(const CFGIntervalNode &I) { return I.ID; }
 
 // `Node` must be one of `CFGBlock` or `CFGIntervalNode`.
 template <typename Node>
-BuildResult<Node> buildInterval(llvm::BitVector &Partitioned,
-                                const Node *Header) {
+static BuildResult<Node> buildInterval(llvm::BitVector &Partitioned,
+                                       const Node *Header) {
   assert(Header != nullptr);
   BuildResult<Node> Interval;
   Interval.Nodes.push_back(Header);
@@ -102,10 +102,10 @@ BuildResult<Node> buildInterval(llvm::BitVector &Partitioned,
 }
 
 template <typename Node>
-void fillIntervalNode(CFGIntervalGraph &Graph,
-                      std::vector<CFGIntervalNode *> &Index,
-                      std::queue<const Node *> &Successors,
-                      llvm::BitVector &Partitioned, const Node *Header) {
+static void fillIntervalNode(CFGIntervalGraph &Graph,
+                             std::vector<CFGIntervalNode *> &Index,
+                             std::queue<const Node *> &Successors,
+                             llvm::BitVector &Partitioned, const Node *Header) {
   BuildResult<Node> Result = buildInterval(Partitioned, Header);
   for (const auto *S : Result.Successors)
     Successors.push(S);
@@ -138,8 +138,8 @@ void fillIntervalNode(CFGIntervalGraph &Graph,
 }
 
 template <typename Node>
-CFGIntervalGraph partitionIntoIntervalsImpl(unsigned NumBlockIDs,
-                                            const Node *EntryBlock) {
+static CFGIntervalGraph partitionIntoIntervalsImpl(unsigned NumBlockIDs,
+                                                   const Node *EntryBlock) {
   assert(EntryBlock != nullptr);
   CFGIntervalGraph Graph;
   // `Index` maps all of the nodes of the input graph to the interval to which

diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 5f36ffa926b269..321097e16a45f7 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -2326,7 +2326,8 @@ static StringRef getEndOfLine() {
 }
 
 // Returns the text indicating that the user needs to provide input there:
-std::string getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") {
+static std::string
+getUserFillPlaceHolder(StringRef HintTextToUser = "placeholder") {
   std::string s = std::string("<# ");
   s += HintTextToUser;
   s += " #>";


        


More information about the cfe-commits mailing list