Commit Graph

24996 Commits

Author SHA1 Message Date
Benjamin Kramer 85be49d26d Update test case for r234543.
llvm-svn: 234544
2015-04-09 22:54:53 +00:00
Benjamin Kramer f3e67de85a [CodeGen] Do a more principled fix for PR231653, always use the inner type.
We were still using the MaterializeTemporaryExpr's type to check if the
transform is legal. Always use the inner Expr type.

llvm-svn: 234543
2015-04-09 22:50:07 +00:00
Reid Kleckner 93d0511e8c Use Linux sysroot in Driver test case from r234521
We don't actually need a real Mac sysroot to make the test pass, just a
linker.  This makes the test pass in environments where no ld is on
PATH.

llvm-svn: 234533
2015-04-09 20:37:38 +00:00
Reid Kleckner 0dbecf2b78 [SEH] Outline finally blocks using the new variable capture support
WinEHPrepare was going to have to pattern match the control flow merge
and split that the old lowering used, and that wasn't really feasible.

Now we can teach WinEHPrepare to pattern match this, which is much
simpler:
  %fp = call i8* @llvm.frameaddress(i32 0)
  call void @func(iN [01], i8* %fp)

This prototype happens to match the prototype used by the Win64 SEH
personality function, so this is really simple.

llvm-svn: 234532
2015-04-09 20:37:24 +00:00
David Majnemer df8f73fd8a [Sema] Diagnose references to unbound arrays in function definitions
A [*] is only allowed in a declaration for a function, not in its
definition.  We didn't correctly recurse on reference types while
looking for it, causing us to crash in CodeGen instead of rejecting it.

llvm-svn: 234528
2015-04-09 19:53:25 +00:00
Kaelyn Takata 0a2e84c41a Properly implement warn_unused_result checking for classes/structs.
The previous implementation would copy the attribute from the class to
functions that have the class as their return type when the functions
are first declared. This proved to have two flaws:
  1) if the class is forward-declared without the attribute and a
     function or method with the class as a its return type is declared,
     and afterward the class is defined with warn_unused_result, the
     function or method would never inherit the attribute, and
  2) the check simply failed for functions and methods that are part of
     a template instantiation, regardless of whether the class with
     warn_unused_result is part of a specific instantiation or part of
     the template itself (presumably because those function/method
     declaration does not hit the same code path as a non-template one
     and so never inherits the attribute).

The new approach is to instead modify the two places where a function or
method call is checked for the warn_unused_result attribute on the decl
by extending the checks to also look for the attribute on the decl's
return type.

Additionally, the check for return types that have the warn_unused_result
now excludes pointers and references to such types, as such return types do
not necessarily imply a transfer of ownership for the underlying object
being referred to by the return value. This does not change the behavior
of functions that are directly given the warn_unused_result attribute.

llvm-svn: 234526
2015-04-09 19:43:04 +00:00
Hans Wennborg 10821e5283 [ASan] Don't link against libc++abi when not using libc++
This is a follow-up to r233860 which added -lc++abi when using ASan
on Mac, and broke Chromium's ASan build which doesn't use libc++.

llvm-svn: 234521
2015-04-09 18:47:01 +00:00
Fariborz Jahanian f8e68e230b [Objective-C modern translation]. Patch to fix type of
objc_msgSend's first argument to "Class" because
objc_getClass is passed. rdar://20477025

llvm-svn: 234520
2015-04-09 18:36:50 +00:00
Olivier Sallenave 5a41f92f69 Added flag to disable isel instruction on PPC target. Using regular branches instead of isel is more efficient in some cases.
llvm-svn: 234509
2015-04-09 17:38:50 +00:00
Benjamin Kramer b2b81439a3 [CodeGen] When promoting a reference temporary to a global use the inner type to fold it.
The MaterializeTemporaryExpr can have a different type than the inner
expression, miscompiling the constant. PR23165.

llvm-svn: 234499
2015-04-09 16:09:29 +00:00
Sanjay Patel 359b105745 Process the -freciprocal-math optimization flag (PR20912)
The driver currently accepts but ignores the -freciprocal-math flag.
This patch passes the flag through and enables 'arcp' fast-math-flag
generation in IR.

Note that this change does not actually enable the optimization for
any target. The reassociation optimization that this flag specifies
was implemented by http://reviews.llvm.org/D6334 :
http://llvm.org/viewvc/llvm-project?view=revision&revision=222510

Because the optimization is done in the backend rather than IR,
the backend must be modified to understand instruction-level
fast-math-flags or a new function-level attribute must be created.

Also note that -freciprocal-math is independent of any target-specific
usage of reciprocal estimate hardware instructions. That requires
its own flag ('-mrecip').

