Skip to content

Commit b93bb69

Browse files
authored
[clang][dataflow] Use containers with deterministic iteration order. (#169512)
1 parent 6a395fe commit b93bb69

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

clang/include/clang/Analysis/FlowSensitive/ASTOps.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "clang/AST/ExprCXX.h"
2020
#include "clang/AST/Type.h"
2121
#include "clang/Analysis/FlowSensitive/StorageLocation.h"
22-
#include "llvm/ADT/DenseSet.h"
2322
#include "llvm/ADT/SetVector.h"
2423

2524
namespace clang {
@@ -145,17 +144,17 @@ struct ReferencedDecls {
145144
FieldSet Fields;
146145
/// All variables with static storage duration, notably including static
147146
/// member variables and static variables declared within a function.
148-
llvm::DenseSet<const VarDecl *> Globals;
147+
llvm::SetVector<const VarDecl *> Globals;
149148
/// Local variables, not including parameters or static variables declared
150149
/// within a function.
151-
llvm::DenseSet<const VarDecl *> Locals;
150+
llvm::SetVector<const VarDecl *> Locals;
152151
/// Free functions and member functions which are referenced (but not
153152
/// necessarily called).
154-
llvm::DenseSet<const FunctionDecl *> Functions;
153+
llvm::SetVector<const FunctionDecl *> Functions;
155154
/// When analyzing a lambda's call operator, the set of all parameters (from
156155
/// the surrounding function) that the lambda captures. Captured local
157156
/// variables are already included in `Locals` above.
158-
llvm::DenseSet<const ParmVarDecl *> LambdaCapturedParams;
157+
llvm::SetVector<const ParmVarDecl *> LambdaCapturedParams;
159158
};
160159

161160
/// Returns declarations that are declared in or referenced from `FD`.

clang/lib/Analysis/FlowSensitive/ASTOps.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include "clang/AST/Type.h"
2323
#include "clang/Analysis/FlowSensitive/StorageLocation.h"
2424
#include "clang/Basic/LLVM.h"
25-
#include "llvm/ADT/DenseSet.h"
2625
#include "llvm/ADT/STLExtras.h"
26+
#include "llvm/ADT/SetVector.h"
2727
#include <cassert>
2828
#include <iterator>
2929
#include <vector>
@@ -164,21 +164,21 @@ RecordInitListHelper::RecordInitListHelper(
164164
}
165165

166166
static void insertIfGlobal(const Decl &D,
167-
llvm::DenseSet<const VarDecl *> &Globals) {
167+
llvm::SetVector<const VarDecl *> &Globals) {
168168
if (auto *V = dyn_cast<VarDecl>(&D))
169169
if (V->hasGlobalStorage())
170170
Globals.insert(V);
171171
}
172172

173173
static void insertIfLocal(const Decl &D,
174-
llvm::DenseSet<const VarDecl *> &Locals) {
174+
llvm::SetVector<const VarDecl *> &Locals) {
175175
if (auto *V = dyn_cast<VarDecl>(&D))
176176
if (V->hasLocalStorage() && !isa<ParmVarDecl>(V))
177177
Locals.insert(V);
178178
}
179179

180180
static void insertIfFunction(const Decl &D,
181-
llvm::DenseSet<const FunctionDecl *> &Funcs) {
181+
llvm::SetVector<const FunctionDecl *> &Funcs) {
182182
if (auto *FD = dyn_cast<FunctionDecl>(&D))
183183
Funcs.insert(FD);
184184
}

0 commit comments

Comments
 (0)