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

1198 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 274f1906f1 Rework the CIndex API for displaying diagnostics. Instead of printing
the diagnostics to a FILE*, return a CXString containing the formatted
diagnostic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96823 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22 23:17:23 +00:00
Daniel Dunbar 79b7f9af94 Remove unused includes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96760 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 21:47:19 +00:00
Douglas Gregor 5f8e1be5b5 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).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96754 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 20:15:42 +00:00
Douglas Gregor 473d7019bb Simplify the CIndex fix-it API, now that we have half-open CXSourceRanges.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96685 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 18:16:06 +00:00
Douglas Gregor 313e26c4e8 Teach ASTUnit to keep track of temporary files, then delete them when
the ASTUnit itself is destroyed. Fixes <rdar://problem/7649385>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96628 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 23:35:40 +00:00
Douglas Gregor 0a812cf707 Re-apply my diagnostics-capture patch for CIndex, with some tweaks to
try to address the msvc failures.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96624 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 23:07:20 +00:00
Ted Kremenek 79758f614c Revert "Sort visitor methods so we can easily tell what's implemented."
This reverts commit 4383e04c75731f8695b8355783f9966ac56b0926.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96622 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 22:36:18 +00:00
Ted Kremenek 6b3b514e31 Revert "Tidy up order of switch statement. No functionality change."
This reverts commit 95575005fc6409df98e6e079caf324308f62171b.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96620 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 22:32:43 +00:00
Douglas Gregor 436f3f0400 Revert my CIndex diagnostic changes (r96603, 96606, 96607), which were
breaking the msvc9 builder for unknown reasons.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96618 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 22:27:07 +00:00
Douglas Gregor b9c8a24d04 Introduce debugging/testing hook clang_enableStackTraces() into
CIndex, so that c-index-test to use it to call
lvm::sys::PrintStackTraceOnErrorSignal().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96607 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 20:22:25 +00:00
Douglas Gregor b271071337 Resurrect the displayDiagnostics parameter to clang_createIndex(), and
display captured diagnostics when we can't return an invalid
CXTranslationUnit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96606 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 20:11:31 +00:00
Douglas Gregor 4c58923ca9 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96603 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 19:08:21 +00:00
Ted Kremenek c4174cc4b9 Tidy up order of switch statement. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96602 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 18:52:18 +00:00
Ted Kremenek 4540c9c737 Sort visitor methods so we can easily tell what's implemented.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96600 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 18:47:08 +00:00
Ted Kremenek 539311e022 Change cursor behavior for attributes to have them visited as part of recursing
to the children of a Decl.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96599 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 18:47:01 +00:00
Douglas Gregor a88084b78f 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96592 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 18:08:43 +00:00
Ted Kremenek 09dfa37dda 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96571 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 05:46:33 +00:00
Douglas Gregor f14bee8dc2 Teach CMake to put the CIndex header into the Xcode/MSVC project
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96566 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 04:01:41 +00:00
Ted Kremenek e77f443dbc Start adding cursor kinds for attributes, with first exposing
IBActionAttr and IBOutletAttr respectively.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96563 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 03:09:07 +00:00
Ted Kremenek 6b5699969d Don't make the inclusion of crashtracer information depend on NDEBUG.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96515 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 21:12:23 +00:00
Daniel Dunbar 0de9a7beb1 clang: Add support for s// edit form of QA_OVERRIDE_GCC3_OPTIONS.
- Used to do regex patsubst on arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96512 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 21:00:34 +00:00
Ted Kremenek 2ef6f8f5a3 Convert clang_getCompletionChunkText() to return a CXString.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96439 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 01:42:24 +00:00
Ted Kremenek f0e23e8ad6 Remove trailing spaces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96427 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 00:41:40 +00:00
Ted Kremenek e68fff6fc0 Change clang_getCursorKindSpelling() to return a CXString
instead of a 'const char *'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96425 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 00:41:32 +00:00
Ted Kremenek 7484407241 Change clang_getFileName() to return a 'CXString' instead of 'const char *'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96424 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 00:41:20 +00:00
Ted Kremenek ee4db4fccb 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().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96423 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17 00:41:08 +00:00
Daniel Dunbar 9715082c88 c-index-test: Pass appropriate client data.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96317 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 01:55:10 +00:00
Daniel Dunbar b26d483a9f ASTUnit: Constant fold UseBumpAllocator to true, we don't care to support this as an argument.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96316 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 01:55:04 +00:00
Daniel Dunbar 42e9f8e498 CompilerInstance: Move LLVMContext member out of constructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96314 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 01:54:47 +00:00
Daniel Dunbar f25491dd27 Switch clang to use its own LLVMContext (not the global one).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96313 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 01:54:33 +00:00
Daniel Dunbar d52864bd33 CIndex: Switch CXSourceRange to proper half-open intervals.
- Doug, please review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96162 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 10:02:57 +00:00
Daniel Dunbar 19e4a07e73 CIndex: Avoid an unnecessary getLocForEndOfToken call, the region of interest
doesn't need to be a full token.
 - Doug, please review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96161 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 10:02:42 +00:00
