Commit Graph

57787 Commits

Author SHA1 Message Date
Benjamin Kramer b2b81439a3 [CodeGen] When promoting a reference temporary to a global use the inner type to fold it.
The MaterializeTemporaryExpr can have a different type than the inner
expression, miscompiling the constant. PR23165.

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

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

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

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

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

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

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

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

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

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

This reverts commit r234261.

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

llvm-svn: 234440
2015-04-08 21:34:04 +00:00
David Blaikie e229011d12 Remove redundant virtual on member functions marked 'override'.
llvm-svn: 234417
2015-04-08 17:01:55 +00:00
Alexey Bataev 7c2ed44905 [OPENMP] Allow redeclaration of variables as threadprivate.
No need to emit an error message if the variable is redeclared as threadprivate.

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

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

Reviewers: rsmith

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

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

This fixes PR23151.

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

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

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

llvm-svn: 234355
2015-04-07 20:46:51 +00:00
Duncan P. N. Exon Smith 373285892b Revert "Fix a compiler error under MSVC"
This reverts the bandaid commit in r234308 now that I have a proper fix
in LLVM as of r234326.

llvm-svn: 234339
2015-04-07 18:41:26 +00:00
Sanjay Patel c64bb49628 fix typo; NFC
llvm-svn: 234338
2015-04-07 18:39:20 +00:00
Fariborz Jahanian d436b2a4ce [Objective-C Sema] Patch to not issue unavailbility/deprecated
warning when multiple method declarations are found in global pool
with differing types and some are available.
rdar://20408445

llvm-svn: 234328
2015-04-07 16:56:27 +00:00
Duncan P. N. Exon Smith ebad0aa3ba DebugInfo: LLVM API change in r234326 for array-like tuple wrappers
Update a few calls to `DIBuilder` now that `MDTuple` array-wrappers
don't have implicit conversions to `MDTuple*`.  I may circle back and
update `DIBuilder` to take arrays here, to make it easier for the
callers.

llvm-svn: 234327
2015-04-07 16:50:49 +00:00
Daniel Jasper 53395406da clang-format: Fix regression formatting QT's "signals:" from r234318.
llvm-svn: 234320
2015-04-07 15:04:40 +00:00
Daniel Jasper 676e516354 clang-format: Don't allow labels when expecting declarations.
This fixes formatting unnamed bitfields (llvm.org/PR21999).

Before:
  struct MyStruct {
    uchar data;
  uchar:
    8;
  uchar:
    8;
    uchar other;
  };

After:
  struct MyStruct {
    uchar data;
    uchar : 8;
    uchar : 8;
    uchar other;
  };

llvm-svn: 234318
2015-04-07 14:36:33 +00:00
Timur Iskhodzhanov 90639edd3d Fix a compiler error under MSVC
Error message was:
CGDebugInfo.cpp(1047) : error C2666: 'llvm::MDTypeRefArray::operator []' : 2 overloads have similar conversions
  DebugInfoMetadata.h(106): could be 'llvm::MDTypeRef llvm::MDTypeRefArray::operator [](unsigned int) const'
  while trying to match the argument list '(llvm::DITypeArray, int)'

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

llvm-svn: 234306
2015-04-07 10:07:47 +00:00
Daniel Jasper acf67e3ecd clang-format: Improve nested block formatting.
Before:
  functionA(functionB({
    int i;
    int j;
  }),
            aaaa, bbbb, cccc);

After:
  functionA(functionB({
              int i;
              int j;
            }),
            aaaa, bbbb, cccc);

llvm-svn: 234304
2015-04-07 08:20:35 +00:00
Daniel Jasper 9dedc775d7 clang-format: Indent relative to the ./-> and not the function name.
Before:
  aaaaaaaaaaa     //
      .aaaa(      //
           bbbb)  // This is different ..
      .aaaa(      //
          cccc);  // .. from this.

After:
  aaaaaaaaaaa     //
      .aaaa(      //
          bbbb)   // This is identical ..
      .aaaa(      //
          cccc);  // .. to this.

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

This fixes PR23117.

llvm-svn: 234297
2015-04-07 06:01:53 +00:00
Duncan P. N. Exon Smith a98fac64ea DebugInfo: Update for LLVM change in r234290
The API for `DIArray` changed; use the new one.

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

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

This fixes PR22042.

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

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

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

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

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

Reviewers: majnemer

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

llvm-svn: 234261
2015-04-06 23:51:44 +00:00
Duncan P. N. Exon Smith c755128673 CGDebugInfo: Stop using DIDescriptor::is*() and auto-casting
The clang edition of r234255: use built-in `isa<>`, `dyn_cast<>`, etc.,
and only build `DIDescriptor`s from pointers that are correctly typed.

llvm-svn: 234256
2015-04-06 23:21:33 +00:00
Duncan P. N. Exon Smith ee55fac1d4 DebugInfo: Use DILexicalBlockFile::getContext() over getScope()
`getScope()` passes the scope back through a `DILexicalBlock` even
though the underlying pointer may be an incompatible `MDSubprogram`.
Just use `getContext()` directly.

llvm-svn: 234245
2015-04-06 22:04:18 +00:00
James Dennett fa24549492 Fix a call to std::unique to actually discard the trailing (junk) elements.
Found by inspection.  (No other instances of this problem were found.)

llvm-svn: 234221
2015-04-06 21:09:24 +00:00
Benjamin Kramer 040725723e MSan told me that we actually dump the entire scratch buffer into PCH files, initialize it.
Writing 4k of zeros is preferrable to 4k of random memory. Document that. While
there remove the initialization of the first byte of the buffer and start at
index zero. It was writing a literal '0' instead of a null byte at the
beginning anyways, which didn't matter since we never read it.

llvm-svn: 234202
2015-04-06 20:01:49 +00:00
Benjamin Kramer c7dd599e9d Prefer uninitialized memory for scratch space.
No functional change intended.

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

llvm-svn: 234176
2015-04-06 16:56:39 +00:00
David Blaikie 981d2a04b7 Fix this test so it doesn't try to open a file to write to the source tree
llvm-svn: 234173
2015-04-06 16:33:18 +00:00
Aaron Ballman 82a2202ae6 Gating clang-fuzzer on the same conditions required to build the LLVMFuzzer library. Otherwise, we can run into a situation where clang-fuzzer attempts to build, but its dependency was never built.
llvm-svn: 234170
2015-04-06 16:10:32 +00:00
Michael Kuperstein aed5ccdeed HasSideEffects() should return false for calls to pure and const functions.
Differential Revision: http://reviews.llvm.org/D8548

llvm-svn: 234152
2015-04-06 13:22:01 +00:00
Benjamin Kramer 1a8fa8b431 Update our list of distros a bit.
- Debian jessie will be released this month, add the next testing version to the list.
- RHEL7 was released last june.
- Ubuntu utopic was released last october, vivid will follow later this month.

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

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

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

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

llvm-svn: 234141
2015-04-06 04:16:48 +00:00
David Blaikie 2e80428dc5 clang-format my last commit
(sorry, keep forgetting that)

llvm-svn: 234129
2015-04-05 22:47:07 +00:00
David Blaikie 1ed728c499 [opaque pointer type] More GEP API migrations
Looks like the VTable code in particular will need some work to pass
around the pointee type explicitly.

llvm-svn: 234128
2015-04-05 22:45:47 +00:00
Benjamin Kramer 67e6a5499c Replace copy loop with std::copy.
No functional change intended.

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

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

Handle this by desugaring the call to the explicit operator.

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

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

This fixes PR23120.

llvm-svn: 234110
2015-04-05 05:32:54 +00:00
David Blaikie 17ea266bac [opaque pointer type] More GEP API migrations
llvm-svn: 234109
2015-04-04 21:07:17 +00:00
Rafael Espindola d7329ef99f Revert "Revert "Revert "Don't use unique section names by default if using the integrated as."""
This reverts commit r234101. I will debug what went wrong with ARM.

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

