Commit Graph

4709 Commits

Author SHA1 Message Date
Richard Smith 27d807cc9c Don't treat a non-deduced 'auto' type as being type-dependent. Instead, there
are now two distinct canonical 'AutoType's: one is the undeduced 'auto'
placeholder type, and the other is a deduced-but-dependent type. All
deduced-to-a-non-dependent-type cases are still non-canonical.

llvm-svn: 180789
2013-04-30 13:56:41 +00:00
Fariborz Jahanian 5a2e4a2dc1 documenttion parsing. Provide a c-index test
and limit comment extraction to public c++
bases. // rdar://13647476

llvm-svn: 180646
2013-04-26 23:34:36 +00:00
Sean Callanan 969c5bd2d8 In the ASTImporter, when checking whether two
structs are compatible, check whether the fields
of the structs have the same name.  This prevents
erroneous coalescing of (in particular) anonymous
structs.

llvm-svn: 180644
2013-04-26 22:49:25 +00:00
Benjamin Kramer 62498ab4d5 Move helper classes into anonymous namespaces.
llvm-svn: 180642
2013-04-26 22:01:47 +00:00
Fariborz Jahanian e970c1b12a document parsing. When a sub-class (c++ Objective-C) missing
a comment, grab the first comment found in its class
heirarchy. Also, when a category is mossing a comment,
grab comment of its primary class. // rdar://13647476

llvm-svn: 180629
2013-04-26 20:55:38 +00:00
Dmitri Gribenko e9585628ae Comment parsing: -fparse-all-comments: recognize empty line comments
In -fparse-all-comments mode empty '//' comments were recognized as
RCK_Invalid, and were not merged with next and previous lines.

Patch by Amin Shali.

llvm-svn: 180625
2013-04-26 20:12:49 +00:00
Richard Smith 74aeef50a0 Implement C++1y decltype(auto).
llvm-svn: 180610
2013-04-26 16:15:35 +00:00
Richard Smith 3da88fac54 C++1y: support simple variable assignments in constexpr functions.
llvm-svn: 180603
2013-04-26 14:36:30 +00:00
Rafael Espindola 327be3cc20 Add r180263 back, but fix hasBraces() to be correct during parsing.
Original commit message:

Fix a case in linkage computation that should check for single line extern "C".

llvm-svn: 180591
2013-04-26 01:30:23 +00:00
Bill Wendling afddaa4719 Revert r180263. It's causing failures.
llvm-svn: 180583
2013-04-25 23:15:02 +00:00
Fariborz Jahanian 73e244a49f Objective-C: This is a small modification to my
patch -n r180198.
When reporting on missing property accessor implementation in
categories, do not report when they are declared in primary class,
class's protocol, or one of it super classes or in of the other
categories. // rdar://13713098

llvm-svn: 180580
2013-04-25 21:59:34 +00:00
Rafael Espindola 7e2e4fafc0 Fix a case in linkage computation that should check for single line extern "C".
llvm-svn: 180263
2013-04-25 13:10:46 +00:00
Rafael Espindola bff5956cfa Don't mark 'extern "C" void f(void)' as having extern storage class.
Instead, we check for one line extern "C" context in linkage computation and
when deciding if a variable is a definition.

This hopefully completes the transition to having "as written" semantics for
hasExternalStorage.

llvm-svn: 180258
2013-04-25 12:11:36 +00:00
Peter Collingbourne 2816c023ea [ms-cxxabi] Fix a number of bugs in the mangler.
This includes the following fixes:
 - Implement 4 subtly different variants of qualifier mangling and use them
   in what I believe are the right places.
 - Fix handling of array types.  Previously we were always decaying them,
   which is wrong if the type appears as a template argument, pointee,
   referent etc.
Fixes PR13182.

Differential Revision: http://llvm-reviews.chandlerc.com/D709