Daniel Dunbar 8f0bf81c0f c-index-test: Unify and always print half-open extents.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96160 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 08:32:51 +00:00
Daniel Dunbar 2389eff264 c-index-test: Simplify file scanning code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96159 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 08:32:32 +00:00
Daniel Dunbar 51b058cb1e c-index-test: Unify syntax for printing extents. Yes, there were 4.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96158 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 08:32:24 +00:00
Daniel Dunbar ecaceb5ab8 CIndex: Simplify (remove provably dead code).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96157 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 08:32:11 +00:00
Daniel Dunbar f408f32aa9 CIndex: Inline CompareRegionOfInterest(CXSourceRange) into sole caller.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96156 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 08:32:05 +00:00
Daniel Dunbar 85b988fdfa Rename translateSourceRange(CXSourceRange) translateCXSourceRange, instead of
having overloaded functions with inverse semantics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96155 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 08:31:57 +00:00
Daniel Dunbar bb4a61a121 CIndex: Kill off CXSourceLocationPtr, and AtEnd arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96145 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 01:47:36 +00:00
Daniel Dunbar 76dd3c2ff2 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96144 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 01:47:29 +00:00
Ted Kremenek a2a9d6e4e5 Make the following functions thread-safe but having them return an std::string that is reconstructed
every time they are called:

