Commit Graph

1187 Commits

Author SHA1 Message Date
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
Bob Wilson 1f24ea15d0 Fix printing of parameterized Objective-C interfaces.
This change was accidentally omitted from Doug's change in r241541.

llvm-svn: 248975
2015-10-01 00:53:13 +00:00
Yaron Keren 91d1b11969 Relax test to allow for __attribute__((thiscall)). Under Win32 c-index-test output is
CXXMethod=foo:4:7 (unavailable) [type=int () __attribute__((thiscall))] [typekind=FunctionProto] [resulttype=int] [resulttypekind=Int] [isPOD=0]
CXXConstructor=Foo:5:3 (unavailable) [type=void () __attribute__((thiscall))] [typekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [isPOD=0]

llvm-svn: 248626
2015-09-25 22:09:07 +00:00
Manuel Klimek 8e3a7ede94 Fix bug on reporting availability of deleted methods in libclang.
Patch by Sergey Kalinichev.

llvm-svn: 248596
2015-09-25 17:53:16 +00:00
Richard Trieu c3096249c1 Improve the printing of ranges when macros are involved.
Trace the ranges through the macro backtrace better.  This allows better
range highlighting through all levels of the macro bracktrace.  Also some
improvements to backtrace printer for omitting different backtraces.

Patch by Zhengkai Wu.

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

llvm-svn: 248454
2015-09-24 01:21:01 +00:00
Argyrios Kyrtzidis 322d853d7d [sema] Fix assertion hit when using libclang to index a particular C++ snippet involving templates.
Assertion hit was in ClassTemplateSpecializationDecl::getSourceRange().

llvm-svn: 247373
2015-09-11 01:44:56 +00:00
Saleem Abdulrasool 79c6971cdf Index: expose visibility attribute
Expose the previously unexposed visibility attribute via the python and C
bindings.

llvm-svn: 246931
2015-09-05 18:53:43 +00:00
Manuel Klimek e0495d987c [libclang] Return deduced type for auto type, not the one written in the source.
It used to work, but was accidentally broken by r179769.
The issue with decayed types was fixed by r190796.
So this patch partially reverts r179769, and adds more tests.

This also fixes PR 18669.

Patch by Sergey Kalinichev.

llvm-svn: 246778
2015-09-03 16:11:10 +00:00
Argyrios Kyrtzidis 6c61288716 [libclang] For convenience to clients, make sure that nullability and __kindof annotations do not hide
the underlying type.

rdar://22063577

llvm-svn: 245867
2015-08-24 19:50:45 +00:00
Richard Smith 293534b1a5 Initialize the AST consumer as soon as we have both an ASTConsumer and an
ASTContext. Fixes some cases where we could previously initialize the AST
consumer more than once.

llvm-svn: 245346
2015-08-18 20:39:29 +00:00
Artem Belevich 194ba60fe2 [CUDA] Added stubs for new attributes used by CUDA headers.
The main purpose is to avoid errors and warnings while parsing CUDA
header files. The attributes are currently unused otherwise.

Differential version: http://reviews.llvm.org/D11690

llvm-svn: 244497
2015-08-10 20:33:56 +00:00
Filipe Cabecinhas 011e388d3c [tests] Remove calls to grep
llvm-svn: 244433
2015-08-10 07:01:11 +00:00
Richard Smith 0f99d6a441 [modules] PR22534: Load files specified by -fmodule-file= eagerly. In particular, this avoids the need to re-parse module map files when using such a module.
llvm-svn: 244416
2015-08-09 08:48:41 +00:00
Argyrios Kyrtzidis 3f84b7353b [test] Another attempt to fix the test.
llvm-svn: 244187
2015-08-06 01:06:55 +00:00
Argyrios Kyrtzidis 5365532b99 [test] Fix tests in non-darwin bots.
llvm-svn: 244176
2015-08-05 23:44:06 +00:00
Argyrios Kyrtzidis 09b9f0eb07 [test] Attempt a change to see if it fixes the test for the windows bot.
llvm-svn: 244076
2015-08-05 17:52:57 +00:00
Argyrios Kyrtzidis 819f9ffe85 [test/Index] Update libclang tests to use libclang for creating PCH files.
This is consistent and tests the primary configuration we want to test, libclang
creating and consuming PCH files.

llvm-svn: 244066
2015-08-05 17:23:59 +00:00
Argyrios Kyrtzidis e159a73c76 [test] Follow-up for r243119, also add a test case using property methods.
llvm-svn: 243455
2015-07-28 17:38:51 +00:00
Argyrios Kyrtzidis ac4803bb45 [test] Attempt to fix failing test in non-darwin bots.
llvm-svn: 243120
2015-07-24 17:18:25 +00:00