summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-query/QuerySession.h
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2013-11-08 00:08:23 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2013-11-08 00:08:23 +0000
commit8b1265b353b027d90252f1a23c5c3121ee70f3a1 (patch)
tree4d104d38960d01338209c32d106c9b6a764976e7 /clang-tools-extra/clang-query/QuerySession.h
parent640830142100ea828ba54b42c68ccc4b3dd1d8ea (diff)
downloadbcm5719-llvm-8b1265b353b027d90252f1a23c5c3121ee70f3a1.tar.gz
bcm5719-llvm-8b1265b353b027d90252f1a23c5c3121ee70f3a1.zip
Introduce clang-query tool.
This tool is for interactive exploration of the Clang AST using AST matchers. It currently allows the user to enter a matcher at an interactive prompt and view the resulting bindings as diagnostics, AST pretty prints or AST dumps. Example session: $ cat foo.c void foo(void) {} $ clang-query foo.c -- clang-query> match functionDecl() Match #1: foo.c:1:1: note: "root" binds here void foo(void) {} ^~~~~~~~~~~~~~~~~ 1 match. Differential Revision: http://llvm-reviews.chandlerc.com/D2098 llvm-svn: 194227
Diffstat (limited to 'clang-tools-extra/clang-query/QuerySession.h')
-rw-r--r--clang-tools-extra/clang-query/QuerySession.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-query/QuerySession.h b/clang-tools-extra/clang-query/QuerySession.h
new file mode 100644
index 00000000000..002b2b56db5
--- /dev/null
+++ b/clang-tools-extra/clang-query/QuerySession.h
@@ -0,0 +1,36 @@
+//===--- QuerySession.h - clang-query ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "Query.h"
+
+namespace clang {
+
+class ASTUnit;
+
+namespace query {
+
+/// Represents the state for a particular clang-query session.
+class QuerySession {
+public:
+ QuerySession(llvm::ArrayRef<ASTUnit *> ASTs)
+ : ASTs(ASTs), OutKind(OK_Diag), BindRoot(true) {}
+
+ llvm::ArrayRef<ASTUnit *> ASTs;
+ OutputKind OutKind;
+ bool BindRoot;
+};
+
+} // namespace query
+} // namespace clang
+
+#endif
OpenPOWER on IntegriCloud