]> granicus.if.org Git - clang/commitdiff
Fix isBeforeInTranslationUnit to not abort on macros defined in cmdline.
authorYury Gribov <y.gribov@samsung.com>
Thu, 28 Jan 2016 09:28:18 +0000 (09:28 +0000)
committerYury Gribov <y.gribov@samsung.com>
Thu, 28 Jan 2016 09:28:18 +0000 (09:28 +0000)
Differential Revision: http://reviews.llvm.org/D15804

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259031 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp

index 959d4d414a660529abcd4b23f63890b50e53c935..416031d4adb7707e540d990924ddc09a50a794a7 100644 (file)
@@ -2110,6 +2110,14 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS,
     assert(LOffs.first == ROffs.first);
     return false;
   }
+  bool LIsScratch = strcmp("<scratch space>", LB) == 0;
+  bool RIsScratch = strcmp("<scratch space>", RB) == 0;
+  // Sort scratch after inline asm, but before the rest.
+  if (LIsScratch || RIsScratch) {
+    if (LIsScratch != RIsScratch)
+      return LIsScratch;
+    return LOffs.second < ROffs.second;
+  }
   llvm_unreachable("Unsortable locations found");
 }