Commit Graph

1205 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 66c49f78a3 [index] Fix regression where ObjC method declarations may mistakenly get indexed as definition.
rdar://25372906

llvm-svn: 265042
2016-03-31 20:18:22 +00:00
Ben Langmuir 443913f4d6 [index] Remove redundancy between symbol kind and language
Condense the ObjCKIND and CXXKIND options into just KIND, since the
language was already specified on a per-symbol basis and this
information was redundant. This only changes the internal
representation; naturally the libclang interface remains the same.

llvm-svn: 264423
2016-03-25 17:01:59 +00:00
Argyrios Kyrtzidis 6377e4e09a [index] Make sure that declarations of builtin functions are indexed.
rdar://25154630

llvm-svn: 263689
2016-03-17 04:28:19 +00:00
Argyrios Kyrtzidis 542f38f31f [index] libclang: Make sure to treat forward ObjC protocols as ObjCProtocolRef declarations, and fix related crash.
rdar://25035376

llvm-svn: 262985
2016-03-09 02:12:46 +00:00
Argyrios Kyrtzidis 0ad65ac816 [index] Fix assertion hit when indexing re-declarations of built-in functions.
llvm-svn: 262984
2016-03-09 02:12:40 +00:00
Argyrios Kyrtzidis 7332106499 [index] Distinguish USRs of anonymous enums by using their first enumerator.
rdar://24609949.

llvm-svn: 262695
2016-03-04 07:17:53 +00:00
Argyrios Kyrtzidis 2682f9e5de [index] Include parameter types in the USRs for C functions marked with 'overloadable' attribute.
llvm-svn: 262694
2016-03-04 07:17:48 +00:00
Argyrios Kyrtzidis 9c99867386 [index] In ObjC++ handle objc type parameters for function USRs.
llvm-svn: 262693
2016-03-04 07:17:43 +00:00
Argyrios Kyrtzidis 8757fc5594 [index] Ignore ObjCTypeParamDecls during indexing.
llvm-svn: 262686
2016-03-04 04:24:32 +00:00
Argyrios Kyrtzidis 34a0c1a572 [index] Report references of ObjC super class/protocols in interfaces and protocols.
llvm-svn: 262584
2016-03-03 05:33:54 +00:00
Argyrios Kyrtzidis d68a4d6ae0 [test] Re-enable asan on the test, stack usage should be lower.
llvm-svn: 262583
2016-03-03 05:33:48 +00:00
Manuel Klimek 0000eeceb6 Fix test breakage on windows where the default std is c++11 by forcing c++03 in the test.
llvm-svn: 262325
2016-03-01 12:53:18 +00:00
Manuel Klimek 016c024ca4 Optionally demote fatal errors to non-fatal errors.
This behavior is enabled when the new CXTranslationUnit_KeepGoing
option is passed to clang_parseTranslationUnit{,2}. It is geared
towards use by IDEs and similar consumers of the clang-c API where
fatal errors may arise when parsing incomplete code mid-edit, or
when include paths are not properly configured yet. In such situations
one still wants to get as much information as possible about a TU.
Previously, the semantic analysis would not instantiate templates
or report additional fatal errors after the first fatal error was
encountered.

Fixes PR24268.

Patch by Milian Wolff.

llvm-svn: 262318
2016-03-01 10:56:19 +00:00
Argyrios Kyrtzidis 14a79d7736 [test] After r262290 reducing stack usage, try re-enabling asan on the related test.
llvm-svn: 262295
2016-03-01 04:40:20 +00:00
Argyrios Kyrtzidis 113387e08e [index] Print and test module import references.
llvm-svn: 262208
2016-02-29 07:56:07 +00:00
Argyrios Kyrtzidis a8b51c1e20 [index] Add a caller relation for a call reference.
llvm-svn: 262207
2016-02-29 07:56:00 +00:00
Argyrios Kyrtzidis c97c7c88c0 [AST/RecursiveASTVisitor] Correction so that dataTraverseStmtPost will get called after the statement has been visited.
Fixes the indexing client of this.

llvm-svn: 262206
2016-02-29 07:55:55 +00:00
Argyrios Kyrtzidis d97ec18fe4 [index] Use ',' to separate symbol roles when printing.
llvm-svn: 262205
2016-02-29 07:55:51 +00:00
Argyrios Kyrtzidis d571908445 [AST/index] Introduce an option 'SuppressTemplateArgsInCXXConstructors' in printing policy.
Enable it for USRs and names when indexing.
Forward references can have different template argument names; including them
makes USRs and names unstable, since the name depends on whether we saw a forward reference or not.

