Commit Graph

112 Commits

Author SHA1 Message Date
Daniel Dunbar d5a2a073a0 Rename 'CIndex' to 'libclang', since it has basically become our stable public
(C) API, and will likely grow further in this direction in the future.

llvm-svn: 102779
2010-04-30 21:51:10 +00:00
Daniel Dunbar 9f84c7b600 Move include installation steps to better location, inside each include dir instead of at the top-level.
Also, don't set NO_INSTALL=1 for c-index-test.

llvm-svn: 102724
2010-04-30 17:59:38 +00:00
Ted Kremenek 6d159c1060 Fix USRs for 'extern' variables declaration in functions/method bodies.
Fix USRs for @synthesize.
Add more USR tests.

llvm-svn: 101954
2010-04-20 23:15:40 +00:00
Ted Kremenek 7afa85b8fa Rework USR generation for symbols with no linkage. Many of the USRs are now shortened,
and we now include the file name that declares the symbol with no linkage in the USR.
USRs for such symbols are generated only in restructed cases, e.g., anonymous enum declarations,
typedefs, etc.

llvm-svn: 101542
2010-04-16 21:31:52 +00:00
Ted Kremenek 599d73aa72 Add c-index-test support for printing USRs.
llvm-svn: 99476
2010-03-25 02:00:39 +00:00
Douglas Gregor 0b46650b66 c-index-test's printing of linkage was completely broken, as was the
test of this functionality. The API worked great, though! :)

llvm-svn: 97736
2010-03-04 19:36:27 +00:00
Ted Kremenek 83b28a2433 Add '-test-print-linkage-source' option to c-index-test
to test clang_getCursorLinkage()

llvm-svn: 97648
2010-03-03 06:37:58 +00:00
Douglas Gregor d770f73fac Rework the CIndex API for displaying diagnostics. Instead of printing
the diagnostics to a FILE*, return a CXString containing the formatted
diagnostic.

llvm-svn: 96823
2010-02-22 23:17:23 +00:00
Douglas Gregor 836ec94c8e Simplify the CIndex fix-it API, now that we have half-open CXSourceRanges.
llvm-svn: 96685
2010-02-19 18:16:06 +00:00
Douglas Gregor 1e21cc7d19 Re-apply my diagnostics-capture patch for CIndex, with some tweaks to
try to address the msvc failures.

llvm-svn: 96624
2010-02-18 23:07:20 +00:00
Douglas Gregor 9773e3d077 Revert my CIndex diagnostic changes (r96603, 96606, 96607), which were
breaking the msvc9 builder for unknown reasons.

llvm-svn: 96618
2010-02-18 22:27:07 +00:00
Douglas Gregor 81d53769b5 Introduce debugging/testing hook clang_enableStackTraces() into
CIndex, so that c-index-test to use it to call
lvm::sys::PrintStackTraceOnErrorSignal().

llvm-svn: 96607
2010-02-18 20:22:25 +00:00
Douglas Gregor 707cf72cb8 Resurrect the displayDiagnostics parameter to clang_createIndex(), and
display captured diagnostics when we can't return an invalid
CXTranslationUnit.

llvm-svn: 96606
2010-02-18 20:11:31 +00:00
Douglas Gregor 06dcf0375b Introduce CIndex API functions for displaying a diagnostic, with some
knobs to control formatting. Eventually, I'd like to merge the
implementation of this code with the TextDiagnosticPrinter, so that
it's easy for CIndex clients to produce beautiful diagnostics like the
clang compiler does.

Use this new function to display diagnostics within c-index-test.

llvm-svn: 96603
2010-02-18 19:08:21 +00:00
Douglas Gregor 33cdd81064 Rework how CIndex handles diagnostics. Rather than using a callback,
we attach diagnostics to translation units and code-completion
results, so they can be queried at any time.

To facilitate this, the new StoredDiagnostic class stores a diagnostic
in a serializable/deserializable form, and ASTUnit knows how to
capture diagnostics in this stored form. CIndex's CXDiagnostic is a
thin wrapper around StoredDiagnostic, providing a C interface to
stored or de-serialized diagnostics.

I've XFAIL'd one test case temporarily, because currently we end up
storing diagnostics in an ASTUnit that's never returned to the user
(because it contains errors). I'll introduce a temporary fix for this
soon; the real fix will be to allow us to return and query invalid ASTs.

llvm-svn: 96592
2010-02-18 18:08:43 +00:00
Ted Kremenek f602f96e60 Convert clang_getCompletionChunkText() to return a CXString.
llvm-svn: 96439
2010-02-17 01:42:24 +00:00
Ted Kremenek 29004673f7 Change clang_getCursorKindSpelling() to return a CXString
instead of a 'const char *'.

