Commit Graph

56274 Commits

Author SHA1 Message Date
Paul Robinson 080b1f3055 When attribute 'optnone' appears on the same declaration with a
conflicting attribute, warn about the conflict and pick a "winning"
attribute to preserve, instead of emitting an error.  This matches the
behavior when the conflicting attributes are on different declarations.

Along the way I discovered that conflicts involving __forceinline were
reported as 'always_inline' (alternate spelling, same attribute) so
fixed that up to report the attribute as spelled in the source.

llvm-svn: 225813
2015-01-13 18:34:56 +00:00
Ben Langmuir c1d88ea5a7 Inherit attributes when infering a framework module
If a module map contains
framework module * [extern_c] {}

We will now infer [extern_c] on the inferred framework modules (we
already inferred [system] as a special case).

llvm-svn: 225803
2015-01-13 17:47:44 +00:00
Ben Langmuir 7615f00e51 Handle [extern_c] attribute in module printer
I'm not sure why we have OS.indent(Indent+2) for the system attribute,
but presumably we want the same behaviour for all attributes...

llvm-svn: 225802
2015-01-13 17:47:38 +00:00
Ben Langmuir d3d7f3b5bd Remove unused method canInferFrameworkModule
llvm-svn: 225801
2015-01-13 17:47:29 +00:00
Daniel Sanders cdcb580d4e [mips] Fix va_arg() for pointer types on big-endian N32.
Summary:
The Mips ABI's treat pointers in the same way as integers. They are
sign-extended to 32-bit for O32, and 64-bit for N32/N64. This doesn't matter
for O32 and N64 where pointers are already the correct width but it does matter
for big-endian N32, where pointers are 32-bit and need promoting.

The caller side is already passing pointers correctly. This patch corrects the
callee.

Reviewers: vmedic, atanasyan

Reviewed By: atanasyan

Subscribers: cfe-commits

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

llvm-svn: 225782
2015-01-13 10:47:00 +00:00
David Majnemer cdf8a71d36 Revert "Sema: An extern declaration can't be a redeclaration of a parameter"
This reverts commit r225780, we can't compile line 181 in
sanitizer_platform_limits_posix.cc with this commit.

llvm-svn: 225781
2015-01-13 10:14:57 +00:00
David Majnemer c3691827c0 Sema: An extern declaration can't be a redeclaration of a parameter
In the following:
void f(int x) { extern int x; }

The second declaration of 'x' shouldn't be considered a redeclaration of
the parameter.

llvm-svn: 225780
2015-01-13 09:55:56 +00:00
Manuel Klimek 1ba46c661c Update clang-format.el to use xml output and patch in the returned chunks.
This leads to better undo behavior and avoids window content jumping
around.

Patch by Johann Klähn.

llvm-svn: 225777
2015-01-13 08:35:34 +00:00
David Majnemer d5946f51a5 Parse: Switch to using EOF tokens for late parsed attributes
The EOF token injection technique is preferable to using
isBeforeInTranslationUnit to determine whether or not additional cleanup
is needed.  I don't have an example off-hand that requires it but it is
nicer nonetheless.

llvm-svn: 225776
2015-01-13 08:35:24 +00:00
David Majnemer b3c6d52d3a Parse: Don't crash when default argument in typedef consists of sole '='
We'd crash trying to make the SourceRange for the tokens we'd like to
highlight.  Don't assume there is more than one token makes up the
default argument.

llvm-svn: 225774
2015-01-13 07:42:33 +00:00
David Majnemer 906ed278b9 Parse: Don't crash if missing an initializer expression
llvm-svn: 225768
2015-01-13 05:28:24 +00:00
David Majnemer a7ea1b1466 Parse: use the EOF token method to lex inline method bodies
Mark the end of the method body with an EOF token, collect it once we
expect to be done with method body parsing.  No functionality change
intended.

llvm-svn: 225765
2015-01-13 05:06:20 +00:00
David Majnemer 7cceba5d76 Parse: Further simplify ParseLexedMethodDeclaration
No functionality change intended, just moving code around to make it
simpler.

