Commit Graph

1279 Commits

Author SHA1 Message Date
Daniel Dunbar 76fa840d09 Driver/Frontend: Add support for -mllvm, which forwards options to the LLVM option parser.
- Note that this is a behavior change, previously -mllvm at the driver level forwarded to clang -cc1. The driver does a little magic to make sure that '-mllvm -disable-llvm-optzns' works correctly, but other users will need to be updated to use -Xclang.

llvm-svn: 101354
2010-04-15 06:09:03 +00:00
Ted Kremenek 9e0cf0978c Add optional timing logging for code completion results. This causes a UDP packet
containing the time taken for the code completion to be sent to a designated server
(which is specified using a compile-time -D flag).

llvm-svn: 101326
2010-04-15 01:02:28 +00:00
Ted Kremenek 225b8e39f1 Add cursor kind for C++ methods.
llvm-svn: 101193
2010-04-13 23:39:06 +00:00
Ted Kremenek 4ed2925b91 Add 'clang_getCursorLanguage' to return the "language" of the AST element (e.g., distinguish between C and Objective-C language features). Currently this only returns results for declarations.
llvm-svn: 101070
2010-04-12 21:22:16 +00:00
Ted Kremenek 601f6d5b59 Sort exports file.
llvm-svn: 101069
2010-04-12 21:22:10 +00:00
Benjamin Kramer 0644145373 Prune includes.
llvm-svn: 101059
2010-04-12 19:45:50 +00:00
Ted Kremenek 2908a20d86 Add initial USR support for macro definitions.
llvm-svn: 100997
2010-04-11 22:20:34 +00:00
Ted Kremenek 74c4389ea6 Augment clang_getCursorUSR() to not always expect that clang_getCursorDecl() does the right
thing if the cursor is not a decl (such as in the case of macros).

llvm-svn: 100996
2010-04-11 22:20:26 +00:00
Ted Kremenek 33b9a42f41 Add CIndex support for blocks.
llvm-svn: 100989
2010-04-11 21:47:37 +00:00
Benjamin Kramer 31160e8469 CIndex: move extractUSRSuffix out of extern "C" and simplify it.
llvm-svn: 100773
2010-04-08 15:54:07 +00:00
Daniel Dunbar 8ee6760971 Fronted: Kill overly specialized RecordLayoutDumper, just make -dump-record-layouts a bit that Sema honors.
llvm-svn: 100747
2010-04-08 02:59:56 +00:00
Chris Lattner 1f054ecca2 update for api change.
llvm-svn: 100718
2010-04-07 23:12:35 +00:00
Ted Kremenek 6ca136a77f Fix CIndex crash on invalid code reported in <rdar://problem/7833619>.
llvm-svn: 100589
2010-04-07 00:27:13 +00:00
Ted Kremenek 7deb7050d5 Fix ccc-analyzer's handling of quoted arguments in the build command. Fixes PR 6791.[B
llvm-svn: 100551
2010-04-06 19:41:24 +00:00
Chris Lattner 6d67213ebb reduce indentation, tidy.
llvm-svn: 100537
2010-04-06 17:52:14 +00:00
Douglas Gregor 7f95d26e53 Make Diagnostic reference-counted, which is simpler than juggling
maybe-ownership vs. ownership.

llvm-svn: 100498
2010-04-05 23:52:57 +00:00
Chris Lattner 61955ab200 inline in MC assembly parsers. clang -integrated-as now
works with inline asm!

llvm-svn: 100493
2010-04-05 23:33:20 +00:00
Chris Lattner 58c79341ab Match MemoryBuffer API changes.
llvm-svn: 100484
2010-04-05 22:42:27 +00:00
Douglas Gregor d03e823fb4 Clarify the ownership semantics of the Diagnostic object used by
ASTUnit. Previously, we would end up with use-after-free errors
because the Diagnostic object would be creating in one place (say,
CIndex) and its ownership would not be transferred into the
ASTUnit. Fixes <rdar://problem/7818608>.

llvm-svn: 100464
2010-04-05 21:10:19 +00:00
Douglas Gregor a2433154c8 Minor ASTUnit cleanups:
- Rename "Diagnostics" and related to "StoredDiagnostics", to better
  capture what we're actually storing.
  - Move SourceManager and FileManager to the heap.

llvm-svn: 100441
2010-04-05 18:10:21 +00:00
Douglas Gregor f3df985ba7 Code completion results that refer to macros now get the cursor kind
of macro definitions when passed to CIndex. Add test for code
completion of macros via CIndex.

llvm-svn: 100431
2010-04-05 16:10:30 +00:00
Daniel Dunbar e43887bd2b Driver: Add support for a CLANGXX_IS_PRODUCTION build variable, which enable
Clang++ support, even in "Production" mode (for testing purposes).

llvm-svn: 100119
2010-04-01 18:21:41 +00:00
Douglas Gregor a771f46c82 Reinstate my CodeModificationHint -> FixItHint renaming patch, without
the C-only "optimization".

