forked from OSchip/llvm-project
a37734f643
Summary: When importing the main FileID the ASTImporter currently gives it no include location. This means that any SourceLocations produced for this FileID look to Clang as if they are coming from the main FileID (as the main FileID has no include location). Clang seems to expect that there is only one main FileID in one translation unit (which makes sense during normal compilation), so this behavior leads to several problems when producing diagnostics, one being that when calling `SourceManager::isBeforeInTranslationUnit` on two SourceLocations that come from two different ASTContext instances, Clang fails to sort the SourceLocations as the include chains of the FileIDs don't end up in a single FileID. This causes that Clang crashes with "Unsortable locations found" in this function. This patch gives any imported main FileIDs the main FileID of the To ASTContext as its include location. This allows Clang to sort all imported SourceLocations as now all include chains point to the main FileID of the To ASTContext. The exact include location is currently set to the start of the To main file (just because that should always be a valid SourceLocation). Reviewers: martong, a_sidorin, a.sidorin, shafik, balazske Reviewed By: martong, a_sidorin, shafik Subscribers: balazske, rnkovacs, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74542 |
||
---|---|---|
.. | ||
ASTContextParentMapTest.cpp | ||
ASTImporterFixtures.cpp | ||
ASTImporterFixtures.h | ||
ASTImporterGenericRedeclTest.cpp | ||
ASTImporterODRStrategiesTest.cpp | ||
ASTImporterTest.cpp | ||
ASTImporterVisibilityTest.cpp | ||
ASTPrint.h | ||
ASTTraverserTest.cpp | ||
ASTTypeTraitsTest.cpp | ||
ASTVectorTest.cpp | ||
CMakeLists.txt | ||
CommentLexer.cpp | ||
CommentParser.cpp | ||
CommentTextTest.cpp | ||
DataCollectionTest.cpp | ||
DeclMatcher.h | ||
DeclPrinterTest.cpp | ||
DeclTest.cpp | ||
EvaluateAsRValueTest.cpp | ||
ExternalASTSourceTest.cpp | ||
Language.cpp | ||
Language.h | ||
MatchVerifier.h | ||
NamedDeclPrinterTest.cpp | ||
OMPStructuredBlockTest.cpp | ||
RecursiveASTVisitorTest.cpp | ||
SourceLocationTest.cpp | ||
StmtPrinterTest.cpp | ||
StructuralEquivalenceTest.cpp |