Commit Graph

17980 Commits

Author SHA1 Message Date
Nico Weber 07425af920 Typo fixo.
llvm-svn: 227554
2015-01-30 03:47:03 +00:00
Filipe Cabecinhas 28f353c7d0 Add some more PS4 driver settings related to rtti and exceptions.
Summary:
The PS4 defaults to -fno-rtti, and has to have rtti enabled when enabling
exceptions.

This commit makes clang add the -fno-rtti by default on the PS4, unless
-frtti was passed in.

It also diagnoses misuses for the PS4:
- Exceptions need rtti. Warn and enable rtti if no rtti flag was passed,
  error if -fno-rtti was passed.

I also added a more general warning for when -fno-rtti is the default
(currently it's only on the PS4) and the vptr sanitizer is on.

Fixed a few tests, due to different flag order when passing cc1 arguments.

Reviewers: chandlerc

Subscribers: cfe-commits

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

llvm-svn: 227518
2015-01-29 23:56:43 +00:00
Rafael Espindola 3c5f2354b8 This reverts commit r227432, r227438 and r227448.
It should bring the bots back.

Original messagses:

r227448:
   Remove unnecessary default.

r227438:
   Fix Index/print-type.cpp test following r227432.

r227432:
    libclang: Add three functions useful for dealing with anonymous fields:
       clang_Cursor_getOffsetOfField
       clang_Cursor_isAnonymous
       clang_Type_visitFields
    Python: Add corresponding methods for dealing with anonymous fields.

    Patch by Loïc Jaquemet

llvm-svn: 227472
2015-01-29 17:22:53 +00:00
Francois Pichet f3be1cc5a9 libclang: Add three functions useful for dealing with anonymous fields:
clang_Cursor_getOffsetOfField
   clang_Cursor_isAnonymous
   clang_Type_visitFields
Python: Add corresponding methods for dealing with anonymous fields.

Patch by Loïc Jaquemet

llvm-svn: 227432
2015-01-29 12:45:29 +00:00
David Majnemer 310e3a8f60 MS ABI: Implement proper support for setjmp
On targets which use the MSVCRT, setjmp is a macro which expands to
_setjmp or _setjmpex.

_setjmp and _setjmpex have a secret, hidden argument which is not listed
in the function prototype on X64 and WoA.  This hidden argument always
seems to be the frame pointer.

_setjmpex isn't used on X86, _setjmp is magically replaced with a call
to _setjmp3.  The second argument is zero for 'normal' setjmp/longjmp
pairs, otherwise it is a count of additional variadic arguments.  This
is used when setjmp appears inside of a try or __try.

It is not safe to use a pointer to setjmp because _setjmp, _setjmpex and
_setmp3 are not compatible with setjmp.

llvm-svn: 227426
2015-01-29 09:29:21 +00:00
David Majnemer b9bf14c549 Basic: Re-sort these builtins
No functional change, it just makes it a little easier to find what you
are looking for.

llvm-svn: 227425
2015-01-29 09:29:17 +00:00
Nico Weber 6cf2df29e7 Make a codegen warning a real warning instead of a getCustomDiagID().
Warnings shouldn't use getCustomDiagID(), since then they can't be disabled
via a flag, can't be remapped, etc.

llvm-svn: 227420
2015-01-29 06:25:59 +00:00
Nathan Sidwell ffa7dc379f PR 17456
More helpful diagnostic on casts between unrelated class hierarchies.

llvm-svn: 227371
2015-01-28 21:31:26 +00:00
Derek Schuff 3970a7ec9b Remove support for pnaclcall attribute
Summary:
It was used for interoperability with PNaCl's calling conventions, but
it's no longer needed.

Also Remove NaCl*ABIInfo which just existed to delegate to either the portable
or native ABIInfo, and remove checkCallingConvention which was now a no-op
override.

Reviewers: jvoung

Subscribers: jfb, llvm-commits

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

llvm-svn: 227362
2015-01-28 20:24:52 +00:00
Richard Smith fee9e20b90 Fix layering violation: include/clang/Basic/PlistSupport.h should not include
files from include/clang/Lex. Clean up module map.

llvm-svn: 227361
2015-01-28 20:14:54 +00:00
Hal Finkel 77366097f4 Fix typo (count correctly) in include/clang/AST/TypeNodes.def
Patch by Mingjie Xing.

llvm-svn: 227313
2015-01-28 15:11:18 +00:00
Nathan Sidwell 0ba1940b8d PR 20146
make new diagnostic an ExtWarn

llvm-svn: 227312
2015-01-28 14:48:39 +00:00
Francisco Lopes da Silva 0c010cddb3 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

llvm-svn: 227309
2015-01-28 14:17:22 +00:00
Kaelyn Takata 7a503694fe Fix a think-o in handling ambiguous corrections for a TypoExpr.
Under certain circumstances, the identifier mentioned in the diagnostic
won't match the intended correction even though the replacement
expression and the note pointing to the decl are both correct.
Basically, the TreeTransform assumes the TypoExpr's Consumer points to
the correct TypoCorrection, but the handling of typos that appear to be
ambiguous from the point of view of TransformTypoExpr would cause that
assumption to be violated by altering the Consumer's correction stream.
This fix allows the Consumer's correction stream to be reset to the
right TypoCorrection after successfully resolving the percieved ambiguity.

Included is a fix to suppress correcting the RHS of an assignment to the
LHS of that assignment for non-C++ code, to prevent a regression in
test/SemaObjC/provisional-ivar-lookup.m.

This fixes PR22297.

llvm-svn: 227251
2015-01-27 22:01:39 +00:00
Nico Weber b3a9978dc8 Don't let virtual calls and dynamic casts call Sema::MarkVTableUsed().
clang currently calls MarkVTableUsed() for classes that get their virtual
methods called or that participate in a dynamic_cast. This is unnecessary,
since CodeGen only emits vtables when it generates constructor, destructor, and
vtt code. (*)

Note that Sema::MarkVTableUsed() doesn't cause the emission of a vtable.
Its main user-visible effect is that it instantiates virtual member functions
of template classes, to make sure that if codegen decides to write a vtable
all the entries in the vtable are defined.

While this shouldn't change the behavior of codegen (other than being faster),
it does make clang more permissive: virtual methods of templates (in particular
destructors) end up being instantiated less often. In particular, classes that
have members that are smart pointers to incomplete types will now get their
implicit virtual destructor instantiated less frequently. For example, this
used to not compile but does now compile:

    template <typename T> struct OwnPtr {
      ~OwnPtr() { static_assert((sizeof(T) > 0), "TypeMustBeComplete"); }
    };
    class ScriptLoader;
    struct Base { virtual ~Base(); };
    struct Sub : public Base {
      virtual void someFun() const {}
      OwnPtr<ScriptLoader> m_loader;
    };
    void f(Sub *s) { s->someFun(); }

The more permissive behavior matches both gcc (where this is not often
observable, since in practice most things with virtual methods have a key
function, and Sema::DefineUsedVTables() skips vtables for classes with key
functions) and cl (which is my motivation for this change) – this fixes
PR20337.  See this issue and the review thread for some discussions about
optimizations.

This is similar to r213109 in spirit. r225761 was a prerequisite for this
change.

Various tests relied on "a->f()" marking a's vtable as used (in the sema
sense), switch these to just construct a on the stack. This forces
instantiation of the implicit constructor, which will mark the vtable as used.

