Commit Graph

11 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 579825a50a [libclang] When getting the cursor for an identifier inside a macro definition, check if
this was ever a macro name and return a specific CXCursor_MacroExpansion cursor in such a case,
instead of the generic CXCursor_MacroDefinition.

Checking for macro name makes sure the identifier is not part of the identifier list in a
function macro.
While, in general, resolving identifiers in macro definitions to other macros may not be completely accurate,
it greatly improves functionality such as give-me-the-definition-of-this, which was not working at all
inside macro definitions.

llvm-svn: 171773
2013-01-07 19:16:25 +00:00
Argyrios Kyrtzidis f77b0f8886 [libclang] Resolve a cursor that points to a macro name inside a #ifdef/#ifndef
directive as a macro expansion.

This is more of a "macro reference" than a macro expansion but it's close enough
for libclang's purposes. If it causes issues we can revisit and introduce a new
kind of cursor.

llvm-svn: 169666
2012-12-08 02:21:17 +00:00
Argyrios Kyrtzidis e552941316 [libclang] Fix getting a cursor inside an angled #include directive.
Fixed by pointing the end location of the preprocessed entity for the #include
at the closing '>', instead of the start of '<'.

rdar://11113134

llvm-svn: 163588
2012-09-11 02:17:21 +00:00
Argyrios Kyrtzidis 80f78b961a [libclang] Fix annotation and getting a "macro expansion" cursor
for a builtin macro expansion.

llvm-svn: 139298
2011-09-08 17:18:41 +00:00
Chandler Carruth 9e4704ab07 Update all of the libclang code corresponding to the preprocessor
MacroInstantiation -> MacroExpansion rename. Internally, everything is
switched.

Introduce a new cursor kind enum with the new name, but retain the old
name as an alias so that we don't break backwards compatibility.

Also update the debug printing routine to use 'macro expansions' as its
explicitly not guaranteed to be stable, and mechanically switch the test
cases over to that.

llvm-svn: 135140
2011-07-14 08:41:15 +00:00
Douglas Gregor 3046b4d72f In clang_getCursor(), don't override a preprocessing cursor within
another preprocessing cursor, since we want the outermost one.

llvm-svn: 121470
2010-12-10 07:23:11 +00:00
Douglas Gregor f88e35ba0b When using a precompiled preamble with detailed preprocessing records,
trap the serialized preprocessing records (macro definitions, macro
instantiations, macro definitions) from the generation of the
precompiled preamble, then replay those when walking the list of
preprocessed entities. This eliminates a bug where clang_getCursor()
wasn't able to find preprocessed-entity cursors in the preamble.

llvm-svn: 120396
2010-11-30 06:16:57 +00:00
Douglas Gregor 12a6c9e441 Update clang_getCursor() test to check searches on include directives
llvm-svn: 117063
2010-10-21 20:55:34 +00:00
Douglas Gregor 5272e80ce5 Visit preprocessing elements (macro instantiations and macro
definitions) as part of the translation unit, so that normal
visitation, token-annotation, and cursor-at retrieval all see
preprocessing elements.

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

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

llvm-svn: 98907
2010-03-19 00:18:31 +00:00