llvm-svn: 100022
2010-03-31 17:46:05 +00:00
Douglas Gregor 30e631862f Revert r100008, which inexplicably breaks the clang-i686-darwin10 builder
llvm-svn: 100018
2010-03-31 17:25:35 +00:00
Douglas Gregor 3baad0d4f7 Rename CodeModificationHint to FixItHint, since we've been using the
term "fix-it" everywhere and even *I* get tired of long names
sometimes. No functionality change.

llvm-svn: 100008
2010-03-31 15:31:50 +00:00
Douglas Gregor 171b780c91 Teach Clang's -cc1 option -print-stats to print LLVM statistics.
llvm-svn: 99894
2010-03-30 17:33:59 +00:00
Chris Lattner 09f8cc8c70 make -ftime-report work even in -disable-free mode. Woo, finally.
rdar://7781603

llvm-svn: 99878
2010-03-30 05:39:52 +00:00
Ted Kremenek d76197a271 scan-build: set environment variable LDPLUSPLUS to 'c++-analyzer' to correctly link projects
with c++ code.

llvm-svn: 99684
2010-03-27 00:20:01 +00:00
Ted Kremenek 014e70b797 Return translation units from clang_createTranslationUnitFromSource()
if even they contain errors.

llvm-svn: 99594
2010-03-26 01:34:51 +00:00
Ted Kremenek 599d73aa72 Add c-index-test support for printing USRs.
llvm-svn: 99476
2010-03-25 02:00:39 +00:00
Ted Kremenek f64a38907d Require that all Clang-based USRs start with the prefix 'c:' for the "USR space".
llvm-svn: 99475
2010-03-25 02:00:36 +00:00
Douglas Gregor 023da0d43a Make sure that we have File IDs for all of the unsaved files before we
deserialize diagnostics.

llvm-svn: 99426
2010-03-24 21:04:06 +00:00
Daniel Dunbar 30b24e95fa Frontend: Don't free the CompilerInstance or FrontendActions when running under
-disable-free. Among other things, this fixes freeing of the LLVM module on
exit.
 - Note that this means we are disable-free'ing of a lot more stuff than we used to -- this should flush out bugs in anything left that is trying to do real work in its destructor. I did a mini-audit but '::~' is not totally uncommon.

llvm-svn: 99258
2010-03-23 05:09:16 +00:00
Douglas Gregor 7bf6b8a416 Use the cursor's ASTContext rather than the ASTContext computed from a
declaration, just in case invalid code makes the latter
incorrect. This may be the cause behind <rdar://problem/7777070>.

llvm-svn: 99179
2010-03-22 15:53:50 +00:00
Kovarththanan Rajaratnam a0170209af Use DEFINE_SYMBOL property to control dllexport/dllimport
llvm-svn: 99176
2010-03-22 15:44:38 +00:00
Daniel Dunbar 6a8efa8a79 Driver: Support CC_PRINT_OPTIONS, used for logging the compile commands (in -v style) to a file.
llvm-svn: 99054
2010-03-20 08:01:59 +00:00
Daniel Dunbar aef1db1d71 Fix unused variable warning.
llvm-svn: 99021
2010-03-20 01:11:56 +00:00
Douglas Gregor 3dc10b530e Optimize region-of-interest based cursor walks through the
preprocessed entities by grouping preprocessed entities by file
ID. This drastically improves performance of repeated
clang_getCursor() calls local tests, although it is a bit ugly.

llvm-svn: 99015
2010-03-20 00:41:21 +00:00
Douglas Gregor aae9224e49 Implement serialization and lazy deserialization of the preprocessing
record (which includes all macro instantiations and definitions). As
with all lay deserialization, this introduces a new external source
(here, an external preprocessing record source) that loads all of the
preprocessed entities prior to iterating over the entities.

The preprocessing record is an optional part of the precompiled header
that is disabled by default (enabled with
-detailed-preprocessing-record). When the preprocessor given to the
PCH writer has a preprocessing record, that record is written into the
PCH file. When the PCH reader is given a PCH file that contains a
preprocessing record, it will be lazily loaded (which, effectively,
implicitly adds -detailed-preprocessing-record). This is the first
case where we have sections of the precompiled header that are
added/removed based on a compilation flag, which is
unfortunate. However, this data consumes ~550k in the PCH file for
Cocoa.h (out of ~9.9MB), and there is a non-trivial cost to gathering
this detailed preprocessing information, so it's too expensive to turn
on by default. In the future, we should investigate a better encoding
of this information.

llvm-svn: 99002
2010-03-19 21:51:54 +00:00
Ted Kremenek 00da3b9a80 Teach clang_getCursorKindSpelling() about CXCursor_InvalidCode.
llvm-svn: 98982
2010-03-19 20:39:05 +00:00
Ted Kremenek e184ac5a66 Make the CIndex API more resilient to being used on invalid code.
llvm-svn: 98981
2010-03-19 20:39:03 +00:00
Daniel Dunbar 1c201fbf73 clang -cc1: Kill off -empty-input only, and replace with -init-only which is an
actual action.
 - This is easier to use, and more reliable for timing the thing this was
   actually meant to be useful for.

llvm-svn: 98978
2010-03-19 19:44:04 +00:00
Douglas Gregor 7f6d60dcc2 Optionally store a PreprocessingRecord in the preprocessor itself, and
tie its creation to a CC1 flag -detailed-preprocessing-record.