llvm-svn: 260866
2016-02-15 01:32:36 +00:00
Argyrios Kyrtzidis 8756107f93 [test/Index] Set a specific target for the test.
llvm-svn: 260861
2016-02-14 22:38:38 +00:00
Argyrios Kyrtzidis ca741cef3e [index] Factor libclang's functionality to determing the mangled name of symbols into the clangIndex library.
llvm-svn: 260858
2016-02-14 22:30:14 +00:00
Argyrios Kyrtzidis 6fdcb9c590 [index] Enhance c-index-test tool and have it link and test the clangIndex library directly.
llvm-svn: 260842
2016-02-14 06:39:11 +00:00
Alexey Samsonov 9d30749446 Disable two tests that use a lot of stack under ASan.
llvm-svn: 260779
2016-02-13 01:02:59 +00:00
Ben Langmuir 6d25fdc41b [Modules] Don't infinite recurse on implicit import of circular modules in preamble
Update the Preprocessor's VisibleModuleSet when typo-correction creates
an implicit module import so that we won't accidentally write an invalid
SourceLocation into the preamble AST.  This would later lead to infinite
recursion when loading the preamble AST because we use the value in
ImportLocs to prevent visiting a module twice.

rdar://problem/24440990

llvm-svn: 260543
2016-02-11 17:04:42 +00:00
NAKAMURA Takumi 8d62f5c7ce clang/test/Index/skip-parsed-bodies/compile_commands.json: Appease targeting msvc.
llvm-svn: 260347
2016-02-10 01:45:51 +00:00
NAKAMURA Takumi cd4d945525 libclang: Enable skip-parsed-bodies on win32.
I guess it would be working since Rafael's r187619.

llvm-svn: 260344
2016-02-10 01:29:57 +00:00
Argyrios Kyrtzidis ca4ad1937c [libclang] indexing: make sure to not visit init-list expressions twice.
llvm-svn: 260255
2016-02-09 19:07:24 +00:00
Saleem Abdulrasool 5e03c655a3 Index: provide adjustment thunk information for C++ manglings
Add support for exposing the adjustment thunk for virtual methods as
appropriate.

llvm-svn: 260011
2016-02-06 22:36:34 +00:00
Argyrios Kyrtzidis 785705b399 [libclang] Introduce APIs for evaluating a cursor and checking if a macro is builtin/function.
rdar://24091595

llvm-svn: 257968
2016-01-16 00:20:02 +00:00
Sergey Kalinichev b8d516a8d9 [libclang] Handle AutoType in clang_getTypeDeclaration
Differential Revision: http://reviews.llvm.org/D13001

llvm-svn: 257043
2016-01-07 09:20:40 +00:00
Erik Verbruggen 8f9d180f09 Show inclusions from a preamble in clang_getInclusions.
When reparsing a translation unit with preamble generation turned on,
no includes are found. This is due to the fact that all SLocs from
AST/PCH files are skipped as they are 'loaded', and inclusions from a
preamble are also 'loaded'. So, in case a file has a preamble, it first
needs to process those loaded inclusions, and then check for any local
inclusions. This latter one is for any includes that are not part of the
preamble, like includes half-way through a file.

This fixes PR24748.

Differential Revision: http://reviews.llvm.org/D14329

llvm-svn: 256939
2016-01-06 15:12:51 +00:00
Benjamin Kramer 5c248d89f3 [libclang] Add a flag to create the precompiled preamble on the first parse.
Summary:
The current default is to create the preamble on the first reparse, aka
second parse. This is useful for clients that do not want to block when
opening a file because serializing the preamble takes a bit of time.
However, this makes the reparse much more expensive and that may be on the
critical path as it's the first interaction a user has with the source code.

YouCompleteMe currently optimizes for the first code interaction by parsing
the file twice when loaded. That's just unnecessarily slow and this flag
helps to avoid that.

Reviewers: doug.gregor, klimek

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15490

llvm-svn: 255635
2015-12-15 09:30:31 +00:00
Richard Smith 97047d8cb6 Preserve source location information for qualified names used in a constructor
initializer list to name a base class. Patch by Shahms King!