(*) The exception is -fapple-kext mode: In this mode, qualified calls to
virtual functions (`a->Base::f()`) still go through the vtable, and since the
vtable pointer off this doesn't point to Base's vtable, this needs to reference
Base's vtable directly. To keep this working, keep referencing the vtable for
virtual calls in apple kext mode.

llvm-svn: 227073
2015-01-26 06:23:36 +00:00
Yaron Keren 3bf8462331 clang-format two Decl* code locations, NFC.
llvm-svn: 227070
2015-01-26 04:41:07 +00:00
Craig Topper ad1766aaa0 [X86] Add AVX512 floating cmpgt and integer comparison builtins. Intrinsic header file usages coming later.
llvm-svn: 227065
2015-01-25 23:30:00 +00:00
Renato Golin b625f48862 Allows Clang to use LLVM's fixes-x18 option
This patch allows clang to have llvm reserve the x18
platform register on AArch64. FreeBSD will use this in the kernel for
per-cpu data but has no need to reserve this register in userland so
will need this flag to reserve it.

This uses llvm r226664 to allow this register to be reserved.

Patch by Andrew Turner.

llvm-svn: 227062
2015-01-25 23:17:48 +00:00
David Blaikie 4e340b75b2 Fix the buildbots (fallout from r227028) by returning the exprloc of non-binary operator overload calls (and ->) to the start of the expression, not the location of the operator
I'll give this some further thought/discussion later, but this is enough
to unbreak the buildbots at least.