llvm-svn: 98963
2010-03-19 16:15:56 +00:00
Douglas Gregor 5272e80ce5 Visit preprocessing elements (macro instantiations and macro
definitions) as part of the translation unit, so that normal
visitation, token-annotation, and cursor-at retrieval all see
preprocessing elements.

llvm-svn: 98935
2010-03-19 05:22:59 +00:00
Bob Wilson 4f559a3042 Revert 98907 since it is breaking buildbots.
--- Reverse-merging r98907 into '.':
D    test/Index/c-index-getCursor-pp.c
U    tools/CIndex/CIndex.cpp

llvm-svn: 98929
2010-03-19 03:57:57 +00:00
Douglas Gregor 20004ee7d2 Visit preprocessing elements (macro instantiations and macro
definitions) as part of the translation unit, so that normal
visitation, token-annotation, and cursor-at retrieval all see
preprocessing elements.

llvm-svn: 98907
2010-03-19 00:18:31 +00:00
Douglas Gregor e56c353eb1 Try to appease MSVC's standard library
llvm-svn: 98878
2010-03-18 21:28:30 +00:00
Douglas Gregor 5810ead358 Try to appease MSVC
llvm-svn: 98875
2010-03-18 21:25:12 +00:00
Douglas Gregor 78ae2481b6 Explicitly link macro instantiations to macro definitions in the
preprocessing record. Use that link with clang_getCursorReferenced()
and clang_getCursorDefinition() to match instantiations of a macro to
the definition of the macro.

llvm-svn: 98842
2010-03-18 18:23:03 +00:00
Douglas Gregor 06d6d32762 Expose macro definitions as CIndex cursors. These can still only be
generated by clang_annotateTokens().

llvm-svn: 98837
2010-03-18 18:04:21 +00:00
Douglas Gregor 065f8d11ca Introduce the notion of a "preprocessing record", which keeps track of
the macro definitions and macro instantiations that are found
during preprocessing. Preprocessing records are *not* generated by
default; rather, we provide a PPCallbacks subclass that hooks into the
existing callback mechanism to record this activity.

The only client of preprocessing records is CIndex, which keeps track
of macro definitions and instantations so that they can be exposed via
cursors. At present, only token annotation uses these facilities, and
only for macro instantiations; both will change in the near
future. However, with this change, token annotation properly annotates
macro instantiations that do not produce any tokens and instantiations
of macros that are later undef'd, improving our consistency.

Preprocessing directives that are not macro definitions are still
handled by clang_annotateTokens() via re-lexing, so that we don't have
to track every preprocessing directive in the preprocessing record.

Performance impact of preprocessing records is still TBD, although it
is limited to CIndex and therefore out of the path of the main compiler.

llvm-svn: 98836
2010-03-18 17:52:52 +00:00
Douglas Gregor 02ded2a56c More token-annotation experimentation, preprocessing the annotated
token sequence to detect macro instantiations (that produce at least
token). WIP.

llvm-svn: 98826
2010-03-18 15:23:44 +00:00
Douglas Gregor 92a524fd47 Experimental stab at using relexing to identify preprocessor
directives while annotating tokens in CIndex. This functionality
should probably be factored out of this routine, but we're not there
yet. 

llvm-svn: 98786
2010-03-18 00:42:48 +00:00
Douglas Gregor 554e0b1ec2 Audit all callers of SourceManager::getBufferData(); fix the one that
needs better error recovery.

llvm-svn: 98667
2010-03-16 20:26:15 +00:00
Benjamin Kramer eb92dc0b09 Let SourceManager::getBufferData return StringRef instead of a pair of two const char*.
llvm-svn: 98630
2010-03-16 14:14:31 +00:00
Douglas Gregor e0fbb83b8b Give SourceManager a Diagnostic object with which to report errors,
and start simplifying the interfaces in SourceManager that can fail.

llvm-svn: 98594
2010-03-16 00:06:06 +00:00
Douglas Gregor 802b77601e Introduce a new BufferResult class to act as the return type of
SourceManager's getBuffer() (and similar) operations. This abstract
can be used to force callers to cope with errors in getBuffer(), such
as missing files and changed files. Fix a bunch of callers to use the
new interface.

Add some very basic checks for file consistency (file size,
modification time) into ContentCache::getBuffer(), although these
checks don't help much until we've updated the main callers (e.g.,
SourceManager::getSpelling()).

llvm-svn: 98585
2010-03-15 22:54:52 +00:00
Ted Kremenek bc1a67bee3 Rename clang_constructUSR_ObjCategory to clang_constructUSR_ObjCCategory.
(there was a missing 'C').

llvm-svn: 98554
2010-03-15 17:38:58 +00:00
Anton Korobeynikov 762c6b7346 Fix thinko and enable clang build on mingw again (hopefully)
llvm-svn: 98492
2010-03-14 12:55:35 +00:00
Benjamin Kramer f156b9d55d Revert 98439. There is a bad race condition in sys::Path::makeUnique on win32.
llvm-svn: 98452
2010-03-13 21:22:49 +00:00
Benjamin Kramer 84c37f9903 Make getTemporaryPath a static member of CIndexer and use it to replace tmpnam calls.
This fixes linker warnings on linux.