getClangRevision()
getClangFullRepositoryVersion()
getClangFullVersion()

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96033 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 22:54:40 +00:00
Ted Kremenek 6492200c31 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95943 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 00:12:25 +00:00
Ted Kremenek 1d81ed9438 Add comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95942 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12 00:10:34 +00:00
Ted Kremenek 020a095de3 Attempt to always dispose of the CXIndex object in c-index-test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95864 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-11 07:41:25 +00:00
Douglas Gregor 952b017601 Eliminate the ASTContext parameter from RecordDecl::getDefinition()
and CXXRecordDecl::getDefinition(); it's totally unnecessary. No
functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-11 01:04:33 +00:00
Daniel Dunbar b1ffee6e57 c-index-test: Add "none" filter, useful for performance testing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95800 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-10 20:42:40 +00:00
Douglas Gregor 9bed879896 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95683 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 19:21:46 +00:00
Ted Kremenek 8d69937281 Tweak output.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95676 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 18:51:44 +00:00
Ted Kremenek 962da0baff Add a check for a running Xcode before modifying its configuration files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95675 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 18:46:58 +00:00
Douglas Gregor a3890baf12 Clean up the CIndex interface to diagnostic ranges. Thanks, Daniel!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95602 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08 23:11:56 +00:00
Ted Kremenek 757a9d1f00 Add some diagnostics for when we cannot update the original spec file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95572 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08 21:19:27 +00:00
Ted Kremenek 7aaa953581 Add a Python script to change what version of Clang is used by Xcode for static analysis (and ONLY static analysis).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95569 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08 20:54:01 +00:00
Ted Kremenek e01ca51f41 Fix how scan-build finds c++-analyzer to work with checker builds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95425 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 20:34:14 +00:00
Ted Kremenek 9f9e0dbc13 Now that the -cc1 options for analyzer checks have a structured naming, add back scanning for analyzer checks to scan-build.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95349 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 02:18:39 +00:00
Ted Kremenek 565e465c6d Rename -cc1 option '-checker-cfref' to '-analyzer-check-objc-mem'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95348 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 02:06:54 +00:00
Ted Kremenek 7909fc8833 Rename -cc1 option '-warn-objc-missing-dealloc' to '-analyzer-check-objc-missing-dealloc'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95347 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 01:59:21 +00:00
Ted Kremenek fa15be4cf9 Rename -cc1 option '-warn-objc-methodsigs' to '-analyzer-check-objc-methodsigs'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95346 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 01:57:44 +00:00
Ted Kremenek 2ade536f68 Rename -cc1 option '-warn-objc-unused-ivars' to '-analyzer-check-objc-unused-ivars'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95345 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 01:55:01 +00:00
Ted Kremenek cd9902bfb7 Rename -cc1 option '-warn-dead-stores' to '-analyzer-check-dead-stores'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95343 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 01:52:40 +00:00
Ted Kremenek fb3f893bc5 Rename -cc1 option '-warn-security-syntactic' to '-analyzer-check-security-syntactic'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95342 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 01:50:36 +00:00
Daniel Dunbar da1573f959 clang -cc1: Wire up -emit-obj, for emitting object files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95182 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 01:18:43 +00:00
John McCall 09cc141c89 Remove abstract expression kinds from the StmtClass enum. Update a few users
appropriately.  Call out a few missing cases in the expression mangler.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95176 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 00:55:45 +00:00
Daniel Dunbar 74198af85e 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95067 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 05:19:57 +00:00
Daniel Dunbar c29f4c3960 CIndex: Fix a crash in clang_createTranslationUnitFromSourceFile when using
external ASTs, and the ASTUnit fails to load.

