Commit Graph

144 Commits

Author SHA1 Message Date
Jordy Rose ae55cf2f90 Don't use BuiltinBug in analyzer plugin example.
llvm-svn: 137811
2011-08-17 03:23:51 +00:00
Jordy Rose 93b86e494d [analyzer] Add basic support for pluggable checkers.
llvm-svn: 137802
2011-08-17 01:30:59 +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 9978c4f730 Fixes Makefile based build for examples/Tooling.
llvm-svn: 132380
2011-06-01 01:21:01 +00:00
Nick Lewycky 15cf577ff9 Put Parse before Sema on the link line since parse depends on sema.
Also reflow these lines to fit in 80-col.

llvm-svn: 132379
2011-06-01 00:59:36 +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
Zhongxing Xu e6a2028fe1 Fix linking of clang-wpa.
llvm-svn: 132329
2011-05-31 07:13:36 +00:00
Manuel Klimek b66b5cef00 Fix examples compile break due to rewrite of isa.
llvm-svn: 131912
2011-05-23 18:25:41 +00:00
Manuel Klimek c9675152b3 Pulls the common part of the clang-check example into Tooling, to allow new tools to be implemented without duplicating the boilerplate.
llvm-svn: 131425
2011-05-16 21:33:46 +00:00
Nico Weber 1eace078a4 Let clang-check actually use the Directory entry in the json file.
llvm-svn: 131367
2011-05-14 21:20:23 +00:00
Manuel Klimek ffecc6b9c2 Fixes compilation with Visual Studio by replacing the non-standard vector::data() access.
llvm-svn: 131116
2011-05-10 00:58:12 +00:00
Nico Weber 1f41ab05f5 Fix gcc 'warning: multi-line comment'.
llvm-svn: 130583
2011-04-30 03:13:21 +00:00
Nico Weber 1bb8e09c37 Add a Makefile to examples/Tooling for people who do not use cmake.
llvm-svn: 130577
2011-04-30 03:03:12 +00:00
Nico Weber 347339f790 Fix Makefile build of examples/clang-interpreter.
llvm-svn: 130576
2011-04-30 02:52:27 +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
John Thompson f71173043f Fixed build error.
llvm-svn: 128470
2011-03-29 18:31:21 +00:00
Argyrios Kyrtzidis 99ea46462a [analyzer] Add LangOptions in CheckerManager.
llvm-svn: 126306
2011-02-23 07:19:14 +00:00
Peter Collingbourne 8f5cf74c77 Re-instate r125819 and r125820 with no functionality change
llvm-svn: 126060
2011-02-19 23:03:58 +00:00
Rafael Espindola a6d2bff0c5 Revert 125820 and 125819 to fix PR9266.
llvm-svn: 126050
2011-02-19 21:39:31 +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
Argyrios Kyrtzidis 6fa0d20a6f Fix the clang-wpa example.
llvm-svn: 125565
2011-02-15 16:54:12 +00:00
Argyrios Kyrtzidis ecd3334dac [analyzer] Introduce libclangStaticAnalyzerFrontend and move Checkers/AnalysisConsumer.cpp into Frontend lib.
llvm-svn: 125499
2011-02-14 18:13:01 +00:00
NAKAMURA Takumi 98dd73d66c CMake: LLVM_NO_RTTI must be obsolete now!
llvm-svn: 125275
2011-02-10 09:15:32 +00:00
Ted Kremenek f8cbac4b91 Split 'include/clang/StaticAnalyzer' into 'include/clang/StaticAnalyzer/Core' and 'include/clang/StaticAnalyzer/Checkers'.
This layout matches lib/StaticAnalyzer, which corresponds to two StaticAnalyzer libraries.

llvm-svn: 125251
2011-02-10 01:03:03 +00:00
Ted Kremenek 0bc2855aa9 Update clang-wpa to pass extra argument to AnalysisManager constructor.
llvm-svn: 125235
2011-02-09 22:59:20 +00:00
Nico Weber 60cd00b2cc make `make` work in examples/PrintFucntionNames on Mac. I checked that it still works on Linux.
llvm-svn: 124325
2011-01-26 21:28:52 +00:00
Nick Lewycky 0c49533039 Fix name to match reality.
llvm-svn: 123813
2011-01-19 05:59:39 +00:00
Ted Kremenek b4384fb0df Get clang-wpa to build in TOT (reflecting updates
to the static analyzer).

llvm-svn: 123727
2011-01-18 04:22:19 +00:00
Ted Kremenek d99bd55a5e Chris Lattner has strong opinions about directory
layout.  :)

Rename the 'EntoSA' directories to 'StaticAnalyzer'.

Internally we will still use the 'ento' namespace
for the analyzer engine (unless there are further
sabre rattlings...).