Original message:

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

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

llvm-svn: 234101
2015-04-04 18:21:14 +00:00
David Blaikie fb901c7abf [opaque pointer type] more GEP API migrations
llvm-svn: 234097
2015-04-04 15:12:29 +00:00
Sanjay Patel a932bb93b0 Remove the cl-no-signed-zeros cc1 option
Use the driver flag -fno-signed-zeros instead.

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

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

llvm-svn: 234093
2015-04-04 14:54:24 +00:00
Daniel Jasper 739ec534d2 clang-format: [JS] Understand object literals with only methods.
Before:
  let theObject = {someMethodName() {
    doTheThing();
    doTheOtherThing();
  },
                   someOtherMethodName() {
                     doSomething();
                     doSomethingElse();
                   }};

After:
  let theObject = {
    someMethodName() {
      doTheThing();
      doTheOtherThing();
    },
    someOtherMethodName() {
      doSomething();
      doSomethingElse();
    }
  };

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

llvm-svn: 234090
2015-04-04 05:37:48 +00:00
Eric Christopher 269c2a29ef Complete comment. Reflow conditional.
llvm-svn: 234083
2015-04-04 03:34:43 +00:00
David Blaikie 5e259a8c6d [opaque pointer type] Explicitly specify some types for GEP
Not all of them (there's still a fallback for this specific function
that omits the type parameter) but it's some I bothered to do now.

llvm-svn: 234063
2015-04-03 22:54:16 +00:00
Daniel Jasper 1662bfe077 clang-format: [Proto] No alternate operator names.
llvm-svn: 234055
2015-04-03 21:15:46 +00:00
Manman Ren 2738278b7f [i386 ABI] expand small C like structs in C++, just like how we handle small
C structs.

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

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

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

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

Reviewed by John.

rdar://20121030

llvm-svn: 234033
2015-04-03 18:10:29 +00:00
David Blaikie 6b2a8306a5 [opaque pointer type] Explicitly specify type to CreateGEP
llvm-svn: 234032
2015-04-03 17:47:16 +00:00
Eric Christopher c168ef4b5f Make this test not rely on a backend being registered.
llvm-svn: 233993
2015-04-03 01:27:02 +00:00
Sean Callanan 72fe0852fd Added support for attributed types to the ASTImporter.
<rdar://problem/20403544>

llvm-svn: 233985
2015-04-02 23:50:08 +00:00
Eric Christopher d05ba3aae3 Add a question mark to the end of an interrogatory warning.
llvm-svn: 233982
2015-04-02 22:30:23 +00:00
Eric Christopher 6e11073b3e Unify warnings/errors from "maybe you meant" to "did you mean".
llvm-svn: 233981
2015-04-02 22:10:06 +00:00
Reid Kleckner 85368fb32d Correct typos in SEH filter expressions
Otherwise we assert due to uncorrected delayed typos.

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

llvm-svn: 233977
2015-04-02 21:36:03 +00:00
David Blaikie e3b172afc3 [opaque pointer type] Update for GEP API changes in LLVM
Now the GEP constant utility functions require the type to be explicitly
passed (since eventually the pointer type will be opaque and not convey
the required type information). For now callers can still pass nullptr
(though none were needed here in Clang, which is nice) if
convenienc/necessary, but eventually that will be disallowed as well.

llvm-svn: 233937
2015-04-02 18:55:21 +00:00
Reid Kleckner a5cad0d6a6 [AST] Shrink the Stmt hierarchy with LLVM_PTR_SIZE for MSVC 2013
Follow-up to r233921 that removes the 'void *Aligner' Stmt union member
for MSVC 2013.

llvm-svn: 233932
2015-04-02 18:02:39 +00:00
Benjamin Kramer 8adeef9632 Lower the default alignment on ASTContext's operator new.
It was documented as 8 and operator new[] defaults to 8, but the normal
operator new was never updated and happily wasted bytes on every other
allocation.

We still have to allocate all Types with 16 byte alignment, update the
allocation calls for Types that were missing explicit alignment.

llvm-svn: 233922
2015-04-02 16:19:54 +00:00
Benjamin Kramer 475386d688 [ast] Put the Stmt hierarchy on a diet for 64 bit targets.
Previously we would waste 32 bits on alignment, use LLVM_ALIGNAS to
free that space for derived classes an place. Sadly still have to #ifdef
out MSVC 2013 because it can't align based on a sizeof expr.

No intended functionality change. New byte counts:
sizeof(before)			|	sizeof(after)

LabelStmt: 32			|	LabelStmt: 24
SwitchStmt: 48			|	SwitchStmt: 40
WhileStmt: 40			|	WhileStmt: 32
DoStmt: 40			|	DoStmt: 32
ForStmt: 64			|	ForStmt: 56
ContinueStmt: 16		|	ContinueStmt: 8
BreakStmt: 16			|	BreakStmt: 8
ReturnStmt: 32			|	ReturnStmt: 24
AsmStmt: 40			|	AsmStmt: 32
GCCAsmStmt: 80			|	GCCAsmStmt: 72
MSAsmStmt: 96			|	MSAsmStmt: 88
SEHExceptStmt: 32		|	SEHExceptStmt: 24
SEHFinallyStmt: 24		|	SEHFinallyStmt: 16
SEHLeaveStmt: 16		|	SEHLeaveStmt: 8
CapturedStmt: 32		|	CapturedStmt: 24
CXXCatchStmt: 32		|	CXXCatchStmt: 24
CXXForRangeStmt: 72		|	CXXForRangeStmt: 64
ObjCAtFinallyStmt: 24		|	ObjCAtFinallyStmt: 16
ObjCAtSynchronizedStmt: 32	|	ObjCAtSynchronizedStmt: 24
ObjCAtThrowStmt: 24		|	ObjCAtThrowStmt: 16
ObjCAutoreleasePoolStmt: 24	|	ObjCAutoreleasePoolStmt: 16
llvm-svn: 233921
2015-04-02 15:29:07 +00:00
Russell Gallop b9e15b2e94 [utils] Add Check Compile Flow Consistency tool (check_cfc.py).
This is a tool for checking consistency of code generation with different
compiler options (such as -g or outputting to .s). This tool has found a number
of code generation issues. The script acts as a wrapper to clang or clang++
performing 2 (or more) compiles then comparing the object files. Instructions
for use are in check_cfc.py including how to use with LNT.

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

llvm-svn: 233919
2015-04-02 15:01:53 +00:00
Alexey Bataev 8bf6b3eaf7 [OPENMP] Fix crash on private variables not used in OpenMP region in templates.
llvm-svn: 233913
2015-04-02 13:07:08 +00:00
Benjamin Kramer 3ebba5237e Partially revert "Replace custom alignment enforcement with LLVM_ALIGNAS."
MSVC 2013 can't even parse __declspec(align(sizeof(foo))). We'll have to
wait until MSVC 2015 for this.

This partially reverts commit r233911.

llvm-svn: 233912
2015-04-02 12:43:31 +00:00
Benjamin Kramer 1d4ffd74c1 Replace custom alignment enforcement with LLVM_ALIGNAS.
This isn't perfect as it still assumes sizeof(void*) == alignof(void*),
but we can fix that when compiler support gets better.

Shrinks some Stmts that happen to inherit from Stmt and have a
SourceLocation as the first member (64 bit archs only).

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

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

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

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

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

Test Plan: regression test suite

Reviewers: kubabrecka, zaks.anna, kcc, rsmith

Subscribers: cfe-commits

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

