Commit Graph

509 Commits

Author SHA1 Message Date
Craig Topper b1e0a551b2 [Sema] Use getLangOpts in Sema instead of Preprocessor. Call getTargetInfo on the AST context instead of Preprocessor. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253175 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-15 17:27:57 +00:00
Sergey Kalinichev 2c0b7d1511 [libclang] Visit TypeAliasTemplateDecl
This makes TypeAliasTemplateDecl accessible via LibClang and python bindings

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253166 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-15 13:48:32 +00:00
John McCall abdd82457f 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251041 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 18:38:17 +00:00
Argyrios Kyrtzidis b1c7d8a207 [code-completion] Strip outer nullability annotations when completing method implementations.
The outer nullability is transferred from the declaration to the implementation so including them is redundant.
The inner ones are not transferred so they are kept to match the exact types. When we transfer the inner ones as well
adding them in the implementation will become redundant and we should strip those as well.

rdar://21737451

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@243119 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-24 17:00:19 +00:00
Benjamin Kramer e2948658dc [CodeCompletion] Don't crash on member inits of templated constructors.
Also fixes a crash (on invalid) member functions with a colon
initializer. PR23948.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241811 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-09 15:31:10 +00:00
Douglas Gregor 490a031b05 [libclang] Replace ObjC generic parameters when code-completing method implementations.
rdar://20643768

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241559 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 06:20:27 +00:00
Douglas Gregor 0316e7d76c [libclang] Fix code-completion of block parameters that are marked with nullability specifier.
rdar://20755276

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241558 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 06:20:22 +00:00
Douglas Gregor 11354e9dc8 [libclang] Replace ObjC generic parameters in code-completion results.
rdar://19369529

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241557 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 06:20:19 +00:00
Douglas Gregor 5df68d34cd Parsing, semantic analysis, and AST for Objective-C type parameters.
Produce type parameter declarations for Objective-C type parameters,
and attach lists of type parameters to Objective-C classes,
categories, forward declarations, and extensions as
appropriate. Perform semantic analysis of type bounds for type
parameters, both in isolation and across classes/categories/extensions
to ensure consistency.

Also handle (de-)serialization of Objective-C type parameter lists,
along with sundry other things one must do to add a new declaration to
Clang.

Note that Objective-C type parameters are typedef name declarations,
like typedefs and C++11 type aliases, in support of type erasure.

Part of rdar://problem/6294649.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241541 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-07 03:57:15 +00:00
Douglas Gregor 673b679df9 Replace __double_underscored type nullability qualifiers with _Uppercase_underscored
Addresses a conflict with glibc's __nonnull macro by renaming the type
nullability qualifiers as follows:

  __nonnull -> _Nonnull
  __nullable -> _Nullable
  __null_unspecified -> _Null_unspecified

This is the major part of rdar://problem/21530726, but does not yet
provide the Darwin-specific behavior for the old names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240596 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-24 22:02:08 +00:00
Alexander Kornienko 8ca7705aa3 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240353 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 23:07:51 +00:00
Alexander Kornienko ac58acc7f2 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

  $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
      -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
      work/llvm/tools/clang

To reduce churn, not touching namespaces spanning less than 10 lines.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240270 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 09:47:44 +00:00
Douglas Gregor fc46d7a97c Code completion for nullability type specifiers.
Another part of rdar://problem/18868820.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240159 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-19 18:27:52 +00:00
Benjamin Kramer b7b56528f9 Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types
If the type isn't trivially moveable emplace can skip a potentially
expensive move. It also saves a couple of characters.


Call sites were found with the ASTMatcher + some semi-automated cleanup.

memberCallExpr(
    argumentCountIs(1), callee(methodDecl(hasName("push_back"))),
    on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))),
    hasArgument(0, bindTemporaryExpr(
                       hasType(recordDecl(hasNonTrivialDestructor())),
                       has(constructExpr()))),
    unless(isInTemplateInstantiation()))

No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238601 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-29 19:42:19 +00:00
Richard Smith 1f468121f5 [modules] Stop trying to fake up a linear MacroDirective history.
Modules builds fundamentally have a non-linear macro history. In the interest
of better source fidelity, represent the macro definition information
faithfully: we have a linear macro directive history within each module, and at
any point we have a unique "latest" local macro directive and a collection of
visible imported directives. This also removes the attendent complexity of
attempting to create a correct MacroDirective history (which we got wrong
in the general case).

