Граф коммитов

93 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 90742c1318 clang_getCompletionChunkText() will treat optional strings as empty text blocks
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91072 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-10 22:46:19 +00:00
Daniel Dunbar bb3503a146 Document that CompilerInvocation::createDiagnostics keeps a reference to the DiagnosticOptions, and update callers to make sure they don't pass in a temporary.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90704 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-06 09:56:30 +00:00
Daniel Dunbar 942209729a CIndex: For the time being, don't return translation units if we encounter an error during parsing.
- We need to be more careful in the rest of CIndex if we are to handle
   possibly-invalid ASTs, and don't have much experience with this yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90643 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-05 02:17:18 +00:00
Daniel Dunbar f772d1e2a5 ASTUnit/CIndex: Explicitly track the top-level decls when using an ASTUnit made
from a source file.
 - This allows CIndex to avoid iterating over all the top-level decls when using
   a PCH, which means we deserialize far fewer decls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90559 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-04 08:17:33 +00:00
Daniel Dunbar 7bd716557b Update test and CIndex to use -FOO BAR form for -{remap-file,code-completion-at}.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90416 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03 05:32:40 +00:00
Daniel Dunbar 8506dde586 Switch clang_createTranslationUnitFromSourceFile to use 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-03 01:54:28 +00:00
Daniel Dunbar 5262fda30b Fix ASTUnit to allows require a (persistent) Diagnostic object be provided; propogate and simplify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90379 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03 01:45:44 +00:00
Douglas Gregor 735df88a38 Extend the CIndex code-completion API to perform code completion
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-02 09:21:34 +00:00
Douglas Gregor 2b4074f1d3 Switch the clang-to-CIndex interface for code-completion to a binary format, for a massive speedup
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90209 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01 05:55:20 +00:00
Daniel Dunbar 9ebfa31222 CIndex: Normalize formatting some more.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90196 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-01 03:14:51 +00:00
Daniel Dunbar acca725aef Reindent buffer, switches in particular were totally out of style.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90155 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-30 20:42:49 +00:00
Daniel Dunbar 0d7dd22238 Strip trailing space.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90154 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-30 20:42:43 +00:00
Daniel Dunbar 4db166b723 Change -code-completion-debug-printer to -no-code-completion-debug-printer.
Also, tweak a few help strings and update CompilerInvocation serialization for prev change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89317 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-19 05:32:09 +00:00
Ted Kremenek 7388555543 Add clang_getNullCursor() and clang_equalCursors() (the latter for comparing cursors).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89131 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 19:28:59 +00:00
Ted Kremenek 4633d1b269 Allow "source_filename" to be an optional argument (the client can provide NULL). This allows the client to put the source_filename in the command_line_args without fear of the file being named twice.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89118 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 18:18:02 +00:00
Ted Kremenek ef7fdc6b73 Sort visitor methods. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89055 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 07:02:15 +00:00
Ted Kremenek 9298cfc747 Have clang_getCursorSource() return NULL when the source location is invalid 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-17 05:31:58 +00:00
Daniel Dunbar 914474ca51 Move code completion options to clang-cc
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87050 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 01:02:10 +00:00
John Thompson 6a6742a8fc Fix clang executable path for Windows
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86896 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 23:11:14 +00:00
Ted Kremenek 0854d70dab CIndex: Only display diagnostics to llvm::errs() when the client has set the 'displayDiagnostics' option to 1 in clang_createIndex(). This fixes <rdar://problem/7370691>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86700 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-10 19:18:52 +00:00
Douglas Gregor ff4393c1ce Make sure that we look into nested, transparent declaration contexts
when looking for a name within a given DeclContext. Now enumerators
will show up in code-completion results.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86591 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 21:35:27 +00:00
Benjamin Kramer 62cf322cf1 Factor CXString creation into a helper method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86577 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 19:13:48 +00:00
Benjamin Kramer 858e5de143 Writing to a struct passed by value is pointless. Remove dead code.
- free(NULL) is a nop anyway.
- if someone thinks calling clang_disposeString twice should be legal
  please change the method to take a pointer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86568 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-09 18:24:53 +00:00
Steve Naroff ef0cef6cec Introduce CXString type and associated functions clang_getCString() and 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-09 17:45:52 +00:00
Daniel Dunbar c6190330e7 Move a function which returns a class outside of extern C scope.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86439 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 04:13:53 +00:00
Daniel Dunbar 4dc99f8928 CIndex: Add temporary hack to leak memory instead of returning invalid pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86438 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 04:11:32 +00:00
Douglas Gregor 0c8296dfb4 Various improvements to Clang's code-completion infrastructure:
- Introduce more code-completion string "chunk" kinds that describe
  symbols, the actual text that the user is expected to type, etc.
  - Make the generation of macro results optional, since it can be
  slow
  - Make code-completion accessible through the C API, marshalling the
  code-completion results through a temporary file (ick) to maintain
  process separation.

The last doesn't have tests yet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86306 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-07 00:00:49 +00:00
Steve Naroff 0d69b8cc8e - Add/tweak some comments.
- change ObjCCategoryImplDecl::getCategoryClass() to getCategoryDecl().

No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85528 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 21:11:04 +00:00
Steve Naroff f9f6196e9f clang_getDeclSpelling(): For category implementations, make sure we hand back the category name (not the class name). This fixes <rdar://problem/7297518>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85521 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 18:55:50 +00:00
Steve Naroff f96b524306 Remove _clang_initCXLookupHint() and _clang_getCursorWithHint(). Related to <rdar://problem/7310688>.
Localize the optimization to ResolveLocationInAST(). The last valid AST location is now stored with ASTUnit. There still isn't optimal, however it's an improvement (with a much cleaner API). Having the client manage an "hint" is error prone and complex.