llvm-svn: 233860
2015-04-01 22:42:25 +00:00
Eli Bendersky 1346717068 Set the type of ptrdiff_t to signed on NVPTX targets
It was unsigned before, which is unlike any other target and also doesn't make
much sense.

llvm-svn: 233836
2015-04-01 20:29:18 +00:00
Reid Kleckner d2f6c726e7 Re-land "MS ABI: lambda call operators are instance methods and should use thiscall"
Update the test cases to pass when lambda call operators use thiscall.

Update the lambda-to-block conversion operator to use the default free
function calling convention instead of the call operator's convention.

This reverts commit r233082 and re-instates r233023.

llvm-svn: 233835
2015-04-01 20:22:13 +00:00
Reid Kleckner 084c384c6f Run dos2unix on test/PCH/cxx1y-lambdas.mm
llvm-svn: 233834
2015-04-01 20:21:34 +00:00
Richard Smith 78163e2356 Minor simplification: do typo-correction before handling inheriting
constructors, instead of having the typo-correction code also dispatch to the
inheriting constructor special case.

llvm-svn: 233833
2015-04-01 19:31:06 +00:00
Eli Bendersky 15f63420a7 Set NVPTX64 target's size_t to match other 64-bit targets
llvm-svn: 233830
2015-04-01 18:29:27 +00:00
Reid Kleckner 2dc063fa16 Fix inlinehint.cpp with an explicit triple to avoid x86_thiscallcc problems
llvm-svn: 233821
2015-04-01 16:48:54 +00:00
Reid Kleckner e20ce1fcbf Remove comdats from inlinehint.cpp to pass test on Darwin
llvm-svn: 233820
2015-04-01 16:45:17 +00:00
Reid Kleckner 7510c09234 Fix data layout mismatch between LLVM and Clang for i686-pc-windows-msvc-elf
Do the same thing as win64. If we're not using COFF, use the ELF
manglings. Maybe if we are targetting *-windows-msvc-macho, we should
use darwin manglings, but I don't need to stir that pot today.

llvm-svn: 233819
2015-04-01 16:45:06 +00:00
Reid Kleckner 5e4fc4e884 Try to fix nacl-direct.c driver test in Cygwin environment
Why is NaCl not using the integrated assembler, by the way?

llvm-svn: 233818
2015-04-01 16:27:07 +00:00
Reid Kleckner 0a33e615f3 Mark instantiated function decls as inline specified if any pattern is
A function template pattern can be declared without the 'inline'
specifier and defined later with the 'inline' specifier. However, during
instantiation, we were only looking at the canonical decl to see if we
should mark the instantiated decl as inline specified. Since the
instantiated decl actually represents many pattern declarations, put the
inline specifier on the instantiation decl if any of the pattern decls
have it.

llvm-svn: 233817
2015-04-01 16:23:44 +00:00
Ulrich Weigand bb0f2bd3c1 [SystemZ] Add BuiltinsSystemZ.def to Clang_Basic modulemap
This should fix the last remaining build bot failures
resulting from the r233804 commit.

llvm-svn: 233814
2015-04-01 15:34:53 +00:00
Ulrich Weigand cc67344a86 [SystemZ] Add header files to Makefile / module.modulemap
This should fix build-bot failures after r233804.

The patch also adds a "systemz" feature, and renames the
"transactional-execution" feature to "htm", since it turns
out "-" is not a legal character in module feature names.

llvm-svn: 233807
2015-04-01 14:15:35 +00:00
Ulrich Weigand 3a610ebf1e [SystemZ] Support transactional execution on zEC12
The zEC12 provides the transactional-execution facility.  This is exposed
to users via a set of builtin routines on other compilers.  This patch
adds clang support to enable those builtins.  In partciular, the patch:

- enables the transactional-execution feature by default on zEC12
- allows to override presence of that feature via the -mhtm/-mno-htm options
- adds a predefined macro __HTM__ if the feature is enabled
- adds support for the transactional-execution GCC builtins
- adds Sema checking to verify the __builtin_tabort abort code
- adds the s390intrin.h header file (for GCC compatibility)
- adds s390 sections to the htmintrin.h and htmxlintrin.h header files

Since this is first use of target-specific intrinsics on the platform,
the patch creates the include/clang/Basic/BuiltinsSystemZ.def file and
hooks it up in TargetBuiltins.h and lib/Basic/Targets.cpp.

An associated LLVM patch adds the required LLVM IR intrinsics.

For reference, the transactional-execution instructions are documented
in the z/Architecture Principles of Operation for the zEC12:
http://publibfp.boulder.ibm.com/cgi-bin/bookmgr/download/DZ9ZR009.pdf
The associated builtins are documented in the GCC manual:
http://gcc.gnu.org/onlinedocs/gcc/S_002f390-System-z-Built-in-Functions.html
The htmxlintrin.h intrinsics provided for compatibility with the IBM XL
compiler are documented in the "z/OS XL C/C++ Programming Guide".

llvm-svn: 233804
2015-04-01 12:54:25 +00:00
Elena Demikhovsky 29da2fba46 AVX-512: added clang intrinsics for logical and, or xor for 512 bits
by Asaf Badouh (asaf.badouh@intel.com)

llvm-svn: 233794
2015-04-01 06:54:16 +00:00
David Majnemer 1f192e26fd [MS ABI] Disregard restrictive exception specifications
MSVC treats all non-empty exception specifications the same way: all
exceptions are permitted.  The .xdata tables provide a way to
efficiently lower exception specifications *but* this probably has to be
implemented as a catch-all/rethrow mechanism instead of the Itanium way.

This fixes PR23092.

llvm-svn: 233787
2015-04-01 04:45:52 +00:00
Alexey Bataev b78ca83d3b [OPENMP] Sema analysis for 'atomic capture' construct.
Added sema checks for forms of expressions/statements allowed under control of 'atomic capture' directive + generation of helper objects for future codegen.

llvm-svn: 233785
2015-04-01 03:33:17 +00:00
Fariborz Jahanian 6a9c46bc3f [Objective-C metadata patch]. Patch to allocate one more space for
Protocol objects in OBJC2. rdar://20286356

llvm-svn: 233766
2015-03-31 22:22:40 +00:00
Derek Schuff 0da48b7c19 Fix nacl's clang driver tests to tolerate libdir suffixes and Windows paths.
llvm-svn: 233764
2015-03-31 21:43:52 +00:00
Benjamin Kramer acfe7d446b [lex] Bitfieldize some booleans.
Lets us fuse some branches into bit tests downstream. NFC.

llvm-svn: 233725
2015-03-31 18:47:05 +00:00
Eli Bendersky 7a0d89153f Add sm_37 target to Clang for NVPTX
Support for this target was added in LLVM r233575 and r233583

llvm-svn: 233715
2015-03-31 17:03:16 +00:00
Tom Stellard b919c7d9eb Sema: Accept pointers to any address space for builtin functions
As long as they don't have an address space explicitly defined.

This allows builtins with pointer arguments to be used with OpenCL.

llvm-svn: 233706
2015-03-31 16:39:02 +00:00
Daniel Jasper f46dec86b6 clang-format: [JS] Support getters, setters and methods in object literals.
llvm-svn: 233698
2015-03-31 14:34:15 +00:00
Daniel Jasper 3292bf6776 Make new test slightly more generic to allow running it under
non-standard test runners.

llvm-svn: 233677
2015-03-31 09:08:16 +00:00
Craig Topper a8bd6008ee [X86] Use getHostCPUFeatures when 'native' is specified for cpu.
This is necessary because not aall Sandybridge, Ivybrige, Haswell, and Broadwell CPUs support AVX. Currently we modify the CPU name back to Nehalem for this case, but that turns off additional features for these CPUs.

