aboutsummaryrefslogtreecommitdiff
path: root/tools/c-index-test/c-index-test.c
AgeCommit message (Collapse)Author
2010-02-18Rework how CIndex handles diagnostics. Rather than using a callback,Douglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96592 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17Convert clang_getCompletionChunkText() to return a CXString.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96439 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17Change clang_getCursorKindSpelling() to return a CXStringTed Kremenek
instead of a 'const char *'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96425 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17Change clang_getFileName() to return a 'CXString' instead of 'const char *'.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96424 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16c-index-test: Pass appropriate client data.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96317 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14CIndex: Switch CXSourceRange to proper half-open intervals.Daniel Dunbar
- Doug, please review. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96162 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14c-index-test: Unify and always print half-open extents.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96160 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14c-index-test: Simplify file scanning code.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96159 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14c-index-test: Unify syntax for printing extents. Yes, there were 4.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96158 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-11Attempt to always dispose of the CXIndex object in c-index-test.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95864 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-10c-index-test: Add "none" filter, useful for performance testing.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95800 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08Clean up the CIndex interface to diagnostic ranges. Thanks, Daniel!Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95602 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29When printing diagnostics in c-index-test, also print source rangesDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94768 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28Switch the remaining diagnostic printing in CIndex over to theDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94714 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28Implement a diagnostics callback for the C interface to Clang, so thatDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94709 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Implement 'clang_getInclusions()' in CIndex. This API allows clients to ↵Ted Kremenek
walk the set of files included in a translation unit via the C API. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94575 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Eliminate clang_getInstantiationLocationOffset(), and instead add anDouglas Gregor
offset parameter to clang_getInstantiationLocation(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94573 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Implement clang_annotateTokens(), which associates cursors with eachDouglas Gregor
of the tokens within a raw token stream. This does not even attempt to handle macros yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Add 'PostVisitTU' callback hook to 'perform_test_load()' to allow a special ↵Ted Kremenek
callback after the translation unit has been loaded (and streamed). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94557 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Allow the 'visitor' argument to 'perform_test_load()' to be NULL. TheTed Kremenek
utility of this change will be made clearer in a subsequent patch when perform_test_load()' does more than stream the AST. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94556 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Introduce a CIndex API for lexing the raw tokens within a given sourceDouglas Gregor
range. The token-annotation function does nothing, yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94551 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23Extend clang_createTranslationUnitFromSourceFile() to support creatingDouglas Gregor
translation units that include unsaved files. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94258 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22Yet more CIndex API cleanup:Douglas Gregor
- Added more routines to manipulate/compare source locations and ranges - Switched clang_getCursor() over to take a CXSourceLocation rather than file/line/column. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94226 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20Stash a CXXUnit pointer into each cursor. This allows us to simplifyDouglas Gregor
the interface to clang_visitChildren() by eliminating the CXTranslationUnit pointer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94051 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20Switch c-index-test from clang_loadDeclaration() andDouglas Gregor
clang_loadTranslationUnit() over to clang_visitChildren(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94031 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Rework the CXSourceLocation and CXSourceRange APIs. They are nowDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93915 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Eliminate cursor kinds used to express definitions. Instead, provideDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93893 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Introduce clang_getCursorReferenced, to get a cursor pointing at theDouglas Gregor
entity that a particular cursor references. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93830 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19Implement clang_getCursorExtent, which provides a source range for theDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93823 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18Introduce clang_getCursorLocation(), which supercedesDouglas Gregor
clang_getCursorLine(), clang_getCursorColumn(), clang_getCursorSource(), and clang_getCursorSourceFile(). Mark those 4 functions as deprecated and stop using them ourselves. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93800 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18Clean up the CIndex API slightly.Douglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93783 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18Replace clang_getDeclUSR() with clang_getCursorUSR(). Also remove printing ↵Ted Kremenek
'contexts' from c-index-test output; it wasn't helpful and was extremely brittle. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93760 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16Remove TranslateKind and centralize Decl -> CXCursorKind in GetCursorKind(). ↵Ted Kremenek
This revealed a bunch of inconsistencies in how CXCursorKinds were being computed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93618 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15Make CXCursor's data opaque.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15Add -cursor-at=file:line:column command line option to c-index-test,Douglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93537 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12Add USR printing modes to c-index-test.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93269 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12Make 'CXTranslationUnitIterator' an argument to perform_test_load(),Ted Kremenek
perform_test_load_tu(), and perform_test_load_source(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10Improve code completion by introducing patterns for the various C andDouglas Gregor
C++ grammatical constructs that show up in top-level (namespace-level) declarations, member declarations, template declarations, statements, expressions, conditions, etc. For example, we now provide a pattern for static_cast<type>(expr) when we can have an expression, or using namespace identifier; when we can have a using directive. Also, improves the results of code completion at the beginning of a top-level declaration. Previously, we would see value names (function names, global variables, etc.); now we see types, namespace names, etc., but no values. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07Add FileCheck prefix to another location in the output of c-index-test.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92890 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05Remove unused variables.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92804 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05Add C API hook 'clang_getDeclExtent()', which returns the source extent of a ↵Ted Kremenek
declaration. This implements <rdar://problem/7280072>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92802 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18Extend code-completion results with the type of each resultDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18Change clang_codeComplete API to return the results in a structure onDouglas Gregor
the heap, so that clients are not forced to copy the results during the initial iteration. A separate clang_disposeCodeCompleteResults function frees the returned results. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91690 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17Test for errors during fread() inside c-index-test and handle themChandler Carruth
appropriately. This also silences some pedantic GCC warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91596 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03Switch clang_createTranslationUnitFromSourceFile to use ↵Daniel Dunbar
ASTUnit::LoadFromCommandLine. - This is much faster, as it avoids the overhead of dumping an AST file to disk and reloading it. - For debugging purposes, there is a clang_setUseExternalASTGeneration hook which can be used to disable this. On the Sketch Cocoa app, the speedup is pretty nice, especially when using a PCH file while scanning the source: Wall time to c-index-test all files (no PCH): Old: 23.4221 New: 12.3884 Wall time to c-index-test all files (with a PCH, and "local" mode): Old: 10.9233 New: 1.9038 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90385 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-02Extend the CIndex code-completion API to perform code completionDouglas Gregor
involving unsaved files, using the -remap-file= functionality recently added to clang-cc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90314 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01c-index-test: Split "function scanning" behavior into its own "filter" -- itsDaniel Dunbar
quite slow and doesn't really stress the APIs people should really use. - I'm not even sure if this mode is still useful given the other scanning mode; Steve? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90193 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01Add c-index-test -test-load-source, which loads the translation unit from a ↵Daniel Dunbar
source file (and other command line arguments). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90187 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-18Add special clang_getCursor() support for @class. Handles ↵Ted Kremenek
<rdar://problem/7383421>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89183 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17fgetln is a BSDism; replace it with more portable code.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89140 91177308-0d34-0410-b5e6-96231b3b80d8