Also, move getLocationFromExpr outside extern "C" block.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95065 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 05:00:22 +00:00
Sebastian Redl 31310a21fb 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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94999 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-01 20:16:42 +00:00
Daniel Dunbar a9f696da69 CIndex/USRs: Disable a bogus assert, we don't want CIndex to crash liberally. I
have sent Ted a test case for this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94935 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31 00:41:05 +00:00
Daniel Dunbar 90a6b9e1e4 CIndex: Fix clang_equalLocations for change to ptr_data field.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94930 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 23:58:27 +00:00
Daniel Dunbar 4914612675 CIndex: Fix diagnostic callback to not return SourceLocations with a reference to a temporary LangOptions object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94928 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 23:31:49 +00:00
Daniel Dunbar 35b8440f61 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94927 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 23:31:40 +00:00
Chandler Carruth e89d1d5be4 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94806 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 10:03:42 +00:00
Zhongxing Xu 0c98670e24 Fix linking problem on Linux.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94797 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 03:25:47 +00:00
Anders Carlsson eb60edffa1 Add an CXXBindReferenceExpr (not used just yet).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94791 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 02:39:32 +00:00
Douglas Gregor 2b37c9e6ca Harden the CIndex implementation a bit, so that it does not assert
when given bad inputs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94769 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 00:47:48 +00:00
Douglas Gregor 51c6d38455 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94768 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29 00:41:11 +00:00
Douglas Gregor d93256e556 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94740 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28 06:00:51 +00:00
Douglas Gregor 936ea3b590 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94714 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28 00:56:43 +00:00
Douglas Gregor 5352ac06d8 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94709 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28 00:27:43 +00:00
Chandler Carruth f1f70b479c Fix libCIndex.so's lookup of the clang executable on CMake out-of-tree builds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94668 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27 07:37:16 +00:00
Ted Kremenek 16b55a7169 Implement 'clang_getInclusions()' in CIndex. This API allows clients to walk the set of files included in a translation unit via the C API.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94575 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 19:31:51 +00:00
Douglas Gregor 46766dc31c Eliminate clang_getInstantiationLocationOffset(), and instead add an
offset parameter to clang_getInstantiationLocation(). 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94573 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 19:19:08 +00:00
Douglas Gregor 0045e9fe1f 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 18:31:56 +00:00
Ted Kremenek ce2ae88f83 Add 'PostVisitTU' callback hook to 'perform_test_load()' to allow a special callback after the translation unit has been loaded (and streamed).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94557 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 17:59:48 +00:00
Ted Kremenek e3ee02a324 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94556 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 17:55:33 +00:00
Douglas Gregor fc8ea23eb6 Introduce a CIndex API for lexing the raw tokens within a given source
range. The token-annotation function does nothing, yet.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94551 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 17:06:03 +00:00
Douglas Gregor e69517ce61 Introduce clang_getInstantiationLocationOffset(), which decomposes a
source location in file + offset.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94497 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26 03:07:15 +00:00
Ted Kremenek a297de20bd Pull functions that translate from CXSourceLocation to SourceLocation (and back) to a separate header file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94462 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 22:34:44 +00:00
Ted Kremenek 2cd10b071e Fix include guard.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94447 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 21:09:34 +00:00
Douglas Gregor 60cbfacd94 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94426 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 16:56:17 +00:00
Douglas Gregor fd64377225 Expect the impossible
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94425 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 16:45:46 +00:00
Douglas Gregor 263b47b627 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94423 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 16:12:32 +00:00
Ted Kremenek 1309f9a3b2 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94406 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 04:41:41 +00:00
Daniel Dunbar 54d67caeee 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?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94391 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 00:40:30 +00:00
Chris Lattner 0bb46d285c -fno-rtti is now the default.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94379 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-24 20:43:31 +00:00
Ted Kremenek a18f1b88a7 Rename getClangFullVendorVersion() to getClangFullVersion().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94273 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 02:11:34 +00:00
Douglas Gregor 336fd81e04 Teach the cursor visitor to recurse into the type information of
explicit casts, sizeof, alignof, and compound literals.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94265 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 00:40:08 +00:00
Douglas Gregor 4db64a461c Extend clang_createTranslationUnitFromSourceFile() to support creating
translation units that include unsaved files.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94258 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 00:14:00 +00:00
Ted Kremenek 04bb716aea Add 'clang_getClangVersion()' function to CIndex. This exposes the full Clang version string through the CIndex API.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94242 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 22:44:15 +00:00
Douglas Gregor b979034b10 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94226 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 21:44:22 +00:00
Douglas Gregor 9fb48de917 Eliminate index-test; all of its tested functionality is now in c-index-test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94211 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 20:40:20 +00:00
Douglas Gregor a030b7cf5e Eliminate CIndex's dependency on the Clang Index library, since we
weren't actually using any of its facilities.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94210 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 20:35:53 +00:00
Douglas Gregor 33e9abd210 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94200 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 19:49:59 +00:00
Douglas Gregor f5bab418ae Visit if, switch statements properly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94126 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 01:00:11 +00:00
Douglas Gregor 1ef2fc1888 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94124 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 00:50:27 +00:00
Douglas Gregor a59e390ed6 Teach the cursor visitor to walk statements and expressions, including
a few important subkinds. Now we're cookin' with gas!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94116 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 23:27:09 +00:00
Douglas Gregor 2332c117b1 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94099 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 20:48:56 +00:00
Douglas Gregor f20dfbcdaa Teach the cursor visitor to walk into a variety of different TypeLoc
kinds, so that we see referenced types, protocols, classes, etc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94085 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 17:29:07 +00:00
Douglas Gregor 7d0d40e588 Introduce type references into the C API, capturing references to
typedefs only (for now).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94078 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 16:28:34 +00:00
Douglas Gregor b2cd487561 Stash a CXXUnit pointer into each cursor. This allows us to simplify
the interface to clang_visitChildren() by eliminating the
CXTranslationUnit pointer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94051 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 23:57:43 +00:00
Douglas Gregor 5bfb8c128c Eliminate the MakeCXCursor routines that require their callers to know too much about the cursor's storage
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94049 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 23:34:41 +00:00
Douglas Gregor 04d1dd476a Kill CXEntity and CXDecl. The first has never been used, while the
second has been wholly replaced by cursors.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94039 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 22:14:22 +00:00
Douglas Gregor 78205d4bad Kill some CXDecl-related APIs that have been superceded by
CXCursor-based APIs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94037 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 21:45:58 +00:00
Douglas Gregor 002a528ab0 Kill clang_loadDeclaration() and clang_loadTranslationUnit().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94034 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 21:37:00 +00:00
Douglas Gregor e5b72bac83 Switch c-index-test from clang_loadDeclaration() and
clang_loadTranslationUnit() over to clang_visitChildren().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94031 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 21:32:04 +00:00
Douglas Gregor 7b691f3382 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!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94025 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 21:13:59 +00:00
Douglas Gregor b1373d03e4 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94022 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 20:59:29 +00:00
Douglas Gregor 09cd6ef46e Remove some #if 0'd code that's never going to get used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93957 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 00:34:08 +00:00
Douglas Gregor e0356b1083 Kill off clang_getDeclColumn, clang_getDeclExtent, clang_getDeclLine,
clang_getDeclSource, and clang_getDeclSourceFile; the cursor
equivalents are the way of the future.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93955 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 00:26:57 +00:00
Douglas Gregor 7eaa8ae869 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93954 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 00:23:15 +00:00
Douglas Gregor e0ca4baa1d Kill CXCursor_ObjCSelectorRef, CXCursor_VarRef, CXCursor_FunctionRef,
and CXCursor_EnumConstantRef; they've been subsumed by expression
references, which do a much nicer job.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93947 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 23:25:01 +00:00
Douglas Gregor 97b9872d57 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).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93946 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 23:20:36 +00:00
Douglas Gregor e8c7043f6c Kill the unused and unnecessary CXCursor_MemberRef, twin to the
now-dead CXCursor_ObjCIvarRef.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93928 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:15:34 +00:00
Douglas Gregor 5a5ec3a318 Kill CXCursor_ObjCIvarRef. Such cursors could never be created, and
have been marked for death for a while.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93927 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:11:32 +00:00
Douglas Gregor 301221313b 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93924 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:07:56 +00:00
Douglas Gregor 1db19dea8d 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93915 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 21:36:55 +00:00
Douglas Gregor b699866820 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93893 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 19:34:47 +00:00
Douglas Gregor c5d1e9375d Introduce clang_getCursorReferenced, to get a cursor pointing at the
entity that a particular cursor references.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93830 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 01:20:04 +00:00
Douglas Gregor a7bde20f8c 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93823 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 00:34:46 +00:00
Douglas Gregor f46034af49 Teach clang_getCursorLocation() to return the locations of references
rather than the locations that refer to.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93812 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 23:41:10 +00:00
Ted Kremenek e381c997e2 Tweak USR output for ObjC categories.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93805 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 23:25:32 +00:00
Douglas Gregor 547836fad9 Now that a reasonable deprecation cycle has passed, kill
clang_getCursorLine(), clang_getCursorColumn(),
clang_getCursorSource(), and clang_getCursorSourceFile() outright.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93801 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:48:04 +00:00
Douglas Gregor 98258afae6 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93800 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:46:11 +00:00
Ted Kremenek b82b3beda0 Refactor USR generation for TagDecls into a common method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93799 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:42:20 +00:00
Douglas Gregor 3c7313d96c Clean up the CIndex API slightly.
Renamed CXSourceFileLine to CXSourceLocation and added a CXFile, to
better match Clang's SourceLocation. Teach clang_getDeclExtent to fill
in the CXFile properly.