llvm-svn: 180250
2013-04-25 04:25:40 +00:00
Fariborz Jahanian eb3f1007d8 Objective-C: When reporting on missing property accessor implementation in
categories, do not report when they are declared in primary class,
class's protocol, or one of it super classes. This is because,
its class is going to implement them. // rdar://13713098

llvm-svn: 180198
2013-04-24 17:06:38 +00:00
Richard Smith d9f663b510 C++1y constexpr extensions, round 1: Allow most forms of declaration and
statement in constexpr functions. Everything which doesn't require variable
mutation is also allowed as an extension in C++11. 'void' becomes a literal
type to support constexpr functions which return 'void'.

llvm-svn: 180022
2013-04-22 15:31:51 +00:00
Richard Smith 9543c5e371 Fix array constant expression evaluation bug: we can have different values for
different array elements, even if they're all constructed using the same
default constructor.

llvm-svn: 180017
2013-04-22 14:44:29 +00:00
Richard Smith 852c9db72b C++1y: Allow aggregates to have default initializers.
Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in
CXXCtorInitializers and in InitListExprs to represent a default initializer.

There's an additional complication here: because the default initializer can
refer to the initialized object via its 'this' pointer, we need to make sure
that 'this' points to the right thing within the evaluation.

llvm-svn: 179958
2013-04-20 22:23:05 +00:00
Richard Smith 2fd1d7aee3 Implement CodeGen for C++11 thread_local, following the Itanium ABI specification as discussed on cxx-abi-dev.
llvm-svn: 179858
2013-04-19 16:42:07 +00:00
Dmitri Gribenko c2c804d145 Comment parsing: simplify code. As a side effect, this also silences GCC's
-Wunitnitialized warning.

Patch by Rui Ueyama.

llvm-svn: 179794
2013-04-18 20:50:35 +00:00
Fariborz Jahanian 799a4036da [document parsing]: When tag declaration (but not definition!)
is part of the decl-specifier-seq of some other declaration, 
it doesn't get comment. // rdar://12390371

llvm-svn: 179722
2013-04-17 21:05:20 +00:00
Argyrios Kyrtzidis a077279184 Correct the range returned by ParmVarDecl::getSourceRange(), for parameters in ObjC methods with postfix types.
For a parameter in a method like this:

-(int)methodWithFn:(void (*)(int *p))fn;

we would return the source range of the type and not include the parameter name.

Fixes rdar://13668626.

llvm-svn: 179660
2013-04-17 01:56:48 +00:00
Argyrios Kyrtzidis c2091d5d71 Use the extra info in global method pool to speed up looking for ObjC overridden methods.
When we are in a implementation, we check the global method pool whether there were category
methods with the same selector. If there were none (common case) we don't need to do lookups for
overridden methods again.