llvm-svn: 233672
2015-03-31 05:45:00 +00:00
Eric Christopher 7e0fadf837 Update for llvm commit r233648.
llvm-svn: 233649
2015-03-31 00:10:23 +00:00
Fariborz Jahanian a8c2a0b0b2 [Objective-C patch]. Amend TransformObjCMessageExpr to handle call
to 'super' of instance/class methods and not assert.
rdar://20350364

llvm-svn: 233642
2015-03-30 23:30:24 +00:00
Derek Schuff 6ab52fabcf Add driver support for Native Client SDK
Add Tool and ToolChain support for clang to target the NaCl OS using the NaCl
SDK for x86-32, x86-64 and ARM.

Includes nacltools::Assemble and Link which are derived from gnutools. They
are similar to Linux but different enought that they warrant their own class.
Also includes a NaCl_TC in ToolChains derived from Generic_ELF with library
and include paths suitable for an SDK and independent of the system tools.

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

llvm-svn: 233594
2015-03-30 20:31:33 +00:00
Jordan Rose ad176b5e10 [analyzer] Add test for previous commit.
Again, this is being applied in a separate commit so that the previous commit
can be reverted while leaving the test in place.

rdar://problem/20335433

llvm-svn: 233593
2015-03-30 20:18:04 +00:00
Jordan Rose 3da3f8e045 [analyzer] Disable all retain count diagnostics on values that come from ivars.
This is imitating a pre-r228174 state where ivars are not considered tracked by
default, but with the addition that even ivars /with/ retain count information
(e.g. "[_ivar retain]; [ivar _release];") are not being tracked as well. This is
to ensure that we don't regress on values accessed through both properties and
ivars, which is what r228174 was trying to fix.

The issue occurs in code like this:

  [_contentView retain];
  [_contentView removeFromSuperview];
  [self addSubview:_contentView]; // invalidates 'self'
  [_contentView release];

In this case, the call to -addSubview: may change the value of self->_contentView,
and so the analyzer can't be sure that we didn't leak the original _contentView.
This is a correct conservative view of the world, but not a useful one. Until we
have a heuristic that allows us to not consider this a leak, not emitting a
diagnostic is our best bet.

This commit disables all of the ivar-related retain count tests, but does not
remove them to ensure that we don't crash trying to evaluate either valid or
erroneous code. The next commit will add a new test for the example above so
that this commit (and the previous one) can be reverted wholesale when a better
solution is implemented.

Rest of rdar://problem/20335433

llvm-svn: 233592
2015-03-30 20:18:00 +00:00
Jordan Rose 218772f87e [analyzer] Don't special-case ivars backing +0 properties.
Give up this checking in order to continue tracking that these values came from
direct ivar access, which will be important in the next commit.

Part of rdar://problem/20335433

llvm-svn: 233591
2015-03-30 20:17:47 +00:00
Duncan P. N. Exon Smith 2809cc7493 DebugInfo: Use new LLVM API for DebugLoc
Use the new API for `DebugLoc` added in r233573 before the old one
disappears.

llvm-svn: 233589
2015-03-30 20:01:41 +00:00
Richard Smith d7eef87e65 Updating code owners file per discussion with Doug at the 2014-10 dev meeting.
llvm-svn: 233588
2015-03-30 19:52:53 +00:00
Kit Barton e50adcb6b1 [PPC] Move argument range checks for HTM and crypto builtins to Sema
The argument range checks for the HTM and Crypto builtins were implemented in
CGBuiltin.cpp, not in Sema. This change moves them to the appropriate location
in SemaChecking.cpp. It requires the creation of a new method in the Sema class
to do checks for PPC-specific builtins.

http://reviews.llvm.org/D8672

llvm-svn: 233586
2015-03-30 19:40:59 +00:00
Ulrich Weigand 283ad7d6b4 [SystemZ] Fix fallout from r233543 on no-assert builds
Test cases must not check for symbolic variable names that are not
present in IR generated by no-assert builds.

Fixed by testing a more complete subset of the va_arg dataflow,
without relying on variable names.

llvm-svn: 233574
2015-03-30 18:08:50 +00:00
Ulrich Weigand 881497ac29 [SystemZ] Fix definition of IntMaxType / Int64Type
Like on other 64-bit platforms, Int64Type should be SignedLong
on SystemZ, not SignedLongLong as per default.  This could cause
ABI incompatibilities in certain cases (e.g. name mangling).

llvm-svn: 233544
2015-03-30 13:50:21 +00:00
Ulrich Weigand 759449c76a [SystemZ] Fix some ABI corner cases
Running the GCC's inter-compiler ABI compatibility test suite uncovered
a couple of errors in clang's SystemZ ABI implementation.  These all
affect only rare corner cases:

- Short vector types

GCC synthetic vector types defined with __attribute__ ((vector_size ...))
are always passed and returned by reference.  (This is not documented in
the official ABI document, but is the de-facto ABI implemented by GCC.)
clang would do that only for vector sizes >= 16 bytes, but not for shorter
vector types.

- Float-like aggregates and empty bitfields

clang would consider any aggregate containing an empty bitfield as
first element to be a float-like aggregate.  That's obviously wrong.
According to the ABI doc, the presence of an empty bitfield makes
an aggregate to be *not* float-like.  However, due to a bug in GCC,
empty bitfields are ignored in C++; this patch changes clang to be
compatible with this "feature" of GCC.

- Float-like aggregates and va_arg

The va_arg implementation would mis-detect some aggregates as float-like
that aren't actually passed as such.  This applies to aggregates that
have only a single element of type float or double, but using an aligned
attribute that increases the total struct size to more than 8 bytes.

This error occurred because the va_arg implement used to have an copy
of the float-like aggregate detection logic (i.e. it would call the
isFPArgumentType routine, but not perform the size check).

To simplify the logic, this patch removes the duplicated logic and
instead simply checks the (possibly coerced) LLVM argument type as
already determined by classifyArgumentType.

llvm-svn: 233543
2015-03-30 13:49:01 +00:00
Daniel Sanders 48fa39e4a1 [mips] Add support for 'ZC' inline assembly memory constraint.
Summary: Also add tests for 'R' and 'm'.

Reviewers: atanasyan

Reviewed By: atanasyan

Subscribers: cfe-commits

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

llvm-svn: 233542
2015-03-30 13:47:23 +00:00
Daniel Jasper 02c7bca5d1 clang-format: [JS] Fix comment formatting in goog.scopes.
Before:
  goog.scope(function() {
  // test
  var x = 0;
  // test
  });

After:
  goog.scope(function() {
  // test
  var x = 0;
    // test
  });

llvm-svn: 233530
2015-03-30 09:56:50 +00:00
Alexey Bataev b4505a7229 [OPENMP] Codegen for 'atomic update' construct.
Adds atomic update codegen for the following forms of expressions:

x binop= expr;
x++;
++x;
x--;
--x;
x = x binop expr;
x = expr binop x;
If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted.
Otherwise compare-and-swap sequence is emitted:

bb:
...
atomic load <x>
cont:
<expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ]
<desired> = <expected> binop <expr>
<res> = cmpxchg atomic &<x>, desired, expected
<new_failed> = <res>.field1;
br <res>field2, label %exit, label %cont
exit:
...

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

llvm-svn: 233513
2015-03-30 05:20:59 +00:00
Alexey Bataev f268568447 [OPENMP] Improved codegen for implicit/explicit 'barrier' constructs.
Replace boolean IsExplicit parameter of OpenMPRuntime::emitBarrierCall() method by OpenMPDirectiveKind Kind for better compatibility with the runtime library. Also add processing of 'nowait' clause on worksharing directives.
Differential Revision: http://reviews.llvm.org/D8659

