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

163 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 1b058e8956 Robustify PreprocessingRecord slightly, by only creating macro
instantiations when we have the corresponding macro definition and by
removing macro definition information from our table when the macro is
undefined. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99004 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 21:58:23 +00:00
Douglas Gregor 6a5a23f8e7 Implement serialization and lazy deserialization of the preprocessing
record (which includes all macro instantiations and definitions). As
with all lay deserialization, this introduces a new external source
(here, an external preprocessing record source) that loads all of the
preprocessed entities prior to iterating over the entities.

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99002 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 21:51:54 +00:00
Douglas Gregor 5de65721bd Fix a longstanding (but previously unknown) bug in the lazy
deserialization of precompiled headers, where the deserialization of
the source location entry for a buffer (e.g., macro instantiation
scratch space) would overwrite a one-element FileID cache in the
source manager. When tickled at the wrong time, we would return the
wrong decomposed source location and eventually cause c-index-test to
crash.

Found by dumb luck. It's amazing this hasn't shown up before.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98940 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 06:12:06 +00:00
Douglas Gregor 0396f46697 Visit preprocessing elements (macro instantiations and macro
definitions) as part of the translation unit, so that normal
visitation, token-annotation, and cursor-at retrieval all see
preprocessing elements.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98935 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 05:22:59 +00:00
Bob Wilson 3178cb674a Revert 98907 since it is breaking buildbots.
--- Reverse-merging r98907 into '.':
D    test/Index/c-index-getCursor-pp.c
U    tools/CIndex/CIndex.cpp


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98929 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 03:57:57 +00:00
Douglas Gregor 2507fa8416 Visit preprocessing elements (macro instantiations and macro
definitions) as part of the translation unit, so that normal
visitation, token-annotation, and cursor-at retrieval all see
preprocessing elements.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98907 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 00:18:31 +00:00
Douglas Gregor 3c26684d03 Try to appease MSVC's standard library
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98878 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 21:28:30 +00:00
Douglas Gregor 1a1f85a935 Try to appease MSVC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98875 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 21:25:12 +00:00
Douglas Gregor bf7efa2742 Explicitly link macro instantiations to macro definitions in the
preprocessing record. Use that link with clang_getCursorReferenced()
and clang_getCursorDefinition() to match instantiations of a macro to
the definition of the macro.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98842 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 18:23:03 +00:00
Douglas Gregor 572feb2a19 Expose macro definitions as CIndex cursors. These can still only be
generated by clang_annotateTokens().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98837 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 18:04:21 +00:00
Douglas Gregor 4ae8f298b1 Introduce the notion of a "preprocessing record", which keeps track of
the macro definitions and macro instantiations that are found
during preprocessing. Preprocessing records are *not* generated by
default; rather, we provide a PPCallbacks subclass that hooks into the
existing callback mechanism to record this activity.

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

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

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98836 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 17:52:52 +00:00
Douglas Gregor 4807231938 More token-annotation experimentation, preprocessing the annotated
token sequence to detect macro instantiations (that produce at least
token). WIP.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98826 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 15:23:44 +00:00
Douglas Gregor 9f1e3ff3b3 Experimental stab at using relexing to identify preprocessor
directives while annotating tokens in CIndex. This functionality
should probably be factored out of this routine, but we're not there
yet. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98786 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 00:42:48 +00:00
John McCall 7c2342dd4c When pretty-printing tag types, only print the tag if we're in C (and
therefore not creating ElaboratedTypes, which are still pretty-printed
with the written tag).

Most of these testcase changes were done by script, so don't feel too
sorry for my fingers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98149 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 11:27:22 +00:00
Douglas Gregor e0610a4941 Improve Objective-C token-annotation test
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98078 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-09 20:57:01 +00:00
Douglas Gregor 98146a6015 Add an Objective-C test for token annotation
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98056 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-09 13:06:04 +00:00
Douglas Gregor c2350e553b Extend ObjCMessageExpr for class method sends with the source location
of the class name.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97943 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-08 16:40:19 +00:00
Douglas Gregor 4bc1cb6aa6 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*.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97942 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-08 14:59:44 +00:00
Douglas Gregor c2a2b3c2c2 c-index-test's printing of linkage was completely broken, as was the
test of this functionality. The API worked great, though! :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97736 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-04 19:36:27 +00:00
Ted Kremenek 3bed527b10 Add '-test-print-linkage-source' option to c-index-test
to test clang_getCursorLinkage()

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97648 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03 06:37:58 +00:00
Douglas Gregor 51d07cb2f9 Don't use echo in the Index test, which I hope will work around an intermittent Windows failure
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97613 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03 00:03:22 +00:00
Douglas Gregor d1eabfb15c Robustify SourceManager::getLocation(), so that it returns an
end-of-line source location when given a column number beyond the
length of the line, or an end-of-file source location when given a
line number beyond the length of the file. Previously, we would return
an invalid location.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97299 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 02:42:25 +00:00
Douglas Gregor fdf321bfde De-XFAIL some win32 tests that are now passing
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96759 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 20:58:24 +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 1e0993c2ba XFAIL some of the c-index-test tests on Windows, where they are failing inexplicably
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96644 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19 01:10:48 +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 9e0493576a Allow GNU attributes to appear in an Objective-C method declaration
before the selector name (but after the return type).  Among other things,
this allows IBAction to be implemented with an attribute.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96623 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 23:05:16 +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 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 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
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 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 b217bcce14 XFAIL two tests on Win32 until some cares to investigate... the problem on
dyncast is just due to \r\n newline interaction w/ regexps. The remap-load.c
failure is a bit stranger (the end of the extent is on the next line), but I
don't care to investigate.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95071 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 05:41:30 +00:00
Daniel Dunbar 96a86600b4 CIndex: Use 'env' instead of relying on bash environment-variable setting
syntax.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95068 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 05:20:37 +00:00
Benjamin Kramer 7297c18c84 PCHReader doesn't implement classof so dyn_casting it will do really weird stuff. Use a static_cast instead.
I don't know if this hack is the right fix. Doug, please take a look.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94895 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-30 16:23:25 +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
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 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
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 3512107be5 Add test case for ? : crasher
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94429 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 17:48:13 +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 b988f9cde9 Move the type specifier location for elaborated-type-specifiers from
the tag kind (union, struct, class, enum) over to the name of the tag,
if there is a name, since most clients want to point at the name.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94424 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25 16:33:23 +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
Chris Lattner f091b4b843 disable this test, it is failing sporadically.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94344 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-24 00:30:31 +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