Skip to content

Commit 48ef912

Browse files
committed
[VFS] Avoid <stack> include (NFC)
Directly use a vector instead of wrapping it in a stack, like we do in most places.
1 parent df86fb0 commit 48ef912

File tree

12 files changed

+21
-11
lines changed

12 files changed

+21
-11
lines changed

clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "RedundantStrcatCallsCheck.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
#include <deque>
1213

1314
using namespace clang::ast_matchers;
1415

clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "clang/Lex/MacroArgs.h"
1313
#include "clang/Lex/PPCallbacks.h"
1414
#include "clang/Lex/Preprocessor.h"
15+
#include <stack>
1516

1617
namespace clang::tidy::bugprone {
1718

clang-tools-extra/clangd/GlobalCompilationDatabase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <atomic>
3131
#include <chrono>
3232
#include <condition_variable>
33+
#include <deque>
3334
#include <mutex>
3435
#include <optional>
3536
#include <string>

clang-tools-extra/clangd/Selection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "clang/AST/PrettyPrinter.h"
4646
#include "clang/Tooling/Syntax/Tokens.h"
4747
#include "llvm/ADT/SmallVector.h"
48+
#include <stack>
4849

4950
namespace clang {
5051
namespace clangd {

clang/lib/Sema/SemaAPINotes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clang/Sema/SemaInternal.h"
1919
#include "clang/Sema/SemaObjC.h"
2020
#include "clang/Sema/SemaSwift.h"
21+
#include <stack>
2122

2223
using namespace clang;
2324

clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include <deque>
6060
#include <memory>
6161
#include <optional>
62+
#include <stack>
6263
#include <string>
6364
#include <utility>
6465

clang/unittests/Support/TimeProfilerTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "llvm/Support/JSON.h"
1414
#include "llvm/Support/TimeProfiler.h"
15+
#include <stack>
1516

1617
#include "gtest/gtest.h"
1718

lldb/include/lldb/Target/StackFrameRecognizer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "lldb/lldb-private-forward.h"
1818
#include "lldb/lldb-public.h"
1919

20+
#include <deque>
2021
#include <optional>
2122
#include <vector>
2223

llvm/include/llvm/Support/VirtualFileSystem.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <ctime>
3232
#include <memory>
3333
#include <optional>
34-
#include <stack>
3534
#include <string>
3635
#include <system_error>
3736
#include <utility>
@@ -219,7 +218,7 @@ namespace detail {
219218

220219
/// Keeps state for the recursive_directory_iterator.
221220
struct RecDirIterState {
222-
std::stack<directory_iterator, std::vector<directory_iterator>> Stack;
221+
std::vector<directory_iterator> Stack;
223222
bool HasNoPushRequest = false;
224223
};
225224

@@ -242,8 +241,8 @@ class recursive_directory_iterator {
242241
/// Equivalent to operator++, with an error code.
243242
recursive_directory_iterator &increment(std::error_code &EC);
244243

245-
const directory_entry &operator*() const { return *State->Stack.top(); }
246-
const directory_entry *operator->() const { return &*State->Stack.top(); }
244+
const directory_entry &operator*() const { return *State->Stack.back(); }
245+
const directory_entry *operator->() const { return &*State->Stack.back(); }
247246

248247
bool operator==(const recursive_directory_iterator &Other) const {
249248
return State == Other.State; // identity

llvm/lib/ProfileData/Coverage/CoverageMapping.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <map>
3838
#include <memory>
3939
#include <optional>
40+
#include <stack>
4041
#include <string>
4142
#include <system_error>
4243
#include <utility>

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,30 +2913,31 @@ vfs::recursive_directory_iterator::recursive_directory_iterator(
29132913
directory_iterator I = FS->dir_begin(Path, EC);
29142914
if (I != directory_iterator()) {
29152915
State = std::make_shared<detail::RecDirIterState>();
2916-
State->Stack.push(I);
2916+
State->Stack.push_back(I);
29172917
}
29182918
}
29192919

29202920
vfs::recursive_directory_iterator &
29212921
recursive_directory_iterator::increment(std::error_code &EC) {
29222922
assert(FS && State && !State->Stack.empty() && "incrementing past end");
2923-
assert(!State->Stack.top()->path().empty() && "non-canonical end iterator");
2923+
assert(!State->Stack.back()->path().empty() && "non-canonical end iterator");
29242924
vfs::directory_iterator End;
29252925

29262926
if (State->HasNoPushRequest)
29272927
State->HasNoPushRequest = false;
29282928
else {
2929-
if (State->Stack.top()->type() == sys::fs::file_type::directory_file) {
2930-
vfs::directory_iterator I = FS->dir_begin(State->Stack.top()->path(), EC);
2929+
if (State->Stack.back()->type() == sys::fs::file_type::directory_file) {
2930+
vfs::directory_iterator I =
2931+
FS->dir_begin(State->Stack.back()->path(), EC);
29312932
if (I != End) {
2932-
State->Stack.push(I);
2933+
State->Stack.push_back(I);
29332934
return *this;
29342935
}
29352936
}
29362937
}
29372938

2938-
while (!State->Stack.empty() && State->Stack.top().increment(EC) == End)
2939-
State->Stack.pop();
2939+
while (!State->Stack.empty() && State->Stack.back().increment(EC) == End)
2940+
State->Stack.pop_back();
29402941

29412942
if (State->Stack.empty())
29422943
State.reset(); // end iterator

llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
#include <memory>
121121
#include <numeric>
122122
#include <optional>
123+
#include <stack>
123124
#include <string>
124125
#include <unordered_map>
125126
#include <utility>

0 commit comments

Comments
 (0)