llvm-svn: 233511
2015-03-30 04:30:22 +00:00
Petar Jovanovic e886cfb612 Add check for kind of UnqualifiedId in Declarator::isStaticMember()
Method CXXMethodDecl::isStaticOverloadedOperator expects Operator field
from the struct OperatorFunctionId, which is a member of the union in
the class UnqualifiedId. If the kind of UnqualifiedId is not checked,
there is no guarantee that the value that this method receives will be
correct, because it can be the value of another union member and not
OperatorFunctionId.

This bug manifests itself when running make check-all on mips64 BE. 

This fix resolves the following regression tests: 
Clang :: CXX/special/class.dtor/p9.cpp
Clang :: CodeGenCXX/2006-09-12-OpaqueStructCrash.cpp
Clang :: CodeGenCXX/ctor-dtor-alias.cpp
Clang :: CodeGenCXX/debug-info-windows-dtor.cpp
Clang :: CodeGenCXX/dllexport-members.cpp
Clang :: CodeGenCXX/dllexport.cpp

Patch by Violeta Vukobrat.

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

llvm-svn: 233508
2015-03-30 00:43:56 +00:00
David Majnemer 37b417f1ed [MS ABI] Rework .xdata HandlerType emission
Utilizing IMAGEREL relocations for synthetic IR constructs isn't
valuable, just clutter.  While we are here, simplify HandlerType names
by making the numeric value for the 'adjective' part of the mangled name
instead of appending '.const', etc.  The old scheme made for very long
global names and leads to wordy things like '.std_bad_alloc'

llvm-svn: 233503
2015-03-29 21:55:10 +00:00
Benjamin Kramer 60be563f3d [parse] Don't crash on alternative operator spellings from macros in c++11 attributes.
Found by afl-fuzz.

llvm-svn: 233499
2015-03-29 19:25:07 +00:00
Benjamin Kramer 0a126adc68 [lex] Provide a valid token when __has_include is found outside of a pp directive
ExpandBuiltinMacro would strip the identifier and downstream users crash
when they encounter an identifier token with nullptr identifier info.

Found by afl-fuzz.

llvm-svn: 233497
2015-03-29 19:05:27 +00:00
Benjamin Kramer 851f310cec [edit] Don't hit an assert when trying to delete a trailing space at EOF
The buffer is guaranteed to be zero-terminated so we can just
circumvent the check. Found by afl-fuzz.

llvm-svn: 233496
2015-03-29 18:07:29 +00:00
Benjamin Kramer d0028dcb86 [parser] Push _Atomic locs through DeclaratorChunk.
Otherwise it stays uninitialized with potentially catastrophic results.
Found by afl-fuzz.

llvm-svn: 233494
2015-03-29 16:42:06 +00:00
Benjamin Kramer 18ff02dd51 [lex] Don't create a garbage token if parsing of __has_include fails.
It will crash downstream somewhere. Found by afl-fuzz.

llvm-svn: 233493
2015-03-29 15:33:29 +00:00
Benjamin Kramer 3012e59bc7 [Parse] Don't crash on ~A::{
Found by clang-fuzz.

llvm-svn: 233492
2015-03-29 14:35:39 +00:00
Benjamin Kramer 8671028e95 [lex] Don't read past the end of the buffer
While dereferencing ThisTokEnd is fine and we know that it's not in
[a-zA-Z0-9_.], ThisTokEnd[1] is really past the end.

Found by asan and with a little help from clang-fuzz.

llvm-svn: 233491
2015-03-29 14:11:37 +00:00
Benjamin Kramer 7fd88386b0 [lex] Turn range checks into asserts.
We know that the last accessible char is not in [a-zA-Z0-9_.] so we can
happily scan on as long as it is. No functionality change.

llvm-svn: 233490
2015-03-29 14:11:22 +00:00
Anna Zaks 50b0956754 [scan-build] Be friendly to "" in the argument list.
Do not fail when "" is one of the compilation arguments.

llvm-svn: 233465
2015-03-28 02:17:21 +00:00
Chandler Carruth ff8d943cb8 [Modules] Don't compute a modules cache path if we're not using modules!
Notably, this prevents us from doing *tons* of work to compute the
modules hash, including trying to read a darwin specific plist file off
of the system. There is a lot that needs cleaning up below this layer
too.

llvm-svn: 233462
2015-03-28 01:10:44 +00:00
Manuel Klimek bea7dfbc5e Make the clang-fuzzer use the CompilerInstance directly.
Going through the driver is too slow.

llvm-svn: 233459
2015-03-28 00:42:36 +00:00
Richard Smith ac8c17533f A conversion from a scoped enumeration bitfield to an integral type is an
integral promotion only if it converts to the underlying type or its promoted
type, not if it converts to the promoted type that the bitfield would have it
if were of the underlying type.

