diff --git a/deps/llvm b/deps/llvm index 585bc0a4..74b7c749 160000 --- a/deps/llvm +++ b/deps/llvm @@ -1 +1 @@ -Subproject commit 585bc0a4669f41c898ccb65f63de8b3e2313c278 +Subproject commit 74b7c749705a62380a58746ead5f7a4cbff74fae diff --git a/src/Compiler/Selection.cpp b/src/Compiler/Selection.cpp index 198dd023..93baf213 100644 --- a/src/Compiler/Selection.cpp +++ b/src/Compiler/Selection.cpp @@ -83,15 +83,6 @@ public: // FIXME: currently we only consider fully nested case. // consider supporting partially nested case. - if(range.getBegin() < left->location() && range.getEnd() > rigth->location()) { - // if the source range of node contains the boundary tokens, its - // children may be selected. so traverse them recursively. - llvm::outs() << "select\n"; - stack.emplace(&storage.back()); - bool ret = callback(); - return ret; - } - // if the boundary tokens contain the source range of node, it means // the node is selected. store the father node and skip its children. if(left->location() <= range.getBegin() && rigth->location() >= range.getEnd()) { @@ -102,6 +93,15 @@ public: return true; } + if(range.getBegin() <= left->location() && range.getEnd() >= rigth->location()) { + // if the source range of node contains the boundary tokens, its + // children may be selected. so traverse them recursively. + llvm::outs() << "select\n"; + stack.emplace(&storage.back()); + bool ret = callback(); + return ret; + } + return true; } diff --git a/tests/AST/ASTVisitor.cpp b/tests/AST/ASTVisitor.cpp index e6f695fe..ef0f0958 100644 --- a/tests/AST/ASTVisitor.cpp +++ b/tests/AST/ASTVisitor.cpp @@ -23,6 +23,16 @@ struct Visitor : public clang::RecursiveASTVisitor { bool VisitVarDecl(clang::VarDecl* decl) { if(decl->getName() == "x") { decl->getType()->dump(); + decl->getType()->castAs()->getDeducedType().dump(); + + auto expr = llvm::dyn_cast(decl->getInit()); + auto unresolved = llvm::dyn_cast(expr->getCallee()); + + + for(auto decl: unresolved->decls()) { + llvm::outs() << "--------------------------\n"; + decl->dump(); + } } return true; diff --git a/tests/AST/Selection.cpp b/tests/AST/Selection.cpp index 8e6ad52e..9b9858d8 100644 --- a/tests/AST/Selection.cpp +++ b/tests/AST/Selection.cpp @@ -18,8 +18,8 @@ TEST(clice, SelectionTree) { auto AST = ParsedAST::build("main.cpp", content, compileArgs); auto id = AST->getFileID("main.cpp"); auto& sm = AST->context.getSourceManager(); - auto begin = sm.translateLineCol(id, 2, 6); - auto end = sm.translateLineCol(id, 2, 12); + auto begin = sm.translateLineCol(id, 7, 17); + auto end = sm.translateLineCol(id, 7, 17); SelectionTree tree(sm.getFileOffset(begin), sm.getFileOffset(end), AST->context, AST->tokenBuffer); }); } diff --git a/tests/Source/ASTVisitor/test.cpp b/tests/Source/ASTVisitor/test.cpp index b491d76d..07276c61 100644 --- a/tests/Source/ASTVisitor/test.cpp +++ b/tests/Source/ASTVisitor/test.cpp @@ -1,3 +1,6 @@ +template +void foo(U) {} + template int foo(T) {} diff --git a/tests/Source/SelectionTree/test.cpp b/tests/Source/SelectionTree/test.cpp index 5ae9c524..58af3e2f 100644 --- a/tests/Source/SelectionTree/test.cpp +++ b/tests/Source/SelectionTree/test.cpp @@ -1,3 +1,7 @@ -struct X { - int xxxxxxx; +namespace XX { +namespace YY { +int x; }; +}; // namespace XX + +int y = XX::YY::x;