aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/CrossTU
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2019-07-18 15:43:26 +0000
committerIlya Biryukov <ibiryukov@google.com>2019-07-18 15:43:26 +0000
commitabc744d2631fd8467c342a05c7c3bc83ad9de54f (patch)
treef9909c5273e5abebd7c5e46b63ed2b1c9c23fffa /clang/unittests/CrossTU
parent6acdf83cfa57503e1202bc5b5e5582c6c9cdacfa (diff)
downloadllvm-abc744d2631fd8467c342a05c7c3bc83ad9de54f.zip
llvm-abc744d2631fd8467c342a05c7c3bc83ad9de54f.tar.gz
llvm-abc744d2631fd8467c342a05c7c3bc83ad9de54f.tar.bz2
Revert r366449: [CrossTU] Add a function to retrieve original source location.
Reason: the commit breaks layering by adding a dependency on ASTUnit (which is inside clangFrontend) from the ASTImporter (which is inside clangAST). llvm-svn: 366453
Diffstat (limited to 'clang/unittests/CrossTU')
-rw-r--r--clang/unittests/CrossTU/CrossTranslationUnitTest.cpp39
1 files changed, 6 insertions, 33 deletions
diff --git a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
index b4f22d5..b3e7243 100644
--- a/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ b/clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -28,18 +28,13 @@ public:
: CTU(CI), Success(Success) {}
void HandleTranslationUnit(ASTContext &Ctx) {
- auto FindFInTU = [](const TranslationUnitDecl *TU) {
- const FunctionDecl *FD = nullptr;
- for (const Decl *D : TU->decls()) {
- FD = dyn_cast<FunctionDecl>(D);
- if (FD && FD->getName() == "f")
- break;
- }
- return FD;
- };
-
const TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl();
- const FunctionDecl *FD = FindFInTU(TU);
+ const FunctionDecl *FD = nullptr;
+ for (const Decl *D : TU->decls()) {
+ FD = dyn_cast<FunctionDecl>(D);
+ if (FD && FD->getName() == "f")
+ break;
+ }
assert(FD && FD->getName() == "f");
bool OrigFDHasBody = FD->hasBody();
@@ -83,28 +78,6 @@ public:
if (NewFDorError) {
const FunctionDecl *NewFD = *NewFDorError;
*Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
-
- if (NewFD) {
- // Check GetImportedFromSourceLocation.
- llvm::Optional<std::pair<SourceLocation, ASTUnit *>> SLocResult =
- CTU.getImportedFromSourceLocation(NewFD->getLocation());
- EXPECT_TRUE(SLocResult);
- if (SLocResult) {
- SourceLocation OrigSLoc = (*SLocResult).first;
- ASTUnit *OrigUnit = (*SLocResult).second;
- // OrigUnit is created internally by CTU (is not the
- // ASTWithDefinition).
- TranslationUnitDecl *OrigTU =
- OrigUnit->getASTContext().getTranslationUnitDecl();
- const FunctionDecl *FDWithDefinition = FindFInTU(OrigTU);
- EXPECT_TRUE(FDWithDefinition);
- if (FDWithDefinition) {
- EXPECT_EQ(FDWithDefinition->getName(), "f");
- EXPECT_TRUE(FDWithDefinition->isThisDeclarationADefinition());
- EXPECT_EQ(OrigSLoc, FDWithDefinition->getLocation());
- }
- }
- }
}
}