diff options
author | Alex Lorenz <arphaman@gmail.com> | 2019-12-04 15:09:35 -0800 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2019-12-04 16:55:25 -0800 |
commit | c0ee0224c4cf52bc6ba74dec88b30b850deca523 (patch) | |
tree | faf44c4d276d1a59cb10d3382f0eadb56522ae32 /clang-tools-extra/clangd/unittests/SourceCodeTests.cpp | |
parent | acda2bc0adf62d9e54bf6d284f91e6cfa5b3cc6e (diff) | |
download | bcm5719-llvm-c0ee0224c4cf52bc6ba74dec88b30b850deca523.tar.gz bcm5719-llvm-c0ee0224c4cf52bc6ba74dec88b30b850deca523.zip |
[clangd] NFC, add getLangOpts helper to ParsedAST
The addition of the helper is split out from https://reviews.llvm.org/D69543
as suggested by Kadir. I also updated the existing uses to use the new API.
Diffstat (limited to 'clang-tools-extra/clangd/unittests/SourceCodeTests.cpp')
-rw-r--r-- | clang-tools-extra/clangd/unittests/SourceCodeTests.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp index 0dabce2a3d6..5979261600b 100644 --- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp +++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp @@ -358,7 +358,7 @@ Bar* bar; auto AST = TestTU::withCode(TestCase.code()).build(); const auto &SourceMgr = AST.getSourceManager(); SourceLocation Actual = getBeginningOfIdentifier( - TestCase.points().back(), SourceMgr, AST.getASTContext().getLangOpts()); + TestCase.points().back(), SourceMgr, AST.getLangOpts()); Position ActualPos = offsetToPosition( TestCase.code(), SourceMgr.getFileOffset(SourceMgr.getSpellingLoc(Actual))); @@ -482,7 +482,7 @@ TEST(SourceCodeTests, GetMacros) { TestTU TU = TestTU::withCode(Code.code()); auto AST = TU.build(); auto Loc = getBeginningOfIdentifier(Code.point(), AST.getSourceManager(), - AST.getASTContext().getLangOpts()); + AST.getLangOpts()); auto Result = locateMacroAt(Loc, AST.getPreprocessor()); ASSERT_TRUE(Result); EXPECT_THAT(*Result, MacroName("MACRO")); @@ -548,7 +548,7 @@ TEST(SourceCodeTests, HalfOpenFileRange) { ParsedAST AST = TestTU::withCode(Test.code()).build(); llvm::errs() << Test.code(); const SourceManager &SM = AST.getSourceManager(); - const LangOptions &LangOpts = AST.getASTContext().getLangOpts(); + const LangOptions &LangOpts = AST.getLangOpts(); // Turn a SourceLocation into a pair of positions auto SourceRangeToRange = [&SM](SourceRange SrcRange) { return Range{sourceLocToPosition(SM, SrcRange.getBegin()), @@ -588,8 +588,7 @@ TEST(SourceCodeTests, HalfOpenFileRangePathologicalPreprocessor) { const auto &Body = cast<CompoundStmt>(Func.getBody()); const auto &Loop = cast<WhileStmt>(*Body->child_begin()); llvm::Optional<SourceRange> Range = toHalfOpenFileRange( - AST.getSourceManager(), AST.getASTContext().getLangOpts(), - Loop->getSourceRange()); + AST.getSourceManager(), AST.getLangOpts(), Loop->getSourceRange()); ASSERT_TRUE(Range) << "Failed to get file range"; EXPECT_EQ(AST.getSourceManager().getFileOffset(Range->getBegin()), Test.llvm::Annotations::range().Begin); |