llvm-svn: 98439
2010-03-13 13:05:20 +00:00
Ted Kremenek d071c6019a Implement several CIndex functions for constructing USRs from C-strings instead of AST elements.
llvm-svn: 98421
2010-03-13 02:50:34 +00:00
Jeffrey Yasskin f6442f80cb Allow users to set CPPFLAGS and CXXFLAGS on the make command line.
Tested: make CPPFLAGS=-m64 CXXFLAGS=-m64 -j8 && (cd tools/clang;make test)
llvm-svn: 98399
2010-03-12 22:55:16 +00:00
Ted Kremenek ff9021b675 Implement clang_isUnexposed(), a predicate function to simplify filtering out
unexposed AST elements.

llvm-svn: 97985
2010-03-08 21:17:29 +00:00
Ted Kremenek adccbca23f Don't enable static analysis support for C++ by default. Users are
accidentally using it without realizing that it is nowhere close
to being generally usable and are reporting crashes that we
already know about.

llvm-svn: 97960
2010-03-08 19:06:44 +00:00
Kovarththanan Rajaratnam 4bc61181f9 Mark variable as const
llvm-svn: 97951
2010-03-08 18:33:04 +00:00
Douglas Gregor de4827dd34 Extend ObjCMessageExpr for class method sends with the source location
of the class name.

llvm-svn: 97943
2010-03-08 16:40:19 +00:00
Douglas Gregor 12852d9521 Keep track of type source information in the return type of an
Objective-C method declaration, e.g., for 

  - (Foo *)myMethod;

we now have TypeSourceInfo for the Foo*.

llvm-svn: 97942
2010-03-08 14:59:44 +00:00
Chris Lattner 03b3eba151 disable these dirs which rely on dynamic linking on mingw/cygwin
llvm-svn: 97892
2010-03-07 00:17:28 +00:00
Ted Kremenek a6d3ab394c Check if 'Unit' is NULL before trying to iterate over the diagnostics.
This obviates a null dereference that can occur when 'NumErrors'
is not zero.

llvm-svn: 97849
2010-03-05 22:43:29 +00:00
Ted Kremenek b39084072f Add clang version to crashtracer string.
llvm-svn: 97848
2010-03-05 22:43:25 +00:00
Douglas Gregor 0c7c2f8b4d A little hack to identify unwanted concurrency in CIndex
llvm-svn: 97831
2010-03-05 21:16:25 +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
Ted Kremenek 547f4172b7 Export clang_getCursorLinkage().
llvm-svn: 97647
2010-03-03 06:37:30 +00:00
Ted Kremenek fb4961dfd0 Add clang_getCursorLinkage(), which returns the
underlying linkage for the entity referred to by a
CXCursor.

llvm-svn: 97646
2010-03-03 06:36:57 +00:00
Charles Davis dde71b93da Pass -m32 and -m64 to the static analyzer when using scan-build. Now we can
use scan-build with Wine, for example.

Ted, I hope this is OK.

llvm-svn: 97566
2010-03-02 15:26:41 +00:00
Douglas Gregor 89a56c561f When given unsaved files in clang_createTranslationUnitFromSourceFile,
copy the source buffers provided rather than referencing them
directly, so that the caller can free those buffers immediately after
calling clang_createTranslationUnitFromSourceFile(). Otherwise, we
risk hitting those buffers later (when building source ranges, forming
diagnostics, etc.). 

llvm-svn: 97296
2010-02-27 01:32:48 +00:00
Daniel Dunbar cea0c70f12 Frontend: Pull CodeGenAction out more, and eliminate CreateBackendConsumer.
This is the way I would like to move the frontend function towards -- distinct
pieces of functionality should be exposed only via FrontendAction
implementations which have clean and relatively-stable APIs.

This also isolates the surface area in clang which depends on LLVM CodeGen.

llvm-svn: 97110
2010-02-25 04:37:45 +00:00
Daniel Dunbar 12ee380a61 Driver: Use TextDiagnosticPrinter instead of a custom one.
llvm-svn: 97102
2010-02-25 03:23:43 +00:00
Daniel Dunbar 253dbad1c9 Fix bogus diagnostic format string.
llvm-svn: 96978
2010-02-23 20:23:45 +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
Daniel Dunbar 43b464cfe5 Remove unused includes.
llvm-svn: 96760
2010-02-21 21:47:19 +00:00
Douglas Gregor e61e24a5e3 Attempt to fix the MSVC9 failure with c-indext-test, where the CIndex DLL
and the c-index-test executable end up getting different copies	of
stderr, causing	non-deterministic ordering of output. Fixed by
flushing the file after printing a diagnostic (only on Windows).

llvm-svn: 96754
2010-02-21 20:15:42 +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 6cb5ba4c4f Teach ASTUnit to keep track of temporary files, then delete them when
the ASTUnit itself is destroyed. Fixes <rdar://problem/7649385>.

