Skip to content

Commit 4a6e673

Browse files
committed
Stop emitting line directive
1 parent db71b07 commit 4a6e673

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎cpp2rust/rule_preprocessing/cpp_rule_indexer.cpp‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ void AddRule(llvm::json::Object &rules, std::string key,
236236
}
237237

238238
void IndexRuleFile(clang::ASTContext &ctx, const std::string &dir_name,
239-
const fs::path &src_path, llvm::json::Object &rules) {
239+
llvm::json::Object &rules) {
240240
bool is_c = !ctx.getLangOpts().CPlusPlus;
241241
auto &sm = ctx.getSourceManager();
242242
for (auto *decl : ctx.getTranslationUnitDecl()->decls()) {
@@ -269,9 +269,7 @@ void IndexRuleFile(clang::ASTContext &ctx, const std::string &dir_name,
269269
std::exit(EXIT_FAILURE);
270270
}
271271
auto range = clang::tooling::getExtendedRange(*decl, clang::tok::semi, ctx);
272-
auto text = std::format(
273-
"#line {} \"{}\"\n{}\n", sm.getSpellingLineNumber(range.getBegin()),
274-
src_path.string(), clang::tooling::getText(range, ctx).str());
272+
auto text = clang::tooling::getText(range, ctx).str() + '\n';
275273
llvm::json::Object rule{{"text", WrapRule(dir_name, is_c, name, text)}};
276274
if (!is_c) {
277275
rule["namespace"] = "cpp2rust_rules_" + dir_name;
@@ -306,7 +304,7 @@ void Index(const fs::path &src_path, bool is_c, const std::string &dir_name,
306304
llvm::errs() << "ERROR: cannot parse " << src_path.string() << '\n';
307305
std::exit(EXIT_FAILURE);
308306
}
309-
IndexRuleFile(ast->getASTContext(), dir_name, src_path, rules);
307+
IndexRuleFile(ast->getASTContext(), dir_name, rules);
310308
}
311309

312310
void WriteJson(const fs::path &path, llvm::json::Object object) {

0 commit comments

Comments
 (0)