Index: cfe/trunk/tools/libclang/CIndex.cpp =================================================================== --- cfe/trunk/tools/libclang/CIndex.cpp +++ cfe/trunk/tools/libclang/CIndex.cpp @@ -1025,8 +1025,9 @@ [&SM](Decl *A, Decl *B) { SourceLocation L_A = A->getLocStart(); SourceLocation L_B = B->getLocStart(); - assert(L_A.isValid() && L_B.isValid()); - return SM.isBeforeInTranslationUnit(L_A, L_B); + return L_A != L_B ? + SM.isBeforeInTranslationUnit(L_A, L_B) : + SM.isBeforeInTranslationUnit(A->getLocEnd(), B->getLocEnd()); }); // Now visit the decls.