PathV2: Fix a possible infinite loop.
[oota-llvm.git] / lib / Support / SourceMgr.cpp
index 5fa987bc3dfd36c611f21e8255b719189d229afe..e4e01be0380291848330485f04318340d4799ac3 100644 (file)
@@ -121,7 +121,7 @@ SourceMgr::getLineAndColumn(SMLoc Loc, int BufferID) const {
   Cache.LineNoOfQuery = LineNo;
   
   size_t NewlineOffs = StringRef(BufStart, Ptr-BufStart).find_last_of("\n\r");
-  if (NewlineOffs == StringRef::npos) NewlineOffs = ~0ULL;
+  if (NewlineOffs == StringRef::npos) NewlineOffs = ~(size_t)0;
   return std::make_pair(LineNo, Ptr-BufStart-NewlineOffs);
 }
 
@@ -243,8 +243,8 @@ SMDiagnostic::SMDiagnostic(const SourceMgr &sm, SMLoc L, const std::string &FN,
 
 void SMDiagnostic::print(const char *ProgName, raw_ostream &S,
                          bool ShowColors) const {
-  // Display colors only if OS goes to a tty.
-  ShowColors &= S.is_displayed();
+  // Display colors only if OS supports colors.
+  ShowColors &= S.has_colors();
 
   if (ShowColors)
     S.changeColor(raw_ostream::SAVEDCOLOR, true);
@@ -358,5 +358,3 @@ void SMDiagnostic::print(const char *ProgName, raw_ostream &S,
   
   S << '\n';
 }
-
-