llvm-svn: 122514
2010-12-23 19:38:26 +00:00
Ted Kremenek ef33f0996c Rename headers: 'clang/GR' 'clang/EntoSA' and
update Makefile.

llvm-svn: 122493
2010-12-23 07:22:02 +00:00
Argyrios Kyrtzidis 1696f508e2 [analyzer] Refactoring: Drop the 'GR' prefix.
llvm-svn: 122424
2010-12-22 18:53:44 +00:00
Argyrios Kyrtzidis a700e976b6 [analyzer] Refactoring: Move checkers into lib/GR/Checkers and their own library, libclangGRCheckers
llvm-svn: 122422
2010-12-22 18:52:56 +00:00
Argyrios Kyrtzidis 2ff5ab1516 [analyzer] Refactoring: lib/Checker -> lib/GR and libclangChecker -> libclangGRCore
llvm-svn: 122421
2010-12-22 18:52:29 +00:00
Argyrios Kyrtzidis 8d602a8aa8 [analyzer] Refactoring: include/clang/Checker -> include/clang/GR
llvm-svn: 122420
2010-12-22 18:51:49 +00:00
Michael J. Spencer 8aaf49959c Merge System into Support.
llvm-svn: 120297
2010-11-29 18:12:39 +00:00
Eli Friedman 9e7baae0c6 Unbreak clang-interpreter. (Should there be some automated testing for this?)
llvm-svn: 120069
2010-11-24 00:32:51 +00:00
Dan Gohman ff66a7c66d Add a comment explaining why r117813 was needed.
llvm-svn: 119518
2010-11-17 17:23:53 +00:00
Benjamin Kramer 4ab36ba726 Turns out that we may end up calling dladdr on GetExecutablePath, give it external linkage to make sure the lookup works on all platforms.
llvm-svn: 117813
2010-10-30 17:32:40 +00:00
Dan Gohman ba76802ed4 These functions don't need external linkage.
llvm-svn: 117733
2010-10-29 22:41:35 +00:00
Tom Care c88ed9561e Rename 'MaxLoop' to 'MaxVisit' in AnalysisManager to more correctly reflect that we aborted analysis may not necessarily be due to a loop.
llvm-svn: 113862
2010-09-14 21:35:27 +00:00
Michael J. Spencer 433e9c7f2a PrintFunctionNames: Fix Windows (MSV{S,C} and mingw) build.
llvm-svn: 113835
2010-09-14 06:39:35 +00:00
Michael J. Spencer 09476212de Revert "CMake: Update to use standard CMake dependency tracking facilities instead"
This reverts commit r113631

Conflicts:

	CMakeLists.txt
	lib/CodeGen/CMakeLists.txt

llvm-svn: 113817
2010-09-13 23:54:41 +00:00
Michael J. Spencer 0881f4a367 CMake: Update to use standard CMake dependency tracking facilities instead
of whatever we were using before...

llvm-svn: 113631
2010-09-10 21:13:16 +00:00
Benjamin Kramer ead810e42b clang-interpreter: libFrontend depends on libSerialization. Fix linux build by changing the link order.
llvm-svn: 112187
2010-08-26 15:21:38 +00:00
Benjamin Kramer 1921fac97e Update clang-interpreter for recent DiagnosticClient ownership changes.
llvm-svn: 112181
2010-08-26 13:48:56 +00:00
Zhongxing Xu 9f077cbc13 Add back clang-wpa. It is useful for experimenting with inter-file analysis.
llvm-svn: 112014
2010-08-25 01:15:20 +00:00
Peter Collingbourne 8e65aeea5e Add Serialization dependency to clang-interpreter
llvm-svn: 111874
2010-08-24 00:31:31 +00:00
Daniel Dunbar 468f5cb8ea Remove wpa 'example', it isn't being maintained.
llvm-svn: 110809
2010-08-11 15:21:41 +00:00
Daniel Dunbar 2be96746b4 Frontend: Change PluginASTAction::ParseArgs to take a CompilerInstance object
for use in reporting diagnostics.
 - We don't want to use the Action's own CompilerInstance, because that is only
   initialized during file processing and I like that invariant.

Also, if ParseArgs returns false then abandon execution.

Also, remove unused PluginASTAction::PrintHelp virtual method.

llvm-svn: 110039
2010-08-02 15:31:28 +00:00
Dan Gohman a8b949883e Make a variable static.
llvm-svn: 109438
2010-07-26 21:12:29 +00:00
Dan Gohman c0539d2eb6 Use an export file. Plugins must export llvm::Registry symbols.
Also, don't link in all the clang libraries statically.