I wanted to land the major changes before finishing up the optimizations. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85425 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-28 20:44:47 +00:00
Steve Naroff 8814503469 Add support for 'CXFile' (<rdar://problem/7303360>).
- 4 new functions (clang_getCursorSourceFile, clang_getDeclSourceFile, clang_getFileName, clang_getFileTime).

- Should remove clang_getDeclSource() and clang_getCursorSource(). For now, just put 'deprecate' comment in header. 

- Also changed CXX style comment to C style (to eliminate warning).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85238 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-27 14:35:18 +00:00
Ted Kremenek feb15e3f39 Unify Unix and Windows code paths when executing 'clang'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85163 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 22:14:08 +00:00
Ted Kremenek 779e5f487d Remove unnecessary calls to 'flush()'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85162 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-26 22:08:39 +00:00
Ted Kremenek 8ee1f3fc0d Always emit error diagnostics when an error occurs within clang_createTranslationUnit() and clang_createTranslationUnitFromSource(). These kind of errors are ones that shouldn't be missed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84904 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 22:19:00 +00:00
Ted Kremenek fbcb2b716b Split clang_getCursor() into clang_getCursor() and clang_getCursorWithHint().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84873 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 17:22:53 +00:00
Ted Kremenek 379afec20c Add some explanatory diagnostics when clang_createTranslationUnitFromSource fails.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84825 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 03:24:01 +00:00
Ted Kremenek 139ba86a36 Enhance 'clang_createTranslationUnitFromSourceFile()' in two ways:
(1) Allow the source file to be specified in the actual command line arguments by allowing the
    caller to set 'source_filename' to NULL.

(2) Automatically strip off the arguments '-emit-ast', '-fsyntax-only', and '-c'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84802 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-22 00:03:57 +00:00
Steve Naroff 6a6de8b4fc Extend clang_getCursor() to take a 'relativeDecl' argument (so speed up searching). Without a 'relativeDecl', the algorithm is n-squared. For example, running the following command on 'Large.m' takes hours without a 'relatvieDecl'.
snaroff% time ../../Debug/bin/c-index-test Large.ast all > Large.out
snaroff% cat Large.m
#import <Cocoa/Cocoa.h>
#import <QuickTime/QuickTime.h>
#import <OpenGL/OpenGL.h>

With a 'relativeDecl', it takes <30 seconds:-)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84760 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-21 13:56:23 +00:00
Steve Naroff e56b4baeba - Extend clang_createIndex() to support PCH and diagnostic 'filtering'. This seems cleaner to me without sacrificing much flexibility.
- Remove clang_wantOnlyLocalDeclarations().

- Remove 'displayDiagnostics' arguments to clang_createTranslationUnitFromSourceFile() and clang_createTranslationUnit().

- Have clang_createTranslationUnitFromSourceFile() strip the '-o <outfile>' command line arguments if they exist. Document this semantic in the header. Also verify we have a valid ASTUnit before telling it to 'unlinkTemporaryFile()'.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84634 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-20 14:46:24 +00:00
Ted Kremenek c46e463f13 Fix inverted preprocessor guard, and fix the resulting compiler error that was unmasked.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84555 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 22:27:32 +00:00
Ted Kremenek 1374598619 Really fix <rdar://problem/7312058> by adding a 'displayDiagnostics' option to
clang_createTranslationUnit() and clang_createTranslationUnitFromSourceFile(). The user can now
specify if the diagnostics from Clang are printed to stderr or are silenced completely. We can
obviously evolve this API to be more general in the future.

Note: Added a FIXME since I wasn't certain what was the best way to redirect to something analogous
to '/dev/null' on Windows.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84548 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 22:15:09 +00:00
Ted Kremenek fc0622155f The constructor for ASTUnit now takes a DiagnosticClient*, allowing uses of ASTUnit to specify
alternate DiagnosticClients. To match this API, ASTUnit::LoadFromPCHFile() now takes a corresponding
DiagnosticClient* argument as well. The DiagnosticClient object is destroyed when the ASTUnit object
is destroyed.

The CIndex library now uses this API to create a 'IgnoreDiagnosticsClient' that simply silences
diagnostics when using the clang_createTranslationUnitFromSourceFile() function. This fixes
<rdar://problem/7312058>. This API can change in the future as we add more flexibility for clients.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84539 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 21:44:57 +00:00
Ted Kremenek 49358d85d7 Re-order includes so that the logic involving '#ifdef LLVM_ON_WIN32' appears after the main #includes. The ultimate solution is to just use LLVM-portable methods in llvm/System.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84534 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 21:17:25 +00:00
Steve Naroff 36c4464ba6 Move Diagnostic/DiagClient/FileManager from Indexer => ASTUnit.
Removing this shared data should enable clang_createTranslationUnit/clang_createTranslationUnitFromSourceFile to be run from multiple threads (related to <rdar://problem/7303432>).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84499 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 14:34:22 +00:00
Steve Naroff bade7de59d Change indenting for case/compound statements to conform to the rest of clang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84498 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 13:41:39 +00:00
Benjamin Kramer c5a9e9511e CIndex: make variable non-static to avoid potential race conditions, per
Daniel's comment.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84484 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-19 10:20:24 +00:00
Daniel Dunbar e013d685c6 Move clients to use IdentifierInfo::getNameStart() instead of getName()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84436 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 20:26:12 +00:00
Benjamin Kramer b14346b95e CIndex: fix typo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84422 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 16:52:07 +00:00
Benjamin Kramer edcd8286f2 Missed a paren.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84421 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 16:20:58 +00:00
Benjamin Kramer 20d758132f CIndex: add a (untested) WIN32 codepath to get ClangPath.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84420 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18 16:13:48 +00:00