llvm-svn: 233457
2015-03-28 00:31:40 +00:00
Manuel Klimek 667c152bce Add initial version of a clang-fuzzer.
llvm-svn: 233455
2015-03-28 00:07:39 +00:00
Duncan P. N. Exon Smith 5043f91657 DebugInfo: Don't call DIBuilder::retainType(nullptr)
An upcoming LLVM commit will make calling
`DIBuilder::retainType(nullptr)` illegal (actually, it already was, but
it wasn't verified).  Check for null before calling.

This triggered in test/CodeGenObjC/debug-info-block-helper.m.

llvm-svn: 233443
2015-03-27 22:58:05 +00:00
Richard Smith d6aab59ad1 [modules] Allow a function template definition if we have a pre-existing but not visible definition of the same template.
llvm-svn: 233430
2015-03-27 21:57:41 +00:00
Chandler Carruth f089372c5c [Modules] Work around PR23030 again, in a different code path, where
I again added the "reasonable" assertions and they again fired during
a modules self-host.

This hopefully will un-break the self-host build bot. No test case handy
and adding one seems to have little or no value really.

llvm-svn: 233426
2015-03-27 21:40:58 +00:00
Richard Smith df5bf99d0b Add file forgotten from r233420.
llvm-svn: 233425
2015-03-27 21:40:57 +00:00
Richard Smith 0279375836 [modules] When merging class definitions, make the retained definition visible
if the merged definition is visible, and perform lookups into all merged copies
of the definition (not just for special members) so that we can complete the
redecl chains for members of the class.

llvm-svn: 233420
2015-03-27 21:16:39 +00:00
Richard Smith 9a71c99844 [modules] Allow a function to be redefined if the old definition is not visible.
llvm-svn: 233407
2015-03-27 20:16:58 +00:00
Rafael Espindola d053d20d0d Revert "Don't use unique section names by default if using the integrated as."
This reverts commit r233393 while a debug a bot failure.

llvm-svn: 233398
2015-03-27 19:01:14 +00:00
Rafael Espindola 463a0afe15 Don't use unique section names by default if using the integrated as.
This saves some IO and ccache space by not creating long section names. It
should work with every ELF linker.

llvm-svn: 233393
2015-03-27 17:55:23 +00:00
Benjamin Kramer 6dcddc21f8 Mark DR777 only as fixed in clang SVN.
llvm-svn: 233391
2015-03-27 17:38:35 +00:00
Benjamin Kramer 3a8650af77 [Sema] Factor diags with %plural. No functionality change intended.
llvm-svn: 233387
2015-03-27 17:23:14 +00:00
Timur Iskhodzhanov 3082d0e984 Make -fsanitize-coverage flag a core option so it's available via the clang-cl driver too
Reviewed at http://reviews.llvm.org/D8663

llvm-svn: 233384
2015-03-27 16:32:10 +00:00
Benjamin Kramer 52bd867399 Remove test for PR12917 for now. I'm relatively sure this is ill-formed per [dcl.fct.default]p3.
llvm-svn: 233379
2015-03-27 14:12:44 +00:00
Benjamin Kramer fe25759022 [Sema] Implement DR777
A parameter pack after a default argument is now valid.

PR23029.

llvm-svn: 233377
2015-03-27 13:58:41 +00:00
Benjamin Kramer 3b8044c02d [Sema] Diagnose default argument on a parameter pack.
This is ill-formed (and cannot be used anyways).

PR23028.

llvm-svn: 233376
2015-03-27 13:58:31 +00:00
Chandler Carruth 74e0585949 [Modules] When walking the lookup results in a namespace, sort them by
declaration name so that we mark declarations for emission in
a deterministic order (and in turn give them deterministic IDs).

This is the last for loop or data structure I can find by inspection of
the AST writer which doesn't use a deterministic order.

Found by inspection, no test case.

llvm-svn: 233348
2015-03-27 01:48:11 +00:00
Kaelyn Takata 92565b51aa Diagnose delayed typos in an expr list that is in an invalid expression.
Previously, if the expr list parsed fine but the expr to the left of the
open parenthesis was invalid (when parsing the suffix of a
postfix-expression), the parsed expr list was just ignored.

Fixes PR23005.

llvm-svn: 233347
2015-03-27 01:44:47 +00:00
Richard Smith a523022b53 [modules] Handle defining a tag with a typedef name for linkage purposes on top of an existing imported-but-not-visible definition.
llvm-svn: 233345
2015-03-27 01:37:43 +00:00
Chandler Carruth 12c8f65408 [Modules] Make Sema's map of referenced selectors have a deterministic
order based on order of insertion.

This should cause both our warnings about these and the modules
serialization to be deterministic as a consequence.

Found by inspection.

llvm-svn: 233343
2015-03-27 00:55:05 +00:00
Chandler Carruth acbbeb9782 [Modules] Make our on-disk hash table of selector IDs be built in
a deterministic order.

This uses a MapVector to track the insertion order of selectors.

Found by inspection.

llvm-svn: 233342
2015-03-27 00:47:43 +00:00
Richard Smith be3980b73c [modules] Handle defining a class template on top of an existing imported-but-not-visible definition.
llvm-svn: 233341
2015-03-27 00:41:57 +00:00
Chandler Carruth b306d73a2d [Modules] Sort the file IDs prior to building the flattened array of
DeclIDs so that in addition to be grouped by file, the order of these
groups is stable.

Found by inspection, no test case. Not sure this can be observed without
a randomized seed for the hash table, but we shouldn't be relying on the
hash table layout under any circumstances.

llvm-svn: 233339
2015-03-27 00:31:20 +00:00
Chandler Carruth 7dd1d0630e [Modules] Fix another pointer keyed set that we iterate over while
writing a module to be a set-vector to preserve insertion order.

No test case, found by inspection.

llvm-svn: 233335
2015-03-27 00:01:44 +00:00
Chandler Carruth 46e3ca1f17 [Modules] Clean up some code that was manually replicating what
SmallSetVector provides directly.

llvm-svn: 233334
2015-03-26 23:59:47 +00:00
Chandler Carruth a469eef7ce [Modules] Fix an obvious lack of deterministic ordering when processing
rewritten decls for Objective-C modules.

Found by inspection and completely obvious, so no test case. Many of the
remaining determinism fixes won't have precise test cases at this point,
but these are the kinds of things we wouldn't ask for a specific test of
during code review but ask authors to fix. The functionality isn't
changing, and should (he he!) already be tested.

llvm-svn: 233333
2015-03-26 23:58:11 +00:00
Chandler Carruth 8440c98642 [Modules] Make the AST serialization always use lexicographic order when
traversing the identifier table.

No easy test case as this table is somewhere between hard and impossible
to observe as non-deterministically ordered. The table is a hash table
but we hash the string contents and never remove entries from the table
so the growth pattern, etc, is all completely fixed. However, relying on
the hash function being deterministic is specifically against the
long-term direction of LLVM's hashing datastructures, which are intended
to provide *no* ordering guarantees. As such, this defends against these
things by sorting the identifiers. Sorting identifiers right before we
emit them to a serialized form seems a low cost for predictability here.

llvm-svn: 233332
2015-03-26 23:54:15 +00:00
Chandler Carruth 7bcfdd516c [Modules] Delete stale, pointless code. All tests still pass with this
logic removed.

This logic was both inserting all builtins into the identifier table and
ensuring they would get serialized. The first happens unconditionally
now, and we always write out the entire identifier table. This code can
simply go away.

llvm-svn: 233331
2015-03-26 23:45:40 +00:00
Chandler Carruth ffbf705cc3 [Modules] Fix a sneaky bug in r233249 where we would look for implicit
constructors in the current lexical context even though name lookup
found them via some other context merged into the redecl chain.

This can only happen for implicit constructors which can only have the
name of the type of the current context, so we can fix this by simply
*always* merging those names first. This also has the advantage of
removing the walk of the current lexical context from the common case
when this is the only constructor name we need to deal with (implicit or
otherwise).

I've enhanced the tests to cover this case (and uncovered an unrelated
bug which I fixed in r233325).

llvm-svn: 233327
2015-03-26 22:27:09 +00:00
Chandler Carruth 36e25f4771 [Modules] Fix tiny bug where we failed to get the canonical decl when
deserializing an inherited constructor.

This is the exact same logic we use when deserializing method overrides
for the same reason: the canonical decl may end up pinned to a different
decl when we are improting modules, we need to re-pin to the canonical
one during reading.

My test case for this will come in a subsequent commit. I was trying to
test a more tricky bug fix and the test case happened to tickle this bug
as well.

llvm-svn: 233325
2015-03-26 22:22:22 +00:00
Richard Smith 8f4d3ff146 [modules] Restrict the module use-declaration to only appear in top-level
modules, and allow sub-modules of a module with a use-declaration to make use
of the nominated modules.

llvm-svn: 233323
2015-03-26 22:10:01 +00:00
Davide Italiano 346048a1fa Fix -Wshift-count-negative. It didn't work if the right hand side
of the shift wasn't a constant integer expression, now it (hopefully)
does.

PR:		22059
llvm-svn: 233320
2015-03-26 21:37:49 +00:00
Bill Schmidt 3303eff774 [PowerPC] Remove assembly testing from test/CodeGen/ppc64-elf-abi.c
Eric Christopher pointed out that we have a check for assembly code
generation in a clang test, which isn't cool.  We already have Driver
and back-end CodeGen tests for the .abiversion handling, so this
testing is unnecessary anyway.  Make it go away.

llvm-svn: 233314
2015-03-26 20:16:52 +00:00
Daniel Jasper 05cd92922d clang-format: Force line break in trailing calls after multline exprs.
Before:
  aaaaaaaa(aaaaaaaaaa,
           bbbbbbbbbb).a();

After:
  aaaaaaaa(aaaaaaaaaa,
           bbbbbbbbbb)
      .a();

llvm-svn: 233304
2015-03-26 18:46:28 +00:00
Ed Schouten 6e57615ac8 Enable -ffunction-sections and -fdata-sections for CloudABI by default.
Unlike most of the other platforms supported by Clang, CloudABI only
supports static linkage, for the reason that global filesystem access is
prohibited. Functions provided by dlfcn.h are not present. As we know
that applications will not try to do any symbol lookups at run-time, we
can garbage collect unused code quite aggressively. Because of this, it
makes sense to enable -ffunction-sections and -fdata-sections by
default.

Object files will be a bit larger than usual, but the resulting binary
will not be affected, as the sections are merged again. However, when
--gc-sections is used, the linker is able to remove unused code far more
more aggressively. It also has the advantage that transitive library
dependencies only need to be provided to the linker in case that
functionality is actually used.

Differential Revision:	http://reviews.llvm.org/D8635
Reviewed by:	echristo

llvm-svn: 233299
2015-03-26 17:50:28 +00:00
Daniel Jasper e99c72fc2e clang-format: Fix merging of _T macros.
NewlinesBefore and HasUnescapedNewline were not properly propagated
leading to llvm.org/PR23032.

