Skip to content

Commit

Permalink
Add a quick readme to get people going. Add a todo file.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjessome committed Jan 13, 2014
1 parent e6468dd commit 407654e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Clang-Scope
===========
Clang-scope is a cross referencing tool intended to be a semantically aware
replacement for cscope.

Once a database is generated for a project, users can query for functions,
classes and their members, global variables, etc. by name.

If the sqlite database is used directly, lookup can also be done by clang USRs.
This comes in handy for guaranteeing that queries are on a specific identifier,
rather than loosely basing queries off of its name.

See the TODO file for a prioritized list of to-do items.

Compile Commands Database
=========================
Generating a clang-scope database requires a compile_commands.json database.
This database is generated at compile time, and contains information on how to
build each file in a project.
- If the project uses cmake, this file can be built by passing
-DCMAKE_EXPORT_COMPILE_COMMANDS to cmake.
- On linux, Bear (https://github.com/rizsotto/Bear) can also be used to
intercept compiler calls and create the compilation database.
For more information see http://clang.llvm.org/docs/JSONCompilationDatabase.html

Usage
=====
To generate the database, run clang-scope in a directory that contains the
compile_commands.json file. This will output a clscope.db file.

Querying is done using the '-q' option. This is to specify a scoped name,
Queries can be narrowed down with the following options:
Specify the reference type to search for (one of):
-d Declaration
-D Definition
-o Override (not yet implemented)
-u Use
Specify the identifier type (one of):
-e Enum
-f Function
-ns Namespace
-t Type
-td Typedef
-v Variable

A few example queries on the llvm/clang/clang-scope codebase:
- Find the definition of llvm::errs():
$ clang-scope -q llvm::errs -D -f
- List all uses of llvm::StringRef::lower():
$ clang-scope -q llvm::StringRef::lower -u
- List all places namespace clang is declared:
$ clang-scope -q clang -ns -d

See 'clang-scope -help' for full usage instructions.

Building
========
1. Clone clang-tools-extra into clang/tools.
git clone http://llvm.org/git/clang-tools-extra.git clang/tools/extra
2. Clone clang-scope into extra.
git clone https://github.com/mjessome/clang-scope clang/tools/extra/clang-scope
3. Add the following to clang/tools/extra/CMakeLists.txt.
add_subdirectory(clang-scope)
4. Go to your llvm build directory, and re-build.
5. The binary will be created in the build directory, at bin/clang-scope.
8 changes: 8 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* Clean up python query wrapper and release it. (Clean up only)
* Vim plugin. (Implemented, needs more testing)
* File dependency tree.
* Multi-threaded database generation.
* Database updates, rather than full re-generation on each run.
* Add each reference's text to database.
* Override listing.
* A nice query interface similar to cscope's.

0 comments on commit 407654e

Please sign in to comment.