llvm-svn: 96628
2010-02-18 23:35:40 +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
Ted Kremenek e21102523a Revert "Sort visitor methods so we can easily tell what's implemented."
This reverts commit 4383e04c75731f8695b8355783f9966ac56b0926.

llvm-svn: 96622
2010-02-18 22:36:18 +00:00
Ted Kremenek aaaf2bfffb Revert "Tidy up order of switch statement. No functionality change."
This reverts commit 95575005fc6409df98e6e079caf324308f62171b.

llvm-svn: 96620
2010-02-18 22:32:43 +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
Ted Kremenek fcb3db7d68 Tidy up order of switch statement. No functionality change.
llvm-svn: 96602
2010-02-18 18:52:18 +00:00
Ted Kremenek 7dff4163aa Sort visitor methods so we can easily tell what's implemented.
llvm-svn: 96600
2010-02-18 18:47:08 +00:00
Ted Kremenek 0e2930979d Change cursor behavior for attributes to have them visited as part of recursing
to the children of a Decl.

llvm-svn: 96599
2010-02-18 18:47:01 +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 6ab9aa02e3 Add basic cursor traversal for attributes. We currently don't have source
ranges for Attr objects, so lookup by cursor location currently doesn't work.

llvm-svn: 96571
2010-02-18 05:46:33 +00:00
Douglas Gregor 4db30233a8 Teach CMake to put the CIndex header into the Xcode/MSVC project
llvm-svn: 96566
2010-02-18 04:01:41 +00:00
Ted Kremenek bff31437ef Start adding cursor kinds for attributes, with first exposing
IBActionAttr and IBOutletAttr respectively.

llvm-svn: 96563
2010-02-18 03:09:07 +00:00
Ted Kremenek 896e164351 Don't make the inclusion of crashtracer information depend on NDEBUG.
llvm-svn: 96515
2010-02-17 21:12:23 +00:00
Daniel Dunbar d2b20c1348 clang: Add support for s// edit form of QA_OVERRIDE_GCC3_OPTIONS.
- Used to do regex patsubst on arguments.

llvm-svn: 96512
2010-02-17 21:00:34 +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 f441baf6dd Remove trailing spaces.
llvm-svn: 96427
2010-02-17 00:41:40 +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
Ted Kremenek 5cca6ebae9 Move createCXString() functions out of CIndexer and into the clang::cxstring namespace.
We can much more succinctly refer to these functions this way.

Also change the default behavior of createCXString(StringRef&) to duplicate the
string.  This is almost always what we want.  The other case is where we pass
a constant c-string, which uses the other version of createCXString().

llvm-svn: 96423
2010-02-17 00:41:08 +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 1951192213 ASTUnit: Constant fold UseBumpAllocator to true, we don't care to support this as an argument.
llvm-svn: 96316
2010-02-16 01:55:04 +00:00
Daniel Dunbar e922d9bdf0 CompilerInstance: Move LLVMContext member out of constructor.
llvm-svn: 96314
2010-02-16 01:54:47 +00:00
Daniel Dunbar aced322c3c Switch clang to use its own LLVMContext (not the global one).
llvm-svn: 96313
2010-02-16 01:54:33 +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 edeb9b87e6 CIndex: Avoid an unnecessary getLocForEndOfToken call, the region of interest
doesn't need to be a full token.
 - Doug, please review.

llvm-svn: 96161
2010-02-14 10:02:42 +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
Daniel Dunbar 2049933196 CIndex: Simplify (remove provably dead code).
llvm-svn: 96157
2010-02-14 08:32:11 +00:00
Daniel Dunbar 2f4ba179f5 CIndex: Inline CompareRegionOfInterest(CXSourceRange) into sole caller.
llvm-svn: 96156
2010-02-14 08:32:05 +00:00
Daniel Dunbar 80daf53600 Rename translateSourceRange(CXSourceRange) translateCXSourceRange, instead of
having overloaded functions with inverse semantics.

llvm-svn: 96155
2010-02-14 08:31:57 +00:00
Daniel Dunbar c4b4d3953c CIndex: Kill off CXSourceLocationPtr, and AtEnd arguments.
llvm-svn: 96145
2010-02-14 01:47:36 +00:00
Daniel Dunbar 474b207716 CIndex: Stop hiding magic end bit in CXSourceRange locations where clients can't
see it. Instead, translate the locations up-front when we create a
CXSourceRange.
 - This is part of a move to make CXSourceRange a pure half-open range, which is
   a more natural API for clients to deal with. More cleanups to follow.

llvm-svn: 96144
2010-02-14 01:47:29 +00:00
Ted Kremenek a3e657064b Make the following functions thread-safe but having them return an std::string that is reconstructed
every time they are called:

getClangRevision()
getClangFullRepositoryVersion()
getClangFullVersion()

llvm-svn: 96033
2010-02-12 22:54:40 +00:00
Ted Kremenek e9711db487 Two changes to scan-build:
(1) When no 'clang' is found with 'scan-build', remember the one from
the path as scan-build sees it, not the build system.  This prevents
us from finding different clangs during the build.

(2) Don't set LDPLUSPLUS when running xcodebuild; instead rely on the
clang driver to do the right thing.

