Skip to content

Commit ba99e91

Browse files
committed
chore: Use std::span for include paths in preprocessor
Signed-off-by: Roberto Raggi <[email protected]>
1 parent 0629fbe commit ba99e91

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/parser/cxx/preprocessor.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <utf8/unchecked.h>
3232

3333
#include <algorithm>
34+
#include <array>
3435
#include <cassert>
3536
#include <format>
3637
#include <forward_list>
@@ -1019,8 +1020,9 @@ struct Preprocessor::Private {
10191020
Resolve(const Resolve &other) = delete;
10201021
auto operator=(const Resolve &other) -> Resolve & = delete;
10211022

1022-
Resolve(const Private *d, bool next)
1023-
: d(d), wantNextInlude(next), currentPaths{{d->currentPath_}} {}
1023+
Resolve(const Private *d, bool next) : d(d), wantNextInlude(next) {
1024+
currentPaths[0] = d->currentPath_.string();
1025+
}
10241026

10251027
using SearchPaths = std::vector<std::span<const std::string>>;
10261028

@@ -1050,15 +1052,15 @@ struct Preprocessor::Private {
10501052

10511053
[[nodiscard]] auto userHeaderSearchPaths() -> SearchPaths {
10521054
std::vector<std::span<const std::string>> paths;
1053-
paths.push_back(currentPaths);
1054-
paths.push_back(d->quoteIncludePaths_);
1055-
paths.push_back(d->systemIncludePaths_);
1055+
paths.push_back(std::span<const std::string>(currentPaths));
1056+
paths.push_back(std::span<const std::string>(d->quoteIncludePaths_));
1057+
paths.push_back(std::span<const std::string>(d->systemIncludePaths_));
10561058
return paths;
10571059
}
10581060

10591061
[[nodiscard]] auto systemHeaderSearchPaths() -> SearchPaths {
10601062
std::vector<std::span<const std::string>> paths;
1061-
paths.push_back(d->systemIncludePaths_);
1063+
paths.push_back(std::span<const std::string>(d->systemIncludePaths_));
10621064
return paths;
10631065
}
10641066

0 commit comments

Comments
 (0)