From af685824de363b413fac21e6d815b8f7affb946f Mon Sep 17 00:00:00 2001 From: Yury Gribov Date: Thu, 28 Jan 2016 09:28:18 +0000 Subject: [PATCH] Fix isBeforeInTranslationUnit to not abort on macros defined in cmdline. 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 959d4d414a..416031d4ad 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -2110,6 +2110,14 @@ bool SourceManager::isBeforeInTranslationUnit(SourceLocation LHS, assert(LOffs.first == ROffs.first); return false; } + bool LIsScratch = strcmp("", LB) == 0; + bool RIsScratch = strcmp("", 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"); } -- 2.50.1