No functionality change intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236176 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-29 23:20:19 +00:00
Richard Smith eacc733943 [modules] Determine the set of macros exported by a submodule at the end of that submodule.
Previously we'd defer this determination until writing the AST, which doesn't
allow us to use this information when building other submodules of the same
module. This change also allows us to use a uniform mechanism for writing
module macro records, independent of whether they are local or imported.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235614 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-23 18:18:26 +00:00
Argyrios Kyrtzidis fdd9dfb443 [libclang] Fix crash when code-completing inside constructor initializer for a builtin type.
rdar://20149746

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 07:39:30 +00:00
Richard Smith a8229d2c00 Cleanup: remove artificial division between lookup results and const lookup
results. No-one was ever modifying a lookup result, and it would not be
reasonable to do so.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230123 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-21 02:45:19 +00:00
Francisco Lopes da Silva f86a3c2715 Sema: Turn some applicable functions static. NBC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227418 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-29 05:54:59 +00:00
Francisco Lopes da Silva 90ffec0e7e Improves overload completion result chunks.
The code building the code completion string for overloads was providing
less detail compared to the one building completion strings for function
declarations. There was no information about optionals and no information
about what's a parameter and what's a function identifier, everything
besides ResultType, CurrentParameter and special characters was classified
as Text.

This makes code completion strings for overload candidates to follow a
pattern very similar, but not identical, to the one in use for function
declarations:

 - return type chunk: ResultType
 - function identifier chunk: Text
 - parameter chunks: Placeholder
 - optional parameter chunks: Optional
 - current parameter chunk: CurrentParameter

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227309 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-28 14:17:22 +00:00
Francisco Lopes da Silva c8a94162ab Sema: Formatting. No behavior change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227052 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-25 17:00:47 +00:00
Francisco Lopes da Silva 35a7e89071 Sema: require a complete type before lookup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227037 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-25 08:47:59 +00:00
Francisco Lopes da Silva 3b7d48dabc Sema: code completion for variadic prototypes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226908 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 13:17:51 +00:00
Francisco Lopes da Silva 8f3dd24e4f Sema: code completion for pointer and reference to functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226865 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 21:14:08 +00:00
Francisco Lopes da Silva 721f778cf0 Sema: Add FIXME note
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226813 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 12:41:44 +00:00
Francisco Lopes da Silva 40785b0b94 Initial support for C++ parameter completion
The improved completion in call context now works with:

 - Functions.
 - Member functions.
 - Constructors.
 - New expressions.
 - Function call expressions.
 - Template variants of the previous.

There are still rough edges to be fixed:

 - Provide support for optional parameters.         (fix known)
 - Provide support for member initializers.         (fix known)
 - Provide support for variadic template functions. (fix unknown)
 - Others?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226670 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-21 16:24:11 +00:00
Richard Smith e533cc869e PR13699: Include friend declarations in code completion results if they had a
prior visible declaration. Prefer to take template parameter names from the
first declaration.

Testcase from a patch by Francisco Lopes!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226083 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 02:27:20 +00:00
Nico Weber 7b38956489 Address review feedback on r221933.
Remove ObjCMethodList::Count, instead store a "has more than one decl" bit in
the low bit of the ObjCMethodDecl pointer, using a PointerIntPair.

Most of this patch is replacing ".Method" with ".getMethod()".

No intended behavior change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224876 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-27 03:58:08 +00:00
David Blaikie f8fdd74444 Update for LLVM API change to make Small(Ptr)Set::insert return pair<iterator, bool> as per the C++ standard's associative container concept.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222335 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 07:49:47 +00:00
Yaron Keren dbbfbed9f5 Typo fix.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222016 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 18:33:42 +00:00
Ben Langmuir 65b3ed258f Avoid a crash after loading an #undef'd macro in code completion
In code-completion, don't assume there is a MacroInfo for everything,
since we aren't serializing the def corresponding to a later #undef in
the same module.  Also setup the HadMacro bit correctly for undefs to
avoid an assertion failure.

rdar://18416901

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218694 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-30 20:00:18 +00:00
Alp Toker e9a2e9d4e3 Switch over a few uses of param_begin() to parameters()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212442 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-07 09:02:20 +00:00
Alp Toker 9ec95c85e7 Extract an isReservedName() function
We'll want to share the implementation if anything else decides to check
for reserved names in future, so make this little snippet of code more
discoverable.