Renamed CXSourceExtent to CXSourceRange, to better match Clang's
SourceLocation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93783 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:13:09 +00:00
Ted Kremenek 6483a773db Explicitly not handle ObjCForwardProtocolDecl in GetCursorKind().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93779 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:07:45 +00:00
Ted Kremenek 3adca6d3f3 Tweak USR generation to handle anonymous bitfields.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93778 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:02:49 +00:00
Ted Kremenek cf84aa46de Replace clang_getDeclUSR() with clang_getCursorUSR(). Also remove printing 'contexts' from c-index-test output; it wasn't helpful and was extremely brittle.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93760 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 20:23:29 +00:00
Douglas Gregor e83b4c17b1 Make CMake's clang++ installation respect DESTDIR, based on a patch by
Ingmar Vanhassel. Fixes PR6046.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93741 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 18:27:29 +00:00
Daniel Dunbar 3f693d25d4 Don't build/install clang++ in CLANG_IS_PRODUCTION build mode yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93732 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 17:52:48 +00:00
Daniel Dunbar c81d718f60 Fix -Asserts warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93731 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 17:52:42 +00:00
Douglas Gregor 1adb082a70 Give ObjCClassRef cursors a sane representation, which is encapsulated
in CXCursor.cpp. With this sane representation, fix the class
reference that is part of Objective-C category declarations so that
the cursor's location matches up with the reference, not the class
being referred to.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93640 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 17:14:40 +00:00
Douglas Gregor 78db0cdd49 Use a sane encoding for CXCursor_ObjCProtocolRef, using the actual
source locations where the protocols were referenced rather than the
location of some random enclosing declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93637 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 15:44:18 +00:00
Douglas Gregor 2e331b938b Give CXCursor_ObjCSuperClassRef a sane encoding, which is only known
to CXCursor.cpp.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93634 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 14:00:32 +00:00
Ted Kremenek 10fa3ccf08 Add mapping from ObjCPropertDecl to CXCursorKind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93623 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 02:08:29 +00:00
Ted Kremenek deb06bd356 Remove 'default' case in switch statement in clang_getCursorKindSpelling(). This identified a missing case (warned by the compiler) and identified that CXCursor_FirstDecl didn't actually correspond to the first decl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93622 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 02:02:09 +00:00
Ted Kremenek 70ee542580 Remove TranslateKind and centralize Decl -> CXCursorKind in GetCursorKind(). This revealed a bunch of inconsistencies in how CXCursorKinds were being computed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93618 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 01:44:12 +00:00
Ted Kremenek edc8aa68ef Migrate Decl* -> cursorkind logic into CXCursor.cpp, and drastically tighten TUVisitor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93599 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 00:36:30 +00:00
Ted Kremenek 38afa4156c Remove unused code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93586 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 23:35:12 +00:00
Ted Kremenek c5b48b3319 Refactor USR logic for EnumDecls and RecordDecls so that both handle 'anonymous' declarations in the same way.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93585 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 23:34:31 +00:00
Ted Kremenek 6a659fb916 USR generation: look at the typedef of an anonymous struct (if any) when trying to generate a USR.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93572 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 23:08:25 +00:00
Douglas Gregor 283cae37b0 Make CXCursor's data opaque.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 21:56:13 +00:00
Ted Kremenek 16c440a377 Add CXCursor.[h,cpp]. These files will centralize the logic for creating/probing CXCursors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93547 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 20:35:54 +00:00
Ted Kremenek 5467b208d5 Add USR generation for enums.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93543 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 20:04:31 +00:00
Douglas Gregor f2c87bd036 Add -cursor-at=file:line:column command line option to c-index-test,
to directly check the results of clang_getCursor(). Also, start
migrating some index-test tests over to c-index test [*] and some
grep-using tests over to FileCheck.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93537 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 19:40:17 +00:00
Ted Kremenek 8b456e841e getLocationFromCursor: If a cursor is a reference and has a referringDecl, using the referringDecl for the location.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93520 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 18:24:18 +00:00
Ted Kremenek f462989fe8 Switch return site to use clang_getNullCursor().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93405 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14 01:51:23 +00:00
Ted Kremenek 2fee4e6446 Further tweak USR generation by shorting names and distinguish between namespaces and functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93404 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14 01:50:21 +00:00
Ted Kremenek fb48049fd5 Reorganize CIndex.cpp into clearer sections of functions, and add a utility function 'MakeCXCursor' to centralize the logic for creating CXCursor objects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93359 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 21:46:36 +00:00
Ted Kremenek b89e8f64e6 Add 'referringDecl' field to CXCursor to prepare the way to better model declaration references from other delcarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93343 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 19:59:20 +00:00
Ted Kremenek bb239b231b Add extra null check in clang_disposeString().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93328 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 18:45:36 +00:00
Daniel Dunbar 0397af277e cc1: Factor out CompilerInstance::ExecuteAction which has the majority of the
clang -cc1 logic for running an action against a set of options.
 - This should make it easier to build tools that have a clang -cc1 like
   interface, but aren't actually part of clang -cc1.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93282 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 00:48:06 +00:00