llvm-svn: 255420
2015-12-12 02:17:54 +00:00
Saleem Abdulrasool 8aa0b80ec7 libclang: expose dllexport, dllimport attributes
These attributes were previously unexposed.  Expose them through the libclang
interfaces.  Add tests that cover both the MSVC spelling and the GNU spelling.

llvm-svn: 255273
2015-12-10 18:45:18 +00:00
Saleem Abdulrasool d5af8ae17f libclang: correct inverted logic
The complete dtor is only emitted when there is a virtual destructor.  The test
itself was incorrect, so the issue in the code was not noticed.

llvm-svn: 255225
2015-12-10 06:30:23 +00:00
Ehsan Akhgari 93697fa755 Make clang_Cursor_getMangling not mangle if the declaration isn't mangled
Right now clang_Cursor_getMangling will attempt to mangle any
declaration, even if the declaration isn't mangled (extern C).  This
results in a partially mangled name which isn't useful for much. This
patch makes clang_Cursor_getMangling return an empty string if the
declaration isn't mangled.

Patch by Michael Wu <mwu@mozilla.com>.

llvm-svn: 253909
2015-11-23 19:56:46 +00:00
Argyrios Kyrtzidis a3e2ff19e5 [libclang] Make sure to use the raw module format for libclang parsing.
Fixes crash when passing '-gmodules' in the compiler options.
rdar://23588717

llvm-svn: 253645
2015-11-20 03:36:21 +00:00
Sergey Kalinichev 8f3b187e21 [libclang] Visit TypeAliasTemplateDecl
This makes TypeAliasTemplateDecl accessible via LibClang and python bindings

Differential Revision: http://reviews.llvm.org/D13844

llvm-svn: 253166
2015-11-15 13:48:32 +00:00
Sergey Kalinichev c015120b53 [libclang] Expose AutoType
Expose the AutoType via LibClang and python bindings

Differential Revision: http://reviews.llvm.org/D13000

llvm-svn: 253165
2015-11-15 13:10:10 +00:00
Ben Langmuir 90717ad731 [modules] Allow "redefinition" of typedef of anon tag from unimported submodule
r233345 started being stricter about typedef names for linkage purposes
in non-visible modules, but broke languages without the ODR.

rdar://23527954

llvm-svn: 253123
2015-11-14 03:26:14 +00:00
Richard Smith 26210db67f [modules] Follow the C++ standard's rule for linkage of enumerators: they have
the linkage of the enumeration. For enumerators of unnamed enumerations, extend
the -Wmodules-ambiguous-internal-linkage extension to allow selecting an
arbitrary enumerator (but only if they all have the same value, otherwise it's
ambiguous).

llvm-svn: 253010
2015-11-13 03:52:13 +00:00
Richard Smith 97135cc94a [modules] Simplify and generalize the existing rule for finding hidden
declarations in redeclaration lookup. A declaration is now visible to
lookup if:

 * It is visible (not in a module, or in an imported module), or
 * We're doing redeclaration lookup and it's externally-visible, or
 * We're doing typo correction and looking for unimported decls.

We now support multiple modules having different internal-linkage or no-linkage
definitions of the same name for all entities, not just for functions,
variables, and some typedefs. As previously, if multiple such entities are
visible, any attempt to use them will result in an ambiguity error.

This patch fixes the linkage calculation for a number of entities where we
previously didn't need to get it right (using-declarations, namespace aliases,
and so on).  It also classifies enumerators as always having no linkage, which
is a slight deviation from the C++ standard's definition, but not an observable
change outside modules (this change is being discussed on the -core reflector
currently).

This also removes the prior special case for tag lookup, which made some cases
of this work, but also led to bizarre, bogus "must use 'struct' to refer to type
'Foo' in this scope" diagnostics in C++.

llvm-svn: 252960
2015-11-12 22:19:45 +00:00
Saleem Abdulrasool 6003443b8e libclang: add clang_Cursor_getCXXManglings
This function permits the mangling of a C++ 'structor.  Depending on the ABI and
the declaration, the declaration may contain more than one associated symbol for
a given declaration.  This allows the consumer to retrieve all of the associated
symbols for the declaration the cursor points to.

