Improve tracking of source position in the presence of /* */ comments.
Don't let the preprocessor remove comments anymore, so that the rules in lex.ll can handle them. Fix lCComment() to update the source position as it eats characters in comments.
This commit is contained in:
4
lex.ll
4
lex.ll
@@ -309,8 +309,10 @@ lParseBinary(const char *ptr, SourcePos pos, char **endPtr) {
|
||||
static void
|
||||
lCComment(SourcePos *pos) {
|
||||
char c, prev = 0;
|
||||
|
||||
|
||||
while ((c = yyinput()) != 0) {
|
||||
++pos->last_column;
|
||||
|
||||
if (c == '\n') {
|
||||
pos->last_line++;
|
||||
pos->last_column = 1;
|
||||
|
||||
@@ -1170,6 +1170,10 @@ Module::execPreprocessor(const char* infilename, llvm::raw_string_ostream* ostre
|
||||
inst.createSourceManager(inst.getFileManager());
|
||||
inst.InitializeSourceManager(infilename);
|
||||
|
||||
// Don't remove comments in the preprocessor, so that we can accurately
|
||||
// track the source file position by handling them ourselves.
|
||||
inst.getPreprocessorOutputOpts().ShowComments = 1;
|
||||
|
||||
clang::PreprocessorOptions &opts = inst.getPreprocessorOpts();
|
||||
|
||||
// Add defs for ISPC and PI
|
||||
|
||||
Reference in New Issue
Block a user