Daniel Dunbar a817b77bbb cc1: Lift creation of the FrontendAction higher.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93281 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 00:47:51 +00:00
Ted Kremenek dd6bcc5f79 Move definitions for visitor methods in CDeclVisitor out-of-line.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93276 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 00:22:49 +00:00
Ted Kremenek f128618615 Make method definitions in TUVisitor out-of-line, making it easy to tell what visitor methods are defined.
Generalize TUVisitor to take a general "root" and "iterator" callback; this is prep. work to merging TUVisitor and CDeclVisitor.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93275 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 00:13:47 +00:00
Ted Kremenek 7d40562f83 Add USR printing modes to c-index-test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93269 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 23:34:26 +00:00
Ted Kremenek 4a884fda19 Make clang_getDeclUSR() visible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93268 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 23:34:05 +00:00
Ted Kremenek c50277f748 Rename clang_getUSR() -> clang_getDeclUSR(). For now we take a CXDecl instead of a CXEntity.
Enhance USR generation a bit with support for records.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93267 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 23:33:42 +00:00
Ted Kremenek e9cde116a9 Further tweaking of USR generation. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93250 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 19:35:53 +00:00
Ted Kremenek 98271567b6 Make 'CXTranslationUnitIterator' an argument to perform_test_load(),
perform_test_load_tu(), and perform_test_load_source().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 18:53:15 +00:00
Benjamin Kramer 9895c6ab2a Remove trailing semicolons and silence MSVC warning about C linkage.
warning C4190: 'GetEntity' has C-linkage specified, but returns UDT
'clang::idx::Entity' which is incompatible with C


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93237 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 11:32:40 +00:00
Daniel Dunbar 140fce2e7f Remove duplicate class name, MSVC doesn't like this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93225 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 02:34:07 +00:00
Ted Kremenek 8776382f7e Add a boilerplate implementation for clang_getUSR(). WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93223 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 02:07:58 +00:00
Ted Kremenek 1fc00e6e49 Change clang_getUSR() to return a CXString instead of a 'const char *'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93213 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 00:38:53 +00:00
Ted Kremenek 4b333d2215 Make createCXString() a static member function of class CIndex.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93212 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 00:36:38 +00:00
Ted Kremenek 3172383341 CIndex:
- Remove unused (and unimplemented) clang_getDeclarationName().
- Remove unused (and unimplemented) clang_getEntity().
- Add clang_getEntityFromDecl(): maps from a CXDecl to a CXEntity)
- Add clang_getDeclaration(): maps from a (CXEntity, CXTranslationUnit) to a CXDecl).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93209 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 23:56:39 +00:00
Douglas Gregor 01dfea02d1 Improve code completion by introducing patterns for the various C and
C++ grammatical constructs that show up in top-level (namespace-level)
declarations, member declarations, template declarations, statements,
expressions, conditions, etc. For example, we now provide a pattern
for

  static_cast<type>(expr)

