From: Yury Gribov Date: Thu, 28 Jan 2016 09:28:18 +0000 (+0000) Subject: Fix isBeforeInTranslationUnit to not abort on macros defined in cmdline. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=af685824de363b413fac21e6d815b8f7affb946f;p=clang 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 --- 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"); }