llvm-svn: 227034
2015-01-25 07:44:05 +00:00
David Blaikie 9f7ae2c948 DebugInfo: Attribute calls to overloaded operators with the operator, not the start of the whole expression
llvm-svn: 227028
2015-01-25 01:25:37 +00:00
Richard Smith 8a63989728 [modules] Sometimes we can deserialize a class member but not have yet
encountered any definition for the class; this happens when the definition is
added by an update record that is not yet loaded. In such a case, eagerly pick
the original parent of the member as the canonical definition of the class
rather than muddling through with the canonical declaration (the latter can
lead to us failing to merge properly later if the canonical definition turns
out to be some other declaration).

llvm-svn: 226977
2015-01-24 01:07:20 +00:00
Sanjay Patel 76c9e0986c Process the -fno-signed-zeros optimization flag (PR20870)
The driver currently accepts but ignores the -fno-signed-zeros flag. 
This patch passes the flag through and enables 'nsz' fast-math-flag 
generation in IR.

The existing OpenCL flag for the same functionality is made into an
alias here. It may be removed in a subsequent patch.

This should resolve bug 20870 ( http://llvm.org/bugs/show_bug.cgi?id=20870 );
patches for the optimizer were checked in at:
http://llvm.org/viewvc/llvm-project?view=revision&revision=225050
http://llvm.org/viewvc/llvm-project?view=revision&revision=224583

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

llvm-svn: 226915
2015-01-23 16:40:50 +00:00
Joerg Sonnenberger a43872ccdd When reporting constraints that should be constant, the type doesn't
really help. Improve diagnostics.

llvm-svn: 226863
2015-01-22 21:01:00 +00:00
Francisco Lopes da Silva 36e1ddfd13 Makes a simple member function static.
This function has been just included with the initial support for C++
parameter completion and it's trivial enough to be a static member.

llvm-svn: 226780
2015-01-22 04:30:23 +00:00
Reid Kleckner 1d59f99f5c Initial support for Win64 SEH IR emission
The lowering looks a lot like normal EH lowering, with the exception
that the exceptions are caught by executing filter expression code
instead of matching typeinfo globals. The filter expressions are
outlined into functions which are used in landingpad clauses where
typeinfo would normally go.

Major aspects that still need work:
- Non-call exceptions in __try bodies won't work yet. The plan is to
  outline the __try block in the frontend to keep things simple.
- Filter expressions cannot use local variables until capturing is
  implemented.
- __finally blocks will not run after exceptions. Fixing this requires
  work in the LLVM SEH preparation pass.

The IR lowering looks like this:

// C code:
bool safe_div(int n, int d, int *r) {
  __try {
    *r = normal_div(n, d);
  } __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) {
    return false;
  }
  return true;
}

; LLVM IR:
define i32 @filter(i8* %e, i8* %fp) {
  %ehptrs = bitcast i8* %e to i32**
  %ehrec = load i32** %ehptrs
  %code = load i32* %ehrec
  %matches = icmp eq i32 %code, i32 u0xC0000094
  %matches.i32 = zext i1 %matches to i32
  ret i32 %matches.i32
}

define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) {
  %rr = invoke i32 @normal_div(i32 %n, i32 %d)
      to label %normal unwind to label %lpad

normal:
  store i32 %rr, i32* %r
  ret i1 1

lpad:
  %ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler
      catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*)
  %ehptr = extractvalue {i8*, i32} %ehvals, i32 0
  %sel = extractvalue {i8*, i32} %ehvals, i32 1
  %filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*))
  %matches = icmp eq i32 %sel, %filter_sel
  br i1 %matches, label %eh.except, label %eh.resume

eh.except:
  ret i1 false

eh.resume:
  resume
}

Reviewers: rjmccall, rsmith, majnemer

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

llvm-svn: 226760
2015-01-22 01:36:17 +00:00
Francisco Lopes da Silva 975a9f6ece 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?

llvm-svn: 226670
2015-01-21 16:24:11 +00:00
David Majnemer 290d347471 Revert "Sema: err_after_alias is unreachable, remove it"
This reverts commit r226626.  err_after_alias is, in fact, reachable.