llvm-svn: 109436
2010-07-26 21:12:10 +00:00
Peter Collingbourne 5a75e1ae07 Fix clang-interpreter build
llvm-svn: 109347
2010-07-24 17:59:51 +00:00
Zhongxing Xu adf644d05e Make a bunch of new data structures for the new analysis
engine of the new translation unit. State marshal is there but no real
work is done. End nodes are passed back.

llvm-svn: 109105
2010-07-22 13:52:13 +00:00
Zhongxing Xu 84f65e0692 Reapply r108617.
llvm-svn: 108668
2010-07-19 01:31:21 +00:00
Benjamin Kramer e2e031ed6f Revert r108617, it broke the build.
llvm-svn: 108621
2010-07-17 13:51:58 +00:00
Zhongxing Xu 4ca4a999b1 Prepare the analyzer for the callee in another translation unit:
Let AnalysisContext contain a TranslationUnit.
  Let CallEnter refer to an AnalysisContext instead of a FunctionDecl.

llvm-svn: 108617
2010-07-17 11:12:42 +00:00
Nick Lewycky d54e2aba6c PrintFunctionNames is a plugin, it should pull in symbols from the clang binary
that loads it, not by linking against them directly.

llvm-svn: 108055
2010-07-10 20:24:23 +00:00
Peter Collingbourne 9701743b1a Fix CMake build
llvm-svn: 108031
2010-07-09 23:06:34 +00:00
Zhongxing Xu 2231a920d0 Add skeleton code to make wpa call the analysis engine.
llvm-svn: 107646
2010-07-06 09:18:02 +00:00
Zhongxing Xu b525bce698 Collect function definitions in the Indexer when indexing through the ASTs.
Add an API to get an Entity associated with a name in the global namespace.

llvm-svn: 107642
2010-07-06 05:55:13 +00:00
Zhongxing Xu d6c221c3ee Create a ASTUnitTU class to interface ASTUnit to the Indexer.
llvm-svn: 107467
2010-07-02 11:52:15 +00:00
Zhongxing Xu a94ec74c6f add -analyze-function option.
llvm-svn: 107463
2010-07-02 07:03:03 +00:00
Zhongxing Xu 7842c0836d add -view-call-graph option to wpa.
llvm-svn: 107462
2010-07-02 06:58:30 +00:00
Zhongxing Xu a74c22daec Change CallGraph::Prog to be a reference. idx::Program means to be a global object to the Index library.
llvm-svn: 107461
2010-07-02 06:39:46 +00:00
Daniel Dunbar 7c995e8fac Frontend: Allow passing -cc1 level arguments to plugins. Patch by Troy Straszheim!
llvm-svn: 106113
2010-06-16 16:59:23 +00:00
Daniel Dunbar c1b1729b66 Break Frontend's dependency on Rewrite, Checker and CodeGen in shared library configuration
Currently, all AST consumers are located in the Frontend library,
meaning that in a shared library configuration, Frontend has a
dependency on Rewrite, Checker and CodeGen.  This is suboptimal for
clients which only wish to make use of the frontend.  CodeGen in
particular introduces a large number of unwanted dependencies.

This patch breaks the dependency by moving all AST consumers with
dependencies on Rewrite, Checker and/or CodeGen to their respective
libraries.  The patch therefore introduces dependencies in the other
direction (i.e. from Rewrite, Checker and CodeGen to Frontend).

After applying this patch, Clang builds correctly using CMake and
shared libraries ("cmake -DBUILD_SHARED_LIBS=ON").

N.B. This patch includes file renames which are indicated in the
patch body.

Changes in this revision of the patch:
 - Fixed some copy-paste mistakes in the header files
 - Modified certain aspects of the coding to comply with the LLVM
   Coding Standards

llvm-svn: 106010
2010-06-15 17:48:49 +00:00
Daniel Dunbar d04e1a7ef1 Makefiles: Remove unnecessary early include of Makefile.config.
llvm-svn: 105640
2010-06-08 20:57:22 +00:00
Daniel Dunbar ee6b692551 Makefiles: Set Clang CPP compiler flags in a single location, instead of scattered throughout the project Makefiles.
llvm-svn: 105638
2010-06-08 20:44:43 +00:00
Daniel Dunbar e6c1daa8fd Makefile: Switch Clang Makefiles to always include the top-level Clang Makefile.
- This eliminates most dependencies on how Clang is installed relative to LLVM.

llvm-svn: 105637
2010-06-08 20:34:18 +00:00
Douglas Gregor 61b5ff5ab4 Teach the PrintFunctionNames example to be a proper module, so that
Clang can load it as a plugin. Original fix by Troy D. Straszheim,
which I extended with Darwin support. Fixes PR6801.