llvm-svn: 225763
2015-01-13 04:20:57 +00:00
Nico Weber 8b51ae93e4 Mark vtable used on explicit destructor definitions.
There are two things in a C++ program that need to read the vtable pointer:
Constructors and destructors.  (A few other operations -- virtual calls,
dynamic cast, rtti -- read the vtable pointer off a this pointer, but for
this they don't need the vtable symbol.)  Implicit constructors and destructors
and explicit constructors already marked the vtable as used, but explicit
destructors didn't.

Note that the only thing sema's "mark a class's vtable used" does is to mark all 
final overriders of the class as referenced, it does _not_ cause emission of
the vtable itself.  This is done on demand by codegen, independent of sema,
since sema might emit functions that are not referenced.  (The exception are
vtables that are forced via key functions -- these are forced onto codegen
by sema.)

This bug went unnoticed for years because it doesn't have observable effects
(yet -- I want to change this in PR20337, which is why I noticed this).

r213109 made it so that _calls_ to constructors don't mark the vtable used.
Currently, _calls_ to destructors still mark the vtable used.  If that
wasn't the case, this program would tickle the problem:

  test.h:
    template <typename T>
    struct B {
      int* p;
      virtual ~B() { delete p; }
      virtual void f() {}
    };

    struct __attribute__((visibility("default"))) C {
      C();
      B<int> m;
    };

  test2.cc:
    #include "test.h"
    int main() {
      C* c = new C;
      delete c;
    }

  test3.cc:
    #include "test.h"
    C::C() {}

  # This bin/clang++ binary doesn't MarkVTableUsed() for virtual dtor calls:
  $ bin/clang++ -shared test3.cc -std=c++11 -O2  -fvisibility=hidden \
        -fvisibility-inlines-hidden  -o libtest3.dylib
  $ bin/clang++ test2.cc -std=c++11 -O2  -fvisibility=hidden \
        -fvisibility-inlines-hidden  libtest3.dylib 
  Undefined symbols for architecture x86_64:
    "B<int>::f()", referenced from:
        vtable for B<int> in test2-af8f4f.o
  ld: symbol(s) not found for architecture x86_64

What's happening here is that there's a copy of B's vtable hidden in
libtest3.dylib, because C's constructor caused an implicit instantiation of that
(and implicit constructors generate vtables).
test2.cc calls C's destructDr, which destroys the B<int> member,
which wants to overwrite the vtable back to B (think of B as the base of a class
hierarchy, and of hierarchical destruction -- maybe we shouldn't do the vtable
writing in destructors of final classes), but there's nothing in test2.cc that
marks B's vtable used.  So codegen writes out the vtable, but since it wasn't
marked used, sema didn't mark all the virtual functions (in particular f())
as used.

Note that this change makes us reject programs we didn't reject before (see
the included Sema test case), but both gcc and cl also reject this code, and
clang used to reject it before r213109.

llvm-svn: 225761
2015-01-13 03:52:11 +00:00
Alexey Bataev 26a3924a4f [OPENMP] Consider global named register variables as threadprivate by default.
Register are thread-local by default, so we have to consider them as threadprivate.

llvm-svn: 225759
2015-01-13 03:35:30 +00:00
Richard Trieu 36d0b2b49f Extend the self move warning to record types.
Move the logic for checking self moves into SemaChecking and add that function
to Sema since it is now used in multiple places.

llvm-svn: 225756
2015-01-13 02:32:02 +00:00
Richard Smith b1c217e492 If we don't find a matching ) for a ( in an exception specification, keep the tokens around so we can diagnose an error rather than silently discarding them.
llvm-svn: 225755
2015-01-13 02:24:58 +00:00
Richard Smith 00a4a85d2b PR22208: On FreeBSD systems, __STDC_MB_MIGHT_NEQ_WC__ is expected to be defined
even though every basic source character literal has the same numerical value
as a narrow or wide character literal.

It appears that the FreeBSD folks are trying to use this macro to mean
something other than what the relevant standards say it means, but their usage
is conforming, so put up with it.

llvm-svn: 225751
2015-01-13 01:47:45 +00:00
Nico Weber c4b8e79396 Simplify a test. No behavior change.
Templates don't have key functions (cf computeKeyFunction() in
RecordLayoutBuilder.cpp), so don't have something that looks like one.

Also, instead of a vcall to force generation of the vtable, just construct
the object.  This is how the repro on PR5557 (what the test is for) worked too.

llvm-svn: 225741
2015-01-13 00:24:46 +00:00
Alexey Samsonov 8845952b54 Reimplement -fsanitize-recover family of flags.
Introduce the following -fsanitize-recover flags:
  - -fsanitize-recover=<list>: Enable recovery for selected checks or
      group of checks. It is forbidden to explicitly list unrecoverable
      sanitizers here (that is, "address", "unreachable", "return").
  - -fno-sanitize-recover=<list>: Disable recovery for selected checks or
     group of checks.
  - -f(no-)?sanitize-recover is now a synonym for
    -f(no-)?sanitize-recover=undefined,integer and will soon be deprecated.

