Commit Graph

20 Commits

Author SHA1 Message Date
Manuel Klimek 3f00134c05 Adds the Refactoring library, which is a layer on top of the Tooling library
that allows easy refactoring across translation units.

llvm-svn: 157331
2012-05-23 16:29:20 +00:00
Manuel Klimek 78d084d942 Adds a method overwriteChangedFiles to the Rewriter. This is implemented by
first writing the changed files to a temporary location and then overwriting
the original files atomically.

Also adds a RewriterTestContext to aid unit testing rewrting logic in general.

llvm-svn: 157260
2012-05-22 17:01:35 +00:00
Manuel Klimek 770691b153 Adds a unit test for the RecursiveASTVisitor.
llvm-svn: 155108
2012-04-19 08:48:53 +00:00
Manuel Klimek 47c245a537 Adds a tooling library.
Provides an API to run clang tools (FrontendActions) as standalone tools,
or repeatedly in-memory in a process. This is useful for unit-testing,
map-reduce style applications, source transformation daemons or command line
tools.

The ability to run over multiple translation units with different command
line arguments enables building up refactoring tools that need to apply
transformations across translation unit boundaries.

See tools/clang-check/ClangCheck.cpp for an example.

llvm-svn: 154008
2012-04-04 12:07:46 +00:00
Argyrios Kyrtzidis d169911cc0 Add unit testing for Lexer.
llvm-svn: 148478
2012-01-19 15:59:01 +00:00
Argyrios Kyrtzidis 2403797eec For SourceManager::isBeforeInTranslationUnit(), have it consider macro arg expanded
token locations as coming before the closing ')' of a function macro expansion.

Include a unit test for SourceManager.

llvm-svn: 147056
2011-12-21 16:56:29 +00:00
Richard Smith f6f003af6a C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit
argument to driver and frontend, to control the maximum number of notes so
produced (default 10). Fix APValue printing to be able to pretty-print all
APValue types, and move the testing for this functionality from a unittest to
a -verify test now that it's visible in clang's output.

llvm-svn: 146749
2011-12-16 19:06:07 +00:00
Jeffrey Yasskin d2af962eee Define DiagnosticBuilder<<APValue so it's easy to include APValues in
diagnostics.

llvm-svn: 135398
2011-07-18 16:43:53 +00:00
Manuel Klimek 8a160cc42b Reverts the Tooling changes as requested by Chris.
llvm-svn: 132462
2011-06-02 16:58:33 +00:00
Manuel Klimek 0cfc6a045c This patch implements an AST matching framework that allows to write
tools that match on the C++ ASTs. The main interface is in ASTMatchers.h,
an example implementation of a tool that removes redundant .c_str() calls
is in the example RemoveCStrCalls.cpp.

Various contributions:
Zhanyong Wan, Chandler Carruth, Marcin Kowalczyk, Wei Xu, James Dennett.

llvm-svn: 132374
2011-05-31 23:49:32 +00:00
Oscar Fuentes cfc9efa43e Handle gcc-compatible compilers (such as clang) the same way we handle
gcc.

Fixes PR9886.

llvm-svn: 131182
2011-05-11 13:53:30 +00:00
Manuel Klimek 6825eebcd6 This is the next step in building the standalone tools infrastructure:
This patch simplifies writing of standalone Clang tools. As an
example, we add clang-check, a tool that runs a syntax only frontend
action over a .cc file. When you integrate this into your favorite
editor, you get much faster feedback on your compilation errors, thus
reducing your feedback cycle especially when writing new code.

The tool depends on integration of an outstanding patch to CMake to
work which allows you to always have a current compile command
database in your cmake output directory when you set
CMAKE_EXPORT_COMPILE_COMMANDS.

llvm-svn: 130306
2011-04-27 16:39:14 +00:00
Manuel Klimek d861e8b7be Adds a function to run FrontendActions over in-memory code. This is
the first step towards a standalone Clang tool infrastructure.
The plan is to make it easy to build command line tools that run over
the AST of source files in a project outside of the build system.

llvm-svn: 129924
2011-04-21 18:37:41 +00:00
Oscar Fuentes 15fe190027 Put targets on folders, if the IDE supports the feature.
Requires CMake 2.8.3 or newer.

llvm-svn: 126094
2011-02-20 22:06:44 +00:00
Jeffrey Yasskin 39a5820059 Use PARSE_ARGUMENTS to clean up add_clang_unittest's calling convention.
It would be nice to propagate this into the other functions to replace
LLVM_LINK_COMPONENTS and friends, but I don't plan to do that.

llvm-svn: 126032
2011-02-19 18:06:01 +00:00
Jeffrey Yasskin ecdd68d760 Remove support and mc from the clang unittests' dependencies because they're not
needed or provided by the libraries under test.

The next step is to import http://www.itk.org/Wiki/CMakeMacroParseArguments to
make the empty string parameter unnecessary.

llvm-svn: 126024
2011-02-19 06:07:17 +00:00
Peter Collingbourne 14a552b2d7 Move CompilerInstance::LLVMContext and LLVMContext ownership to CodeGenAction
This removes the final dependency edge from any lib outside of CodeGen
to core.  As a result we can, and do, trim the dependency on core
from libclang, PrintFunctionNames, the unit tests and c-index-test.
While at it, review and trim other unneeded dependencies.

llvm-svn: 125820
2011-02-18 02:25:12 +00:00
Zhanyong Wan 5201b66530 Adds a CMake target for the Basic lib's unit tests. Reviewed by
jyasskin and chapuni.

llvm-svn: 125657
2011-02-16 05:45:20 +00:00
Zhanyong Wan f8a620f8e1 Improves CMakeLists.txt for Clang's unit tests: make "linked
components" and "used libs" arguments of add_clang_unittest().
Reviewed by jyasskin and chapuni.

llvm-svn: 125652
2011-02-16 05:19:17 +00:00
Jeffrey Yasskin cd3858b103 Add CMake support to the clang unittests.
llvm-svn: 125561
2011-02-15 07:54:28 +00:00