Note that for an interface method (if we don't encounter its implementation), it is considered that
it overrides methods that were declared before it, not for category methods introduced after it.

This is tradeoff in favor of performance, since it is expensive to do lookups in case there was a
category, and moving the global method pool to ASTContext (so we can check it) would increase complexity.

rdar://13508196

llvm-svn: 179654
2013-04-17 00:09:08 +00:00
Argyrios Kyrtzidis c8e700848c In ASTContext::getOverriddenMethods, call overridden_methods_begin/overridden_methods_end directly.
This avoids unnecessary Decl::getASTContext() invocations.

llvm-svn: 179653
2013-04-17 00:09:03 +00:00
Tareq A. Siraj 6dfa25a19f Sema for Captured Statements
Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic
analysis. Currently captures all variables by reference.

TODO: templates

Author: Ben Langmuir <ben.langmuir@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D433

llvm-svn: 179618
2013-04-16 19:37:38 +00:00
Tareq A. Siraj 24110cc733 Implement CapturedStmt AST
CapturedStmt can be used to implement generic function outlining as described in
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2013-January/027540.html.

CapturedStmt is not exposed to the C api.

Serialization and template support are pending.

Author: Wei Pan <wei.pan@intel.com>

Differential Revision: http://llvm-reviews.chandlerc.com/D370

llvm-svn: 179615
2013-04-16 18:53:08 +00:00
John McCall 5e77d76c95 Basic support for Microsoft property declarations and
references thereto.

Patch by Tong Shen!

llvm-svn: 179585
2013-04-16 07:28:30 +00:00
Argyrios Kyrtzidis fe7a59d9c2 Revert "Speed-up ObjCMethodDecl::getOverriddenMethods()."
This reverts commit r179436.

Due to caching, it was possible that we could miss overridden methods that
were introduced by categories later on.

Along with reverting the commit I also included a test case that would have caught this.

llvm-svn: 179547
2013-04-15 18:47:22 +00:00
Rafael Espindola 5bddd6a92a Remove hasExternalLinkageUncached.
It was being used correctly, but it is a very dangerous API to have around.
Instead, move the logic from the filtering to when we are deciding if we should
link two decls.

llvm-svn: 179523
2013-04-15 12:49:13 +00:00
Rafael Espindola 29cda59a9d Fix the storage class of method instantiations.
We keep the "as written" storage class, but that is a fuzzy concept for
instantiations. With this patch instantiations of methods of class templates
now get a storage class that is based on the semantics of isStatic(). With this
can simplify isStatic() itself.

llvm-svn: 179521
2013-04-15 12:38:20 +00:00
Richard Smith fd3834f7a1 Annotate flavor of TLS variable (statically or dynamically initialized) onto the AST.
llvm-svn: 179447
2013-04-13 02:43:54 +00:00
Argyrios Kyrtzidis 53a6558771 Speed-up ObjCMethodDecl::getOverriddenMethods().
Use an newly introduce ASTContext::getBaseObjCCategoriesAfterInterface() which caches its
results instead of re-calculating the categories multiple times.

llvm-svn: 179436
2013-04-13 01:04:01 +00:00
Reid Kleckner 2341ae3856 [ms-cxxabi] Implement member pointer emission and dereferencing
Summary:
Handles all inheritance models for both data and function member
pointers.

Also implements isZeroInitializable() and refactors some of the null
member pointer code.

MSVC supports converting member pointers through virtual bases, which
clang does not (yet?) support.  Implementing that extension is covered
by http://llvm.org/15713

Reviewers: rjmccall

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D613

llvm-svn: 179305
2013-04-11 18:13:19 +00:00
Jordan Rose b1312a5495 Force a load when creating a reference to a temporary copied from a bitfield.
For this source:
  const int &ref = someStruct.bitfield;

We used to generate this AST:

  DeclStmt [...]
  `-VarDecl [...] ref 'const int &'
    `-MaterializeTemporaryExpr [...] 'const int' lvalue
      `-ImplicitCastExpr [...] 'const int' lvalue <NoOp>
        `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...]
          `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X'

Notice the lvalue inside the MaterializeTemporaryExpr, which is very
confusing (and caused an assertion to fire in the analyzer - PR15694).

We now generate this:

  DeclStmt [...]
  `-VarDecl [...] ref 'const int &'
    `-MaterializeTemporaryExpr [...] 'const int' lvalue
      `-ImplicitCastExpr [...] 'int' <LValueToRValue>
        `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...]
          `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X'

Which makes a lot more sense. This allows us to remove code in both
CodeGen and AST that hacked around this special case.

The commit also makes Clang accept this (legal) C++11 code:

  int &&ref = std::move(someStruct).bitfield

PR15694 / <rdar://problem/13600396>

llvm-svn: 179250
2013-04-11 00:58:58 +00:00
Dmitri Gribenko a7d16ceee6 Add an option to parse all comments as documentation comments
Patch by Amin Shali.

llvm-svn: 179180
2013-04-10 15:35:17 +00:00
John McCall 924046f1ec Don't crash when mangling types defined in ObjC class extensions.
The original test case here was mangling a type name for TBAA,
but we can provoke this in C++11 easily enough.

rdar://13434937

