This patch fixes assert "Unsortable locations found" when calling
PathDiagnosticLocation(SM.getSpellingLoc(E->getLocStart()), SM);
on an expression which comes from cmdline (i.e. macro defined with -D). Such expressions come from a special scratch buffer and thus trigger assert when passed to isBeforeInTranslationUnit.
Unfortunately this only reproduces on a local branch so I can not provide a minimal testcase. I hope the fix is self-evident though.