Commit Graph

607 Commits

Author SHA1 Message Date
John Thompson de258b5ab9 Changes for building as a Windows DLL
llvm-svn: 85234
2009-10-27 13:42:56 +00:00
Ted Kremenek 12e678d550 Unify Unix and Windows code paths when executing 'clang'.
llvm-svn: 85163
2009-10-26 22:14:08 +00:00
Ted Kremenek bf0690c99f Remove unnecessary calls to 'flush()'.
llvm-svn: 85162
2009-10-26 22:08:39 +00:00
Daniel Dunbar 431895f748 clang-cc: Allow building for x86_64 with -mmacosx-version-min=10.4.
llvm-svn: 85132
2009-10-26 17:52:49 +00:00
Rafael Espindola b3549d74da Rename -nostdclanginc to -nobuiltininc.
llvm-svn: 85116
2009-10-26 13:36:57 +00:00
Fariborz Jahanian 0797404a33 Fixes a warning.
llvm-svn: 84909
2009-10-22 22:49:47 +00:00
Ted Kremenek 2a3ffa9658 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.
llvm-svn: 84904
2009-10-22 22:19:00 +00:00
Ted Kremenek a96b72a4ca Split clang_getCursor() into clang_getCursor() and clang_getCursorWithHint().
llvm-svn: 84873
2009-10-22 17:22:53 +00:00
Ted Kremenek 44886fd124 Add some explanatory diagnostics when clang_createTranslationUnitFromSource fails.
llvm-svn: 84825
2009-10-22 03:24:01 +00:00
Ted Kremenek 649bf5c04b 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'.

llvm-svn: 84802
2009-10-22 00:03:57 +00:00
Steve Naroff 20bad0b7c6 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:-)

llvm-svn: 84760
2009-10-21 13:56:23 +00:00
Steve Naroff 531e284064 - 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()'.

llvm-svn: 84634
2009-10-20 14:46:24 +00:00
Ted Kremenek e28968828b Fix inverted preprocessor guard, and fix the resulting compiler error that was unmasked.
llvm-svn: 84555
2009-10-19 22:27:32 +00:00
Ted Kremenek 02b319ce18 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.

llvm-svn: 84548
2009-10-19 22:15:09 +00:00
Ted Kremenek 428c637ada 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.

llvm-svn: 84539
2009-10-19 21:44:57 +00:00
Ted Kremenek 9dd89ba393 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.
llvm-svn: 84534
2009-10-19 21:17:25 +00:00
Steve Naroff 505fb84ed9 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>).

llvm-svn: 84499
2009-10-19 14:34:22 +00:00
Steve Naroff 2f78a6f368 Change indenting for case/compound statements to conform to the rest of clang.
llvm-svn: 84498
2009-10-19 13:41:39 +00:00
Benjamin Kramer b625a13c79 CIndex: make variable non-static to avoid potential race conditions, per
Daniel's comment.

llvm-svn: 84484
2009-10-19 10:20:24 +00:00
Daniel Dunbar 2c422dc9ca Move clients to use IdentifierInfo::getNameStart() instead of getName()
llvm-svn: 84436
2009-10-18 20:26:12 +00:00
Benjamin Kramer a259086fd5 Try to unbreak MSVC build.
llvm-svn: 84433
2009-10-18 19:59:44 +00:00
Benjamin Kramer ad9c37661b CIndex: fix typo.
llvm-svn: 84422
2009-10-18 16:52:07 +00:00
Benjamin Kramer 49ce64eb88 Missed a paren.
llvm-svn: 84421
2009-10-18 16:20:58 +00:00
Benjamin Kramer 6bd6d50b42 CIndex: add a (untested) WIN32 codepath to get ClangPath.
llvm-svn: 84420
2009-10-18 16:13:48 +00:00
Benjamin Kramer 61f5d0cb15 CIndex: compute ClangPath lazily.
llvm-svn: 84419
2009-10-18 16:11:04 +00:00
Benjamin Kramer 2836c4ccb6 CIndex: replace fork/exec with our portable ExecuteAndWait wrapper.
llvm-svn: 84414
2009-10-18 11:19:36 +00:00
Benjamin Kramer 817e7e4fb8 CIndex: avoid a dangling pointer issue.
llvm-svn: 84413
2009-10-18 11:10:55 +00:00
Daniel Dunbar cd23718ca1 Attempt to unbreak the MSVC build.
llvm-svn: 84381
2009-10-17 23:53:11 +00:00
Daniel Dunbar f997f1e896 Simplify (move guard to caller instead of callee).
llvm-svn: 84325
2009-10-17 09:04:56 +00:00
Ted Kremenek 5ccfc98d19 Fix compiler warning: "ISO C90 forbids mixed declarations and code"
llvm-svn: 84318
2009-10-17 06:42:15 +00:00
Ted Kremenek bbf7fa317a Fix warning: 'warning: C++ style comments are not allowed in ISO C90'
llvm-svn: 84317
2009-10-17 06:37:16 +00:00
Ted Kremenek 05729c2835 Resolve FIXME: delete the 'Program' object in the destructor of CIndexer.
llvm-svn: 84313
2009-10-17 06:21:47 +00:00
Ted Kremenek 8bcb1c6883 Add 'UseBumpPtrAllocator' flag to ASTUnit::LoadFromPCHFile() to cause the created ASTContext to use
its own BumpPtrAllocator to allocate ASTs.

