From 7bd56c9b98096cb8996ff9c15828be11bfd84628 Mon Sep 17 00:00:00 2001 From: triton Date: Fri, 9 Aug 2013 01:58:35 +0100 Subject: [PATCH] Do not try to handle preprocessed entities for invalid locations. --- src/Parser/Parser.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index 214f420f..cfdca5f4 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -1752,6 +1752,17 @@ void Parser::HandlePreprocessedEntities(CppSharp::AST::Declaration^ Decl, clang::SourceRange sourceRange, CppSharp::AST::MacroLocation macroLocation) { + if (sourceRange.isInvalid()) return; + + auto& SourceMgr = C->getSourceManager(); + auto isBefore = SourceMgr.isBeforeInTranslationUnit(sourceRange.getEnd(), + sourceRange.getBegin()); + + if (isBefore) return; + + assert(!SourceMgr.isBeforeInTranslationUnit(sourceRange.getEnd(), + sourceRange.getBegin())); + using namespace clang; auto PPRecord = C->getPreprocessor().getPreprocessingRecord();