These flags are parsed left to right, and mask of "recoverable"
sanitizer is updated accordingly, much like what we do for -fsanitize= flags.
-fsanitize= and -fsanitize-recover= flag families are independent.

CodeGen change: If there is a single UBSan handler function, responsible
for implementing multiple checks, which have different recoverable setting,
then we emit two handler calls instead of one:
the first one for the set of "unrecoverable" checks, another one - for
set of "recoverable" checks. If all checks implemented by a handler have the
same recoverability setting, then the generated code will be the same.

llvm-svn: 225719
2015-01-12 22:39:12 +00:00
Rafael Espindola 0d4fb98504 [patch][pr19848] Produce explicit comdats in clang.
The llvm IR until recently had no support for comdats. This was a problem when
targeting C++ on ELF/COFF as just using weak linkage would cause quite a bit of
dead bits to remain on the executable (unless -ffunction-sections,
-fdata-sections and --gc-sections were used).

To fix the problem, llvm's codegen will just assume that any weak or linkonce
that is not in an explicit comdat should be output in one with the same name as
the global.

This unfortunately breaks cases like pr19848 where a weak symbol is not
xpected to be part of any comdat.

Now that we have explicit comdats in the IR, we can finally get both cases
right.

This first patch just makes clang give explicit comdats to GlobalValues where
t is allowed to.

A followup patch to llvm will then stop implicitly producing comdats.

llvm-svn: 225705
2015-01-12 22:13:53 +00:00
Nico Weber 0a02992dc0 Wrap to 80 columns. No behavior change.
llvm-svn: 225703
2015-01-12 21:24:10 +00:00
Nico Weber f867c17ab5 Don't use a doc comment in a function body.
llvm-svn: 225701
2015-01-12 21:22:27 +00:00
Nathan Sidwell 822f041619 reverting due to build bot failure
llvm-svn: 225684
2015-01-12 20:13:20 +00:00
Ben Langmuir 74d5e7a79e Fix typo Block.h vs Blocks.h
Thanks for Jeremy for noticing!

llvm-svn: 225666
2015-01-12 19:42:27 +00:00
Bill Seurer cf2c96b0f6 [PowerPC]To provide better compatibility with gcc I added the __bool keyword to the Alitivec support in clang. __bool is functionally identical to using bool when declaring vector types. For example:
vector bool char v_bc;
vector __bool char v___bc;

clang already supported vector/__vector and pixel/__pixel but was missing __bool.

http://llvm.org/bugs/show_bug.cgi?id=19220

For reference: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html

http://reviews.llvm.org/D6882

llvm-svn: 225664
2015-01-12 19:35:51 +00:00
Ben Langmuir a0c32e9310 Fix bogus 'method is unavailable' errors with modules
This just tweaks the fix from r224892 (which handled PCHs) to work with
modules, where we will serialize each method individually and hence the
hasMoreThanOneDecl bit needs to be updated as we add the methods.

