Commit Graph

1167 Commits

Author SHA1 Message Date
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
Douglas Gregor 8f40bbee78 Extend the CIndex API with direct support for expressions and
statements, moving some of the more unnatural kinds of references
(VarRef, EnumConstantRef, etc.) over to the expressions. We can now
poke at arbitrary expressions and statements with, e.g.,
clang_getCursor() and get back useful information (e.g., source
ranges).

llvm-svn: 93946
2010-01-19 23:20:36 +00:00
Douglas Gregor 7d1efeb43d Kill the unused and unnecessary CXCursor_MemberRef, twin to the
now-dead CXCursor_ObjCIvarRef.

llvm-svn: 93928
2010-01-19 22:15:34 +00:00
Douglas Gregor 015026e358 Kill CXCursor_ObjCIvarRef. Such cursors could never be created, and
have been marked for death for a while.

llvm-svn: 93927
2010-01-19 22:11:32 +00:00
Douglas Gregor accb183371 Introduce the notion of an "unexposed" declaration into the CIndex
API. This is a catch-all for any declaration known to Clang but not
specifically part of the CIndex API. We'll use the same approach with
expressions, statements, references, etc., as needed.

llvm-svn: 93924
2010-01-19 22:07:56 +00:00
Douglas Gregor 4f46e789b3 Rework the CXSourceLocation and CXSourceRange APIs. They are now
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.

llvm-svn: 93915
2010-01-19 21:36:55 +00:00
Douglas Gregor 6b8232ff82 Eliminate cursor kinds used to express definitions. Instead, provide
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.

llvm-svn: 93893
2010-01-19 19:34:47 +00:00
Douglas Gregor ad27e8b777 Introduce clang_getCursorReferenced, to get a cursor pointing at the
entity that a particular cursor references.

llvm-svn: 93830
2010-01-19 01:20:04 +00:00
Douglas Gregor 33c34ac19a Implement clang_getCursorExtent, which provides a source range for the
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.

llvm-svn: 93823
2010-01-19 00:34:46 +00:00
Douglas Gregor 7ecd020cf2 Teach clang_getCursorLocation() to return the locations of references
rather than the locations that refer to.

llvm-svn: 93812
2010-01-18 23:41:10 +00:00
Ted Kremenek 7161fc1e2f Tweak USR output for ObjC categories.
llvm-svn: 93805
2010-01-18 23:25:32 +00:00
Douglas Gregor 3338c1f5d2 Now that a reasonable deprecation cycle has passed, kill
clang_getCursorLine(), clang_getCursorColumn(),
clang_getCursorSource(), and clang_getCursorSourceFile() outright.

llvm-svn: 93801
2010-01-18 22:48:04 +00:00
Douglas Gregor 66a58819d1 Introduce clang_getCursorLocation(), which supercedes
clang_getCursorLine(), clang_getCursorColumn(),
clang_getCursorSource(), and clang_getCursorSourceFile(). Mark those 4
functions as deprecated and stop using them ourselves.

llvm-svn: 93800
2010-01-18 22:46:11 +00:00