llvm-svn: 95943
2010-02-12 00:12:25 +00:00
Ted Kremenek 14015de619 Add comments.
llvm-svn: 95942
2010-02-12 00:10:34 +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
Douglas Gregor 0a5a2216e2 Eliminate the ASTContext parameter from RecordDecl::getDefinition()
and CXXRecordDecl::getDefinition(); it's totally unnecessary. No
functionality change.

llvm-svn: 95836
2010-02-11 01:04:33 +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 62d311fdf4 Introduce a testbed for merging multiple ASTs into a single AST
context with the AST importer. WIP, still useless but at least it has
a test.

llvm-svn: 95683
2010-02-09 19:21:46 +00:00
Ted Kremenek 74cc62e161 Tweak output.
llvm-svn: 95676
2010-02-09 18:51:44 +00:00
Ted Kremenek 8de7a0efd1 Add a check for a running Xcode before modifying its configuration files.
llvm-svn: 95675
2010-02-09 18:46:58 +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
Ted Kremenek e52f932f5f Add some diagnostics for when we cannot update the original spec file.
llvm-svn: 95572
2010-02-08 21:19:27 +00:00
Ted Kremenek 94c5349ef2 Add a Python script to change what version of Clang is used by Xcode for static analysis (and ONLY static analysis).
llvm-svn: 95569
2010-02-08 20:54:01 +00:00
Ted Kremenek 6a93195783 Fix how scan-build finds c++-analyzer to work with checker builds.
llvm-svn: 95425
2010-02-05 20:34:14 +00:00
Ted Kremenek 01a83104a2 Now that the -cc1 options for analyzer checks have a structured naming, add back scanning for analyzer checks to scan-build.
llvm-svn: 95349
2010-02-05 02:18:39 +00:00
Ted Kremenek 2f2692f8ca Rename -cc1 option '-checker-cfref' to '-analyzer-check-objc-mem'.
llvm-svn: 95348
2010-02-05 02:06:54 +00:00
Ted Kremenek b6e400c87c Rename -cc1 option '-warn-objc-missing-dealloc' to '-analyzer-check-objc-missing-dealloc'.
llvm-svn: 95347
2010-02-05 01:59:21 +00:00
Ted Kremenek 61b506aa8f Rename -cc1 option '-warn-objc-methodsigs' to '-analyzer-check-objc-methodsigs'.
llvm-svn: 95346
2010-02-05 01:57:44 +00:00
Ted Kremenek 2d8ef71ae6 Rename -cc1 option '-warn-objc-unused-ivars' to '-analyzer-check-objc-unused-ivars'.
llvm-svn: 95345
2010-02-05 01:55:01 +00:00
Ted Kremenek d519b83757 Rename -cc1 option '-warn-dead-stores' to '-analyzer-check-dead-stores'.
llvm-svn: 95343
2010-02-05 01:52:40 +00:00
Ted Kremenek ec5b3d45c1 Rename -cc1 option '-warn-security-syntactic' to '-analyzer-check-security-syntactic'.
llvm-svn: 95342
2010-02-05 01:50:36 +00:00
Daniel Dunbar 92db0fbe5a clang -cc1: Wire up -emit-obj, for emitting object files.
llvm-svn: 95182
2010-02-03 01:18:43 +00:00
John McCall 2adddcae7e Remove abstract expression kinds from the StmtClass enum. Update a few users
appropriately.  Call out a few missing cases in the expression mangler.

llvm-svn: 95176
2010-02-03 00:55:45 +00:00
Daniel Dunbar 64ee535382 CIndex: Respect TMPDIR/TEMP/TMP when making temporary files for remapping. As a
side effect, this also fixes some cases on Windows where the file would end up
on a different drive, because tmpnam doesn't include the drive component. PR3837
strikes again.

llvm-svn: 95067
2010-02-02 05:19:57 +00:00
Daniel Dunbar a4a2e5dd5b CIndex: Fix a crash in clang_createTranslationUnitFromSourceFile when using
external ASTs, and the ASTUnit fails to load.

Also, move getLocationFromExpr outside extern "C" block.

llvm-svn: 95065
2010-02-02 05:00:22 +00:00
Sebastian Redl 5ca7984bb4 In C++, an initializer on a variable doesn't necessarily mean it's the definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function.
llvm-svn: 94999
2010-02-01 20:16:42 +00:00
Daniel Dunbar baf33fc56f CIndex/USRs: Disable a bogus assert, we don't want CIndex to crash liberally. I
have sent Ted a test case for this.

llvm-svn: 94935
2010-01-31 00:41:05 +00:00
Daniel Dunbar 83a2354c8b CIndex: Fix clang_equalLocations for change to ptr_data field.
llvm-svn: 94930
2010-01-30 23:58:27 +00:00
Daniel Dunbar 9ee3a92a75 CIndex: Fix diagnostic callback to not return SourceLocations with a reference to a temporary LangOptions object.
llvm-svn: 94928
2010-01-30 23:31:49 +00:00
Daniel Dunbar 854d36bd9b CIndex: Fix ReportSerializedDiagnostics to honor the DiagnosticClient contract
that diagnostics with a source location should occur inside
{Begin,End}SourceFile.