llvm-svn: 96425
2010-02-17 00:41:32 +00:00
Ted Kremenek c560b6835e Change clang_getFileName() to return a 'CXString' instead of 'const char *'.
llvm-svn: 96424
2010-02-17 00:41:20 +00:00
Daniel Dunbar ce79bc9c7a c-index-test: Pass appropriate client data.
llvm-svn: 96317
2010-02-16 01:55:10 +00:00
Daniel Dunbar 02968e53cf CIndex: Switch CXSourceRange to proper half-open intervals.
- Doug, please review.

llvm-svn: 96162
2010-02-14 10:02:57 +00:00
Daniel Dunbar 6092d507f0 c-index-test: Unify and always print half-open extents.
llvm-svn: 96160
2010-02-14 08:32:51 +00:00
Daniel Dunbar eb27e7d999 c-index-test: Simplify file scanning code.
llvm-svn: 96159
2010-02-14 08:32:32 +00:00
Daniel Dunbar 98c07e0e23 c-index-test: Unify syntax for printing extents. Yes, there were 4.
llvm-svn: 96158
2010-02-14 08:32:24 +00:00
Ted Kremenek 50228be0f3 Attempt to always dispose of the CXIndex object in c-index-test.
llvm-svn: 95864
2010-02-11 07:41:25 +00:00
Daniel Dunbar d64ce7b611 c-index-test: Add "none" filter, useful for performance testing.
llvm-svn: 95800
2010-02-10 20:42:40 +00:00
Douglas Gregor 4b8fd6d3d3 Clean up the CIndex interface to diagnostic ranges. Thanks, Daniel!
llvm-svn: 95602
2010-02-08 23:11:56 +00:00
Douglas Gregor 60b11f6dfd When printing diagnostics in c-index-test, also print source ranges
and fix-it information, so we can see everything in one place. Along
the way, fix a few bugs with deserialization and query of diagnostics
in CIndex.

llvm-svn: 94768
2010-01-29 00:41:11 +00:00
Douglas Gregor ba965fb2a7 Switch the remaining diagnostic printing in CIndex over to the
diagnostic callback mechanism, so all diagnostics now go through that
callback. Also, eliminate the displayDiagnostics flag to
clang_createIndex(), since it is no longer necessary: the client
determines whether to display diagnostics or not.

llvm-svn: 94714
2010-01-28 00:56:43 +00:00
Douglas Gregor 4f9c376570 Implement a diagnostics callback for the C interface to Clang, so that
clients can format diagnostics as they wish rather than having to
parse standard error. All of the important parts of the front end's
diagnostics are exposed: text, severity, location, source ranges, and
fix-its. The diagnostics callback is now available with
clang_createTranslationUnitFromSource() and
clang_createTranslationUnit().

As part of this change, CXSourceLocation and CXSourceRange got one
pointer larger, since we need to hold on to the SourceManager and
LangOptions structures in the source location. This is the minimum
amount of information needed for the functions that operate on source
locations and ranges (as implemented now). Previously we held on to
the ASTContext, but the diagnostics callback can end up with source
locations when there is no ASTContext (or preprocessor).

Still to do:
  - Code completion needs to support the diagnostics callback, once we
  have the ability to (de-)serialize diagnostics.
  - Eliminate the "displayDiagnostics" argument to createIndex; we'll
  always pass diagnostics to the callback and let it deal with display.

llvm-svn: 94709
2010-01-28 00:27:43 +00:00
Ted Kremenek 0b86e3a72d Implement 'clang_getInclusions()' in CIndex. This API allows clients to walk the set of files included in a translation unit via the C API.
llvm-svn: 94575
2010-01-26 19:31:51 +00:00
Douglas Gregor 9bd6db5834 Eliminate clang_getInstantiationLocationOffset(), and instead add an
offset parameter to clang_getInstantiationLocation(). 

llvm-svn: 94573
2010-01-26 19:19:08 +00:00
Douglas Gregor 6165611986 Implement clang_annotateTokens(), which associates cursors with each
of the tokens within a raw token stream. This does not even attempt to
handle macros yet.

llvm-svn: 94561
2010-01-26 18:31:56 +00:00
Ted Kremenek b478ff4efc Add 'PostVisitTU' callback hook to 'perform_test_load()' to allow a special callback after the translation unit has been loaded (and streamed).
llvm-svn: 94557
2010-01-26 17:59:48 +00:00
Ted Kremenek a97a5cd59e Allow the 'visitor' argument to 'perform_test_load()' to be NULL. The
utility of this change will be made clearer in a subsequent patch when
perform_test_load()' does more than stream the AST.

llvm-svn: 94556
2010-01-26 17:55:33 +00:00
Douglas Gregor 27b4fa994d Introduce a CIndex API for lexing the raw tokens within a given source
range. The token-annotation function does nothing, yet.

