aboutsummaryrefslogtreecommitdiff
path: root/tools/c-index-test
AgeCommit message (Collapse)Author
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-24-fno-rtti is now the default.Chris Lattner
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94379 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-02Normalize CIndex/c-index-test/index-test link lines in the hopes it will fixDaniel Dunbar
*something*. - We really need to fix how LLVM's build systems manage linking. Pretty-please-someone-else-do-this? :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90350 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-02Fix relative ordering of Analyis library.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90312 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01Add ASTUnit::LoadFromCompilerInvocation, which does what it says.Daniel Dunbar
Also, add an -ast-from-source option to index-test which allows index-test to run on source files directly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90223 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
2009-11-17Add c-index-test mode "-test-file-scan", which scans a source file and calls ↵Ted Kremenek
clang_getCursor() on every character. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89136 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17Organize c-index-test into logic sections, and add section headers.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89117 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17Clean up c-index-test command line usage a bit by requiring a ↵Ted Kremenek
"-test-load-tu" option when testing clang_loadTranslationUnit(). Running c-index-test without the correct arguments now also prints a useful summary of its correct usage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89115 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17Have clang_getCursorSource() return NULL when the source location is invalid ↵Ted Kremenek
or refers to a built-in buffer. Implements <rdar://problem/7296243>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89044 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09Improve c-index-test's parsing of the -code-completion-at=file:line:column ↵Douglas Gregor
argument git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86566 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09Introduce CXString type and associated functions clang_getCString() and ↵Steve Naroff
clang_disposeString(). This abstraction will help us manage string memory for complex names that cross the C++/C boundary (e.g. ObjC methods, selectors). This patch also uses it in clang_getTranslationUnitSpelling (which I'm not sure is necessary). Will investigate later...since the extra malloc() can't hurt (for now). Patch by John Thompson. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86562 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09C doesn't allow mixing declarations and statements, sillyDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86556 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09Minor cleanup for CIndex-based code-completion:Douglas Gregor
- Provide an actual test for code-completion via CIndex. - Actually print optional strings in c-index-test - Export clang_getCompletionChunkCompletionString from CIndex git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86550 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08Revert unintentional change to this file.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86455 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08CIndex: Add temporary hack to leak memory instead of returning invalid pointers.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86438 91177308-0d34-0410-b5e6-96231b3b80d8