Commit Graph

57781 Commits

Author SHA1 Message Date
Daniel Jasper e4ab49e8d3 clang-format: Fix incorrect multi-var declstmt detection.
This is now obvious as the pointer alignment behavior was changed.

Before (even with pointer alignment "Left"):
  MACRO Constructor(const int &i) : a(a), b(b) {}

After:
  MACRO Constructor(const int& i) : a(a), b(b) {}

llvm-svn: 235301
2015-04-20 12:54:29 +00:00
Manuel Klimek b1223b1de5 Fix bug in Replacement's toString on Windows (missing flush).
Adapt function to LLVM coding style.

llvm-svn: 235286
2015-04-20 06:58:56 +00:00
Argyrios Kyrtzidis 4ecdd2cff3 [Sema] Check availability of ObjC super class and protocols of a container
in the context of the container itself.

Otherwise we will emit 'unavailable' errors when referencing an unavailable super class
even though the subclass is also marked 'unavailable'.

rdar://20598702

llvm-svn: 235276
2015-04-19 20:15:55 +00:00
David Majnemer 936b411bc8 [MS ABI] Correctly associate align attrs before the class-key
__declspec(align(...)) is unlike all other attributes in that it is not
applied to a variable if it appears before the class-key.  If the
tag in question isn't part of a variable declaration, it is not ignored.

Instead, the alignment attribute is applied to the tag.

This fixes PR18024.

llvm-svn: 235272
2015-04-19 07:53:29 +00:00
Richard Smith 9eb309371b Try to work around failure to convert this lambda to a function pointer in some versions of GCC.
llvm-svn: 235264
2015-04-19 01:47:53 +00:00
Richard Smith cf97cf6693 [modules] Refactor macro emission. No functionality change.
llvm-svn: 235263
2015-04-19 01:34:23 +00:00
Benjamin Kramer 5df7c1a4eb Make helper function static. NFC.
llvm-svn: 235253
2015-04-18 10:00:10 +00:00
David Majnemer bc4cc14cd7 [Sema] Don't crash if array bound calculation overflowed constexpr array
We didn't correctly expect a QualifiedTypeLoc when faced with fixing a
variable array type into a constant array type.

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

llvm-svn: 235251
2015-04-18 04:55:51 +00:00
Duncan P. N. Exon Smith edc76a7ede Remove dead code, NFC
llvm-svn: 235246
2015-04-18 00:26:49 +00:00
Duncan P. N. Exon Smith d899f6e4de DebugInfo: Prepare for deletion of DIDescriptor
Prepare for upcoming LLVM change to delete `DIDescriptor`.

llvm-svn: 235245
2015-04-18 00:07:30 +00:00
Pete Cooper 635b509dee Change AArch64 i128 returns to use [2 x i64] when possible.
Something like { void*, void * } would be passed to a function as a [2 x i64], but returned as an i128.  This patch unifies the 2 behaviours so that we also return it as a [2 x i64].

This is better for the quality of the IR, and the size of the final LLVM binary as we tend to want to insert/extract values from these types and do so with the insert/extract instructions is less IR than shifting, truncating, and or'ing values.

Reviewed by Tim Northover.

llvm-svn: 235231
2015-04-17 22:16:24 +00:00
Pete Cooper f9db5737d0 Add a missing forward def of CheckerManager. NFC.
This file doesn't include CheckerManager or forward declare it, so is sensitive to include order.

llvm-svn: 235209
2015-04-17 17:00:16 +00:00
Sylvestre Ledru 3dbaf8534a Remove the assertion as it was useless and broken.
Enforcing the assert caused the following tests to fail:
Clang :: Analysis__bstring.c
Clang :: Analysis__comparison-implicit-casts.cpp
Clang :: Analysis__malloc-interprocedural.c
Clang :: Analysis__malloc.c
Clang :: Analysis__redefined_system.c
Clang :: Analysis__string.c
Clang :: Analysis__weak-functions.c

llvm-svn: 235190
2015-04-17 13:21:39 +00:00
Sylvestre Ledru 91ba4b1af6 Fix a bad assert. Found by coverity. CID 1101110
llvm-svn: 235188
2015-04-17 13:08:54 +00:00
Will Wilson db2588ab82 [MSVC] Mimic MSVC whitespace collapse for incompatible token pasting
In public MS headers for XAudio, clang would fail to generate a valid UUID due to the UUID components being combined with the '-' UUID separators. Clang would attempting to recover but would preserve the leading whitespace from the tokens after each failed paste leading to spaces creeping into the UUID and causing an error in the __declspace(uuid()) parsing.

