]> granicus.if.org Git - clang/log
clang
9 years agoclang-format: [Java] Prefer not to break in parameter annotations.
Daniel Jasper [Wed, 14 Jan 2015 10:36:31 +0000 (10:36 +0000)]
clang-format: [Java] Prefer not to break in parameter annotations.

Before:
  boolean someFunction(@Param(aaaaaaaaaaaaaaaa)
                       String aaaaa,
      String bbbbbbbbbbbbbbb) {}

After:
  boolean someFunction(
      @Param(aaaaaaaaaaaaaaaa) String aaaaa,
      String bbbbbbbbbbbbbbb) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225971 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: [Java] Understand "import static".
Daniel Jasper [Wed, 14 Jan 2015 10:02:49 +0000 (10:02 +0000)]
clang-format: [Java] Understand "import static".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225965 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: [Java] Don't let annotations confuse return type analysis.
Daniel Jasper [Wed, 14 Jan 2015 10:00:20 +0000 (10:00 +0000)]
clang-format: [Java] Don't let annotations confuse return type analysis.

Before:
  @Test
  ReturnType
  doSomething(String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}

After:
  @Test
  ReturnType doSomething(
      String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225964 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: [Java] Don't line-wrap before annotations' l_parens.
Daniel Jasper [Wed, 14 Jan 2015 09:51:32 +0000 (09:51 +0000)]
clang-format: [Java] Don't line-wrap before annotations' l_parens.

Before:
  @SomeAnnotation
  (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
  int i;

After:
  @SomeAnnotation(
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
  int i;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225963 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: [Java] Don't get confused by leading annotations.
Daniel Jasper [Wed, 14 Jan 2015 09:47:57 +0000 (09:47 +0000)]
clang-format: [Java] Don't get confused by leading annotations.

Before:
  @Test(a)
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaa);

After:
  @Test(a)
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225962 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoThe assembler is now enabled by default.
Brad Smith [Wed, 14 Jan 2015 08:23:49 +0000 (08:23 +0000)]
The assembler is now enabled by default.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225961 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: It's cheaper to ask LookupResult::empty than to calculate linkage
David Majnemer [Wed, 14 Jan 2015 08:08:52 +0000 (08:08 +0000)]
Sema: It's cheaper to ask LookupResult::empty than to calculate linkage

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225960 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoUse the integrated assembler by default on 32-bit PowerPC and SPARC.
Brad Smith [Wed, 14 Jan 2015 07:55:36 +0000 (07:55 +0000)]
Use the integrated assembler by default on 32-bit PowerPC and SPARC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225958 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoReapply r225000 (reverted in r225555): DebugInfo: Generalize debug info location...
David Blaikie [Wed, 14 Jan 2015 07:38:27 +0000 (07:38 +0000)]
Reapply r225000 (reverted in r225555): DebugInfo: Generalize debug info location handling (and follow-up commits).

Several pieces of code were relying on implicit debug location setting
which usually lead to incorrect line information anyway. So I've fixed
those (in r225955 and r225845) separately which should pave the way for
this commit to be cleanly reapplied.

The reason these implicit dependencies resulted in crashes with this
patch is that the debug location would no longer implicitly leak from
one place to another, but be set back to invalid. Once a call with
no/invalid location was emitted, if that call was ever inlined it could
produce invalid debugloc chains and assert during LLVM's codegen.

There may be further cases of such bugs in this patch - they're hard to
flush out with regression testing, so I'll keep an eye out for reports
and investigate/fix them ASAP if they come up.

Original commit message:

Reapply "DebugInfo: Generalize debug info location handling"

Originally committed in r224385 and reverted in r224441 due to concerns
this change might've introduced a crash. Turns out this change fixes the
crash introduced by one of my earlier more specific location handling
changes (those specific fixes are reverted by this patch, in favor of
the more general solution).

Recommitted in r224941 and reverted in r224970 after it caused a crash
when building compiler-rt. Looks to be due to this change zeroing out
the debug location when emitting default arguments (which were meant to
inherit their outer expression's location) thus creating call
instructions without locations - these create problems for inlining and
must not be created. That is fixed and tested in this version of the
change.

Original commit message:

This is a more scalable (fixed in mostly one place, rather than many
places that will need constant improvement/maintenance) solution to
several commits I've made recently to increase source fidelity for
subexpressions.

This resetting had to be done at the DebugLoc level (not the
SourceLocation level) to preserve scoping information (if the resetting
was done with CGDebugInfo::EmitLocation, it would've caused the tail end
of an expression's codegen to end up in a potentially different scope
than the start, even though it was at the same source location). The
drawback to this is that it might leave CGDebugInfo out of sync. Ideally
CGDebugInfo shouldn't have a duplicate sense of the current
SourceLocation, but for now it seems it does... - I don't think I'm
going to tackle removing that just now.

I expect this'll probably cause some more buildbot fallout & I'll
investigate that as it comes up.

Also these sort of improvements might be starting to show a weakness/bug
in LLVM's line table handling: we don't correctly emit is_stmt for
statements, we just put it on every line table entry. This means one
statement split over multiple lines appears as multiple 'statements' and
two statements on one line (without column info) are treated as one
statement.

I don't think we have any IR representation of statements that would
help us distinguish these cases and identify the beginning of each
statement - so that might be something we need to add (possibly to the
lexical scope chain - a scope for each statement). This does cause some
problems for GDB and possibly other DWARF consumers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225956 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDebugInof: Correct the location of exception cleanups in global ctors/dtors and ObjC...
David Blaikie [Wed, 14 Jan 2015 07:10:46 +0000 (07:10 +0000)]
DebugInof: Correct the location of exception cleanups in global ctors/dtors and ObjC methods

Without setting the CurEHLocation these cleanups would be attributed to
whatever the last active debug line location was (the 'fn' call in the
included test cases). By setting CurEHLocation correctly the line
information is improved/corrected.

This quality bug turned into a crasher with r225000 when, instead of
allowing the last location to persist, it would be zero'd out. This
could lead to a function call (such as the dtor) being made without a
debug location - if that call was subsequently inlined (and the caller
and callee had debug info, just not the call instruction) the inliner
would violate important constraints about the debug location chains by
not updating the inlined instructions to chain up to the callee
locations.

So, by fixing this bug, I am addressing the assertion failures
introduced by r225000 and should be able to recommit that patch with
impunity...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225955 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRevert "Insert random noops to increase security against ROP attacks (clang)"
JF Bastien [Wed, 14 Jan 2015 05:24:11 +0000 (05:24 +0000)]
Revert "Insert random noops to increase security against ROP attacks (clang)"

This reverts commit:
http://reviews.llvm.org/D3393

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225947 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: Relax parsing of '#' in constraints
David Majnemer [Wed, 14 Jan 2015 05:11:09 +0000 (05:11 +0000)]
Sema: Relax parsing of '#' in constraints

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225942 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: Check type compatibility with the most recent decl when merging
David Majnemer [Wed, 14 Jan 2015 02:27:38 +0000 (02:27 +0000)]
Sema: Check type compatibility with the most recent decl when merging

We would check the type information from the declaration found by lookup
but we would neglect checking compatibility with the most recent
declaration.  This would make it possible for us to not correctly
diagnose inconsistencies with declarations which were made in a
different scope.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225934 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[AVX512] Add FP unpack intrinsics
Adam Nemet [Wed, 14 Jan 2015 01:31:17 +0000 (01:31 +0000)]
[AVX512] Add FP unpack intrinsics

These are implemented with __builtin_shufflevector just like AVX.

We have some tests on the LLVM side to assert that these shufflevectors do
indeed generate the corresponding unpck instruction.

Part of <rdar://problem/17688758>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225922 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoInsert random noops to increase security against ROP attacks (clang)
JF Bastien [Wed, 14 Jan 2015 01:07:51 +0000 (01:07 +0000)]
Insert random noops to increase security against ROP attacks (clang)

A pass that adds random noops to X86 binaries to introduce diversity with the goal of increasing security against most return-oriented programming attacks.

Command line options:
  -noop-insertion // Enable noop insertion.
  -noop-insertion-percentage=X // X% of assembly instructions will have a noop prepended (default: 50%, requires -noop-insertion)
  -max-noops-per-instruction=X // Randomly generate X noops per instruction. ie. roll the dice X times with probability set above (default: 1). This doesn't guarantee X noop instructions.

In addition, the following 'quick switch' in clang enables basic diversity using default settings (currently: noop insertion and schedule randomization; it is intended to be extended in the future).
  -fdiversify

This is the clang part of the patch.
llvm part: D3392

http://reviews.llvm.org/D3393
Patch by Stephen Crane (@rinon)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225910 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoUpdate HelpText for -fsanitize= option.
Alexey Samsonov [Wed, 14 Jan 2015 00:51:17 +0000 (00:51 +0000)]
Update HelpText for -fsanitize= option.

There are too many available sanitizers now - redirect to
user manual instead of listing them all.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225894 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoUpdate for move in llvm.
Eric Christopher [Wed, 14 Jan 2015 00:50:32 +0000 (00:50 +0000)]
Update for move in llvm.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225892 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoLook through sugar when determining whether a type is a scoped enumeration
Richard Smith [Wed, 14 Jan 2015 00:33:10 +0000 (00:33 +0000)]
Look through sugar when determining whether a type is a scoped enumeration
type. Patch by Stephan Bergmann!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225889 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: An extern declaration can't be a redeclaration of a parameter
David Majnemer [Wed, 14 Jan 2015 00:31:13 +0000 (00:31 +0000)]
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.

This is a different approach to r225780.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225875 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSink a parameter into the callee since it's always the same expression in terms of...
David Blaikie [Wed, 14 Jan 2015 00:04:42 +0000 (00:04 +0000)]
Sink a parameter into the callee since it's always the same expression in terms of another parameter

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225856 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDebugInfo: Correct the location of EH cleanup for blocks
David Blaikie [Tue, 13 Jan 2015 23:06:27 +0000 (23:06 +0000)]
DebugInfo: Correct the location of EH cleanup for blocks

This was previously piggybacking on whatever happened to be the last
location set on CGDebugInfo/DIBuilder, which was wrong (it was often the
current location, such as the 'fn()' call site, not the end of the
block). With my improvements to set/unset the location in a scoped
manner (r225000) this went from a bad quality situation, to a crash.
Fixing this goes part-way to unblocking the recommit of r225000.

It's likely that any call to CodeGenFunction::StartFunction without the
CurEHLocation set represents a similar bug or risk of a bug. Perhaps
there are some callers that know they won't generate EH cleanups, but
I'm not sure.

I considered a generic catch-fix in StartFunction (just fallback to the
GlobalDecl's location) but that seemed like it'd mask bugs where the EH
location shouldn't be the same as the decl's location (& indeed by not
using that stop-gap I found this bug). We'll see how long I can hold out
on the generic catch-all. I might eventually be able to add an assertion
in.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225845 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: [Java] Detect `native` keyword.
Nico Weber [Tue, 13 Jan 2015 22:32:50 +0000 (22:32 +0000)]
clang-format: [Java] Detect `native` keyword.

Before:
  public native<X> Foo foo();

After:
  public native <X> Foo foo();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225839 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoAdd [extern_c] attribute to _Builtin_intrinsics module
Ben Langmuir [Tue, 13 Jan 2015 21:54:32 +0000 (21:54 +0000)]
Add [extern_c] attribute to _Builtin_intrinsics module

This allows users to import this module inside an extern "C" {} block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225835 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoMention FreeBSD support.
Roman Divacky [Tue, 13 Jan 2015 21:31:03 +0000 (21:31 +0000)]
Mention FreeBSD support.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225834 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoWhen attribute 'optnone' appears on the same declaration with a
Paul Robinson [Tue, 13 Jan 2015 18:34:56 +0000 (18:34 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225813 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoInherit attributes when infering a framework module
Ben Langmuir [Tue, 13 Jan 2015 17:47:44 +0000 (17:47 +0000)]
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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225803 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoHandle [extern_c] attribute in module printer
Ben Langmuir [Tue, 13 Jan 2015 17:47:38 +0000 (17:47 +0000)]
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...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225802 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRemove unused method canInferFrameworkModule
Ben Langmuir [Tue, 13 Jan 2015 17:47:29 +0000 (17:47 +0000)]
Remove unused method canInferFrameworkModule

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225801 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[mips] Fix va_arg() for pointer types on big-endian N32.
Daniel Sanders [Tue, 13 Jan 2015 10:47:00 +0000 (10:47 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225782 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRevert "Sema: An extern declaration can't be a redeclaration of a parameter"
David Majnemer [Tue, 13 Jan 2015 10:14:57 +0000 (10:14 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225781 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: An extern declaration can't be a redeclaration of a parameter
David Majnemer [Tue, 13 Jan 2015 09:55:56 +0000 (09:55 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225780 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoUpdate clang-format.el to use xml output and patch in the returned chunks.
Manuel Klimek [Tue, 13 Jan 2015 08:35:34 +0000 (08:35 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225777 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Switch to using EOF tokens for late parsed attributes
David Majnemer [Tue, 13 Jan 2015 08:35:24 +0000 (08:35 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225776 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Don't crash when default argument in typedef consists of sole '='
David Majnemer [Tue, 13 Jan 2015 07:42:33 +0000 (07:42 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225774 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Don't crash if missing an initializer expression
David Majnemer [Tue, 13 Jan 2015 05:28:24 +0000 (05:28 +0000)]
Parse: Don't crash if missing an initializer expression

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225768 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: use the EOF token method to lex inline method bodies
David Majnemer [Tue, 13 Jan 2015 05:06:20 +0000 (05:06 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225765 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Further simplify ParseLexedMethodDeclaration
David Majnemer [Tue, 13 Jan 2015 04:20:57 +0000 (04:20 +0000)]
Parse: Further simplify ParseLexedMethodDeclaration

No functionality change intended, just moving code around to make it
simpler.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225763 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoMark vtable used on explicit destructor definitions.
Nico Weber [Tue, 13 Jan 2015 03:52:11 +0000 (03:52 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225761 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[OPENMP] Consider global named register variables as threadprivate by default.
Alexey Bataev [Tue, 13 Jan 2015 03:35:30 +0000 (03:35 +0000)]
[OPENMP] Consider global named register variables as threadprivate by default.
Register are thread-local by default, so we have to consider them as threadprivate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225759 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoExtend the self move warning to record types.
Richard Trieu [Tue, 13 Jan 2015 02:32:02 +0000 (02:32 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225756 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoIf we don't find a matching ) for a ( in an exception specification, keep the tokens...
Richard Smith [Tue, 13 Jan 2015 02:24:58 +0000 (02:24 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225755 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoPR22208: On FreeBSD systems, __STDC_MB_MIGHT_NEQ_WC__ is expected to be defined
Richard Smith [Tue, 13 Jan 2015 01:47:45 +0000 (01:47 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225751 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSimplify a test. No behavior change.
Nico Weber [Tue, 13 Jan 2015 00:24:46 +0000 (00:24 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225741 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoReimplement -fsanitize-recover family of flags.
Alexey Samsonov [Mon, 12 Jan 2015 22:39:12 +0000 (22:39 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225719 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[patch][pr19848] Produce explicit comdats in clang.
Rafael Espindola [Mon, 12 Jan 2015 22:13:53 +0000 (22:13 +0000)]
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225705 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoWrap to 80 columns. No behavior change.
Nico Weber [Mon, 12 Jan 2015 21:24:10 +0000 (21:24 +0000)]
Wrap to 80 columns. No behavior change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225703 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDon't use a doc comment in a function body.
Nico Weber [Mon, 12 Jan 2015 21:22:27 +0000 (21:22 +0000)]
Don't use a doc comment in a function body.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225701 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoreverting due to build bot failure
Nathan Sidwell [Mon, 12 Jan 2015 20:13:20 +0000 (20:13 +0000)]
reverting due to build bot failure

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225684 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix typo Block.h vs Blocks.h
Ben Langmuir [Mon, 12 Jan 2015 19:42:27 +0000 (19:42 +0000)]
Fix typo Block.h vs Blocks.h

Thanks for Jeremy for noticing!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225666 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[PowerPC]To provide better compatibility with gcc I added the __bool keyword to the...
Bill Seurer [Mon, 12 Jan 2015 19:35:51 +0000 (19:35 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225664 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix bogus 'method is unavailable' errors with modules
Ben Langmuir [Mon, 12 Jan 2015 19:27:00 +0000 (19:27 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225659 91177308-0d34-0410-b5e6-96231b3b80d8

9 years ago[mips] Explain why we need to always clobber for MIPS inline asm. NFC.
Toma Tabacu [Mon, 12 Jan 2015 14:41:30 +0000 (14:41 +0000)]
[mips] Explain why we need to always clobber  for MIPS inline asm. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225632 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix assertion in BreakableBlockComment (http://llvm.org/PR21916).
Alexander Kornienko [Mon, 12 Jan 2015 13:11:12 +0000 (13:11 +0000)]
Fix assertion in BreakableBlockComment (http://llvm.org/PR21916).

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225628 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSuppress clang/test/Driver/rewrite-map-in-diagnostics.c on win32 for now. This doesn...
NAKAMURA Takumi [Mon, 12 Jan 2015 11:39:04 +0000 (11:39 +0000)]
Suppress clang/test/Driver/rewrite-map-in-diagnostics.c on win32 for now. This doesn't fail on "env clang". Investigating.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225626 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Improve format of lambdas in ctor initializers.
Daniel Jasper [Mon, 12 Jan 2015 10:23:24 +0000 (10:23 +0000)]
clang-format: Improve format of lambdas in ctor initializers.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225625 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFC
Alexey Bataev [Mon, 12 Jan 2015 10:17:46 +0000 (10:17 +0000)]
Rename RefersToCapturedVariable to RefersToEnclosingVariableOrCapture, NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225624 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Fix formatting of inline asm.
Daniel Jasper [Mon, 12 Jan 2015 10:14:56 +0000 (10:14 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225623 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Get rid of cxx_exceptspec_end, use EOF instead
David Majnemer [Mon, 12 Jan 2015 09:16:57 +0000 (09:16 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225622 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Just a small tidy-up in ParseLexedMethodDeclaration
David Majnemer [Mon, 12 Jan 2015 06:51:15 +0000 (06:51 +0000)]
Parse: Just a small tidy-up in ParseLexedMethodDeclaration

No functional change intended, just tidy up the parse flow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225620 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Get rid of tok::cxx_defaultarg_end, use EOF instead
David Majnemer [Mon, 12 Jan 2015 05:17:40 +0000 (05:17 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225619 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directly
David Majnemer [Mon, 12 Jan 2015 03:36:37 +0000 (03:36 +0000)]
Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directly

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225616 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Don't let BalancedDelimiterTracker consume cxx_defaultarg_end
David Majnemer [Mon, 12 Jan 2015 03:14:18 +0000 (03:14 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225615 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDriver: include rewrite maps in the diagnostics
Saleem Abdulrasool [Mon, 12 Jan 2015 02:33:09 +0000 (02:33 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225614 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Don't parse beyond the end of the synthetic default argument tok
David Majnemer [Mon, 12 Jan 2015 02:28:16 +0000 (02:28 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225613 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoBasic: Numeric constraints are multidigit
David Majnemer [Sun, 11 Jan 2015 10:22:41 +0000 (10:22 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225606 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoBasic: [asmSymbolicName] follows the same rule as numbers in asm inputs
David Majnemer [Sun, 11 Jan 2015 09:57:13 +0000 (09:57 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225605 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoBasic: The asm constraint '#m' isn't valid, reject it
David Majnemer [Sun, 11 Jan 2015 09:39:03 +0000 (09:39 +0000)]
Basic: The asm constraint '#m' isn't valid, reject it

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225603 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoCodeGen: Simplify consecutive '%' modifiers
David Majnemer [Sun, 11 Jan 2015 09:13:56 +0000 (09:13 +0000)]
CodeGen: Simplify consecutive '%' modifiers

LLVM the consecutive '%' modifiers are redundant, skip them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225602 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoCodeGen: Simplify consecutive '&' modifiers
David Majnemer [Sun, 11 Jan 2015 09:09:01 +0000 (09:09 +0000)]
CodeGen: Simplify consecutive '&' modifiers

LLVM the consecutive '&' modifiers are redundant, skip them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225601 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoBasic: The asm constraint '+#r' isn't valid, reject it
David Majnemer [Sun, 11 Jan 2015 08:52:38 +0000 (08:52 +0000)]
Basic: The asm constraint '+#r' isn't valid, reject it

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225600 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDon't rely on the default constructor default constructing a begin and
Chandler Carruth [Sun, 11 Jan 2015 01:43:06 +0000 (01:43 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225594 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agofix pr18645. Correct logic concerning 'T &&' deduction against lvalues.
Nathan Sidwell [Sat, 10 Jan 2015 18:16:25 +0000 (18:16 +0000)]
fix pr18645. Correct logic concerning 'T &&' deduction against lvalues.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225587 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: The asm constraint '+&m' isn't valid, reject it
David Majnemer [Sat, 10 Jan 2015 10:43:19 +0000 (10:43 +0000)]
Sema: The asm constraint '+&m' isn't valid, reject it

Don't permit '+&m' to make it to CodeGen, it's invalid.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225586 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoAdd a new warning, -Wself-move, to Clang.
Richard Trieu [Sat, 10 Jan 2015 06:04:18 +0000 (06:04 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225581 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix temporary lifetime extension from an initializer using braced "functional"
Richard Smith [Sat, 10 Jan 2015 01:28:13 +0000 (01:28 +0000)]
Fix temporary lifetime extension from an initializer using braced "functional"
cast notation T{...} when T is a reference type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225571 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDon't emit implicit template instantiations eagerly (PR21718)
Hans Wennborg [Sat, 10 Jan 2015 01:19:48 +0000 (01:19 +0000)]
Don't emit implicit template instantiations eagerly (PR21718)

Their linkage can change if they are later explicitly instantiated. We would
previously emit such functions eagerly (as opposed to lazily on first use) if
they have a 'dllexport' or 'used' attribute, and fail an assert when hitting the
explicit instantiation.

This is achieved by replacing the old CodeGenModule::MayDeferGeneration() method
with two new ones: MustBeEmitted() and MayBeEmittedEagerly().

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225570 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRemove unnecessary/incorrect XFAIL after the revert of 225000
David Blaikie [Fri, 9 Jan 2015 23:38:45 +0000 (23:38 +0000)]
Remove unnecessary/incorrect XFAIL after the revert of 225000

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225561 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: [Java] Support formatting qualified annotations.
Nico Weber [Fri, 9 Jan 2015 23:25:06 +0000 (23:25 +0000)]
clang-format: [Java] Support formatting qualified annotations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225559 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoRevert "DebugInfo: Generalize debug info location handling" and related commits
David Blaikie [Fri, 9 Jan 2015 23:00:28 +0000 (23:00 +0000)]
Revert "DebugInfo: Generalize debug info location handling" and related commits

This reverts commit r225000, r225021, r225083, r225086, r225090.

The root change (r225000) still has several issues where it's caused
calls to be emitted without debug locations. This causes assertion
failures if/when those calls are inlined.

I'll work up some test cases and fixes before recommitting this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225555 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Don't crash when an annotation token shows up in a C++11 attr
David Majnemer [Fri, 9 Jan 2015 18:09:39 +0000 (18:09 +0000)]
Parse: Don't crash when an annotation token shows up in a C++11 attr

It's not safe to blindly call getIdentifierInfo without checking the
token is not an annotation token.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225533 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDriver: tweak the code for determining default image name
Hans Wennborg [Fri, 9 Jan 2015 17:38:53 +0000 (17:38 +0000)]
Driver: tweak the code for determining default image name

It seemed odd to have to make DefaultImageName be a mutable member of Driver.
We don't need to the full result of computeTargetTriple() to determine the
image name; just base it on DefaultTargetTriple.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225530 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: Don't crash when variable is redefined as a constexpr function
David Majnemer [Fri, 9 Jan 2015 10:33:23 +0000 (10:33 +0000)]
Sema: Don't crash when variable is redefined as a constexpr function

We have a diagnostic describing that constexpr changed in C++14 when
compiling in C++11 mode.  While doing this, it examines the previous
declaration and assumes that it is a function.  However it is possible,
in the context of error recovery, for this to not be the case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225518 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoAdd the shifted cursor position to XML output, so it can be used by editor integrations.
Manuel Klimek [Fri, 9 Jan 2015 10:03:47 +0000 (10:03 +0000)]
Add the shifted cursor position to XML output, so it can be used by editor integrations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225516 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix test from my previous commit
Olivier Goffart [Fri, 9 Jan 2015 09:42:32 +0000 (09:42 +0000)]
Fix test from my previous commit

(I should have re-run the test after running clang-format)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225515 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Don't crash when namespace is in GNU statement expr
David Majnemer [Fri, 9 Jan 2015 09:38:14 +0000 (09:38 +0000)]
Parse: Don't crash when namespace is in GNU statement expr

Parser::ParseNamespace can get a little confused when it found itself
inside a compound statement inside of a non-static data member
initializer.

Try to determine that the statement expression's scope makes sense
before trying to parse it's contents.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225514 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFix crash in typo correction while correcting enum within a struct in C
Olivier Goffart [Fri, 9 Jan 2015 09:37:26 +0000 (09:37 +0000)]
Fix crash in typo correction while correcting enum within a struct in C

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225513 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: RecordDecl shouldn't have a FunctionDecl as a Decl
David Majnemer [Fri, 9 Jan 2015 07:36:13 +0000 (07:36 +0000)]
Sema: RecordDecl shouldn't have a FunctionDecl as a Decl

RecordDecls should have things like CXXMethodDecls or FriendDecls as a
decl but not things like FunctionDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225511 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: Don't crash when specializing a global scope function in a class
David Majnemer [Fri, 9 Jan 2015 06:10:21 +0000 (06:10 +0000)]
Sema: Don't crash when specializing a global scope function in a class

We assumed that class-scope specializations would result in a
CXXMethodDecl for that class.  However, globally qualified functions
will result in normal FunctionDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225508 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: Remove some dead code from CreateNewFunctionDecl
David Majnemer [Fri, 9 Jan 2015 05:56:10 +0000 (05:56 +0000)]
Sema: Remove some dead code from CreateNewFunctionDecl

The same code is already in Sema::ActOnFunctionDeclarator, the only
caller of CreateNewFunctionDecl.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225506 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoParse: Don't crash when trailing return type is missing
David Majnemer [Fri, 9 Jan 2015 05:10:55 +0000 (05:10 +0000)]
Parse: Don't crash when trailing return type is missing

Sema::CheckParmsForFunctionDef can't cope with a null TypeSourceInfo.
Don't let the AST contain the malformed lambda.

This fixes PR22122.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225505 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDriver: begin threading frontend support for SymbolRewriter
Saleem Abdulrasool [Fri, 9 Jan 2015 05:10:20 +0000 (05:10 +0000)]
Driver: begin threading frontend support for SymbolRewriter

Allow blessed access to the symbol rewriter from the driver. Although the
symbol rewriter could be invoked through tools like opt and llc, it would not
accessible from the frontend. This allows us to read the rewrite map files in
the frontend rather than the backend and enable symbol rewriting for actually
performing the symbol interpositioning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225504 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoInstrProf: Don't emit counter increments in dead code
Justin Bogner [Fri, 9 Jan 2015 01:46:40 +0000 (01:46 +0000)]
InstrProf: Don't emit counter increments in dead code

We were previously emitting counter increments even if we didn't have
an insertion point, which would result in a CallInst with no
parent. This leads to a crash, as in pr22166, if we try to do
GlobalDCE.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225495 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoSema: Dependent array designators cannot be checked
David Majnemer [Fri, 9 Jan 2015 01:39:09 +0000 (01:39 +0000)]
Sema: Dependent array designators cannot be checked

We forgot to mark designated initializer expression that contain type
dependent array designators as type dependent.  This would lead to
crashes when we try to determine which array element we were trying to
initialize.

This fixes PR22056.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225494 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoPR22117: Fix a case where we would get confused about which function parameter
Richard Smith [Fri, 9 Jan 2015 01:19:56 +0000 (01:19 +0000)]
PR22117: Fix a case where we would get confused about which function parameter
we're instantiating, if there's a ParmVarDecl within a FunctionDecl context
that is not a parameter of that function. Add some asserts to catch this kind
of issue more generally, and fix another bug exposed by those asserts where we
were missing a local instantiation scope around substitution of
explicitly-specified template arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225490 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoDon't invent a '$auto-x-y' name for auto types in generic lambdas. This is no
Richard Smith [Fri, 9 Jan 2015 00:59:40 +0000 (00:59 +0000)]
Don't invent a '$auto-x-y' name for auto types in generic lambdas. This is no
better than the 'template-parameter-x-y' name that we'd get in AST printing,
and is worse in several ways (it's harder to distinguish it from a
user-supplied name, it's wrong after substituting some number of outer
levels, it wastes time and space constructing an IdentifierInfo, ...).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225489 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoUse APSInt::isSameValue instead of operator== in a place where two APSInt's
Richard Trieu [Fri, 9 Jan 2015 00:58:16 +0000 (00:58 +0000)]
Use APSInt::isSameValue instead of operator== in a place where two APSInt's
may have different sizes.  Fixes PR22017

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225488 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoIR: Add 'distinct' MDNodes to bitcode and assembly (clang)
Duncan P. N. Exon Smith [Thu, 8 Jan 2015 22:39:28 +0000 (22:39 +0000)]
IR: Add 'distinct' MDNodes to bitcode and assembly (clang)

Update testcases for LLVM change in r225474 to make `MDNode`s explicitly
distinct (when they aren't uniqued).

Part of PR22111.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225475 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoImprove clang-format.el.
Manuel Klimek [Thu, 8 Jan 2015 15:29:03 +0000 (15:29 +0000)]
Improve clang-format.el.

- includes header/footer as required by MELPA
- correctly handles buffers that are not associated with a file
- displays stderr and exit code of clang-format process
- customizable via the emacs customization interface and file-/directory-
  local variables

Patch by Johann Klähn.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225447 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoclang-format: Force line break between "endl" and "<<".
Daniel Jasper [Thu, 8 Jan 2015 13:56:57 +0000 (13:56 +0000)]
clang-format: Force line break between "endl" and "<<".

This makes piped output easier to read in many instances.

Before:
  llvm::errs() << aaaa << std::endl << bbbb << std::endl;

After:
  llvm::errs() << aaaa << std::endl
               << bbbb << std::endl;

Also fix a few instance of "don't use else after return" as per the
coding standards.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225444 91177308-0d34-0410-b5e6-96231b3b80d8

9 years agoFrontend: Fix SourceColumnMap assertion failure on non-ascii characters.
Logan Chien [Thu, 8 Jan 2015 13:19:07 +0000 (13:19 +0000)]
Frontend: Fix SourceColumnMap assertion failure on non-ascii characters.

If there are some non-ascii character in the input source code, the
column index might be smallar than the byte index.  This will result
in two possible assertion failures.  This CL fixes the computation of
the column index and byte index.

1. The assertion in startOfNextColumn() and startOfPreviousColumn()
   should not be raised when the byte index is greater than the column
   index since the non-ascii characters may use more than one bytes to
   store a character in a column.

2. The length of the caret line should be equal to the number of columns
   of source line, instead of the length of the source line.  Otherwise,
   the assertion in selectInterestingSourceRegion will be raised because
   the removed columns plus the kept columns are not greater than the max
   column, which means that we should not remove any column at all.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225442 91177308-0d34-0410-b5e6-96231b3b80d8