You can tokenize without a lexer, but the line/caret combo might actually be 
better. Nice work!


================
Comment at: lib/Basic/SourceLocation.cpp:70-71
@@ +69,4 @@
+  StringRef Buffer = SM.getBufferData(LocInfo.first);
+  int First = std::max<int>(Buffer.rfind('\n', LocInfo.second) + 1, 0);
+  int Last = std::min<int>(Buffer.find('\n', LocInfo.second), Buffer.size());
+  OS << "|" << Buffer.substr(First, Last - First) << "|\n" << IndentStr
----------------
Not super-happy about relying on the value of StringRef::npos here, but okay.

================
Comment at: lib/Basic/SourceLocation.cpp:73
@@ +72,3 @@
+  OS << "|" << Buffer.substr(First, Last - First) << "|\n" << IndentStr
+     << std::string(1 + LocInfo.second - First, ' ') << "^ ";
+}
----------------
This is all nice and inline, but it does make an extra temporary std::string. 
raw_ostream::indent instead?


http://llvm-reviews.chandlerc.com/D768
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to