llvm-svn: 226633
2015-01-21 01:30:40 +00:00
David Majnemer 1efd55ff21 Sema: err_after_alias is unreachable, remove it
Examples this would have catched are now handled by the attribute
verification code.

llvm-svn: 226626
2015-01-21 00:52:17 +00:00
Hans Wennborg 77dc236605 Implement command line options for stack probe space
This code adds the -mstack-probe-size command line option and implements the /Gs
compiler switch for clang-cl.

This should fix http://llvm.org/bugs/show_bug.cgi?id=21896

Patch by Andrew H!

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

llvm-svn: 226601
2015-01-20 19:45:50 +00:00
Alexander Kornienko 21de0ae3d4 Re-apply "r226548 - Introduce SPIR calling conventions" reverted in r226558.
The test was fixed after a discussion with the revision author: the check
pattern was made more flexible as the "%call" part is not what we actually want
to check strictly there.

The original patch description:
===
Introduce SPIR calling conventions.

This implements Section 3.7 from the SPIR 1.2 spec:

    SPIR kernels should use "spir_kernel" calling convention.
    Non-kernel functions use "spir_func" calling convention. All
    other calling conventions are disallowed.

The patch works only for OpenCL source. Any other uses will need
to ensure that kernels are assigned the spir_kernel calling
convention correctly.
===

llvm-svn: 226561
2015-01-20 11:20:41 +00:00
Alexander Kornienko 22c9d67e34 Reverting r226548 as one of the tests fails in some configurations.
Here's the fail log from our internal setup:
===
  .../tools/clang/clang -cc1 -internal-isystem .../tools/clang/staging/include -nostdsysteminc .../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl -triple spir-unknown-unknown -emit-llvm -o -
  FileCheck .../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl
.../tools/clang/test/CodeGenOpenCL/spir-calling-conv.cl:11:12: error: expected string not found in input
 // CHECK: %call = tail call spir_func i32 @get_dummy_id(i32 0)
           ^
<stdin>:6:52: note: scanning from here
define spir_kernel void @foo(i32 addrspace(1)* %A) #0 {
                                                   ^
<stdin>:7:2: note: possible intended match here
 %1 = tail call spir_func i32 @get_dummy_id(i32 0) #2
 ^
===

Here's a failure on a public CI server:
http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_check/1183/

llvm-svn: 226558
2015-01-20 10:55:33 +00:00
Sameer Sahasrabuddhe 450a58b8af Introduce SPIR calling conventions.
This implements Section 3.7 from the SPIR 1.2 spec:

    SPIR kernels should use "spir_kernel" calling convention.
    Non-kernel functions use "spir_func" calling convention. All
    other calling conventions are disallowed.

The patch works only for OpenCL source. Any other uses will need
to ensure that kernels are assigned the spir_kernel calling
convention correctly.

llvm-svn: 226548
2015-01-20 06:44:32 +00:00
Adam Nemet f893edeaea [AVX512] Add sub-vector FP extracts
Analogous to AVX2, these need to be implemented as macros to properly
propagate the immediate index operand.

Part of <rdar://problem/17688758>

llvm-svn: 226496
2015-01-19 20:12:05 +00:00
David Majnemer 6b90356ab4 Add back a check removed in r226436
It shouldn't have been removed, the code which replaced it didn't cover
this case.

llvm-svn: 226442
2015-01-19 10:21:22 +00:00
David Majnemer 2dc8146643 Sema: Variable definitions cannot be __attribute__((alias))
Things that are OK:
  extern int var1 __attribute((alias("v1")));
  static int var2 __attribute((alias("v2")));

Things that are not OK:
  int var3 __attribute((alias("v3")));
  extern int var4 __attribute((alias("v4"))) = 4;

We choose to accpet:
  struct S { static int var5 __attribute((alias("v5"))); };

  This code causes assertion failues in GCC 4.8 and ICC 13.0.1, we have
  no reason to reject it.

This partially fixes PR22217.

llvm-svn: 226436
2015-01-19 09:00:28 +00:00
Craig Topper e954fd4cfa [X86] Change AVX512 intrinsics to take a 8-bit immediate for the comparision kind instead of a 32-bit immediate. This matches an equivalent change in llvm.
llvm-svn: 226431
2015-01-19 06:08:02 +00:00
Alexey Bataev 3255bf3aac [OPENMP] Disable copyprivate an nowait clauses in 'single' directive.
The copyprivate clause must not be used with the nowait clause in single
directive.