Note that code completion is currently passing in an invalid LangOptions object
due to its implementation, I need to sort this out with Doug.

llvm-svn: 94927
2010-01-30 23:31:40 +00:00
Chandler Carruth 7e6c0fcc59 Bring driver link order in CMake into alignment with the order in the Makefile.
This includes the fix in r94797 to reflect the new dependency of Sema on
Analysis.

llvm-svn: 94806
2010-01-29 10:03:42 +00:00
Zhongxing Xu 0fcbe369aa Fix linking problem on Linux.
llvm-svn: 94797
2010-01-29 03:25:47 +00:00
Anders Carlsson ba6c437d52 Add an CXXBindReferenceExpr (not used just yet).
llvm-svn: 94791
2010-01-29 02:39:32 +00:00
Douglas Gregor 69ff5dc0cb Harden the CIndex implementation a bit, so that it does not assert
when given bad inputs.

llvm-svn: 94769
2010-01-29 00:47:48 +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 ac0605e927 Introduce serialization and deserialization of diagnostic information
so that CIndex can report diagnostics through the normal mechanisms
even when executing Clang in a separate process. This applies both
when performing code completion and when using ASTs as an intermediary
for clang_createTranslationUnitFromSourceFile().

The serialized format is not perfect at the moment, because it does
not encapsulate macro-instantiation information. Instead, it maps all
source locations back to the instantiation location. However, it does
maintain source-range and fix-it information. To get perfect fidelity
from the serialized format would require serializing a large chunk of
the source manager; at present, it isn't clear if this code will live
long enough for that to matter.

llvm-svn: 94740
2010-01-28 06:00:51 +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
Chandler Carruth 2370ec6513 Fix libCIndex.so's lookup of the clang executable on CMake out-of-tree builds.
llvm-svn: 94668
2010-01-27 07:37:16 +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
Douglas Gregor 47751d6c21 Introduce clang_getInstantiationLocationOffset(), which decomposes a
source location in file + offset.

llvm-svn: 94497
2010-01-26 03:07:15 +00:00
Ted Kremenek 97a4537138 Pull functions that translate from CXSourceLocation to SourceLocation (and back) to a separate header file.
llvm-svn: 94462
2010-01-25 22:34:44 +00:00
Ted Kremenek 6dc73bc183 Fix include guard.
llvm-svn: 94447
2010-01-25 21:09:34 +00:00
Douglas Gregor 5bce76cd53 Loosen preconditions for clang_getCursorSpelling(), returning an empty
string when given a cursor that does not have a name. Also, don't give
silly names for statements and non-reference expressions.

llvm-svn: 94426
2010-01-25 16:56:17 +00:00
Douglas Gregor 33f1685607 Expect the impossible
llvm-svn: 94425
2010-01-25 16:45:46 +00:00
Douglas Gregor 7201f9f6b8 Visit the condition variables of while and for loops; also, visit the
condition even when we've visited the condition variable, so that
we'll see implicit conversions there.

llvm-svn: 94423
2010-01-25 16:12:32 +00:00
Ted Kremenek d6b8708643 Split libAnalysis into two libraries: libAnalysis and libChecker.
(1) libAnalysis is a generic analysis library that can be used by
    Sema.  It defines the CFG, basic dataflow analysis primitives, and
    inexpensive flow-sensitive analyses (e.g. LiveVariables).

(2) libChecker contains the guts of the static analyzer, incuding the
    path-sensitive analysis engine and domain-specific checks.

Now any clients that want to use the frontend to build their own tools
don't need to link in the entire static analyzer.

This change exposes various obvious cleanups that can be made to the
layout of files and headers in libChecker.  More changes pending.  :)