https://llvm.org/bugs/show_bug.cgi?id=20912

llvm-svn: 234493
2015-04-09 15:03:23 +00:00
Javed Absar 879d18b843 [ARM] add support for Cortex-R4/R4F
Adds ARM Cortex-R4 and R4F support and tests in Clang. Though Cortex-R4
support was present, the support for hwdiv in thumb-mode was not defined
or tested properly. This has also been added.

llvm-svn: 234488
2015-04-09 14:12:10 +00:00
Hans Wennborg 7a2e5c260c clang-cl: Support the /fp options (PR23112)
This hooks up the /fp options as aliases for -f[no-]fast-math and
-f[no]-trapping-math. It probably doesn't match cl.exe's behaviour
completely (e.g. LLVM is currently never as precise as /fp:precise),
but it's close enough.

Differential revision: http://reviews.llvm.org/D8909

llvm-svn: 234449
2015-04-08 22:55:09 +00:00
Reid Kleckner e5b064205a [WinEH] Don't wrap cleanups in terminate actions
_CxxFrameHandler3 calls terminate if a cleanup action throws, regardless
of what bits you put in the xdata tables. There's no need to model this
in the IR, since we just have to take it out later.

llvm-svn: 234448
2015-04-08 22:48:50 +00:00
Reid Kleckner 31a1bb0c14 Reland "[SEH] Implement filter capturing in CodeGen"
The test should be fixed. It was failing in NDEBUG builds due to a
missing '*' character in a regex. In asserts builds, the pattern matched
a single digit value, which became a double digit value in NDEBUG
builds. Go figure.

This reverts commit r234261.

llvm-svn: 234447
2015-04-08 22:23:48 +00:00
Fariborz Jahanian 576ff12839 [Objective-C Sema] Use canonical type of properties when comparing
redeclaration of property in class extension and to avoid
bogus error. rdar://20469452

llvm-svn: 234440
2015-04-08 21:34:04 +00:00
Alexey Bataev 7c2ed44905 [OPENMP] Allow redeclaration of variables as threadprivate.
No need to emit an error message if the variable is redeclared as threadprivate.

llvm-svn: 234402
2015-04-08 12:45:41 +00:00
Aaron Ballman 8aee642909 Generate a diagnostic when a catch handler cannot execute due to class hierarchy inversion with regards to other catch handlers for the same block.
llvm-svn: 234375
2015-04-08 00:05:29 +00:00
Reid Kleckner 9386417047 Use the most recent previous decl to check if inline is added after a definition
This affects this test case:
  void foo();
  template <typename T> class C {
    friend inline void foo();
  };
  inline void foo() {}
  C<int> c;

Here, we instantiate the foo friend decl and add it to foo's redecl
chain. However, our previous decl pointer happens to reference the first
declaration of foo, which is not marked inline. When we check to see if
foo was already defined, we implicitly search all previous decls. We
should do the same for the inline check, instead of just checking this
particular previous decl.

Reviewers: rsmith

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

llvm-svn: 234374
2015-04-08 00:04:47 +00:00
David Majnemer 61a5bbf92a [Sema] Correctly recurse when looking for [*] in function definitions
A [*] is only allowed in a declaration for a function, not in its
definition.  We didn't correctly recurse while looking for it, causing
us to crash in CodeGen instead of rejecting it.

This fixes PR23151.

llvm-svn: 234363
2015-04-07 22:08:51 +00:00
Reid Kleckner 0f764e57fc Revert "Mark instantiated function decls as inline specified if any pattern is"
It breaks down on this test case:
  void foo();
  template <typename T> class C {
    friend void foo();
  };
  inline void foo() {}
  C<int> c;

We shouldn't be marking the instantiation of the friend decl of foo as
inline-specified. It may be possible to fix this by determining if the
full definition is part of the current template, but it seems better to
rever tot green until we come up with a full solution.

This reverts commit r233817, as well as follow-ups r233820 and r233821.

llvm-svn: 234355
2015-04-07 20:46:51 +00:00
Fariborz Jahanian d436b2a4ce [Objective-C Sema] Patch to not issue unavailbility/deprecated
warning when multiple method declarations are found in global pool
with differing types and some are available.
rdar://20408445

llvm-svn: 234328
2015-04-07 16:56:27 +00:00
Daniel Jasper 303c3ac925 Revert "[SEH] Implement filter capturing in CodeGen"
Test fails:
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/3182/

llvm-svn: 234306
2015-04-07 10:07:47 +00:00
David Majnemer 06864814e5 [Sema] Don't crash when __attribute__((nonnull)) is applied to blocks
A simple case of asserting isFunctionOrMethod when we should have
asserted isFunctionOrMethodOrBlock.

