diff --git a/lex.ll b/lex.ll index 9797e4e5..e5e395c3 100644 --- a/lex.ll +++ b/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; diff --git a/module.cpp b/module.cpp index 3881ae2b..6bd79332 100644 --- a/module.cpp +++ b/module.cpp @@ -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