Reference: Microsoft DirectX SDK (June 2010)\Include\XAudio2.h(51)

Resolves http://llvm.org/pr23071

llvm-svn: 235186
2015-04-17 12:43:57 +00:00
Nico Weber 796a772617 Follow-up to r235046: selectany only causes a definition if it's not inherited.
(For example needed to parse system header inputscope.h, which first has
an extern "C" selectany IID and then later an extern "C" declaration of that
same IID.)

llvm-svn: 235174
2015-04-17 09:50:28 +00:00
Nico Weber 337d5aa58f Move fixit for const init from note to diag, weaken to warning in MS mode.
r235046 turned "extern __declspec(selectany) int a;" from a declaration into
a definition to fix PR23242 (required for compatibility with mc.exe output).
However, this broke parsing Windows headers: A  d3d11 headers contain something
like

  struct SomeStruct {};
  extern const __declspec(selectany) SomeStruct some_struct;

This is now a definition, and const objects either need an explicit default
ctor or an initializer so this errors out with 

  d3d11.h(1065,48) :
    error: default initialization of an object of const type
           'const CD3D11_DEFAULT' without a user-provided default constructor

(cl.exe just doesn't implement this rule, independent of selectany.)

To work around this, weaken this error into a warning for selectany decls
in microsoft mode, and recover with zero-initialization.

Doing this is a bit hairy since it adds a fixit on an error emitted
by InitializationSequence – this means it needs to build a correct AST, which
in turn means InitializationSequence::Failed() cannot return true when this
fixit is applied. As a workaround, the patch adds a fixit member to
InitializationSequence, and InitializationSequence::Perform() prints the
diagnostic if the fixit member is set right after its call to Diagnose.
That function is usually called when InitializationSequences are used –
InitListChecker::PerformEmptyInit() doesn't call it, but the InitListChecker
case never performs default-initialization, so this is technically OK.

This is the alternative, original fix for PR20208 that got reviewed in the
thread "[patch] Improve diagnostic on default-initializing const variables
(PR20208)".  This change basically reverts r213725, adds the original fix for
PR20208, and makes the error a warning in Microsoft mode.

llvm-svn: 235166
2015-04-17 08:32:38 +00:00
Daniel Jasper 4b08ea8eca Revert file unintentionally changed in r235162.
llvm-svn: 235163
2015-04-17 08:01:41 +00:00
Daniel Jasper 0fe44465c3 clang-format: Add default fallback style.
Thanks to Michael Schlottke.

llvm-svn: 235162
2015-04-17 07:59:19 +00:00
David Majnemer 2ccba83401 [MS ABI] Use the right types for filter and finally blocks
The type for abnormal_termination can't be an i1, it an i8.
Filter functions return 'LONG', not 'int'.

llvm-svn: 235161
2015-04-17 06:57:25 +00:00
David Blaikie ab8f7d5876 Improve const-ness
This allows callers to pass a char ** (such as the one coming from the
standard decreed main declaration - even though everyone usually puts
const on that themselves).

llvm-svn: 235150
2015-04-17 00:19:34 +00:00
David Blaikie d6c88ece21 [opaque pointer types] Explicit non-pointer type for call expressions
(migration for recent LLVM change to textual IR for calls)

llvm-svn: 235147
2015-04-16 23:25:00 +00:00
Fariborz Jahanian 029e52bb57 [Objective-C Sema]. In my last patch change the
attribute name to objc_independent_class. 
rdar://20255473

llvm-svn: 235135
2015-04-16 21:52:34 +00:00
Fariborz Jahanian 7a60b6db76 [Objective-C Sema] patch to introduce IndependentClass
attribute to be placed on Objective-C pointer typedef
to make them strong enough so on their "new" method
family no attempt is made to override these 
types. rdar://20255473

llvm-svn: 235128
2015-04-16 18:38:44 +00:00
Duncan P. N. Exon Smith 4078ad4122 DebugInfo: Update for LLVM API change in DIBuilder (r235111)
LLVM r235111 changed the `DIBuilder` API to stop using `DIDescriptor`
and its subclasses.  Rolled into this was some tightening up of types:

  - Scopes: `DIDescriptor` => `MDScope*`.
  - Generic debug nodes: `DIDescriptor` => `DebugNode*`.
  - Subroutine types: `DICompositeType` => `MDSubroutineType*`.
  - Composite types: `DICompositeType` => `MDCompositeType*`.

Note that `DIDescriptor` wraps `MDNode`, and `DICompositeType` wraps
`MDCompositeTypeBase`.

It's this new type strictness that requires changes here.

llvm-svn: 235112
2015-04-16 16:36:45 +00:00
Vladimir Sukharev e851e04262 [AArch64] Add v8.1a architecture
Add support for AArch64 v8.1 architecture. Briefly it is described on http://community.arm.com/groups/processors/blog/2014/12/02/the-armv8-a-architecture-and-its-ongoing-development

Reviewers: jmolloy

Subscribers: cfe-commits

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

llvm-svn: 235110
2015-04-16 15:53:09 +00:00
Alexey Bataev 6ddfe1a6af [OPENMP] Fix for checking of data-sharing attributes for canonical var decls only.
Currently checks for active data-sharing attributes for variables are performed for found var decls. Instead these checks must be performed for canonical decls of these variables to avoid possible troubles with with the differently qualified re-declarations of the same variable, for example:
namespace A { int x; }
namespace B { using A::x; }
Both A::x and B::x actually reference the same object A::x and this fact must be taken into account during data-sharing attributes analysis.

llvm-svn: 235096
2015-04-16 13:49:42 +00:00
Daniel Jasper 23341446e8 clang-format: add an option for fallback style in vimrc
With this patch, clang-format.py will search and use existing .clang-format
file if there is one and fallback to the specific format style if
not. It should cover the projects which don't have .clang-format
files in their source. As the option fallback-style is available in
clang 3.5 or later, it is safe to use.

Patch by "Chilledheart" (http://reviews.llvm.org/D8489).

llvm-svn: 235080
2015-04-16 08:26:37 +00:00
Daniel Jasper 0d6ac27b86 clang-format: [JS] handle comments in template strings.
Patch by Martin Probst. Thank you.

llvm-svn: 235078
2015-04-16 08:20:51 +00:00
Daniel Jasper 20e15563ff clang-format: Undo r214508. It was essentially always removing the
space where we already had the flag ObjCSpaceBeforeProtocolList to
control it. I don't know what I was thinking.

llvm-svn: 235076
2015-04-16 07:02:19 +00:00
Alexey Bataev f56f98c925 [OPENMP] Codegen for 'copyin' clause in 'parallel' directive.
Emits the following code for the clause at the beginning of the outlined function for implicit threads:

if (<not a master thread>) {
  ...
  <thread local copy of var> = <master thread local copy of var>;
  ...
}
<sync point>;
Checking for a non-master thread is performed by comparing of the address of the thread local variable with the address of the master's variable. Master thread always uses original variables, so you always know the address of the variable in the master thread.
Differential Revision: http://reviews.llvm.org/D9026

llvm-svn: 235075
2015-04-16 05:39:01 +00:00
Alexey Bataev 38e8953352 [OPENMP] Codegen for 'lastprivate' clause in 'for' directive.
#pragma omp for lastprivate(<var>)
for (i = a; i < b; ++b)
  <BODY>;

This construct is translated into something like:

  <last_iter> = alloca i32
  <lastprivate_var> = alloca <type>
  <last_iter> = 0
  ; No initializer for simple variables or a default constructor is called for objects.
  ; For arrays perform element by element initialization by the call of the default constructor.
  ...
  OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration.
  <BODY>
  ...
  OMP_FOR_END
  if (<last_iter> != 0) {
    <var> = <lastprivate_var> ; Update original variable with the lastprivate value.
  }
  call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race.

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

llvm-svn: 235074
2015-04-16 04:54:05 +00:00
Duncan P. N. Exon Smith 526ab07e3c DebugInfo: Prepare for DIDescriptor to be gutted in LLVM
All the API is about to be dropped from `DIDescriptor` in LLVM, so stop
using it.

llvm-svn: 235068
2015-04-16 01:53:23 +00:00
Duncan P. N. Exon Smith 373ee85966 DebugInfo: Prepare for DIScope to be gutted in LLVM
An upcoming LLVM commit will gut `DIScope`, so just use `MDScope*`
directly.

llvm-svn: 235066
2015-04-16 01:36:36 +00:00
Duncan P. N. Exon Smith 4caa7f2a9c DebugInfo: Prepare for DIType to be gutted
`DIType` and its subclasses are about to be gutted in LLVM.  Prepare for
that by treating these like the raw pointers they wrap.

llvm-svn: 235063
2015-04-16 01:00:56 +00:00
Duncan P. N. Exon Smith b747023081 DebugInfo: Prepare for LLVM change removing DIType::isValid()
This is being replaced with a null check.

llvm-svn: 235058
2015-04-15 23:48:50 +00:00
Dmitri Gribenko 8b7206250f Comment parsing: fix an assertion failure on a verbatim block terminated with "**/"
llvm-svn: 235057
2015-04-15 23:45:43 +00:00
Duncan P. N. Exon Smith 798d565fd8 DebugInfo: Prepare for LLVM gutting DICompileUnit/DIFile
An upcoming LLVM commit will gut `DICompileUnit` and `DIFile`, so start
treating them more like pointers.

llvm-svn: 235054
2015-04-15 23:19:15 +00:00
Nico Weber 608e768d8d Don't crash when a selectany symbol would get common linkage
Things can't both be in comdats and have common linkage, so never give things
in comdats common linkage. Common linkage is only used in .c files, and the
only thing that can trigger a comdat in c is selectany from what I can tell.
Fixes PR23243.

Also address an over-the-shoulder review comment from rnk by moving the
hasAttr<SelectAnyAttr>() in Decl.cpp around a bit. It only makes a minor
difference for selectany on global variables, so it goes well with the rest of
this patch.

http://reviews.llvm.org/D9042

llvm-svn: 235053
2015-04-15 23:04:24 +00:00
DeLesley Hutchins 773ba37529 Fix for PR20402 in -Wconsumed.
https://llvm.org/bugs/show_bug.cgi?id=20402
Patch by Chris Wailes.

llvm-svn: 235051
2015-04-15 22:32:44 +00:00
Eli Bendersky 4bdc50eccb Create a frontend flag to disable CUDA cross-target call checks
For CUDA source, Sema checks that the targets of call expressions make sense
(e.g. a host function can't call a device function).

Adding a flag that lets us skip this check. Motivation: for source-to-source
translation tools that have to accept code that's not strictly kosher CUDA but
is still accepted by nvcc. The source-to-source translation tool can then fix
the code and leave calls that are semantically valid for the actual compilation
stage.

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

llvm-svn: 235049
2015-04-15 22:27:06 +00:00
Nico Weber 7f5015a9cc clang-format a line containing nothing but a "{". No behavior change.
llvm-svn: 235047
2015-04-15 21:53:00 +00:00
Nico Weber ea7386d40c Make __declspec(selectany) turn variable declartions into definitions.
Fixes PR23242.

llvm-svn: 235046
2015-04-15 21:50:06 +00:00
Duncan P. N. Exon Smith fe88b48632 DebugInfo: Pass DebugLocs when creating intrinsics
Update for LLVM API change r235041 that makes `DIBuilder` require a
`DebugLoc` to create a debug info intrinsic.

llvm-svn: 235042
2015-04-15 21:18:30 +00:00
Jonathan Roelofs c7749fca07 Fix docs typo in FunctionTemplateSpecializationInfo
llvm-svn: 235039
2015-04-15 20:47:22 +00:00
Fariborz Jahanian 890803f5f4 [Objective-C Sema]This patch fixes the warning when clang issues
"multiple methods named '<selector>' found" warning by noting 
the method that is actualy used. It also cleans up and refactors
code in this area and selects a method that matches actual arguments
in case of receiver being a forward class object.
rdar://19265430

llvm-svn: 235023
2015-04-15 17:26:21 +00:00
Hans Wennborg 5615f6bcd5 clang-cl: support -fsyntax-only (PR23197)
This might help running Clang tooling (which appends this option)
with clang-cl command-lines.

llvm-svn: 234990
2015-04-15 10:02:21 +00:00
Alexey Bataev bcb4a8fe1b Changed test to not brake ARM buildbots, NFC.
llvm-svn: 234988
2015-04-15 09:52:50 +00:00
Renato Golin c640ff63e2 Revert "[CodeGen] Fix crash with duplicated mangled name."
This reverts commit r234767, as it was breaking all ARM buildbots for two days and the
assert is not in the code, making it difficult to spot the error, which would keep the
bots red for a few more days. New errors were silently introduced because of this bug,
and we don't want this to escalate.

llvm-svn: 234983
2015-04-15 08:44:40 +00:00
Daniel Jasper 2b1865c251 clang-format: Determine "in" as a keyword in ObjC for loops more precisely
Before:
  for (int i = 0; i < in [a]; ++i) ..

After:
  for (int i = 0; i < in[a]; ++i) ..

Also do some related cleanups.

llvm-svn: 234980
2015-04-15 07:26:18 +00:00