SourceManager::translateLineCol works fine on Linux, asserts on Windows


I am trying to solve a problem seems to be Windows only. Here is the code that works on Linux, but asserts on Windows:

SourceLocation s = sm.translateLineCol(sm.getMainFileID(), line, 1);
rewriter.InsertTextBefore(s, repl);

The debug version on Windows shows this:

Assertion failed: Index < LoadedSLocEntryTable.size() && “Invalid index”, file llvm_clang\v3.5\src\tools\clang\include\clang/Basic/SourceManager.h, line 1487

Just wondering if anyone happens to know anything.

I will report back when I get a clue