llvm-svn: 94551
2010-01-26 17:06:03 +00:00
Chris Lattner 0bcc858a2b -fno-rtti is now the default.
llvm-svn: 94379
2010-01-24 20:43:31 +00:00
Douglas Gregor aa98ed9a07 Extend clang_createTranslationUnitFromSourceFile() to support creating
translation units that include unsaved files.

llvm-svn: 94258
2010-01-23 00:14:00 +00:00
Douglas Gregor 816fd36316 Yet more CIndex API cleanup:
- Added more routines to manipulate/compare source locations and ranges
  - Switched clang_getCursor() over to take a CXSourceLocation rather
  than file/line/column.

llvm-svn: 94226
2010-01-22 21:44:22 +00:00
Douglas Gregor fed36b1aa1 Stash a CXXUnit pointer into each cursor. This allows us to simplify
the interface to clang_visitChildren() by eliminating the
CXTranslationUnit pointer.

llvm-svn: 94051
2010-01-20 23:57:43 +00:00
Douglas Gregor 720d00553a Switch c-index-test from clang_loadDeclaration() and
clang_loadTranslationUnit() over to clang_visitChildren().

llvm-svn: 94031
2010-01-20 21:32:04 +00:00
Douglas Gregor 4f46e789b3 Rework the CXSourceLocation and CXSourceRange APIs. They are now
opaque data structures accessed through the new functions
clang_getInstantiationLocation(), clang_getRangeStart(), and
clang_getRangeEnd(). The new API permits later extensions to introduce
new functions to allow CIndex clients to walk macro instantiations, if
we ever care.

llvm-svn: 93915
2010-01-19 21:36:55 +00:00
Douglas Gregor 6b8232ff82 Eliminate cursor kinds used to express definitions. Instead, provide
CIndex functions that (1) map from a reference or declaration to the
corresponding definition, if available, and (2) determine whether a
given declaration cursor is also a definition. This eliminates a lot
of duplication in the cursor kinds, and maps more closely to the Clang
ASTs.

This is another API + ABI breaker with no deprecation. Yay, progress.

llvm-svn: 93893
2010-01-19 19:34:47 +00:00
Douglas Gregor ad27e8b777 Introduce clang_getCursorReferenced, to get a cursor pointing at the
entity that a particular cursor references.

llvm-svn: 93830
2010-01-19 01:20:04 +00:00
Douglas Gregor 33c34ac19a Implement clang_getCursorExtent, which provides a source range for the
cursor itself. In particular, for references this returns the source
range of the reference rather than the source range of the thing it
refers to.

Switch c-index-test from clang_getDeclExtent (which will eventually be
deprecated and removed) over to clang_getCursorExtent. The source
ranges we print for references now make sense; fix up the tests
appropriately.

llvm-svn: 93823
2010-01-19 00:34:46 +00:00
Douglas Gregor 66a58819d1 Introduce clang_getCursorLocation(), which supercedes
clang_getCursorLine(), clang_getCursorColumn(),
clang_getCursorSource(), and clang_getCursorSourceFile(). Mark those 4
functions as deprecated and stop using them ourselves.

llvm-svn: 93800
2010-01-18 22:46:11 +00:00
Douglas Gregor 49c4baf430 Clean up the CIndex API slightly.
Renamed CXSourceFileLine to CXSourceLocation and added a CXFile, to
better match Clang's SourceLocation. Teach clang_getDeclExtent to fill
in the CXFile properly.

Renamed CXSourceExtent to CXSourceRange, to better match Clang's
SourceLocation.

llvm-svn: 93783
2010-01-18 22:13:09 +00:00
Ted Kremenek 473c7a72f1 Replace clang_getDeclUSR() with clang_getCursorUSR(). Also remove printing 'contexts' from c-index-test output; it wasn't helpful and was extremely brittle.
llvm-svn: 93760
2010-01-18 20:23:29 +00:00
Ted Kremenek 9cec00019a Remove TranslateKind and centralize Decl -> CXCursorKind in GetCursorKind(). This revealed a bunch of inconsistencies in how CXCursorKinds were being computed.
llvm-svn: 93618
2010-01-16 01:44:12 +00:00
Douglas Gregor c58d05bcf9 Make CXCursor's data opaque.
llvm-svn: 93561
2010-01-15 21:56:13 +00:00
Douglas Gregor 082c3e69eb Add -cursor-at=file:line:column command line option to c-index-test,
to directly check the results of clang_getCursor(). Also, start
migrating some index-test tests over to c-index test [*] and some
grep-using tests over to FileCheck.

llvm-svn: 93537
2010-01-15 19:40:17 +00:00