Skip to content

Commit 1ee02ba

Browse files
committed
Fix include next warning
1 parent a11871e commit 1ee02ba

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

cpp2rust/compat/platform_flags.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
#include <string>
77
#include <vector>
88

9-
static inline std::vector<std::string> getPlatformClangFlags() {
9+
static inline std::vector<std::string> getPlatformClangBeginFlags() {
1010
std::vector<std::string> flags = {
1111
"-resource-dir=" CLANG_RESOURCE_DIR,
1212
"-I" COMPAT_INCLUDE_DIR,
1313
"-D_FORTIFY_SOURCE=0",
14-
"-Wno-gnu-include-next",
1514
};
1615
#ifdef MACOS_SDK_PATH
1716
flags.push_back("-isysroot" MACOS_SDK_PATH);
1817
#endif
1918
return flags;
2019
}
20+
21+
static inline std::vector<std::string> getPlatformClangEndFlags() {
22+
return {
23+
"-Wno-gnu-include-next",
24+
};
25+
}

cpp2rust/converter/translation_rule.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,8 +853,10 @@ TypeTgt ParseTypeTgtJSON(const llvm::json::Object &obj) {
853853
}
854854

855855
RuleMap LoadSrc(const std::filesystem::path &src_path) {
856-
clang::tooling::FixedCompilationDatabase compilations(
857-
".", getPlatformClangFlags());
856+
auto flags = getPlatformClangBeginFlags();
857+
auto end_flags = getPlatformClangEndFlags();
858+
flags.insert(flags.end(), end_flags.begin(), end_flags.end());
859+
clang::tooling::FixedCompilationDatabase compilations(".", flags);
858860
RuleMap out;
859861
ActionFactory factory(out);
860862
clang::tooling::ClangTool tool(compilations, {src_path.string()});

cpp2rust/cpp2rust_lib.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ std::string TranspileSrc(std::string_view cc_code, Model model,
1515
const std::vector<std::string_view> &cxx_flags,
1616
const std::string &rules_dir,
1717
std::string_view filename) {
18-
auto tool_args = getPlatformClangFlags();
18+
auto tool_args = getPlatformClangBeginFlags();
1919
tool_args.push_back("-fparse-all-comments");
2020
tool_args.insert(tool_args.end(), cxx_flags.begin(), cxx_flags.end());
21+
auto end_flags = getPlatformClangEndFlags();
22+
tool_args.insert(tool_args.end(), end_flags.begin(), end_flags.end());
2123

2224
std::string rs_code;
2325
clang::tooling::runToolOnCodeWithArgs(
@@ -43,7 +45,10 @@ std::string TranspileDir(std::string_view build_dir, Model model,
4345

4446
clang::tooling::ClangTool Tool(*compile_dbase, files);
4547
Tool.appendArgumentsAdjuster(clang::tooling::getInsertArgumentAdjuster(
46-
getPlatformClangFlags(), clang::tooling::ArgumentInsertPosition::BEGIN));
48+
getPlatformClangBeginFlags(),
49+
clang::tooling::ArgumentInsertPosition::BEGIN));
50+
Tool.appendArgumentsAdjuster(clang::tooling::getInsertArgumentAdjuster(
51+
getPlatformClangEndFlags(), clang::tooling::ArgumentInsertPosition::END));
4752

4853
std::string rs_code;
4954
FrontendActionFactory factory(rs_code, model, rules_dir);

0 commit comments

Comments
 (0)