forked from qt-creator/qt-creator
Clang: Make SourceLocation lazily calculate its fields
Trigger path, line, column and offset evaluation only if one of them is accessed. Change-Id: Ib2f8b06ece94a3b7424db28523b5796628865202 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -101,6 +101,30 @@ TEST_F(SourceLocation, NotEqual)
|
||||
ASSERT_THAT(document.translationUnit().sourceLocationAt(3, 1), Not(sourceLocation));
|
||||
}
|
||||
|
||||
TEST_F(SourceLocation, BeforeMultibyteCharacter)
|
||||
{
|
||||
ClangBackEnd::SourceLocation sourceLocation(
|
||||
document.translationUnit().cxTranslationUnit(),
|
||||
clang_getLocation(document.translationUnit().cxTranslationUnit(),
|
||||
clang_getFile(document.translationUnit().cxTranslationUnit(),
|
||||
document.filePath().constData()),
|
||||
8, 10));
|
||||
|
||||
ASSERT_THAT(document.translationUnit().sourceLocationAt(8, 10).column(), sourceLocation.column());
|
||||
}
|
||||
|
||||
TEST_F(SourceLocation, AfterMultibyteCharacter)
|
||||
{
|
||||
ClangBackEnd::SourceLocation sourceLocation(
|
||||
document.translationUnit().cxTranslationUnit(),
|
||||
clang_getLocation(document.translationUnit().cxTranslationUnit(),
|
||||
clang_getFile(document.translationUnit().cxTranslationUnit(),
|
||||
document.filePath().constData()),
|
||||
8, 12));
|
||||
|
||||
ASSERT_THAT(document.translationUnit().sourceLocationAt(8, 13).column(), sourceLocation.column());
|
||||
}
|
||||
|
||||
std::unique_ptr<const Data> SourceLocation::data;
|
||||
|
||||
void SourceLocation::SetUpTestCase()
|
||||
|
||||
Reference in New Issue
Block a user