Also remove the __va_list_tag and __builtin_va_list special-case
checks. They're leftovers from before when the reserved name logic was
added.

No change in functionality.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212006 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-30 01:33:53 +00:00
Nikola Smiljanic be481708fb Refactoring. Remove release and take methods from ActionResult. Rename takeAs to getAs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209800 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-29 10:55:11 +00:00
Craig Topper 6b8c5857eb [C++11] Use 'nullptr'. Sema edition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209613 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-26 06:22:03 +00:00
Benjamin Kramer 10ffef9f56 Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.
Required pulling LambdaExpr::Capture into its own header.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208470 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-10 16:31:55 +00:00
Richard Smith 13e47c4358 Implement [over.match.oper]p3 properly, by filtering the non-candidates out
when building the candidate set, rather than trying to contort name lookup into
handling this.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206436 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-17 01:52:14 +00:00
Argyrios Kyrtzidis 99a20e0f3d [Preprocessor/CodeComplete] Don't add include guard macros to code-completion results.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205917 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-09 18:21:23 +00:00
Aaron Ballman ae20647f17 [C++11] Replacing Scope iterators decl_begin() and decl_end() with iterator_range decls(). Updating all of the usages of the iterators with range-based for loops, and removing the no-longer-needed iterator versions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204052 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-17 16:55:25 +00:00
Aaron Ballman 4f8e7df26b [C++11] Replacing ObjCObjectPointerType iterators qual_begin() and qual_end() with iterator_range quals(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204048 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-17 16:14:00 +00:00
Aaron Ballman 58e3220f76 [C++11] Replacing ObjCCategoryDecl iterators protocol_begin() and protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203922 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-14 12:55:57 +00:00
Aaron Ballman 09c79d9b98 [C++11] Replacing ObjCProtocolDecl iterators protocol_begin() and protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203863 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 22:58:06 +00:00
Aaron Ballman 847d1a3426 [C++11] Replacing ObjCInterfaceDecl iterators known_categories_begin() and known_categories_end() with iterator_range known_categories(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203854 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 21:35:02 +00:00
Aaron Ballman 2609ccf0a3 [C++11] Replacing ObjCInterfaceDecl iterators visible_categories_begin() and visible_categories_end() with iterator_range visible_categories(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203851 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 21:23:55 +00:00
Aaron Ballman a2a1fef4c9 [C++11] Replacing ObjCInterfaceDecl iterators all_referenced_protocol_begin() and all_referenced_protocol_end() with iterator_range all_referenced_protocols(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203848 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 20:55:22 +00:00
Aaron Ballman 460fea20dc [C++11] Replacing ObjCInterfaceDecl iterators protocol_begin() and protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops.
Drive-by fixing some incorrect types where a for loop would be improperly using ObjCInterfaceDecl::protocol_iterator. No functional changes in these cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203842 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 20:29:09 +00:00
Aaron Ballman f5244d23c9 Renaming the recently-created (r203830) props() range API to properties() for clarity.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203835 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 19:11:50 +00:00
Aaron Ballman 94d23bc5f4 [C++11] Replacing ObjCContainerDecl iterators meth_begin() and meth_end() with iterator_range methods(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203832 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 19:03:34 +00:00
Aaron Ballman fc41e95ace [C++11] Replacing ObjCContainerDecl iterators prop_begin() and prop_end() with iterator_range props(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203830 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 18:47:37 +00:00
Aaron Ballman c3aad302fe [C++11] Replacing CXXRecordDecl iterators vbases_begin() and vbases_end() with iterator_range vbases(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203808 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 16:15:17 +00:00
Aaron Ballman 7191c6b061 [C++11] Replacing CXXRecordDecl iterators bases_begin() and bases_end() with iterator_range bases(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203803 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 15:41:46 +00:00
Craig Topper 34e9e13d3a [C++11] Add 'override' keyword to virtual methods that override their base class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203640 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-12 04:55:44 +00:00
Aaron Ballman 15fd658d17 [C++11] Replacing DeclBase iterators specific_attr_begin() and specific_attr_end() with iterator_range specific_attrs(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203474 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-10 17:08:28 +00:00
Aaron Ballman d856df28b2 [C++11] Replacing Decl iterators attr_begin() and attr_end() with iterator_range attrs(). Updating all of the usages of the iterators with range-based for loops.
This is a reapplication of r203236 with modifications to the definition of attrs() and following the new style guidelines on auto usage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203362 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-08 22:19:01 +00:00
Aaron Ballman 8328f6462b [C++11] Replacing RecordDecl iterators field_begin() and field_end() with iterator_range fields(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203355 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-08 20:12:42 +00:00
Aaron Ballman 0ce08a0739 [C++11] Replacing EnumDecl iterators enumerator_begin() and enumerator_end() with iterator_range enumerators(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203353 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-08 18:45:14 +00:00
Aaron Ballman caabaa8e4b [C++11] Replacing DeclBase iterators decls_begin() and decls_end() with iterator_range decls(). The same is true for the noload versions of these APIs. Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203278 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-07 19:56:05 +00:00
Aaron Ballman ecb8277062 [C++11] Replacing ObjCMethodDecl iterators param_begin() and param_end() with iterator_range params(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203255 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-07 17:50:17 +00:00
Aaron Ballman 32e45c49cd Fully reverting r203236 -- it seems the only bots that are happy are the MSVC bots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203237 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-07 13:13:38 +00:00
Aaron Ballman 3dd81e64ab [C++11] Replacing iterators attr_begin() and attr_end() with iterator_range attrs(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203236 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-07 12:50:00 +00:00
Benjamin Kramer 802ac72495 [C++11] Replace verbose functors with succinct lambdas
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202590 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-01 14:48:57 +00:00
Anders Carlsson b7947f06d2 When completing Objective-C instance method invocations, perform a contextual conversion to an Objective-C pointer type of the target expression if needed. This fixes code completion of method invocations where the target is a smart pointer that has an explicit conversion operator to an Objective-C type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202529 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 19:07:22 +00:00
Argyrios Kyrtzidis 24ea2325c1 [code-completion] Style guideline for Cocoa has custom accessor in property declarations without spaces around '='.
rdar://16059171

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201765 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-20 07:55:15 +00:00
Alp Toker 37545f747c Rename getResultType() on function and method declarations to getReturnType()
A return type is the declared or deduced part of the function type specified in
the declaration.

A result type is the (potentially adjusted) type of the value of an expression
that calls the function.

Rule of thumb:

  * Declarations have return types and parameters.
  * Expressions have result types and arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200082 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-25 16:55:45 +00:00
Alp Toker 296a4e5499 Introduce and use Decl::getAsFunction() to simplify templated function checks
Lift the getFunctionDecl() utility out of the parser into a general
Decl::getAsFunction() and use it to simplify other parts of the implementation.

Reduce isFunctionOrFunctionTemplate() to a simple type check that works the
same was as the other is* functions and move unwrapping of shadowed decls to
callers so it doesn't get run twice.

Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer.
There's no need to query when we already know the body can't be skipped.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199794 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-22 07:29:52 +00:00
Alp Toker 5972ab3bb1 Update FunctionTypeLoc and related names to match r199686
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199699 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-21 00:32:38 +00:00
Alp Toker c50bf3d128 Rename FunctionProtoType accessors from 'arguments' to 'parameters'
Fix a perennial source of confusion in the clang type system: Declarations and
function prototypes have parameters to which arguments are supplied, so calling
these 'arguments' was a stretch even in C mode, let alone C++ where default
arguments, templates and overloading make the distinction important to get
right.

Readability win across the board, especially in the casting, ADL and
overloading implementations which make a lot more sense at a glance now.

Will keep an eye on the builders and update dependent projects shortly.

No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199686 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-20 20:26:09 +00:00
Aaron Ballman 08b3500a18 It turns out the problem was a bit more wide-spread. Removing a lot of unneeded typecasts. getScopeRep() already returns a NestedNameSpecifier.
No functional changes intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198414 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-03 13:56:08 +00:00
Ted Kremenek f0d5861d2d Convert anachronistic use of 'void *' to 'DeclContext *' in Scope that was a holdover from the long-dead Action interface.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192203 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-08 17:08:03 +00:00
Richard Smith a41c97a5d1 Switch the semantic DeclContext for a block-scope declaration of a function or
variable from being the function to being the enclosing namespace scope (in
C++) or the TU (in C). This allows us to fix a selection of related issues
where we would build incorrect redeclaration chains for such declarations, and
fail to notice type mismatches.

Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern,
which is only found when searching scopes, and not found when searching
DeclContexts. Such a declaration is only made visible in its DeclContext if
there are no non-LocalExtern declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191064 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-20 01:15:31 +00:00
Serge Pavlov 18062394db Cleanup of OpaquePtr. No functionality changes.
- Some documenation were added.
- Usages of OpaquePtr<A>.getAsVal<A>() were replaced by OpaquePtr<A>.get().
- Methods getAs and getAsVal were renamed to getPtrTo and getPtrAs respectively.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189346 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-27 13:15:56 +00:00
Robert Wilhelm 344472ebed Use pop_back_val() instead of both back() and pop_back().
No functionality change intended.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189112 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-23 16:11:15 +00:00
Robert Wilhelm 834c058cb6 Omit llvm:: before ArrayRef, as we have using llvm::ArrayRef in include/clang/Basic/LLVM.h.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188089 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-09 18:02:13 +00:00
Daniel Jasper 056ec12ca1 Add option to disable module loading.
This patch was created by Lawrence Crowl and reviewed in:
http://llvm-reviews.chandlerc.com/D963

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187738 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-05 20:26:17 +00:00
Benjamin Kramer e103979cea Compress pairs. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185264 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-29 17:52:13 +00:00
Dmitri Gribenko 572cf585da ArrayRef'ize Sema::CodeCompleteConstructorInitializer
Patch by Robert Wilhelm.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184675 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-23 22:58:02 +00:00
Dmitri Gribenko 050315bfd0 ArrayRef'ize Sema::CodeComplete*
Patch by Robert Wilhelm.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184052 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-16 03:47:57 +00:00
Argyrios Kyrtzidis fe038a3290 [libclang] For "@import .." code-completion results, associate a CXCursor_ModuleImportDecl cursor instead of CXCursor_NotImplemented.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182871 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-29 18:50:15 +00:00
Argyrios Kyrtzidis 2e3d8c0815 Enhance the ObjC global method pool to record whether there were 0, 1, or >= 2 methods (with a particular selector) inside categories.
This is done by extending ObjCMethodList (which is only used by the global method pool) to have 2 extra bits of information.
We will later take advantage of this info in global method pool for the overridden methods calculation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179652 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-17 00:08:58 +00:00
Richard Smith ec64244f59 Parsing support for thread_local and _Thread_local. We give them the same
semantics as __thread for now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179424 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-12 22:46:28 +00:00
Rafael Espindola d2615cc53b Add 178663 back.
http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb went back green
before it processed the reverted 178663, so it could not have been the culprit.

Revert "Revert 178663."

This reverts commit 4f8a3eb2ce.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178682 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 19:27:57 +00:00
Rafael Espindola 4f8a3eb2ce Revert 178663.
Looks like it broke http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb

Revert "Don't compute a patched/semantic storage class."

This reverts commit 8f187f62cb.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178681 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 19:22:20 +00:00
Rafael Espindola 8f187f62cb Don't compute a patched/semantic storage class.
For variables and functions clang used to store two storage classes. The one
"as written" in the code and a patched one, which, for example, propagates
static to the following decls.

This apparently is from the days clang lacked linkage computation. It is now
redundant and this patch removes it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178663 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 15:50:00 +00:00
Richard Smith 4cf4a5e96a Support C11 _Atomic type qualifier. This is more-or-less just syntactic sugar for the _Atomic type specifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178210 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-28 01:55:44 +00:00
Argyrios Kyrtzidis c56fff7fd2 [Preprocessor/Modules] Separate the macro directives kinds into their own MacroDirective's subclasses.
For each macro directive (define, undefine, visibility) have a separate object that gets chained
to the macro directive history. This has several benefits:

-No need to mutate a MacroDirective when there is a undefine/visibility directive. Stuff like
 PPMutationListener become unnecessary.
-No need to keep extra source locations for the undef/visibility locations for the define directive object
 (which is the majority of the directives)
-Much easier to hide/unhide a section in the macro directive history.
-Easier to track the effects of the directives across different submodules.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178037 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-26 17:17:01 +00:00
Fariborz Jahanian 168613735d documentation parsing: when providing code completion comment
for a getter used in property-dot syntax, if geter has its own
comment use it. // rdar://12791315



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177797 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-23 01:10:45 +00:00
Fariborz Jahanian c02ddb23c0 documentation parsing. Provide code completion comment
for self.GetterName where GetterName is the getter method 
for a property with name different from the property name 
(declared via a property getter attribute) // rdar://12791315


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177744 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-22 17:55:27 +00:00
Argyrios Kyrtzidis 57f8da506a Don't try to typo-correct 'super' in an objc method.
This created 2 issues:

1) Performance issue, since typo-correction with PCH/modules is rather expensive.
2) Correctness issue, since if it managed to "correct" 'super' then bogus compiler errors would
be emitted, like this:

3.m:8:3: error: unknown type name 'super'; did you mean 'super1'?
  super.x = 0;
  ^~~~~
  super1
t3.m:5:13: note: 'super1' declared here
typedef int super1;
            ^
t3.m:8:8: error: expected identifier or '('
  super.x = 0;
       ^

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177126 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-14 22:56:43 +00:00
John McCall 83972f128e Add TagDecl::hasNameForLinkage(), which is true if the tag
is non-anonymous or is defined in a typedef of itself.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176742 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-09 00:54:27 +00:00
Douglas Gregor 0689863f7b Add code completion for @import <rdar://problem/13344306>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176666 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-07 23:26:24 +00:00
Fariborz Jahanian b98f7af568 objective-C code completion. Property accessors may not
have their own code completion comments. Use those in 
their properties in this case. 
// rdar://12791315


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176271 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-28 17:47:14 +00:00
Argyrios Kyrtzidis 9818a1d443 [preprocessor] Split the MacroInfo class into two separate concepts, MacroInfo class
for the data specific to a macro definition (e.g. what the tokens are), and
MacroDirective class which encapsulates the changes to the "macro namespace"
(e.g. the location where the macro name became active, the location where it was undefined, etc.)

(A MacroDirective always points to a MacroInfo object.)

Usually a macro definition (MacroInfo) is where a macro name becomes active (MacroDirective) but
splitting the concepts allows us to better model the effect of modules to the macro namespace
(also as a bonus it allows better modeling of push_macro/pop_macro #pragmas).
Modules can have their own macro history, separate from the local (current translation unit)
macro history; MacroDirectives will be used to model the macro history (changes to macro namespace).

For example, if "@import A;" imports macro FOO, there will be a new local MacroDirective created
to indicate that "FOO" became active at the import location. Module "A" itself will contain another
MacroDirective in its macro history (at the point of the definition of FOO) and both MacroDirectives
will point to the same MacroInfo object.

Introducing the separation of macro concepts is the first part towards better modeling of module macros.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175585 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-20 00:54:57 +00:00
David Blaikie 39e6ab4be9 Replace TypeLoc llvm::cast support to be well-defined.
The TypeLoc hierarchy used the llvm::cast machinery to perform undefined
behavior by casting pointers/references to TypeLoc objects to derived types
and then using the derived copy constructors (or even returning pointers to
derived types that actually point to the original TypeLoc object).

Some context is in this thread:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html
Though it's spread over a few months which can be hard to read in the mail
archive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175462 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-18 22:06:02 +00:00
Dmitri Gribenko 68a932d416 Remove a const_cast by propagating constness to called functions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175161 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-14 13:53:30 +00:00
Jordan Rose 223f0ff6a9 Remove some stray uses of <ctype.h> functions.
These are causing assertions on some MSVC builds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174805 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-09 10:09:43 +00:00
Douglas Gregor 626799b290 When code completing in a statement, parenthesized expression, or
Objective-C message receiver, the user is as likely to want to write a
type name as any other declaration, so give types the same priority as
other declarations. Fixes <rdar://problem/12480600>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174038 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 05:03:46 +00:00
Douglas Gregor d1f09b482b Allow the computation of the base priority for a declaration code completion result to consider the completion context
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174037 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 04:52:16 +00:00
Douglas Gregor 31aa577150 Add "instancetype" as a code completion result for the return type of
an Objective-C method. Fixes <rdar://problem/13069990>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173905 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30 07:11:43 +00:00
Douglas Gregor 5824b803bb The instance methods of the root class of an Objective-C hieararchy
can be messaged via the metaclass. Provide code completions for this
case. Fixes <rdar://problem/12560296>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173903 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30 06:58:39 +00:00
Dmitri Gribenko 89cf425f11 Use 'const Decl *' throughout code completion in Sema
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173277 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-23 17:21:11 +00:00