ioeric added inline comments. ================ Comment at: lib/Format/Format.cpp:1500 @@ +1499,3 @@ + // Get the first token. + Lex.LexFromRawLexer(Tok); + skipComments(Lex, Tok); ---------------- djasper wrote: > Can this go wrong? Maybe in an empty file? Added a test case for empty file.
If the code is empty, Tok will be `tok::eof`, which would leave `MinInsertionOffset` as `Code.size()`. But the program does fail when we insert at the end of code that does not end with '\n'. We always +1 when we calculate the offset for each line (in the for-loop on Lines); however, the last line does not necessarily end with '\n', which makes offset exceed code size. I will fix this in a follow-up patch. http://reviews.llvm.org/D20959 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits