Commit Graph

23952 Commits

Author SHA1 Message Date
Douglas Gregor 355efbb2e0 Rework the Sema/AST/IRgen dance for the lambda closure type's
conversion to function pointer. Rather than having IRgen synthesize
the body of this function, we instead introduce a static member
function "__invoke" with the same signature as the lambda's
operator() in the AST. Sema then generates a body for the conversion
to function pointer which simply returns the address of __invoke. This
approach makes it easier to evaluate a call to the conversion function
as a constant, makes the linkage of the __invoke function follow the
normal rules for member functions, and may make life easier down the
road if we ever want to constexpr'ify some of lambdas.

Note that IR generation is responsible for filling in the body of
__invoke (Sema just adds a dummy body), because the body can't
generally be expressed in C++.

Eli, please review!

llvm-svn: 150783
2012-02-17 03:02:34 +00:00
Richard Smith 1002d10aaa Reject continue/break statements within members of local functions nested within
loop and switch statements, by teaching Scope that a function scope never has
a continue/break parent for the purposes of control flow. Remove the hack in
block and lambda expressions which worked around this by pretending that such
expressions were continue/break scopes.

Remove Scope::ControlParent, since it's unused.

In passing, teach default statements to recover properly from a missing ';', and
add a fixit for same to both default and case labels (the latter already
recovered correctly).

llvm-svn: 150776
2012-02-17 01:35:32 +00:00
Richard Smith 5d108606cc PR12012: Fix a regression in r150419 where we would try (and fail) to
zero-initialize class types with virtual bases when constant-evaluating an
initializer.

llvm-svn: 150770
2012-02-17 00:44:16 +00:00
Fariborz Jahanian e7a0c93cd9 objective-c translator. More stuff for modern meta-data.
llvm-svn: 150767
2012-02-17 00:06:14 +00:00
Eric Christopher 4c006e557d Reapply r150631:
"Add a completed/incomplete type difference. This allows us to have
    partial types for contexts and forward decls while allowing us to
    complete types later on for debug purposes.

    This piggy-backs on the metadata replacement and rauw changes
    for temporary nodes and takes advantage of the incremental
    support I added in earlier. This allows us to, if we decide,
    to limit adding methods and variables to structures in order
    to limit the amount of debug information output into a .o file.

    The caching is a bit complicated though so any thoughts on
    untangling that are welcome."

with a fix:

 - Remove all RAUW during type construction by adding stub versions
   of types that we later complete.

and some TODOs:

 - Add an RAUW cache for forward declared types so that we can replace
   them at the end of compilation.
 - Remove the code that updates on completed types because we no
   longer need to have that happen. We emit incomplete types on
   purpose and only want to know when we want to complete them.

llvm-svn: 150752
2012-02-16 22:54:45 +00:00
Eli Friedman b971d49765 Elide copy construction in new expressions. PR11757.
llvm-svn: 150738
2012-02-16 22:45:48 +00:00
Kaelyn Uhrain 7c019177b0 Avoid infinite mutual recursion in DiagnoseInvalidRedeclaration.
Don't try to typo-correct a method redeclaration to declarations not in
the current record as it could lead to infinite recursion if CorrectTypo
finds more than one correction candidate in a parent record.

llvm-svn: 150735
2012-02-16 22:40:59 +00:00
Anna Zaks 546c49c3b2 [analyzer] Malloc Checker: Clean up bug naming:
- Rename the category "Logic Error" -> "Memory Error".
 - Shorten all the messages.

llvm-svn: 150733
2012-02-16 22:26:12 +00:00
Anna Zaks 9eb7bc82ae [analyzer] Malloc Checker: Make the diagnostic visitor handle the case
of failing realloc. + Minor cleanups.

llvm-svn: 150732
2012-02-16 22:26:07 +00:00
Matt Beaumont-Gay 2150d38a19 Pacify gcc's -Wreturn-type
llvm-svn: 150731
2012-02-16 22:15:50 +00:00
Fariborz Jahanian c41d828053 fix the property list metadata name.
llvm-svn: 150728
2012-02-16 21:57:59 +00:00
Douglas Gregor 6746c5d487 Improve recovery for lambda expressions that have 'mutable' or a
trailing return type but not a '()'. Recover by inserting the
parentheses. Thanks to Xeo on IRC for the example.

llvm-svn: 150727
2012-02-16 21:53:36 +00:00
Fariborz Jahanian 638252fb5a modern objective-c translator: write the root class meta-data.
llvm-svn: 150726
2012-02-16 21:37:05 +00:00
Douglas Gregor a86bc00d3e Lambda closure types are always considered to be like "local" classes,
even if they are not within a function scope. Teach template
instantiation to treat them as such, and make sure that we have a
local instantiation scope when instantiating default arguments and
static data members.

llvm-svn: 150725
2012-02-16 21:36:18 +00:00
Ted Kremenek 2eef6b9e4b Add checker visitation hooks in ExprEngine::Visit() for common no-op expressions. To be used later.
llvm-svn: 150723
2012-02-16 20:56:01 +00:00
Ted Kremenek 35e55fe49f Revert "Move ExplodedNode reclaimation out of ExprEngine and into CoreEngine. Also have it based on adding predecessors/successors, not node allocation. No measurable performance change."
llvm-svn: 150722
2012-02-16 20:48:04 +00:00
Richard Smith 4297375561 C++11 allows unions to have static data members. Remove the corresponding
restriction and add some tests.

llvm-svn: 150721
2012-02-16 20:41:22 +00:00
Ted Kremenek ea8dbdeefd Move ExplodedNode reclaimation out of ExprEngine and into CoreEngine. Also have it based on adding predecessors/successors, not node allocation. No measurable performance change.
llvm-svn: 150720
2012-02-16 20:19:30 +00:00
Ted Kremenek a2aa929e74 Minor cleanup to node data structures in ExplodedGraph. No functionality change.
llvm-svn: 150719
2012-02-16 20:19:25 +00:00
Fariborz Jahanian 0a25688b74 modern objc translator: meta-data generation for first
part of class meta-data.

llvm-svn: 150714
2012-02-16 18:54:09 +00:00
Douglas Gregor 36107ade6f In Objective-C++, allow the keyword 'class' to be used as a property
name for dot syntax, e.g., NSObject.class or foo.class. For other
C++-keywords-as-method-names, use message send syntax. Fixes
<rdar://problem/10794452>.

llvm-svn: 150710
2012-02-16 18:19:22 +00:00
Douglas Gregor 3a5d6c27b2 If code completion patterns are not enabled, use simpler else/else if
completions that don't insert braces. Fixes <rdar://problem/10764168>.

llvm-svn: 150707
2012-02-16 17:49:04 +00:00
Argyrios Kyrtzidis 6aa70e2c83 Add fixits for ARC casting errors for implicit conversions as well. rdar://10289283
Also fix the fixit (oh the irony) when it uses CFBridgingRetain/CFBridgingRelease;
they are supposed to be calls with the casted expression as parameter, they should
not be inserted into the cast like the __bridge keywords.

llvm-svn: 150705
2012-02-16 17:31:07 +00:00
DeLesley Hutchins 6f13b09a00 Minor fix to template instantiation, which properly instantiates
dependent attributes on static members of templatized classes.

llvm-svn: 150704
2012-02-16 17:30:51 +00:00
DeLesley Hutchins 3509f29ec5 Thread safety analysis: Don't check for lockable on undefined types.
llvm-svn: 150702
2012-02-16 17:15:51 +00:00
DeLesley Hutchins c2286f6402 Thread-safety analysis: Disable checking inside constructors, destructors, lock, and unlock functions
llvm-svn: 150701
2012-02-16 17:13:43 +00:00
DeLesley Hutchins bc8ffdb68c Thread-Safety: added support for 'this' as a lock expression.
llvm-svn: 150700
2012-02-16 17:03:24 +00:00
DeLesley Hutchins 3fc6e4a7cd Allow thread safety attributes on function definitions.
For compatibility with gcc, clang will now parse gcc attributes on
function definitions, but issue a warning if the attribute is not a
thread safety attribute.  Warning controlled by -Wgcc-compat.

llvm-svn: 150698
2012-02-16 16:50:43 +00:00
Hans Wennborg 9bc9bcc247 Format string analysis: give 'q' its own enumerator.
This is in preparation for being able to warn about 'q' and other
non-standard format string features.

It also allows us to print its name correctly.

llvm-svn: 150697
2012-02-16 16:34:54 +00:00
David Chisnall 96de9933fb Tweak link order on Solaris so that global ctors work.
llvm-svn: 150696
2012-02-16 16:00:47 +00:00
Sebastian Redl b8fc4775d1 Proper checking of list-initializers for array new expressions.
This finishes generalized initializer support in Sema.

llvm-svn: 150688
2012-02-16 12:59:47 +00:00
Sebastian Redl 6047f07e81 Revert "Revert "Make CXXNewExpr contain only a single initialier, and not hold the used constructor itself.""
This reintroduces commit r150682 with a fix for the Bullet benchmark crash.

llvm-svn: 150685
2012-02-16 12:22:20 +00:00
Sebastian Redl c3a3c60040 Revert "Make CXXNewExpr contain only a single initialier, and not hold the used constructor itself."
It leads to a compiler crash in the Bullet benchmark.

This reverts commit r12014.

llvm-svn: 150684
2012-02-16 11:35:52 +00:00
Sebastian Redl 86fab844bb Make CXXNewExpr contain only a single initialier, and not hold the used constructor itself.
Holding the constructor directly makes no sense when list-initialized arrays come into play. The constructor is now held in a CXXConstructExpr, if construction is what is done. The new design can also distinguish properly between list-initialization and direct-initialization, as well as implicit default-initialization constructors and explicit value-initialization constructors. Finally, doing it this way removes redundance from the AST because CXXNewExpr doesn't try to handle both the allocation and the initialization responsibilities.

This breaks the static analysis of new expressions. I've filed PR12014 to track this.

llvm-svn: 150682
2012-02-16 10:58:10 +00:00
Eli Friedman 59e41d046e Shift Microsoft enum extensions from -fms-extensions to -fms-compatibility, so -fms-extensions doesn't affect enum semantics in incompatible ways. <rdar://problem/10657186>.
llvm-svn: 150663
2012-02-16 05:20:44 +00:00
Eli Friedman 5b44688d6b Initial implementation of IRGen for the lambda conversion-to-function-pointer operator.
llvm-svn: 150660
2012-02-16 03:47:28 +00:00
Anna Zaks 95308d3798 [analyzer] Diagnostics: Ensure that the default end of diagnostic path
piece can always be generated.

The default end of diagnostic path piece was failing to generate on a
BlockEdge that was outgoing from a basic block without a terminator,
resulting in a very simple diagnostic being rendered (ex: no path
highlighting or custom visitors). Reuse another function, which is
essentially doing the same thing and correct it not to fail when a block
has no terminator.

llvm-svn: 150659
2012-02-16 03:41:01 +00:00
Anna Zaks d32ead82d9 [analyzer] Malloc Checker: Give up when a pointer escapes into a struct.
We are not properly handling the memory regions that escape into struct
fields, which led to a bunch of false positives. Be conservative here
and give up when a pointer escapes into a struct.

llvm-svn: 150658
2012-02-16 03:40:57 +00:00
Richard Smith 17100bad0a constexpr tidyups:
* Fix bug when determining whether && / || are potential constant expressions
  * Try harder when determining whether ?: is a potential constant expression
  * Produce a diagnostic on sizeof(VLA) to provide a better source location

llvm-svn: 150657
2012-02-16 02:46:34 +00:00
Eli Friedman 5a6d507d1b Start of IRGen for lambda conversion operators.
llvm-svn: 150649
2012-02-16 01:37:33 +00:00
Bill Wendling b6f795eee6 Use the new method for specifying garbage collection metadata in the module.
The garbage collection metadata needs to be merged "intelligently", when two or
more modules are linked together, and not merely appended. (Appending creates a
section which is too large.) The module flags metadata method is the way to do
this.
<rdar://problem/8198537>

llvm-svn: 150648
2012-02-16 01:13:30 +00:00
Douglas Gregor d3b672c385 Implicitly define a lambda's conversion functions (to function
pointers and block pointers). We use dummy definitions to keep the
invariant that an implicit, used definition has a body; IR generation
will substitute the actual contents, since they can't be represented
as C++. 

For the block pointer case, compute the copy-initialization needed to
capture the lambda object in the block, which IR generation will need
later.

llvm-svn: 150645
2012-02-16 01:06:16 +00:00
Dan Gohman 515a60daff Teach clang to add metadata tags to calls and invokes in ObjC with
-fno-objc-arc-exceptions. This will allow the optimizer to perform
optimizations which are only safe under that flag.

This is a part of rdar://10803830.

llvm-svn: 150644
2012-02-16 00:57:37 +00:00
Fariborz Jahanian 430b35edf8 objc-arc: For arc's ivar layout, treat __unsafe_unretained ivars
as unscanned. // rdar://10832643

llvm-svn: 150639
2012-02-16 00:15:02 +00:00
Eric Christopher 9a89705d03 Revert "Add a completed/incomplete type difference. This allows us to have"
This reverts commit 9a68d4584afcd0853b930bd80235b58736e785b4.

llvm-svn: 150637
2012-02-15 23:51:20 +00:00
Eric Christopher 7381907e65 Add a completed/incomplete type difference. This allows us to have
partial types for contexts and forward decls while allowing us to
complete types later on for debug purposes.

This piggy-backs on the metadata replacement and rauw changes
for temporary nodes and takes advantage of the incremental
support I added in earlier. This allows us to, if we decide,
to limit adding methods and variables to structures in order
to limit the amount of debug information output into a .o file.

The caching is a bit complicated though so any thoughts on
untangling that are welcome.

llvm-svn: 150631
2012-02-15 23:25:18 +00:00
Kaelyn Uhrain 618f97ca21 Silence a valgrind warning, and remove an unused var.
llvm-svn: 150629
2012-02-15 22:59:03 +00:00
Richard Smith ebeed41587 Support GCC's bug^Wextension allowing class array members to be initalized by a
parenthesized braced-init-list in the base/member initialization list.

llvm-svn: 150625
2012-02-15 22:38:09 +00:00
Kaelyn Uhrain 5986c3e90a Improve typo correction involving nested name specifiers.
Snooping in other namespaces when the identifier being corrected is
already qualified (i.e. a valid CXXScopeSpec is passed to CorrectTypo)
and ranking synthesized namespace qualifiers relative to the existing
qualifier is now performed. Support for disambiguating the string
representation of synthesized namespace qualifers has also been added
(the change to test/Parser/cxx-using-directive.cpp is an example of an
ambiguous relative qualifier).

llvm-svn: 150622
2012-02-15 22:14:18 +00:00
Douglas Gregor 33e863cfc8 Lambda closure types have a conversion function to a block pointer
with the same parameter types and return type as the function call
operator. This is the real answer to

  http://stackoverflow.com/questions/4148242/is-it-possible-to-convert-a-c0x-lambda-to-a-clang-block

:)

llvm-svn: 150620
2012-02-15 22:08:38 +00:00