This fixes PR23117.

llvm-svn: 234297
2015-04-07 06:01:53 +00:00
David Majnemer 26a1e0ef76 [Sema] Don't permit dependent alignments on non-dependent typedef-names
A dependent alignment attribute (like __attribute__((aligned(...))) or
__declspec(align(...))) on a non-dependent typedef or using declaration
poses a considerable challenge: the type is _not_ dependent, the size
_may_ be dependent if the type is used as an array type, the alignment
_is_ dependent.

It is reasonable for a compiler to be able to query the size and
alignment of a complete type.  Let's help that become an invariant.

This fixes PR22042.

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

llvm-svn: 234280
2015-04-07 02:37:09 +00:00
Bob Wilson 433cb315d3 Report an error when -m<os>-version-min= does not specify a version.
Currently if you use -mmacosx-version-min or -mios-version-min without
specifying a version number, clang silently sets the minimum version to
"0.0.0". This is almost certainly not what was intended, so it is better
to report it as an error. rdar://problem/20433945

llvm-svn: 234270
2015-04-07 01:03:35 +00:00
Reid Kleckner 67cf035a99 [WinEH] Don't create an alloca for unnamed catch parameters
The catch object parameter to llvm.eh.begincatch is optional, and can be
null. We can save some ourselves the stack space, copy ctor, and dtor
calls if we pass null.

llvm-svn: 234264
2015-04-07 00:09:59 +00:00
Reid Kleckner 0ada50f17f [SEH] Implement filter capturing in CodeGen
While capturing filters aren't very common, we'd like to outline
__finally blocks in the frontend to simplify -O0 EH preparation and
reduce code size. Finally blocks are usually have captures, and this is
the first step towards that.

Currently we don't support capturing 'this' or VLAs.

Reviewers: majnemer

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

llvm-svn: 234261
2015-04-06 23:51:44 +00:00
Fariborz Jahanian 220d08d942 [Objective-C patch] Patch to fix a crash in IRGen because
of incorrect AST when a compound literal of Objective-C
property access is used to initialize a vertor of floats.
rdar://20407999

llvm-svn: 234176
2015-04-06 16:56:39 +00:00
David Blaikie 981d2a04b7 Fix this test so it doesn't try to open a file to write to the source tree
llvm-svn: 234173
2015-04-06 16:33:18 +00:00
Michael Kuperstein aed5ccdeed HasSideEffects() should return false for calls to pure and const functions.
Differential Revision: http://reviews.llvm.org/D8548

llvm-svn: 234152
2015-04-06 13:22:01 +00:00
NAKAMURA Takumi a01846de2a clang/test/Profile/profile-does-not-exist.c: Avoid checking a message line in the message catalog.
llvm-svn: 234146
2015-04-06 08:16:36 +00:00
Rafael Espindola 298059a4ac This reverts commit r234104, bringing back 233393 now that ARM is fixed.
Original message:

Don't use unique section names by default if using the integrated as.

This saves some IO and ccache space by not creating long section names. It
should work with every ELF linker.

llvm-svn: 234143
2015-04-06 04:36:45 +00:00
Nico Weber 176efac95b Don't crash when passing a non-existent file to -fprofile-instr-use=.
Fixes a regression from r229434.

llvm-svn: 234141
2015-04-06 04:16:48 +00:00
David Majnemer 9c2ad31abf Switch test from wchar_t to char32_t
Windows has a 16-bit wchar_t, most Unix platforms have a 32-bit wchar_t.
Use a char32_t to keep the test's output stable.

llvm-svn: 234111
2015-04-05 05:42:02 +00:00
David Majnemer 314b72f842 [AST] String literal operator templates have two template args, not one
StmtPrinter assumed that the first template arg was the pack and
attempted to iterate it.  However, the GNU extension (which is really
just N3599), has two template arguments.  In this case, the second
argument is the pack containing the string contents.

Handle this by desugaring the call to the explicit operator.

For example:
"qux" _zombocom will be shown as
operator "" _zombocom<char, 'q', 'u', 'x'>() in diagnostics and AST
dumps.

N.B.  It is actually impossible to render the arguments back to the
source form without storing more information in the AST.  For example,
we cannot tell if the user wrote u8"qux" or "qux".  We also lose
fidelity when it comes to non-char types for this exact reason (e.g. it
is hard to render a list of wchar_t back to something that can be
printed to the screen even if you don't have to consider surrogate
pairs).

This fixes PR23120.

llvm-svn: 234110
2015-04-05 05:32:54 +00:00
Rafael Espindola d7329ef99f Revert "Revert "Revert "Don't use unique section names by default if using the integrated as."""
This reverts commit r234101. I will debug what went wrong with ARM.

