Skip to content

Correct #line directive to cpp2 source file #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion source/cppfront.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class positional_printer
{
// Core information
std::ofstream out = {}; // Cpp1 syntax output file
std::string cpp2source = {};
std::string filename = {};
std::vector<comment> const* pcomments = {}; // Cpp2 comments data

Expand Down Expand Up @@ -235,7 +236,7 @@ class positional_printer

// Not using print() here because this is transparent to the curr_pos
if (!flag_clean_cpp1) {
out << "#line " << line << " " << std::quoted(filename + "2") << "\n";
out << "#line " << line << " " << std::quoted(cpp2source) << "\n";
}
}

Expand Down Expand Up @@ -324,12 +325,14 @@ class positional_printer
// Open
//
auto open(
std::string cpp2_filename,
std::string cpp1_filename,
std::vector<comment> const& comments
)
-> void
{
assert (!out.is_open() && !pcomments && "ICE: tried to call .open twice");
cpp2source = cpp2_filename;
filename = cpp1_filename;
out.open(filename);
pcomments = &comments;
Expand Down Expand Up @@ -721,6 +724,7 @@ class cppfront
cpp1_filename = flag_cpp1_filename; // use override if present
}
printer.open(
sourcefile,
cpp1_filename,
tokens.get_comments()
);
Expand Down