llvm-svn: 233276
2015-03-26 14:47:35 +00:00
Ed Schouten 3c3e58c42d Let Clang invoke CloudABI's linker.
Now that CloudABI's target information and header search logic for Clang
has been submitted, the only thing that remains to be done is adding
support for CloudABI's linker.

CloudABI uses Binutils ld, although there is some work to use lld
instead. This means that this code is largely based on what we use on
FreeBSD. There are some exceptions, however:

- Only static linking is performed. CloudABI does not support any
  dynamically linked executables.
- CloudABI uses compiler-rt, libc++ and libc++abi unconditionally. Link
  in these libraries instead of using libgcc_s, libstdc++, etc.
- We must ensure that the .eh_frame_hdr is present to make C++
  exceptions work properly.


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

llvm-svn: 233269
2015-03-26 11:13:44 +00:00
Chandler Carruth 52cee4dad2 [Modules] Preserve source order for the map of late parsed templates.
Clang was inserting these into a dense map. While it never iterated the
dense map during normal compilation, it did when emitting a module. Fix
this by using a standard MapVector to preserve the order in which we
encounter the late parsed templates.

I suspect this still isn't ideal, as we don't seem to remove things from
this map even when we mark the templates as no longer late parsed. But
I don't know enough about this particular extension to craft a nice,
subtle test case covering this. I've managed to get the stress test to
at least do some late parsing and demonstrate the core problem here.
This patch fixes the test and provides deterministic behavior which is
a strict improvement over the prior state.

I've cleaned up some of the code here as well to be explicit about
inserting when that is what is actually going on.

llvm-svn: 233264
2015-03-26 09:08:15 +00:00
Chandler Carruth 70a1369b34 [Modules] Add some more fun code to my modules stress test, this time
templates. Turns out all of this works correctly (so far). But it should
cover more code paths and will let me test some things that don't
actually work next.

llvm-svn: 233263
2015-03-26 08:49:55 +00:00
Chandler Carruth f85d98285e [Modules] Make "#pragma weak" undeclared identifiers be tracked
deterministically.

This fixes a latent issue where even Clang's Sema (and diagnostics) were
non-deterministic in the face of this pragma. The fix is super simple --
just use a MapVector so we track the order in which these are parsed (or
imported). Especially considering how rare they are, this seems like the
perfect tradeoff. I've also simplified the client code with judicious
use of auto and range based for loops.

I've added some pretty hilarious code to my stress test which now
survives the binary diff without issue.

llvm-svn: 233261
2015-03-26 08:32:49 +00:00
Chandler Carruth 8a3d24dcf8 [Modules] Delete a bunch of complex code for ensuring visible decls in
updated decl contexts get emitted.

Since this code was added, we have newer vastly simpler code for
handling this. The code I'm removing was very expensive and also
generated unstable order of declarations which made module outputs
non-deterministic.

All of the tests continue to pass for me and I'm able to check the
difference between the .pcm files after merging modules together.

llvm-svn: 233251
2015-03-26 04:27:10 +00:00
Richard Smith 65ebb4ac8a [modules] If we reach a definition of a class for which we already have a
non-visible definition, skip the new definition and make the old one visible
instead of trying to parse it again and failing horribly. C++'s ODR allows
us to assume that the two definitions are identical.

llvm-svn: 233250
2015-03-26 04:09:53 +00:00
Chandler Carruth e972c36221 [Modules] A second attempt at writing out on-disk hash tables for the
decl context lookup tables.

The first attepmt at this caused problems. We had significantly more
sources of non-determinism that I realized at first, and my change
essentially turned them from non-deterministic output into
use-after-free. Except that they weren't necessarily caught by tools
because the data wasn't really freed.

The new approach is much simpler. The first big simplification is to
inline the "visit" code and handle this directly. That works much
better, and I'll try to go and clean up the other caller of the visit
logic similarly.

The second key to the entire approach is that we need to *only* collect
names into a stable order at first. We then need to issue all of the
actual 'lookup()' calls in the stable order of the names so that we load
external results in a stable order. Once we have loaded all the results,
the table of results will stop being invalidated and we can walk all of
the names again and use the cheap 'noload_lookup()' method to quickly
get the results and serialize them.

To handle constructors and conversion functions (whose names can't be
stably ordered) in this approach, what we do is record only the visible
constructor and conversion function names at first. Then, if we have
any, we walk the decls of the class and add those names in the order
they occur in the AST. The rest falls out naturally.

This actually ends up simpler than the previous approach and seems much
more robust.

It uncovered a latent issue where we were building on-disk hash tables
for lookup results when the context was a linkage spec! This happened to
dodge all of the assert by some miracle. Instead, add a proper predicate
to the DeclContext class and use that which tests both for function
contexts and linkage specs.

It also uncovered PR23030 where we are forming somewhat bizarre negative
lookup results. I've just worked around this with a FIXME in place
because fixing this particular Clang bug seems quite hard.

I've flipped the first part of the test case I added for stability back
on in this commit. I'm taking it gradually to try and make sure the
build bots are happy this time.

llvm-svn: 233249
2015-03-26 03:11:40 +00:00
Eric Christopher 118ee4c07b Add an explanatory comment as to why we're turning on and off
certain other options as aliases. There be dragons here.

llvm-svn: 233238
2015-03-26 00:50:13 +00:00
Richard Smith 88f4bba21e Reformatting, NFC
llvm-svn: 233234
2015-03-26 00:16:07 +00:00
Manuel Klimek 093b2d48b4 Keep track of canonical decls in Redeclarable.
More than 2x speedup on modules builds with large redecl chains.
Roughly 15-20% speedup on non-modules builds for very large TUs.
Between 2-3% cost in memory on large TUs.

llvm-svn: 233228
2015-03-25 23:18:30 +00:00
Eric Christopher 70c1665d83 Reapply r232888 after applying a fix for -msse4 code generation.
As a note, any target that uses fake target features via command
line options will have similar problems.

llvm-svn: 233227
2015-03-25 23:14:47 +00:00
Eric Christopher f43966f38d Make the msse4/mno-sse4 flags aliases of the maximum sse values
they enable/disable.

This fixes two things:

a) sse4 isn't actually a target feature, don't treat it as one.
b) we weren't correctly disabling sse4.1 when we'd pass -mno-sse4
   after enabling it, thus passing preprocessor directives and
   (soon) passing the function attribute as well when we shouldn't.

llvm-svn: 233223
2015-03-25 22:09:26 +00:00
Ehsan Akhgari a2956ff405 Fix coverage-ld.c on systems with an Android linker in $PATH
Summary:
On my system, clang tries to invoke /path/to/arm-linux-androideabi-ld
as the linker for Android, and the regex inside the test file considers
this as unacceptable.

Reviewers: samsonov

Subscribers: tberghammer, aemerson, cfe-commits

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

llvm-svn: 233211
2015-03-25 20:17:20 +00:00
Yunzhong Gao 7b0f428573 Disable this test for PS4 target because PS4 issues different diagnostics.
llvm-svn: 233210
2015-03-25 20:16:29 +00:00
Jingyue Wu 4f7b9eb217 Fix addrspace when emitting constructors of static local variables
Summary:
Due to CUDA's implicit address space casting, the type of a static local
variable may be more specific (i.e. with address space qualifiers) than
the type expected by the constructor. Emit an addrspacecast in that
case.

Test Plan: Clang used to crash on the added test.

Reviewers: nlewycky, pcc, eliben, rsmith

Reviewed By: eliben, rsmith

Subscribers: llvm-commits

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

