Fix #684: Keep line directives in tokenized output by glankk · Pull Request #685 · cppcheck-opensource/simplecpp · GitHub
Skip to content
Closed
Show file tree
Hide file tree
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
43 changes: 17 additions & 26 deletions simplecpp.cpp
5 changes: 3 additions & 2 deletions simplecpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ namespace simplecpp {
}

Token(const Token &tok) :
macro(tok.macro), op(tok.op), comment(tok.comment), name(tok.name), number(tok.number), whitespaceahead(tok.whitespaceahead), location(tok.location), string(tok.string), mExpandedFrom(tok.mExpandedFrom) {}
macro(tok.macro), op(tok.op), comment(tok.comment), name(tok.name), number(tok.number), whitespaceahead(tok.whitespaceahead), locationchange(tok.locationchange), location(tok.location), string(tok.string), mExpandedFrom(tok.mExpandedFrom) {}

Token &operator=(const Token &tok) = delete;

Expand All @@ -182,6 +182,8 @@ namespace simplecpp {
bool name;
bool number;
bool whitespaceahead;
/** whether token location is at a discontinuity from a #line directive */
bool locationchange {false};
Location location;
Token *previous{};
Token *next{};
Expand Down Expand Up @@ -396,7 +398,6 @@ namespace simplecpp {
void constFoldQuestionOp(Token *&tok1);

std::string readUntil(Stream &stream, const Location &location, char start, char end, OutputList *outputList);
void lineDirective(unsigned int fileIndex_, unsigned int line, Location &location);

const Token* lastLineTok(int maxsize=1000) const;
const Token* isLastLinePreprocessor(int maxsize=1000) const;
Expand Down
59 changes: 59 additions & 0 deletions test.cpp
Loading