when we can have an expression, or

  using namespace identifier;

when we can have a using directive.

Also, improves the results of code completion at the beginning of a
top-level declaration. Previously, we would see value names (function
names, global variables, etc.); now we see types, namespace names,
etc., but no values.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 23:08:15 +00:00
Ted Kremenek 6ab9db10c5 For now, add back clang_getDeclSource().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93003 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 17:11:32 +00:00
Ted Kremenek 254ba7cd3b More crashtracer enhancements to CIndex. When "popping" a crashtracer string
restore to the one most recently created.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92959 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 23:13:53 +00:00
Ted Kremenek 29b7284c98 Tidy up crashtracer logic in CIndex.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92955 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 22:49:05 +00:00
Ted Kremenek 9096a20fc0 Add FileCheck prefix to another location in the output of c-index-test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92890 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 01:17:12 +00:00
Ted Kremenek d8210650ed Change clang_getDeclExtent() to have the endpoint point to the last character in the last token.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92869 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 23:43:31 +00:00
Daniel Dunbar 378d4baf37 Add _clang_getDeclExtent to export list.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92825 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 05:41:00 +00:00
Ted Kremenek 8a8da7d17d Add enhanced crash reporter breadcrumbs for clang_createTranslationUnitFromSourceFile().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92820 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 03:42:32 +00:00
Ted Kremenek 377adb6cff Remove unused variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92804 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 23:22:20 +00:00
Ted Kremenek 817db7cb9b Remove deprecated function 'clang_getDeclSource()'. Use 'clang_getDeclFile()' instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92803 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 23:21:30 +00:00
Ted Kremenek fe6fd3d41a Add C API hook 'clang_getDeclExtent()', which returns the source extent of a declaration. This implements <rdar://problem/7280072>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92802 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 23:18:49 +00:00
Ted Kremenek 1b6869a183 Split (mostly nonexistent) USR code out from the main CIndex logic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92789 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 22:06:45 +00:00
Ted Kremenek db3d0da170 Add back #include of 'cstdio' to hopefully unbreak the build on Linux.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92765 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 20:55:39 +00:00
Ted Kremenek ab1889321f Split code in CIndex.cpp into multiple source files, and remove some unnecessary #includes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92756 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 19:32:54 +00:00
Douglas Gregor 1733c35f44 Turn on code-completion for macros within CIndex
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92500 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 19:45:17 +00:00
Daniel Dunbar 0dea4be511 Driver: Use "g++" as generic gcc name when running in C++ mode, for platforms
that lack real tool definitions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92164 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-25 20:21:23 +00:00
Kovarththanan Rajaratnam 49ac8e63a0 Remove RewriteBlocks. It has been superseded by RewriteObjC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92014 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 18:03:34 +00:00
Ted Kremenek 20b4a58e52 Add c++-analyzer symlink (which is used by scan-build)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91937 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 23:00:32 +00:00
Douglas Gregor ff5ce6eefc Extend code-completion results with the type of each result
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 18:53:37 +00:00
Douglas Gregor ec6762c709 Change clang_codeComplete API to return the results in a structure on
the heap, so that clients are not forced to copy the results during
the initial iteration. A separate clang_disposeCodeCompleteResults
function frees the returned results.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91690 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 16:20:58 +00:00
Chandler Carruth 4da689a025 Test for errors during fread() inside c-index-test and handle them
appropriately. This also silences some pedantic GCC warnings.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91596 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 09:18:43 +00:00
Ted Kremenek 79433b5991 Compute the right extension for preprocessed Objective-C++ files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91547 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 18:32:41 +00:00
Daniel Dunbar 3055be7e5a Fix pretty stack traces.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91537 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 11:47:38 +00:00
Ted Kremenek 51b939fe14 Add logic for computing preprocessor file extensions for C++ files.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91505 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 05:02:47 +00:00
Ted Kremenek 51365b5f74 scan-build/ccc-analyzer: start analyzing C++ FTW.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91398 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 02:35:54 +00:00
Daniel Dunbar 8b9adfea5e Add -resource-dir to clang -cc1, this allows the base directory for compiler
resources (e.g., /usr/lib/clang/1.1) to be passed on the command line instead of
computed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91370 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 00:06:45 +00:00