Avoid printing a spurious semicolon when there is no filename.
authorDan Gohman <gohman@apple.com>
Thu, 21 Jan 2010 10:13:27 +0000 (10:13 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 21 Jan 2010 10:13:27 +0000 (10:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94071 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/SourceMgr.cpp

index 7dd42f4df8f76d272c090ceb6686ca50a2ba97a4..bdc637a4a3756a7f3dfd3348bf5fbddc7a72a02d 100644 (file)
@@ -192,18 +192,21 @@ void SMDiagnostic::Print(const char *ProgName, raw_ostream &S) {
   if (ProgName && ProgName[0])
     S << ProgName << ": ";
 
-  if (Filename == "-")
-    S << "<stdin>";
-  else
-    S << Filename;
+  if (!Filename.empty()) {
+    if (Filename == "-")
+      S << "<stdin>";
+    else
+      S << Filename;
   
-  if (LineNo != -1) {
-    S << ':' << LineNo;
-    if (ColumnNo != -1)
-      S << ':' << (ColumnNo+1);
+    if (LineNo != -1) {
+      S << ':' << LineNo;
+      if (ColumnNo != -1)
+        S << ':' << (ColumnNo+1);
+    }
+    S << ": ";
   }
   
-  S << ": " << Message << '\n';
+  S << Message << '\n';
 
   if (LineNo != -1 && ColumnNo != -1 && ShowLine) {
     S << LineContents << '\n';