llvm-svn: 225659
2015-01-12 19:27:00 +00:00
Toma Tabacu cfab40f95b [mips] Explain why we need to always clobber for MIPS inline asm. NFC.
llvm-svn: 225632
2015-01-12 14:41:30 +00:00
Alexander Kornienko 00691cf3bb Fix assertion in BreakableBlockComment (http://llvm.org/PR21916).
Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 225628
2015-01-12 13:11:12 +00:00
NAKAMURA Takumi b70f83eb10 Suppress clang/test/Driver/rewrite-map-in-diagnostics.c on win32 for now. This doesn't fail on "env clang". Investigating.
llvm-svn: 225626
2015-01-12 11:39:04 +00:00
Daniel Jasper d6a1cab1bc clang-format: Improve format of lambdas in ctor initializers.
Before:
  Constructor()
      : Constructor([] { // comment
        int i;
      }) {}

After:
  Constructor()
      : Constructor([] { // comment
          int i;
        }) {}

llvm-svn: 225625
2015-01-12 10:23:24 +00:00
Alexey Bataev 19acc3d351 Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFC
llvm-svn: 225624
2015-01-12 10:17:46 +00:00
Daniel Jasper 2337f28063 clang-format: Fix formatting of inline asm.
Specifically, adjust the leading "__asm {" and trailing "}" while still
leaving the assembly inside it alone.

This fixes llvm.org/PR22190.

llvm-svn: 225623
2015-01-12 10:14:56 +00:00
David Majnemer 83de336b71 Parse: Get rid of cxx_exceptspec_end, use EOF instead
Similar to r225619, use a special EOF token to mark the end of the
exception specification instead of cxx_exceptspec_end.  Use the current
scope as the marker.

llvm-svn: 225622
2015-01-12 09:16:57 +00:00
David Majnemer bba1234849 Parse: Just a small tidy-up in ParseLexedMethodDeclaration
No functional change intended, just tidy up the parse flow.

llvm-svn: 225620
2015-01-12 06:51:15 +00:00
David Majnemer 06b7d006b8 Parse: Get rid of tok::cxx_defaultarg_end, use EOF instead
I added setEofData/getEofData to solve this sort of problem back in
r224505.  Use the Param's decl to tell us if this is *our* EOF token.

llvm-svn: 225619
2015-01-12 05:17:40 +00:00
David Majnemer 234b8188df Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directly
llvm-svn: 225616
2015-01-12 03:36:37 +00:00
David Majnemer a3aef35d54 Parse: Don't let BalancedDelimiterTracker consume cxx_defaultarg_end
It is not correct to let it consume the cxx_defaultarg_end token.  I'm
starting to wonder if it makes more sense to stop SkipUntil from
consuming such tokens.

llvm-svn: 225615
2015-01-12 03:14:18 +00:00
Saleem Abdulrasool 3661a82ef6 Driver: include rewrite maps in the diagnostics
The rewrite map files are not copied, and so cannot be tracked as temporary
files.  Add them explicitly to the list of files that we request from the user
to be attached to bug reports.

llvm-svn: 225614
2015-01-12 02:33:09 +00:00
David Majnemer 89296ee2c3 Parse: Don't parse beyond the end of the synthetic default argument tok
Recovery from malformed lambda introducers would find us consuming the
synthetic default argument token, which is bad.  Instead, stop right
before that token.

llvm-svn: 225613
2015-01-12 02:28:16 +00:00
David Majnemer b6b5643b36 Basic: Numeric constraints are multidigit
Clang would treat the digits in an "11m" input constraint separately as
if it was handling constraint 1 twice instead of constraint 11.

llvm-svn: 225606
2015-01-11 10:22:41 +00:00
David Majnemer 55164f901b Basic: [asmSymbolicName] follows the same rule as numbers in asm inputs
Input constraints like "0" and "[foo]" should be treated the same when
it comes to their corresponding output constraint.

This fixes PR21850.

llvm-svn: 225605
2015-01-11 09:57:13 +00:00
David Majnemer c71a566d00 Basic: The asm constraint '#m' isn't valid, reject it
llvm-svn: 225603
2015-01-11 09:39:03 +00:00
David Majnemer f1fdf4a80c CodeGen: Simplify consecutive '%' modifiers
LLVM the consecutive '%' modifiers are redundant, skip them.

llvm-svn: 225602
2015-01-11 09:13:56 +00:00
David Majnemer 14d4e7bdbf CodeGen: Simplify consecutive '&' modifiers
LLVM the consecutive '&' modifiers are redundant, skip them.

llvm-svn: 225601
2015-01-11 09:09:01 +00:00
David Majnemer 50cb05591d Basic: The asm constraint '+#r' isn't valid, reject it
llvm-svn: 225600
2015-01-11 08:52:38 +00:00
Chandler Carruth 68fba279bc Don't rely on the default constructor default constructing a begin and
end iterator for iterator_range<>. I removed this constructor because
for some iterators (notably pointers) it left begin and end
uninitialized. It also is an usual constraint that an iterator default
constructs to a valid end iterator such that the pair of them for
a valid range. In the three places where this was used in Clang,
explicitly build the empty range from the iterators and comment on why
default constructed iterators make sense here.

llvm-svn: 225594
2015-01-11 01:43:06 +00:00
Nathan Sidwell f9701c6e83 fix pr18645. Correct logic concerning 'T &&' deduction against lvalues.
llvm-svn: 225587
2015-01-10 18:16:25 +00:00
David Majnemer a0040df38c Sema: The asm constraint '+&m' isn't valid, reject it
Don't permit '+&m' to make it to CodeGen, it's invalid.

llvm-svn: 225586
2015-01-10 10:43:19 +00:00
Richard Trieu 17ddb829aa Add a new warning, -Wself-move, to Clang.
-Wself-move is similiar to -Wself-assign.  This warning is triggered when
a value is attempted to be moved to itself.  See r221008 for a bug that
would have been caught with this warning.

llvm-svn: 225581
2015-01-10 06:04:18 +00:00