This change also exposed a layering violation between AnalysisContext
and MemRegion.  BlockInvocationContext shouldn't explicitly know about
BlockDataRegions.  For now I've removed the BlockDataRegion* from
BlockInvocationContext (removing context-sensitivity; although this
wasn't used yet).  We need to have a better way to extend
BlockInvocationContext (and any LocationContext) to add
context-sensitivty.

llvm-svn: 94406
2010-01-25 04:41:41 +00:00
Daniel Dunbar 2def7eb3ca CIndex: Don't crash when visitor passes null child statements, and sprinkle some
asserts in cursor construction functions to make this more obvious.

Doug, please check. c-index-test would previously crash on this code:
--
for(;;) {}
--
Do we need a custom visit of the for statement to cover the variable
declarations?

llvm-svn: 94391
2010-01-25 00:40:30 +00:00
Chris Lattner 0bcc858a2b -fno-rtti is now the default.
llvm-svn: 94379
2010-01-24 20:43:31 +00:00
Ted Kremenek 4c0df3dc1d Rename getClangFullVendorVersion() to getClangFullVersion().
llvm-svn: 94273
2010-01-23 02:11:34 +00:00
Douglas Gregor 625a515120 Teach the cursor visitor to recurse into the type information of
explicit casts, sizeof, alignof, and compound literals.

llvm-svn: 94265
2010-01-23 00:40:08 +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
Ted Kremenek c0f3f72fa4 Add 'clang_getClangVersion()' function to CIndex. This exposes the full Clang version string through the CIndex API.
llvm-svn: 94242
2010-01-22 22:44:15 +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 9ae8d349e6 Eliminate index-test; all of its tested functionality is now in c-index-test.
llvm-svn: 94211
2010-01-22 20:40:20 +00:00
Douglas Gregor 877524918a Eliminate CIndex's dependency on the Clang Index library, since we
weren't actually using any of its facilities.

llvm-svn: 94210
2010-01-22 20:35:53 +00:00
Douglas Gregor 562c1f9365 Teach CIndex's cursor visitor to restrict its traversal to a specific
region of interest (if provided). Implement clang_getCursor() in terms
of this traversal rather than using the Index library; the unified
cursor visitor is more complete, and will be The Way Forward.

Minor other tweaks needed to make this work:
  - Extend Preprocessor::getLocForEndOfToken() to accept an offset
  from the end, making it easy to move to the last character in the
  token (rather than just past the end of the token).
  - In Lexer::MeasureTokenLength(), the length of whitespace is zero.

llvm-svn: 94200
2010-01-22 19:49:59 +00:00
Douglas Gregor e1084fa2d2 Visit if, switch statements properly
llvm-svn: 94126
2010-01-22 01:00:11 +00:00
Douglas Gregor d824f8825b Teach the cursor visitor to walk all of the C and Objective-C
declarations that have enough source information to make such a walk
useful. This includes walking into variable initializers and enum
constants, the types behind typedefs, etc.

llvm-svn: 94124
2010-01-22 00:50:27 +00:00
Douglas Gregor 5e8cf37917 Teach the cursor visitor to walk statements and expressions, including
a few important subkinds. Now we're cookin' with gas!

llvm-svn: 94116
2010-01-21 23:27:09 +00:00
Douglas Gregor 6479fc4554 Teach the cursor visitor to walk into typeof types (both kinds). This
is hard to test now; tests will come when we can walk stataements and
expressions properly.

llvm-svn: 94099
2010-01-21 20:48:56 +00:00
Douglas Gregor d182431968 Teach the cursor visitor to walk into a variety of different TypeLoc
kinds, so that we see referenced types, protocols, classes, etc.

llvm-svn: 94085
2010-01-21 17:29:07 +00:00
Douglas Gregor 93f899509d Introduce type references into the C API, capturing references to
typedefs only (for now).

llvm-svn: 94078
2010-01-21 16:28:34 +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 58552bcd65 Eliminate the MakeCXCursor routines that require their callers to know too much about the cursor's storage
llvm-svn: 94049
2010-01-20 23:34:41 +00:00
Douglas Gregor 721e82edbc Kill CXEntity and CXDecl. The first has never been used, while the
second has been wholly replaced by cursors.

llvm-svn: 94039
2010-01-20 22:14:22 +00:00
Douglas Gregor dd969c897e Kill some CXDecl-related APIs that have been superceded by
CXCursor-based APIs.

llvm-svn: 94037
2010-01-20 21:45:58 +00:00
Douglas Gregor 990b576ec8 Kill clang_loadDeclaration() and clang_loadTranslationUnit().
llvm-svn: 94034
2010-01-20 21:37:00 +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 befc4a1658 Switch the internals of clang_loadTranslationUnit() over to the new
cursor-based traversal, and eliminate TUVisitor. We're now down to one
visitor for traversing the AST. Yay!

llvm-svn: 94025
2010-01-20 21:13:59 +00:00
Douglas Gregor 71f3d94391 Introduce a new, cursor-based traversal function that visits the
children of a given cursor, regardless of what kind of cursor it
is. This is a generalization of clang_loadDeclaration and
clang_loadTranslationUnit that will also extent to statements,
expressions, etc.

As proof-of-concept, switched clang_loadDeclaration() from its own
visitor over to an instance of this traversal function internally.

llvm-svn: 94022
2010-01-20 20:59:29 +00:00
Douglas Gregor b693f65c4d Remove some #if 0'd code that's never going to get used.
llvm-svn: 93957
2010-01-20 00:34:08 +00:00
Douglas Gregor 9074c3fe97 Kill off clang_getDeclColumn, clang_getDeclExtent, clang_getDeclLine,
clang_getDeclSource, and clang_getDeclSourceFile; the cursor
equivalents are the way of the future.

llvm-svn: 93955
2010-01-20 00:26:57 +00:00
Douglas Gregor d2fc7277be Introduce a special cursor kind for the translation unit, to serve as
the root of the conceptual cursor hierarchy (just like we do with
declarations). This will be used when we get to unify
clang_loadTranslationUnit() and clang_loadDeclaration() into something
more generally useful.

llvm-svn: 93954
2010-01-20 00:23:15 +00:00
Douglas Gregor 084236fafd Kill CXCursor_ObjCSelectorRef, CXCursor_VarRef, CXCursor_FunctionRef,
and CXCursor_EnumConstantRef; they've been subsumed by expression
references, which do a much nicer job.

llvm-svn: 93947
2010-01-19 23:25:01 +00:00