Skip to content

Commit

Permalink
Fix handling of include prefix
Browse files Browse the repository at this point in the history
Summary:
D47195241 changed the order of processing includes breaking one corner case. Fix this by always setting the include prefix if it is not empty.

The whole include prefix manipulation is a mess and we should get rid of it but this is a much bigger change. This is a quick fix that restores the old behavior and unbreaks at least one target.

Reviewed By: iahs

Differential Revision: D47340496

fbshipit-source-id: 03a26d1e4bd65ef113364d6e511baace4ff2ce75
  • Loading branch information
vitaut authored and facebook-github-bot committed Jul 10, 2023
1 parent ea5950d commit 1adea38
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions thrift/compiler/parse/parse_ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1113,17 +1113,17 @@ std::unique_ptr<t_program_bundle> parse_ast(
program = included_program.get();
programs->add_program(std::move(included_program));
program_cache[include_path] = program;

std::string include_prefix;
auto last_slash = include_name.find_last_of("/\\");
if (last_slash != std::string::npos) {
include_prefix = include_name.substr(0, last_slash);
}
program->set_include_prefix(include_prefix);
} else {
program = it->second;
}

std::string include_prefix;
auto last_slash = include_name.find_last_of("/\\");
if (last_slash != std::string::npos) {
include_prefix = include_name.substr(0, last_slash);
program->set_include_prefix(include_prefix);
}

// Skip already parsed files.
if (!parsed_paths.insert(include_path).second) {
return program;
Expand Down

0 comments on commit 1adea38

Please sign in to comment.