Change clang_createTranslationUnit (CIndex) to pass 'UseBumpPtrAllocator = true' to
ASTUnit::LoadFromPCHFile().

llvm-svn: 84296
2009-10-17 00:34:24 +00:00
Douglas Gregor d3d923a0f2 Make CIndex and c-index-test a little bit more robust. The only
substantive change is that clang_getCursorSource() now returns the
file in which a macro was instantiated when the cursor points into a
macro instantiation, rather than crashing.

llvm-svn: 84275
2009-10-16 21:24:31 +00:00
Douglas Gregor 16bef857d9 Keep track of whether declararions were loaded from a precompiled
header or not via a new "PCHLevel" field in Decl. We currently use
this information to help CIndex filter out declarations that came from
a precompiled header (rather than from an AST file). Further down the
road, it can be used to help implement multi-level precompiled
headers.

llvm-svn: 84267
2009-10-16 20:01:17 +00:00
Ted Kremenek 51d06bbe5b Use an std::vector<> instead of an array of ARG_MAX size, as ARG_MAX may not be defined everywhere.
llvm-svn: 84220
2009-10-15 23:21:22 +00:00
Steve Naroff 44cd60eebe Make sure temporary files get unlinked.
llvm-svn: 84208
2009-10-15 22:23:48 +00:00
Ted Kremenek fb8e47323f Add missing #include for wait().
llvm-svn: 84207
2009-10-15 22:10:56 +00:00
Steve Naroff 1cfb96cd14 Minor improvement to format...no functionality change.
llvm-svn: 84203
2009-10-15 20:50:09 +00:00
Steve Naroff 7781daa4e0 Implement <rdar://problem/7303432> [Clang/Index] In-memory-style AST generation API (initial API implementation).
Added clang_createTranslationUnitFromSourceFile().
Changed clang_createIndex() to lookup the location of clang (using dladdr).

llvm-svn: 84198
2009-10-15 20:04:39 +00:00
Mike Stump 904ad90bc8 Set up include paths for VC++ and Cygwin headers, along with the
existing MinGW headers, plus the newer 4.4.0 version.  Patch by John
Thompson.

llvm-svn: 83594
2009-10-08 23:29:47 +00:00
Douglas Gregor 084a654334 Make sure that c-index-test links as a C++ executable
llvm-svn: 83335
2009-10-05 22:29:42 +00:00
Douglas Gregor 629f4811a0 Make sure that libCIndex links as a C++ library
llvm-svn: 83331
2009-10-05 22:25:29 +00:00
Eric Christopher c2ac4f020b Fix C90 compile warning about mixed declarations and code.
llvm-svn: 83327
2009-10-05 21:33:42 +00:00
Steve Naroff d7eb7179a2 - Fix assert in clang_getCursorDecl (having to do with recently added ObjC_ProtocolRef).
- Make sure CHECK: lines in test case match the expected output. 

llvm-svn: 83316
2009-10-05 17:58:19 +00:00
Rafael Espindola e7178953f9 Add a -nostdclanginc flag to clang-cc that prevents it from searching
its own binary-relative headers. Useful when using clang's preprocessor
with gcc.

llvm-svn: 83302
2009-10-05 13:12:17 +00:00
Steve Naroff a6c56bb849 Add support for class and protocol references.
llvm-svn: 83186
2009-10-01 00:31:07 +00:00
Argyrios Kyrtzidis 419e38bbe2 When pointing at a type decl reference, ASTLocation is a NamedDeclRef.
llvm-svn: 83099
2009-09-29 19:45:58 +00:00
Argyrios Kyrtzidis 4cbe85904c Modify ASTLocation and apart from being a Decl or Stmt, allow it to also be:
-A NamedDecl reference
-A TypeLoc

llvm-svn: 83095
2009-09-29 19:44:27 +00:00
Douglas Gregor 63b3556c9c Set GNUMode only for the "gnu" language standard options, from Ken Dyck!
llvm-svn: 83064
2009-09-29 14:42:43 +00:00