llvm-svn: 234104
2015-04-04 19:32:41 +00:00
Rafael Espindola 321fabfd8e Revert "Revert "Don't use unique section names by default if using the integrated as.""
This reverts commit r233398, bringing back 233393 now that LLVM is fixed.

Original message:

Don't use unique section names by default if using the integrated as.

This saves some IO and ccache space by not creating long section names. It
should work with every ELF linker.

llvm-svn: 234101
2015-04-04 18:21:14 +00:00
Sanjay Patel a932bb93b0 Remove the cl-no-signed-zeros cc1 option
Use the driver flag -fno-signed-zeros instead.

This was recommended but not implemented in D6873:
http://reviews.llvm.org/D6873

which was checked in at r226915:
http://reviews.llvm.org/rL226915

llvm-svn: 234093
2015-04-04 14:54:24 +00:00
David Majnemer f205f5324b [MS ABI] A pointer-to-function cannot be caught as a pointer-to-void
Don't assume that all pointers are convertible to void pointer.
Instead correctly respect [conv.ptr]p2; only allow pointer types with an
object pointee type to be caught as pointer-to-void.

llvm-svn: 234090
2015-04-04 05:37:48 +00:00
Manman Ren 2738278b7f [i386 ABI] expand small C like structs in C++, just like how we handle small
C structs.

This comes up when we have a function that takes a struct and is defined in a
C++ file and used in a C file.

Before this commit, we will generate byval for C++ and will expand the struct
for C, thus causing difference at IR level. We will use bitcast of function type
at the callsite, which causes the inliner to not inline the function.

This commit changes how we handle small C like structs at IR level, but at
backend, we should generate the same argument passing before and after the
commit.

Note that the condition for expanding is still over conservative. We should be
able to expand type that is spelled with “class” and types that are not C-like.
But this commit fixes the inconsistent argument passing between C/C++.

Reviewed by John.

rdar://20121030

llvm-svn: 234033
2015-04-03 18:10:29 +00:00
Eric Christopher c168ef4b5f Make this test not rely on a backend being registered.
llvm-svn: 233993
2015-04-03 01:27:02 +00:00
Eric Christopher 6e11073b3e Unify warnings/errors from "maybe you meant" to "did you mean".
llvm-svn: 233981
2015-04-02 22:10:06 +00:00
Reid Kleckner 85368fb32d Correct typos in SEH filter expressions
Otherwise we assert due to uncorrected delayed typos.

llvm-svn: 233980
2015-04-02 22:09:32 +00:00
Fariborz Jahanian e1b9843375 [Objective-C SDK modernizer]. Patch to convert setter/getter
methods in protocols to their respective property
declarations. rdar://19372798

llvm-svn: 233977
2015-04-02 21:36:03 +00:00
Alexey Bataev 8bf6b3eaf7 [OPENMP] Fix crash on private variables not used in OpenMP region in templates.
llvm-svn: 233913
2015-04-02 13:07:08 +00:00
Alexey Bataev a8d4a54346 [OPENMP] Fix crash on private variables not used in OpenMP region.
llvm-svn: 233902
2015-04-02 07:48:16 +00:00
Peter Collingbourne 1a7488afaa Implement CFI type checks for non-virtual calls.
This uses the same class metadata currently used for virtual call and
cast checks.

The new flag is -fsanitize=cfi-nvcall. For consistency, the -fsanitize=cfi-vptr
flag has been renamed -fsanitize=cfi-vcall.

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

llvm-svn: 233874
2015-04-02 00:23:30 +00:00
Reid Kleckner 56f84515a2 Add test intended for commit in r231317
llvm-svn: 233866
2015-04-01 23:32:03 +00:00
Alexey Samsonov 31095469aa [UBSan] Embed UBSan into ASan runtime (Clang part).
Summary:
Change the way we use ASan and UBSan together. Instead of keeping two
separate runtimes (libclang_rt.asan and libclang_rt.ubsan), embed UBSan
into ASan and get rid of libclang_rt.ubsan. If UBSan is not supported on
a platform, all UBSan sources are just compiled into dummy empty object
files. UBSan initialization code (e.g. flag parsing) is directly called
from ASan initialization, so we are able to enforce correct
initialization order.

This mirrors the approach we already use for ASan+LSan. This change doesn't
modify the way we use standalone UBSan.

Test Plan: regression test suite

Reviewers: kubabrecka, zaks.anna, kcc, rsmith

Subscribers: cfe-commits

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

llvm-svn: 233860
2015-04-01 22:42:25 +00:00