llvm-svn: 226429
2015-01-19 05:20:46 +00:00
Nathan Sidwell 44b21749b9 PR6037
Warn on inaccessible direct base

llvm-svn: 226423
2015-01-19 01:44:02 +00:00
Craig Topper f557b09f14 [x86] Mark that the AVX-512 cmpps/cmppd builtins need an ICE for the comparison immediate. This requires converting to a macro in the header file.
llvm-svn: 226421
2015-01-19 01:18:19 +00:00
Serge Pavlov 25a8afa957 Handle unscoped enumeration in nested name specifier.
If an unscoped enum is used as a nested name specifier and the language dialect
is not C++ 11, issue an extension warning.
This fixes PR16951.

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

llvm-svn: 226413
2015-01-18 20:04:35 +00:00
Serge Pavlov f80df57d39 Update error message text.
Previously if an enumeration was used in a nested name specifier in pre-C++11
language dialect, error message was 'XXX is not a class, namespace, or scoped
enumeration'. This patch removes the word 'scoped' as in C++11 any enumeration
may be used in this context.

llvm-svn: 226410
2015-01-18 19:05:48 +00:00
Nico Weber 7a92e1ad3d Address review feedback from r215780: Use a flag insteda of the heap. No behavior change.
llvm-svn: 226389
2015-01-18 01:50:35 +00:00
Steven Wu cb0d13fc23 Adding option -fno-inline-asm to disallow inline asm
Summary:
This patch add a new option to dis-allow all inline asm.
Any GCC style inline asm will be reported as an error.

Reviewers: rnk, echristo

Reviewed By: rnk, echristo

Subscribers: bob.wilson, rnk, echristo, rsmith, cfe-commits

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

llvm-svn: 226340
2015-01-16 23:05:28 +00:00
Jordan Rose a34d04d35e Suggest objc_method_family(none) for a property named -newFoo or similar.
As mentioned in the previous commit, if a property (declared with @property)
has a name that matches a special Objective-C method family, the getter picks
up that family despite being declared by the property. The most correct way
to solve this problem is to add the 'objc_method_family' attribute to the
getter with an argument of 'none', which unfortunately requires an explicit
declaration of the getter.

This commit adds a note to the existing error (ARC) or warning (MRR) for
such a poorly-named property that suggests the solution; if there's already
a declaration of the getter, it even includes a fix-it.

llvm-svn: 226339
2015-01-16 23:04:31 +00:00
Nico Weber d89e6f79f7 Don't crash if a declarator in a friend decl doesn't have a name.
There was already an explicit check for that for the first decl.  Move that
to a different place so that it's called for the following decls too.  Also
don't randomly set the BitfieldSize ExprResult to true (this sets a pointer to
true internally).

Found by SLi's bot.

llvm-svn: 226306
2015-01-16 19:34:13 +00:00
Adam Nemet c0cff244fc [AVX512] Add intrinsics for masked aligned FP loads and stores
Part of <rdar://problem/17688758>

llvm-svn: 226298
2015-01-16 18:51:50 +00:00
Hal Finkel 74618cc622 [PowerPC] Add a target option for invariant function descriptors
The PPC backend will now assume that PPC64 ELFv1 function descriptors are
invariant. This must be true for well-defined C/C++ code, but I'm providing an
option to disable this assumption in case someone's JIT-engine needs it.

llvm-svn: 226209
2015-01-15 21:22:22 +00:00
Hans Wennborg fd76d91366 Warn about dllexported explicit class template instantiation declarations (PR22035)
Clang would previously become confused and crash here.

It does not make a lot of sense to export these, so warning seems appropriate.

MSVC will export some member functions for this kind of specializations, whereas
MinGW ignores the dllexport-edness. The latter behaviour seems better.

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

llvm-svn: 226208
2015-01-15 21:18:30 +00:00
Nathan Sidwell c116802ef3 PR 20146
reject CV void return type on C definitions per 6.9.1/3

llvm-svn: 226178
2015-01-15 16:45:53 +00:00
David Majnemer 10fd83d11f AST: alignof might be dependent because of alignment attributes
Dependent alignment attributes should make an alignof expression
dependent as well.

llvm-svn: 226156
2015-01-15 10:04:14 +00:00