llvm-svn: 252853
2015-11-12 03:57:22 +00:00
Douglas Gregor acf4fd3039 Stop back-patching 'readonly' Objective-C properties with 'readwrite' ones.
A 'readonly' Objective-C property declared in the primary class can
effectively be shadowed by a 'readwrite' property declared within an
extension of that class, so long as the types and attributes of the
two property declarations are compatible.

Previously, this functionality was implemented by back-patching the
original 'readonly' property to make it 'readwrite', destroying source
information and causing some hideously redundant, incorrect
code. Simplify the implementation to express how this should actually
be modeled: as a separate property declaration in the extension that
shadows (via the name lookup rules) the declaration in the primary
class. While here, correct some broken Fix-Its, eliminate a pile of
redundant code, clean up the ARC migrator's handling of properties
declared in extensions, and fix debug info's naming of methods that
come from categories.

A wonderous side effect of doing this write is that it eliminates the
"AddedObjCPropertyInClassExtension" method from the AST mutation
listener, which in turn eliminates the last place where we rewrite
entire declarations in a chained PCH file or a module file. This
change (which fixes rdar://problem/18475765) will allow us to
eliminate the rewritten-decls logic from the serialization library,
and fixes a crash (rdar://problem/23247794) illustrated by the
test/PCH/chain-categories.m example.

llvm-svn: 251874
2015-11-03 01:15:46 +00:00
Nico Weber b25423525c Suppress uninteresting output from crash-recovery-modules.m
No behavior change, but it makes this test a bit easier to debug when it fails.

llvm-svn: 251650
2015-10-29 20:43:31 +00:00
Saleem Abdulrasool 6ea75dbeb0 Index: expose is_mutable_field
Expose isMutable via libClang and python bindings.

Patch by Jonathan B Coe!

llvm-svn: 251410
2015-10-27 15:50:22 +00:00
John McCall 460ce58fa6 Define weak and __weak to mean ARC-style weak references, even in MRC.
Previously, __weak was silently accepted and ignored in MRC mode.
That makes this a potentially source-breaking change that we have to
roll out cautiously.  Accordingly, for the time being, actual support
for __weak references in MRC is experimental, and the compiler will
reject attempts to actually form such references.  The intent is to
eventually enable the feature by default in all non-GC modes.
(It is, of course, incompatible with ObjC GC's interpretation of
__weak.)

If you like, you can enable this feature with
  -Xclang -fobjc-weak
but like any -Xclang option, this option may be removed at any point,
e.g. if/when it is eventually enabled by default.

This patch also enables the use of the ARC __unsafe_unretained qualifier
in MRC.  Unlike __weak, this is being enabled immediately.  Since
variables are essentially __unsafe_unretained by default in MRC,
the only practical uses are (1) communication and (2) changing the
default behavior of by-value block capture.

As an implementation matter, this means that the ObjC ownership
qualifiers may appear in any ObjC language mode, and so this patch
removes a number of checks for getLangOpts().ObjCAutoRefCount
that were guarding the processing of these qualifiers.  I don't
expect this to be a significant drain on performance; it may even
be faster to just check for these qualifiers directly on a type
(since it's probably in a register anyway) than to do N dependent
loads to grab the LangOptions.

rdar://9674298

llvm-svn: 251041
2015-10-22 18:38:17 +00:00
Ehsan Akhgari f8d44de143 Make clang_Cursor_getMangling not mangle if the declaration isn't mangled
Right now clang_Cursor_getMangling will attempt to mangle any
declaration, even if the declaration isn't mangled (extern C).  This
results in a partially mangled name which isn't useful for much. This
patch makes clang_Cursor_getMangling return an empty string if the
declaration isn't mangled.

Patch by Michael Wu <mwu@mozilla.com>.

llvm-svn: 249639
2015-10-08 00:01:20 +00:00
Ehsan Akhgari c9d174fae5 Revert r249437
llvm-svn: 249440
2015-10-06 18:53:12 +00:00
Ehsan Akhgari 9d1f05aef8 Make clang_Cursor_getMangling don't mangle if the declaration isn't mangled
Right now clang_Cursor_getMangling will attempt to mangle any
declaration, even if the declaration isn't mangled (extern "C").  This
results in a partially mangled name which isn't useful for much. This
patch makes clang_Cursor_getMangling return an empty string if the
declaration isn't mangled.

Patch by Michael Wu <mwu@mozilla.com>.

llvm-svn: 249437
2015-10-06 18:24:33 +00:00