diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-05 22:21:40 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-05 22:21:40 +0000 |
commit | a4d36d5a58060229aa5288589601f149ea163536 (patch) | |
tree | 507e01e7aef989087456f5205e7ec25dcf997a25 /clang/tools/index-test/index-test.cpp | |
parent | 97e10d64e8ef43258456e83295719f3103e78f1e (diff) | |
download | bcm5719-llvm-a4d36d5a58060229aa5288589601f149ea163536.tar.gz bcm5719-llvm-a4d36d5a58060229aa5288589601f149ea163536.zip |
Make use of ASTNode for return value of clang::ResolveLocationInAST() and in the index-test tool.
llvm-svn: 74798
Diffstat (limited to 'clang/tools/index-test/index-test.cpp')
-rw-r--r-- | clang/tools/index-test/index-test.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/clang/tools/index-test/index-test.cpp b/clang/tools/index-test/index-test.cpp index 552b7b01498..0fa0d5a466f 100644 --- a/clang/tools/index-test/index-test.cpp +++ b/clang/tools/index-test/index-test.cpp @@ -28,6 +28,7 @@ #include "clang/Frontend/CommandLineSourceLoc.h" #include "clang/AST/Decl.h" #include "clang/AST/Stmt.h" +#include "clang/AST/ASTNode.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "llvm/ADT/STLExtras.h" @@ -77,13 +78,7 @@ int main(int argc, char **argv) { return 1; } - struct ASTPoint { - Decl *D; - Stmt *Node; - ASTPoint() : D(0), Node(0) {} - }; - - ASTPoint Point; + ASTNode Node; if (!PointAtLocation.empty()) { const std::string &Filename = PointAtLocation[0].FileName; @@ -114,30 +109,31 @@ int main(int argc, char **argv) { return 1; } - llvm::tie(Point.D, Point.Node) = - ResolveLocationInAST(AST->getASTContext(), Loc); - if (Point.D == 0) { + Node = ResolveLocationInAST(AST->getASTContext(), Loc); + if (Node.isInvalid()) { llvm::errs() << "[" << InFile << "] Error: " << "Couldn't resolve source location (no declaration found)\n"; return 1; } } - if (Point.D) { + if (Node.isValid()) { llvm::raw_ostream &OS = llvm::outs(); - OS << "Declaration node at point: " << Point.D->getDeclKindName() << " "; - if (NamedDecl *ND = dyn_cast<NamedDecl>(Point.D)) + OS << "Declaration node at point: " << Node.getDecl()->getDeclKindName() + << " "; + if (NamedDecl *ND = dyn_cast<NamedDecl>(Node.getDecl())) OS << ND->getNameAsString(); OS << "\n"; - if (const char *Comment = AST->getASTContext().getCommentForDecl(Point.D)) + if (const char *Comment = + AST->getASTContext().getCommentForDecl(Node.getDecl())) OS << "Comment associated with this declaration:\n" << Comment << "\n"; - if (Point.Node) { - OS << "Statement node at point: " << Point.Node->getStmtClassName() + if (Node.getStmt()) { + OS << "Statement node at point: " << Node.getStmt()->getStmtClassName() << " "; - Point.Node->printPretty(OS, AST->getASTContext(), 0, - PrintingPolicy(AST->getASTContext().getLangOptions())); + Node.getStmt()->printPretty(OS, AST->getASTContext(), 0, + PrintingPolicy(AST->getASTContext().getLangOptions())); OS << "\n"; } } |