llvm-svn: 233208
2015-03-25 20:06:28 +00:00
Kit Barton 8246f28237 Add Hardware Transactional Memory (HTM) Support
This patch adds Hardware Transaction Memory (HTM) support supported by ISA 2.07
(POWER8). The intrinsic support is based on GCC one [1], with both 'PowerPC HTM
Low Level Built-in Functions' and 'PowerPC HTM High Level Inline Functions'
implemented.

Along with builtins a new driver switch is added to enable/disable HTM
instruction support (-mhtm) and a header with common definitions (mostly to
parse the TFHAR register value). The HTM switch also sets a preprocessor builtin
HTM.

The HTM usage requires a recently newer kernel with PPC HTM enabled. Tested on
powerpc64 and powerpc64le.

This is send along a llvm patch to enabled the builtins and option switch.

[1]
https://gcc.gnu.org/onlinedocs/gcc/PowerPC-Hardware-Transactional-Memory-Built-in-Functions.html

Phabricator Review: http://reviews.llvm.org/D8248

llvm-svn: 233205
2015-03-25 19:41:41 +00:00
Tamas Berghammer 6373cee3b6 Create android x86_32 and x86_64 target info
On android x86_32 the long double is only 64 bits (compared to 80 bits
on linux x86_32) and on android x86_64 the long double is IEEEquad
(compared to x87DoubleExtended on linux x86_64). This CL creates new
TargetInfo classes for this targets to represent these differences.

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

llvm-svn: 233177
2015-03-25 10:38:50 +00:00
Daniel Jasper cb47d8d17b Temporarily disable one more non-determinism flag.
This turned the bots to red after r233172 which reverted r233156.

llvm-svn: 233173
2015-03-25 06:59:19 +00:00
Rafael Espindola c606b3e6d0 Revert "[Modules] When writing out the on-disk hash table for the decl context lookup tables, we need to establish a stable ordering for constructing the hash table. This is trickier than it might seem."
This reverts commit r233156. It broke the bots.

llvm-svn: 233172
2015-03-25 04:43:15 +00:00
Justin Bogner f14b207882 InstrProf: Handle whitespace and comments at the ends of macros
When we try to find the end loc for a token, we have to re-lex the
token. This was running into a problem when we'd store the end loc of
a macro's coverage region, since we wouldn't actually be at the
beginning of a token when we tried to re-lex it, leading us to do
silly things (and eventually assert) when whitespace or comments
followed.

This pushes our use of getPreciseTokenLocEnd earlier, so that we won't
call it when it doesn't make sense to. It also removes an unnecessary
adjustment by 1 that was working around this problem in some cases.

llvm-svn: 233169
2015-03-25 04:13:49 +00:00
Chandler Carruth d5f1db6b36 [Modules] Disable the diff of the merged module, there is still some
non-determinism here, I just got lucky a bunch of times on my system.

llvm-svn: 233163
2015-03-25 01:30:02 +00:00
Chandler Carruth 75fc6a7f61 [Modules] Make the DeclUpdates map be processed in insertion order.
This fixes my stress tests non-determinism so far. However, I've not
started playing with templates, friends, or terrible macros. I've found
at least two more seeming instabilities and am just waiting for a test
case to actually trigger them.

llvm-svn: 233162
2015-03-25 01:02:12 +00:00
Ehsan Akhgari c07d1e23fb Diagnose ref-qualifiers occuring after virt-specifier-seq and generate fixit hints
Summary: Follow-up to the fix of PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 233161
2015-03-25 00:53:33 +00:00
Ehsan Akhgari 93ed5cf5e6 Diagnose declspecs occuring after virt-specifier-seq and generate fixit hints
Summary: This fixes PR22075.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 233160
2015-03-25 00:53:27 +00:00
Chandler Carruth 75c9f13aa8 [Modules] When writing out the on-disk hash table for the decl context
lookup tables, we need to establish a stable ordering for constructing
the hash table. This is trickier than it might seem.

Most of these cases are easily handled by sorting the lookup results
associated with a specific name that has an identifier. However for
constructors and conversion functions, the story is more complicated.
Here we need to merge all of the constructors or conversion functions
together and this merge needs to be stable. We don't have any stable
ordering for either constructors or conversion functions as both would
require a stable ordering across types.

Instead, when we have constructors or conversion functions in the
results, we reconstruct a stable order by walking the decl context in
lexical order and merging them in the order their particular declaration
names are encountered. This doesn't generalize as there might be found
declaration names which don't actually occur within the lexical context,
but for constructors and conversion functions it is safe. It does
require loading the entire decl context if necessary to establish the
ordering but there doesn't seem to be a meaningful way around that.

Many thanks to Richard for talking through all of the design choices
here. While I wrote the code, he guided all the actual decisions about
how to establish the order of things.

No test case yet because the test case I have doesn't pass yet -- there
are still more sources of non-determinism. However, this is complex
enough that I wanted it to go into its own commit in case it causes some
unforseen issue or needs to be reverted.

llvm-svn: 233156
2015-03-25 00:34:51 +00:00
Reid Kleckner 5a63d7073c Fix obviously broken assertion, NFC
llvm-svn: 233138
2015-03-24 23:46:25 +00:00
Ahmed Bougacha 6ba3831ebe [CodeGen] Support native half inc/dec amounts.
We previously defaulted to long double, but it's also possible to have
a half inc/dec amount, when LangOpts NativeHalfType is set.
Currently, that's only true for OpenCL.

llvm-svn: 233135
2015-03-24 23:44:42 +00:00
Chandler Carruth 580dd296fa [Modules] Stop creating timestamps for the modules cache and trying to
prune it when we have disabled implicit module generation and thus are
not using any cached modules.

Also update a test of explicitly generated modules to pass this CC1 flag
correctly.

This fixes an issue where Clang was dropping files into the source tree
while running its tests.

llvm-svn: 233117
2015-03-24 21:44:25 +00:00
Chandler Carruth 885e78cb22 [Modules] Start making explicit modules produce deterministic output.
There are two aspects of non-determinism fixed here, which was the
minimum required to cause at least an empty module to be deterministic.

First, the random number signature is only inserted into the module when
we are building modules implicitly. The use case for these random
signatures is to work around the very fact that modules are not
deterministic in their output when working with the implicitly built and
populated module cache. Eventually this should go away entirely when
we're confident that Clang is producing deterministic output.

Second, the on-disk hash table is populated based on the order of
iteration over a DenseMap. Instead, use a MapVector so that we can walk
it in insertion order.

I've added a test that an empty module, when built twice, produces the
same binary PCM file.

llvm-svn: 233115
2015-03-24 21:18:10 +00:00
Sanjay Patel 7a9f5d380b Adding back a CHECK that works with r233110
llvm-svn: 233111
2015-03-24 20:42:20 +00:00
Sanjay Patel 1a94ccbec8 Removing a CHECK that is about to go wrong.
I'm about to commit a patch for:
http://reviews.llvm.org/D8567

That patch will break this one existing test case in Clang.
I'm not sure if this file is intending to create a Clang
dependency on the LLVM IR optimizer, but that's the
consequence of specifying -O3 on this test file.

My hope is to avoid buildbot rage by removing this check,
committing the LLVM patch, and then fixing this check.
I don't know how to make a simultaneous commit to Clang
and LLVM.

I will commit the correct CHECK line fix for this test 
shortly.

llvm-svn: 233109
2015-03-24 20:35:24 +00:00
Fariborz Jahanian a9dccd41e9 [Objective-C diagnostic PATCH] Accept and ignore -Wreceiver-is-weak
warning until Xcode removes the warning setting.
rdar://20262140

llvm-svn: 233093
2015-03-24 17:14:20 +00:00
Aaron Ballman f4cb2be05a Track the source location of the dot or arrow operator in a MemberExpr.
Patch by Joe Ranieri!

llvm-svn: 233085
2015-03-24 15:07:53 +00:00