llvm-svn: 179153
2013-04-10 06:08:21 +00:00
Reid Kleckner 5fdaac15ec [ms-cxxabi] Add "$$C" when mangling template arg QualTypes
Credit goes to Timur Iskhodzhanov for finding the problem and solution.

llvm-svn: 179093
2013-04-09 12:47:38 +00:00
Douglas Gregor 92fde2f8bc <rdar://problem/12806802> Propagate access specifiers for conversion functions to the conversion function set eagerly.
This slightly propagates an existing hack that delays when we provide
access specifiers for the visible conversion functions of a class by
copying the available access specifier early. The only client this
affects is LLDB, which tends to discover and add conversion functions
after the class is technically "complete". As such, the only
observable difference is in LLDB, so the testing will go there.

llvm-svn: 179029
2013-04-08 17:12:58 +00:00
Benjamin Kramer 08db461ca7 Make helpers static & 80 cols.
llvm-svn: 178767
2013-04-04 17:07:04 +00:00
Rafael Espindola 7b51ae8e0e Add hasExternalLinkageUncached back with the test that Richard provided, but
keep the call at the current location.

llvm-svn: 178741
2013-04-04 04:40:17 +00:00
Rafael Espindola 4dc336b20f Avoid computing the linkage instead of avoiding caching it.
This mostly reverts 178733, but keeps the tests.

I don't claim to understand how hidden sub modules work or when we need to see
them (is that documented?), but this has the same semantics and avoids adding
hasExternalLinkageUncached which has the same foot gun potential as the old
hasExternalLinkage.

Last but not least, not computing linkage when it is not needed is more
efficient.

llvm-svn: 178739
2013-04-04 03:27:32 +00:00
Richard Smith 86c0d06194 Fix 41 of the 61 tests which fail with modules enabled: we were computing and
caching the linkage for a declaration before we set up its redeclaration chain,
when determining whether a declaration could be a redeclaration of something
from an unimported submodule. We actually want to look at the declaration as if
it were not a redeclaration here, so compute the linkage but don't cache it.

llvm-svn: 178733
2013-04-04 01:51:11 +00:00
Rafael Espindola 6ae7e50be4 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 4f8a3eb2ce5d4ba422483439e20c8cbb4d953a41.

llvm-svn: 178682
2013-04-03 19:27:57 +00:00
Rafael Espindola 985a3abee4 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 8f187f62cb0487d31bc4afdfcd47e11fe9a51d05.

llvm-svn: 178681
2013-04-03 19:22:20 +00:00
Rafael Espindola adea16bd9e 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.

llvm-svn: 178663
2013-04-03 15:50:00 +00:00
Richard Trieu 17f13ecc5b Refactor the Get* functions to be more consistant among themselves.
llvm-svn: 178613
2013-04-03 03:06:48 +00:00
Richard Trieu bcd06c0220 Do not assume the template argument is an integer only because the
expressions are integer.  It can also be ValueDecl expressions

Use the type information from the TemplateParameterList instead

Patch by Olivier Goffart!

llvm-svn: 178611
2013-04-03 02:31:17 +00:00
Richard Trieu ad13f55356 Fix a crasher in Template Diffing.
When support was added for declaration arguments, the case of variadic
declaration arguments was not supported.  This patch fixes that problem by
not crashing when certain ValueDecl's are null.

Patch by Olivier Goffart!

llvm-svn: 178610
2013-04-03 02:22:12 +00:00
Richard Trieu 981de5cef3 Fix a crasher in Template Diffing.
Value depenedent expressions for default arguments cannot be evaluated.
Instead, use the desugared template type to get an argument expression that
can be used.  This is needed for both integer and declaration arguements.

Also, move this common code into a separate function.

Patch by Olivier Goffart!

llvm-svn: 178609
2013-04-03 02:11:36 +00:00
Reid Kleckner 08a39a686e [ms-cxxabi] Rename enum and remove dead case per Jordan's suggestion
The IHM_ prefix was a fairly gross abbreviation to try to hit three
characters for uniqueness.

llvm-svn: 178551
2013-04-02 17:40:19 +00:00