llvm-svn: 105630
2010-06-08 19:23:49 +00:00
Daniel Dunbar 6311731341 Update LINK_COMPONENTS for examples.
llvm-svn: 105607
2010-06-08 15:38:01 +00:00
Benjamin Kramer 6a2542b629 Tip of the day: save before commit.
llvm-svn: 101896
2010-04-20 11:55:38 +00:00
Benjamin Kramer 25d3d782d2 Fix -Wcast-qual warnings.
llvm-svn: 101895
2010-04-20 11:50:39 +00:00
Douglas Gregor 6314641822 clang-wpa fixes for Diagnostic
llvm-svn: 100518
2010-04-06 04:03:12 +00:00
Douglas Gregor ff8f4f6262 Unbreak build
llvm-svn: 100514
2010-04-06 01:25:58 +00:00
Douglas Gregor 01fa5c3734 Grrrr
llvm-svn: 100476
2010-04-05 21:47:48 +00:00
Douglas Gregor 0228a9c76b Try to de-bork build of WPA
llvm-svn: 100475
2010-04-05 21:47:24 +00:00
Daniel Dunbar e43887bd2b Driver: Add support for a CLANGXX_IS_PRODUCTION build variable, which enable
Clang++ support, even in "Production" mode (for testing purposes).

llvm-svn: 100119
2010-04-01 18:21:41 +00:00
Kovarththanan Rajaratnam 9a3f55c2a4 Wire up Daniel's new spiffy C interpreter into the CMake build system
llvm-svn: 97311
2010-02-27 07:46:49 +00:00
Kovarththanan Rajaratnam 7cfffceec7 Add comment
llvm-svn: 97309
2010-02-27 07:06:44 +00:00
Kovarththanan Rajaratnam fa0a4bcb55 Add header + comments
llvm-svn: 97308
2010-02-27 07:05:56 +00:00
Daniel Dunbar 0076d94466 Add a minimal C interpreter example.
- Demonstrates how to build a standalone tool which loads source code using the
   Driver and Frontend libraries, and then uses CodeGen and the JIT to actually
   execute the code.

 - Still more complicated than it should be, but hey its only 153 lines. :)

--
ddunbar@ozzy:tmp$ cat hello.c
#include <stdio.h>
int main() { printf("hello world\n"); return 0; }
ddunbar@ozzy:tmp$ clang-interpreter hello.c
hello world
--

llvm-svn: 97133
2010-02-25 08:49:05 +00:00
Chris Lattner 0bcc858a2b -fno-rtti is now the default.
llvm-svn: 94379
2010-01-24 20:43:31 +00:00
Daniel Dunbar d79f40ac7a Fix -plugin command line argument syntax for clang -cc1 change.
llvm-svn: 92780
2010-01-05 21:42:23 +00:00
Douglas Gregor b752f1e25c Fix CMake build on windows, from Cedric Venet
llvm-svn: 91794
2009-12-20 20:56:30 +00:00
Daniel Dunbar 520d1e6c6b Update docs/comments/utils/examples to refer to clang -cc1 instead of clang-cc.
llvm-svn: 91176
2009-12-11 23:04:35 +00:00
Daniel Dunbar 1597da4c05 Document that CompilerInvocation::createDiagnostics keeps a reference to the DiagnosticOptions, and update callers to make sure they don't pass in a temporary.
llvm-svn: 90704
2009-12-06 09:56:30 +00:00
Daniel Dunbar 19a30ca8c0 Fix layering violation by moving Analysis/CallGraph to Index
llvm-svn: 90424
2009-12-03 07:20:04 +00:00
Daniel Dunbar 59203007ac Fix ASTUnit to allows require a (persistent) Diagnostic object be provided; propogate and simplify.
llvm-svn: 90379
2009-12-03 01:45:44 +00:00
Daniel Dunbar 5732ce39bc Update example link lines.
llvm-svn: 90359
2009-12-03 00:00:22 +00:00
Daniel Dunbar 9110165da9 Add a very minimal README.txt for examples/PrintFunctionNames.
llvm-svn: 90197
2009-12-01 03:15:49 +00:00
Daniel Dunbar 53f6f61c95 Add missed CMake file for adding clang examples to CMake build.
llvm-svn: 89080
2009-11-17 09:40:40 +00:00
Daniel Dunbar 6499e9c625 Add a trivial example plugin, which prints the names of the top-level decls.
- The build scriptage is about twice as long as the code, which is nice. :)

llvm-svn: 88826
2009-11-15 00:27:43 +00:00
Daniel Dunbar 9b30eb721f Add examples dir, built with BUILD_EXAMPLES=1 (Makefiles, no CMake equivalent yet).
Move tools/wpa to examples/wpa, and unbreak its build.

llvm-svn: 88825
2009-11-15 00:22:33 +00:00