Commit Graph

65085 Commits

Author SHA1 Message Date
Bruno Cardoso Lopes c73e4c3f89 [Sema] Add more strict check for sizeof diagnostics for bzero
Follow-up from r278264 after Joerg's feedback.

Since bzero is not standard, be more strict: also check if the first
argument is a pointer, which harden the check for when it does not come
originally from a builtin.

llvm-svn: 278379
2016-08-11 18:33:15 +00:00
Saleem Abdulrasool ae0e635f60 bindings: expose diagnostic formatting to Python
This makes it easier for tools using the Python libclang bindings to display
diagnostics in a manner consistent with clang.

Patch by Omar Sandoval!

llvm-svn: 278315
2016-08-11 05:31:07 +00:00
Chris Bieneman 8a22e502bd [Order Files] Don't use empty order files
LD64 does optimization on symbol layouts that gets disabled whenever an order file is passed (even if it is empty). This change prevents disabling that optimization, and still enables iterative generation and usage of order files.

If the order file is empty it does not setup the order file flags, instead it sets the empty order file as a configuration dependency. When the order file changes it will then trigger a re-configuration that adds the linker flag.

llvm-svn: 278306
2016-08-11 00:19:51 +00:00
Bruno Cardoso Lopes 7ea9fd233b Reapply [Sema] Add sizeof diagnostics for bzero
Reapply r277787. For memset (and others) we can get diagnostics like:

  struct stat { int x; };
  void foo(struct stat *stamps) {
    bzero(stamps, sizeof(stamps));
    memset(stamps, 0, sizeof(stamps));
  }

  t.c:7:28: warning: 'memset' call operates on objects of type 'struct stat' while the size is based on a different type 'struct stat *' [-Wsizeof-pointer-memaccess]
    memset(stamps, 0, sizeof(stamps));
           ~~~~~~            ^~~~~~
  t.c:7:28: note: did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?
    memset(stamps, 0, sizeof(stamps));
                             ^~~~~~

This patch implements the same class of warnings for bzero.

Differential Revision: https://reviews.llvm.org/D22525

rdar://problem/18963514

llvm-svn: 278264
2016-08-10 18:34:47 +00:00
Artem Dergachev cad151491e [analyzer] Fix a crash in CloneDetector when calling functions by pointers.
CallExpr may have a null direct callee when the callee function is not
known in compile-time. Do not try to take callee name in this case.

Patch by Raphael Isemann!

Differential Revision: https://reviews.llvm.org/D23320

llvm-svn: 278238
2016-08-10 16:25:16 +00:00
Joey Gouly b95e36027f [OpenCL] Fix typo in test that I accidentally introduced in my previous commit.
llvm-svn: 278235
2016-08-10 16:04:14 +00:00
Joey Gouly ddbda40245 [OpenCL] Change block descriptor address space to constant.
The block descriptor is a GlobalVariable in the LLVM IR, so it shouldn't be
in the private address space.

llvm-svn: 278234
2016-08-10 15:57:02 +00:00
Martin Bohme 56c91a1dc2 [ASTMatchers] Extend documentation for match()
Summary:
Adds an explanation of how to use findAll() to find all matches in a subtree.

llvm-svn: 278213
2016-08-10 11:22:57 +00:00
Lama Saba 5d01f224cf [X86][AVX512] lower __mm512_andnot_ps/__mm512_andnot_pd to IR
Differential revision: https://reviews.llvm.org/D23262
 

llvm-svn: 278209
2016-08-10 10:34:45 +00:00
Simon Pilgrim ebaabc7b99 [X86][AVX] Ensure we only match against 1-byte alignment
llvm-svn: 278208
2016-08-10 09:59:49 +00:00
Eric Liu a992afe809 Make clang-format remove duplicate headers when sorting #includes.
Summary: When sorting #includes, #include directives that have the same text will be deduplicated when sorting #includes, and only the first #include in the duplicate #includes remains. If the `Cursor` is provided and put on a deleted #include, it will be put on the remaining #include in the duplicate #includes.

Reviewers: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D23274

llvm-svn: 278206
2016-08-10 09:32:23 +00:00
Chandler Carruth 4c5e8ccf74 [x86] Fix a really nasty bug introduced in r276417 where alignment
constraints were added to _mm256_broadcast_{pd,ps} intel intrinsics.

The spec for these intrinics is ... pretty much silent on alignment.
This is especially frustrating considering the amount of discussion of
alignment in the load and store instrinsics. So I was forced to rely on
the specification for the VBROADCASTF128 instruction.

That instruction's spec is *also* completely silent on alignment.
Fortunately, when it comes to the instruction's spec, silence is enough.
There is no #GP fault option for an underaligned address so this
instruction, and by inference the intrinsic, can read any alignment.

As it happens, the old code worked exactly this way and in fact we have
plenty of code that hands pointers with less than 16-byte alignment to
these intrinsics. This code broke pretty spectacularly with this commit.

Fortunately, the fix is super simple! Change a 16 to a 1, and ta da!

Anyways, a lot of debugging for a really boring fix. =]

llvm-svn: 278202
2016-08-10 07:32:47 +00:00
Justin Lebar c989c3e784 [CUDA] Reject calls to __device__ functions from host variable global initializers.
Reviewers: tra

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23335

llvm-svn: 278196
2016-08-10 01:09:21 +00:00
Justin Lebar 7d078bddbd [CUDA] Print a "previous-decl" note when calling an illegal member fn.
Summary:
When we emit err_ref_bad_target, we should emit a "'method' declared
here" note.  We already do so in most places, just not in
BuildCallToMemberFunction.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23240

llvm-svn: 278195
2016-08-10 01:09:18 +00:00
Justin Lebar 2ef3dabd45 [CUDA] Add __device__ overloads for placement new and delete.
Summary:
Previously these sort of worked because they didn't end up resulting in
calls at the ptx layer.  But I'm adding stricter checks that break
placement new without these changes.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23239

llvm-svn: 278194
2016-08-10 01:09:14 +00:00
Justin Lebar b008003aa3 [CUDA] Rename CheckCUDATarget to IsAllowedCUDACall. NFC
Summary:
I want to reuse "CheckCUDAFoo" in a later patch.  Also, I think
IsAllowedCUDACall gets the point across more clearly.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23238

llvm-svn: 278193
2016-08-10 01:09:11 +00:00
Justin Lebar bf16db1cf2 [Diag] Fix idiom in comment: "on the lam", not "on the lamb".
llvm-svn: 278192
2016-08-10 01:09:07 +00:00
Justin Lebar 0af91f57ca [CUDA] Fix out-of-date comment.
LangOpts.CUDADisableTargetCallChecks no longer exists (it's effectively
always true now).

llvm-svn: 278184
2016-08-10 00:40:46 +00:00
Justin Lebar 66a2ab9175 [CUDA] Minor comment nits.
llvm-svn: 278183
2016-08-10 00:40:43 +00:00
Tim Shen 0c74967186 [ADT] Change iterator_adaptor_base's default template arguments to forward more underlying typedefs
Summary:
The corresponding LLVM change: D23217.

LazyVector::iterator breaks, because int isn't an iterator type.
Since iterator_adaptor_base shouldn't be blamed to break at the call to
iterator_traits<int>::xxx, I'd rather "fix" LazyVector::iterator.

The perfect solution is to model "relative pointer", but it's beyond the goal of this patch.

Reviewers: chandlerc, bkramer

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23218

llvm-svn: 278156
2016-08-09 20:22:55 +00:00
Yaxun Liu ffb60901fe [OpenCL] Handle -cl-fp32-correctly-rounded-divide-sqrt
Let the driver pass the option to frontend. Do not set precision metadata for division instructions when this option is set. Set function attribute "correctly-rounded-divide-sqrt-fp-math" based on this option.

Differential Revision: https://reviews.llvm.org/D22940

llvm-svn: 278155
2016-08-09 20:10:18 +00:00
Yaxun Liu 2c17e82bc7 [OpenCL][AMDGPU] Add support for -cl-denorms-are-zero
Adjust target features for amdgcn target when -cl-denorms-are-zero is set.

Denormal support is controlled by feature strings fp32-denormals fp64-denormals in amdgcn target. If -cl-denorms-are-zero is not set and the command line does not set fp32/64-denormals feature string, +fp32-denormals +fp64-denormals will be on for GPU's supporting them.

A new virtual function virtual void TargetInfo::adjustTargetOptions(const CodeGenOptions &CGOpts, TargetOptions &TargetOpts) const is introduced to allow adjusting target option by codegen option.

Differential Revision: https://reviews.llvm.org/D22815

llvm-svn: 278151
2016-08-09 19:43:38 +00:00
Benjamin Kramer a203c41dd9 Add a missing -no-canonical-prefixes.
llvm-svn: 278148
2016-08-09 19:20:25 +00:00
Samuel Antao 3be88013c6 [CUDA] Regression test to make sure C++ include path are forwarded to host and device frontends.
Summary: Add test to detect the C++ include paths are passed to both CUDA host and device frontends.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22946

llvm-svn: 278140
2016-08-09 17:27:24 +00:00
Reid Kleckner bab5a5d704 [clang-cl] Make -gline-tables-only imply -gcodeview
It's surprising that you have to pass /Z7 in addition to -gcodeview to
get debug info. The sanitizer runtime, for example, expects that if the
compiler supports the -gline-tables-only flag, then it will emit debug
info.

llvm-svn: 278139
2016-08-09 17:23:56 +00:00
Martin Bohme 8cef2c2f2d [ASTMatchers] Add matchers canReferToDecl() and hasUnderlyingDecl()
Summary: Required for D22220

Reviewers: sbenza, klimek, aaron.ballman, alexfh

Subscribers: alexfh, klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D23004

llvm-svn: 278123
2016-08-09 15:07:52 +00:00
Sylvestre Ledru 83bbd5731b clang-format: Add SpaceAfterTemplate
Summary:
This is required for compliance with the Mozilla style guide.

This is a rebase+minor change of Birunthan Mohanathas's patch


Reviewers: djasper

Subscribers: klimek, cfe-commits, opilarium

Differential Revision: https://reviews.llvm.org/D23317

llvm-svn: 278121
2016-08-09 14:24:40 +00:00
Vassil Vassilev 5721e0f37a [analyzer] Try to fix coverity CID 1360469.
Patch by Raphael Isemann!

llvm-svn: 278110
2016-08-09 10:00:23 +00:00
Charles Davis 0e37911334 Revert "[Attr] Add support for the `ms_hook_prologue` attribute."
This reverts commit r278050. It depends on r278048, which will be
reverted.

llvm-svn: 278052
2016-08-08 21:19:08 +00:00
Derek Schuff ef313059e5 [Driver] Enable CFI for WebAssembly
Since CFI support has landed in the WebAssembly backend, enable it in
the frontend driver.

Patch by Dominic Chen

Differential Revision: https://reviews.llvm.org/D23244

llvm-svn: 278051
2016-08-08 21:14:15 +00:00
Charles Davis 3e43970d71 [Attr] Add support for the `ms_hook_prologue` attribute.
Summary:
Based on a patch by Michael Mueller.

This attribute specifies that a function can be hooked or patched. This
mechanism was originally devised by Microsoft for hotpatching their
binaries (which they're constantly updating to stay ahead of crackers,
script kiddies, and other ne'er-do-wells on the Internet), but it's now
commonly abused by Windows programs that want to hook API functions. It
is for this reason that this attribute was added to GCC--hence the name,
`ms_hook_prologue`.

Depends on D19908.

Reviewers: rnk, aaron.ballman

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D19909

llvm-svn: 278050
2016-08-08 21:03:39 +00:00
Artem Dergachev 6a76a1639f [analyzer] Change -analyze-function to accept qualified names.
Both -analyze-function and -analyzer-display-progress now share the same
convention for naming functions, which allows discriminating between
methods with the same name in different classes, C++ overloads, and also
presents Objective-C instance and class methods in the convenient notation.

This also allows looking up the name for the particular function you're trying
to restrict analysis to in the -analyzer-display-progress output,
in case it was not instantly obvious.

Differential Revision: https://reviews.llvm.org/D22856

llvm-svn: 278018
2016-08-08 16:01:02 +00:00
Oliver Stannard 218c4cbd3d [ARM] Command-line options for embedded position-independent code
This patch (with the corresponding ARM backend patch) adds support for
some new relocation models:

* Read-only position independence (ROPI): Code and read-only data is accessed
  PC-relative. The offsets between all code and RO data sections are known at
  static link time.
* Read-write position independence (RWPI): Read-write data is accessed relative
  to a static base register. The offsets between all writeable data sections
  are known at static link time.

These two modes are independent (they specify how different objects
should be addressed), so they can be used individually or together.

These modes are intended for bare-metal systems or systems with small
real-time operating systems. They are designed to avoid the need for a
dynamic linker, the only initialisation required is setting the static
base register to an appropriate value for RWPI code.

There is one C construct not currently supported by these modes: global
variables initialised to the address of another global variable or
function, where that address is not known at static-link time. There are
a few possible ways to solve this:

* Disallow this, and require the user to write their own initialisation
  function if they need variables like this.
* Emit dynamic initialisers for these variables in the compiler, called from
  the .init_array section (as is currently done for C++ dynamic initialisers).
  We have a patch to do this, described in my original RFC email
  (http://lists.llvm.org/pipermail/llvm-dev/2015-December/093022.html), but the
  feedback from that RFC thread was that this is not something that belongs in
  clang.
* Use a small dynamic loader to fix up these variables, by adding the
  difference between the load and execution address of the relevant section.
  This would require linker co-operation to generate a table of addresses that
  need fixing up.

Differential Revision: https://reviews.llvm.org/D23196

llvm-svn: 278016
2016-08-08 15:28:40 +00:00
Gabor Horvath c430990d0b [analyzer] Command line option to show enabled checker list.
This patch adds a command line option to list the checkers that were enabled
by analyzer-checker and not disabled by -analyzer-disable-checker.

It can be very useful to debug long command lines when it is not immediately
apparent which checkers are turned on and which checkers are turned off.

Differential Revision: https://reviews.llvm.org/D23060

llvm-svn: 278006
2016-08-08 13:41:04 +00:00
Eric Liu 73337f3dfa Fixes calculateRangesAfterReplacements crash when Replacements is empty.
Reviewers: klimek, djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D23264

llvm-svn: 278004
2016-08-08 13:37:39 +00:00
Gabor Horvath 44583ce65a [analyzer] Model base to derived casts more precisely.
Dynamic casts are handled relatively well by the static analyzer.
BaseToDerived casts however are treated conservatively. This can cause some
false positives with the NewDeleteLeaks checker.

This patch alters the behavior of BaseToDerived casts. In case a dynamic cast
would succeed use the same semantics. Otherwise fall back to the conservative
approach.

Differential Revision: https://reviews.llvm.org/D23014

llvm-svn: 277989
2016-08-08 09:22:59 +00:00
Diana Picus 86db9e7b66 Fix two bugs for musl-libc on ARM
Bug 1: triples like armv7-pc-linux-musl use the wrong linker name
ld-musl-armv7.so.1; the right name should be ld-musl-arm.so.1, disregarding the
subarch field.

Bug 2: when compiler option -mhard-float is used, we should use the "hardfloat"
linker, no matter whether the triple itself mentions "hardfloat".

Patch by Lei Zhang!

Differential Revision: https://reviews.llvm.org/D22904

llvm-svn: 277985
2016-08-08 08:27:36 +00:00
Serge Pavlov d931b9f200 Pass information in a record instead of stack. NFC
Functions of Sema that work with building of nested name specifiers have too
many parameters (BuildCXXNestedNameSpecifier already expects 10 arguments).
With this change the information about identifier and its context is packed
into a structure, which is then passes to the semantic functions.

llvm-svn: 277976
2016-08-08 04:02:15 +00:00
Asaf Badouh 2f344b788c [AVX512] integer comparisions enumeration.
fix Bug 28842 https://llvm.org/bugs/show_bug.cgi?id=28842

Differential Revision: https://reviews.llvm.org/D22212

 

llvm-svn: 277955
2016-08-07 10:43:04 +00:00
David Majnemer d61d963490 Update clang tests for LLVM r277950
We infer inbounds on GEPs of allocas leading to minor perturbations in
tests.

llvm-svn: 277953
2016-08-07 08:28:58 +00:00
Sylvestre Ledru ea49d3addc Add the new scan-build option (--show-description) in the 4.0 release notes
llvm-svn: 277935
2016-08-06 20:23:54 +00:00
Saleem Abdulrasool afdef205d8 Headers: Add ARM support to intrin.h for MSVC compatibility
This fixes compiling with headers from the Windows SDK for ARM, where the
YieldProcessor function (in winnt.h) refers to _ARM_BARRIER_ISHST.

The actual MSVC armintr.h contains a lot more definitions, but this is enough to
build code that uses the Windows SDK but doesn't use ARM intrinsics directly.

An alternative would to just keep the addition to intrin.h (to include
armintr.h), but not actually ship armintr.h, instead having clang's intrin.h
include armintr.h from MSVC's include directory. (That one works fine with
clang, at least for building code that uses the Windows SDK.)

Patch by Martin Storsjö!

llvm-svn: 277928
2016-08-06 17:58:24 +00:00
Benjamin Kramer b6aadc1ca5 [ASTReader] Use real move semantics instead of emulating them in the copy ctor.
No functionality change intended.

llvm-svn: 277923
2016-08-06 12:45:16 +00:00
Benjamin Kramer 01d3a35aa3 [Sema] Make switch fully covered again.
llvm-svn: 277920
2016-08-06 11:28:20 +00:00
Benjamin Kramer a0a13c3649 Move helpers into anonymous namespaces. NFC.
llvm-svn: 277918
2016-08-06 11:21:04 +00:00
Benjamin Kramer 5251494969 [StaticAnalyzer] Remove dead code.
llvm-svn: 277917
2016-08-06 11:20:59 +00:00
Erik Pilkington f3d77e45c4 [NFC] Silence noisy -Wreturn-type warnings
llvm-svn: 277906
2016-08-06 01:54:50 +00:00
Richard Trieu e056aee9d9 Fix typos from r277797 and unused variable from r277889.
llvm-svn: 277900
2016-08-06 01:44:06 +00:00
Richard Trieu 81b6c561ea Fix two false positives in -Wreturn-stack-address
If the return type is a pointer and the function returns the reference to a
pointer, don't warn since only the value is returned, not the reference.

If a reference function parameter appears in the reference chain, don't warn
since binding happens at the caller scope, so addresses returned are not
to local stack.  This includes default arguments as well.

llvm-svn: 277889
2016-08-05 23:24:47 +00:00
Erik Pilkington 796a3e2bdd [NFC][ObjC Availability] Refactor DiagnoseAvailabilityOfDecl
Differential revision: https://reviews.llvm.org/D23221

llvm-svn: 277887
2016-08-05 22:59:03 +00:00
Vedant Kumar 957d7a00bc [clang-tblgen] Remove unused #include (NFC)
llvm-svn: 277885
2016-08-05 22:48:53 +00:00
Richard Trieu 71d74d4b25 Fix false positive in -Wunsequenced and templates.
For builtin logical operators, there is a well-defined ordering of argument
evaluation.  For overloaded operator of the same type, there is no argument
evaluation order, similar to other function calls.  When both are present,
uninstantiated templates with an operator&& is treated as an unresolved
function call.  Unresolved function calls are treated as normal function calls,
and may result in false positives when the builtin logical operator is used.
Have the unsequenced checker ignore dependent expressions to avoid this
false positive.  The check also happens in template instantiations to catch
when the overloaded operator is used.

llvm-svn: 277866
2016-08-05 21:02:34 +00:00
David Blaikie 2a58a18d67 PR26423: Assert on valid use of using declaration of a function with an undeduced auto return type
For now just disregard the using declaration in this case. Suboptimal,
but wiring up the ability to have declarations of functions that are
separate from their definition (we currently only do that for member
functions) and have differing return types (we don't have any support
for that) is more work than seems reasonable to at least fix this crash.

llvm-svn: 277852
2016-08-05 19:03:01 +00:00
David Majnemer 9d16822224 [SemaOpenMP] Some miscellaneous cleanups
Clean up some typos, follow the coding style a little more rigorously.

No functionality change is intended.

llvm-svn: 277840
2016-08-05 17:44:54 +00:00
Bruno Cardoso Lopes 9e4374daa3 Revert "[Sema] Add sizeof diagnostics for bzero"
This reverts commit r277787, which caused PR28870.

llvm-svn: 277830
2016-08-05 16:41:00 +00:00
Wei Ding 91c8450967 AMDGPU : Add Clang builtin intrinsics for compare with the full
wavefront result.

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

llvm-svn: 277824
2016-08-05 15:38:46 +00:00
Kelvin Li 0253287633 [OpenMP] Sema and parsing for 'teams distribute' pragma
This patch is to implement sema and parsing for 'teams distribute' pragma.

Differential Revision: https://reviews.llvm.org/D23189

llvm-svn: 277818
2016-08-05 14:37:37 +00:00
John Brawn 4d79ec7fe8 Reapply r276973 "Adjust Registry interface to not require plugins to export a registry"
This differs from the previous version by being more careful about template
instantiation/specialization in order to prevent errors when building with
clang -Werror. Specifically:
 * begin is not defined in the template and is instead instantiated when Head
   is. I think the warning when we don't do that is wrong (PR28815) but for now
   at least do it this way to avoid the warning.
 * Instead of performing template specializations in LLVM_INSTANTIATE_REGISTRY
   instead provide a template definition then do explicit instantiation. No
   compiler I've tried has problems with doing it the other way, but strictly
   speaking it's not permitted by the C++ standard so better safe than sorry.

Original commit message:

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

llvm-svn: 277806
2016-08-05 11:01:08 +00:00
Richard Trieu e1a6a7d6d3 Fix crash in template type diffing.
When the type being diffed is a type alias, and the orginal type is not a
templated type, then there will be no unsugared TemplateSpecializationType.
When this happens, exit early from the constructor.  Also add assertions to
the other iterator accessor to prevent the iterator from being used.

llvm-svn: 277797
2016-08-05 03:16:36 +00:00
Richard Trieu 7561ed01cb Allow -1 to assign max value to unsigned bitfields.
Silence the -Wbitfield-constant-conversion warning for when -1 or other
negative values are assigned to unsigned bitfields, provided that the bitfield
is wider than the minimum number of bits needed to encode the negative value.

llvm-svn: 277796
2016-08-05 02:39:30 +00:00
Bruno Cardoso Lopes edf3d81cbf [Sema] Add sizeof diagnostics for bzero
For memset (and others) we can get diagnostics like:

  struct stat { int x; };
  void foo(struct stat *stamps) {
    bzero(stamps, sizeof(stamps));
    memset(stamps, 0, sizeof(stamps));
  }

  t.c:7:28: warning: 'memset' call operates on objects of type 'struct stat' while the size is based on a different type 'struct stat *' [-Wsizeof-pointer-memaccess]
    memset(stamps, 0, sizeof(stamps));
           ~~~~~~            ^~~~~~
  t.c:7:28: note: did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?
    memset(stamps, 0, sizeof(stamps));
                             ^~~~~~

This patch implements the same class of warnings for bzero.

Differential Revision: https://reviews.llvm.org/D22525

rdar://problem/18963514

llvm-svn: 277787
2016-08-04 23:55:22 +00:00
Tim Shen 68de2e98a6 [ADT] Migrate DepthFirstIterator to use NodeRef
Summary: The corresponding LLVM change is D23146.

Reviewers: dblaikie, chandlerc

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23147

llvm-svn: 277783
2016-08-04 23:03:44 +00:00
Artem Dergachev 7a0088bbae [analyzer] Make CloneDetector recognize different variable patterns.
CloneDetector should be able to detect clones with renamed variables.
However, if variables are referenced multiple times around the code sample,
the usage patterns need to be recognized.

For example, (x < y ? y : x) and (y < x ? y : x) are no longer clones,
however (a < b ? b : a) is still a clone of the former.

Variable patterns are computed and compared during a separate filtering pass.

Patch by Raphael Isemann!

Differential Revision: https://reviews.llvm.org/D22982

llvm-svn: 277757
2016-08-04 19:37:00 +00:00
Yaxun Liu c8acb4f37b [OpenCL] Add the lit test for image size which was omitted by r277647.
llvm-svn: 277756
2016-08-04 19:35:17 +00:00
Yaxun Liu c489e39eca [OpenCL] Remove extra native_ functions from opencl-c.h
There should be no native_ builtin functions with double type arguments.

Patch by Aaron En Ye Shi.

Differential Revision : https://reviews.llvm.org/D23071

llvm-svn: 277754
2016-08-04 19:30:54 +00:00
Alexey Bader d81623261a [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins.
Summary:
In order to re-define OpenCL built-in functions
'to_{private,local,global}' in OpenCL run-time library LLVM names must
be different from the clang built-in function names.

Reviewers: yaxunl, Anastasia

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D23120

llvm-svn: 277743
2016-08-04 18:06:27 +00:00
Benjamin Kramer 87e6d99487 Make isExternC work on VarDecls too.
llvm-svn: 277712
2016-08-04 10:02:03 +00:00
Eric Christopher abb2b54ad3 After PR28761 use -Wall with -Werror in builtins tests to identify
possible problems in headers.

llvm-svn: 277696
2016-08-04 06:02:50 +00:00
Hubert Tong 129e709a03 [Concepts] remove default argument for RequiresClause; NFC
llvm-svn: 277658
2016-08-03 22:07:50 +00:00
Yaxun Liu 99444cb860 [OpenCL] Fix size of image type
The size of image type is reported incorrectly as size of a pointer to address space 0, which causes error when casting image type to pointers by __builtin_astype.

The fix is to get image address space from TargetInfo then report the size accordingly.

Differential Revision: https://reviews.llvm.org/D22927

llvm-svn: 277647
2016-08-03 20:38:06 +00:00
Manuel Klimek 16c6d0ac37 Fix bug in conflict check for Replacements::add().
We would not detect conflicts when inserting insertions at the same
offset as previously contained replacements.

llvm-svn: 277603
2016-08-03 15:12:00 +00:00
Manuel Klimek dcb910b1cf Fix quadratic runtime when adding items to tooling::Replacements.
Previously, we would search through all replacements when inserting a
new one to check for overlaps. Instead, make use of the fact that we
already have a set of replacments without overlaps to find the potential
overlap with lower_bound.

Differential Revision: https://reviews.llvm.org/D23119

llvm-svn: 277597
2016-08-03 14:12:17 +00:00
Etienne Bergeron 74dc9b8388 [clang/test] Fix a flaky unittest on windows
Summary:
The append operator on a shell command for quick command-line is
causing trouble on windows. [NFC]
The easiest way to fix them is to avoid using them.

This patch is an attempt to fix this broken build bot:
  clang-x86-win2008-selfhost

http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/9523

Reviewers: rnk

Subscribers: cfe-commits, chrisha

Differential Revision: https://reviews.llvm.org/D23105

llvm-svn: 277576
2016-08-03 06:10:15 +00:00
Argyrios Kyrtzidis f60c395e84 [index] Fix crash with indexing designated init expressions inside templates.
rdar://27452869

llvm-svn: 277570
2016-08-03 05:38:53 +00:00
Artem Belevich c3ded37ccf [CUDA] Updated CUDA tests that must run w/o CUDA installation.
Fixes test failures after r277542 on systems that don't have
CUDA installed.

llvm-svn: 277552
2016-08-02 23:43:04 +00:00
Devin Coughlin 1bb47ac0c8 [analyzer] Update two comments in MPI-Checker. NFC.
Correct two comments that do not match the current behavior of the checker.

A patch by Alexander Droste!

Differential Revision: https://reviews.llvm.org/D22670

llvm-svn: 277547
2016-08-02 23:24:40 +00:00
Artem Belevich 02a1e973a8 [CUDA] Fix libdevice selection.
This makes clang's libdevice selection match that of NVCC as described in
http://docs.nvidia.com/cuda/libdevice-users-guide/basic-usage.html#version-selection

If required libdevice variant is not found, driver now fails with an error.

Differential Revision: https://reviews.llvm.org/D23037

llvm-svn: 277542
2016-08-02 23:12:51 +00:00
Artem Belevich f981e30b45 [CUDA] Do not allow using NVPTX target for host compilation.
Differential Revision: https://reviews.llvm.org/D23042

llvm-svn: 277537
2016-08-02 22:37:47 +00:00
Devin Coughlin 6eb1ca7416 [CFG] Fix crash finding destructor of lifetime-extended temporary.
Fix a crash under -Wthread-safety when finding the destructor for a
lifetime-extending reference.

A patch by Nandor Licker!

Differential Revision: https://reviews.llvm.org/D22419

llvm-svn: 277522
2016-08-02 21:07:23 +00:00
Chris Bieneman 54e044736f Revert "[Order Files] Remove dtrace predicate"
This reverts commit r277487.

Removing the probe predicate was a red herring. It results in more symbols being placed in the final order file, but they are symbols from outside the clang image.

llvm-svn: 277492
2016-08-02 18:23:56 +00:00
Nirav Dave 0e31955c86 Update Clang Parser test error message to match new parser errors
Update clang tests in light of r277489.

llvm-svn: 277490
2016-08-02 17:58:14 +00:00
Vitaly Buka ca2f9d1cb2 Updated documentation
Reviewers: kcc, eugenis

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D22992

llvm-svn: 277488
2016-08-02 17:51:48 +00:00
Chris Bieneman f7a024b886 [Order Files] Remove dtrace predicate
Having the dtrace predicate setup to only show probes in clang filters out static initializers executed by dyld, which we do want included in the order files.

llvm-svn: 277487
2016-08-02 17:50:53 +00:00
Artem Dergachev 7a7004a999 [analyzer] Hotfix for buildbot failure due to unspecified triple in r277449
If a target triple is not specified, the default host triple is used,
which is not good for compiling inline assembler code.

Patch by Raphael Isemann!

llvm-svn: 277473
2016-08-02 15:16:06 +00:00
Diana Picus 7ef9a07f96 [clang-cl] Fix PCH tests to use x86_64 as target
These tests require x86-registered-target, but they don't force the target as
x86 on the command line, which means they will be run and they might fail when
building the x86 backend on another platform (such as AArch64).

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

Differential Revision: https://reviews.llvm.org/D23054

llvm-svn: 277457
2016-08-02 13:53:00 +00:00
Artem Dergachev 78692ea590 [analyzer] Respect statement-specific data in CloneDetection.
So far the CloneDetector only respected the kind of each statement when
searching for clones. This patch refines the way the CloneDetector collects data
from each statement by providing methods for each statement kind,
that will read the kind-specific attributes.

For example, statements 'a < b' and 'a > b' are no longer considered to be
clones, because they are different in operation code, which is an attribute
specific to the BinaryOperator statement kind.

Patch by Raphael Isemann!

Differential Revision: https://reviews.llvm.org/D22514

llvm-svn: 277449
2016-08-02 12:21:09 +00:00
Hans Wennborg 622adc524f Revert r276896 "Update Clang Parser test error message to match new parser errors"
This depended on r276895, which was reverted in r277402.

llvm-svn: 277405
2016-08-01 23:34:42 +00:00
Chris Bieneman 973781bbb4 [Order Files] Fixing an error in the perf-helper script
Dtrace probemod needs to be based on the first argument of the command, not the first argument of the args. This error was introduced a while back when I added support for skipping the driver and invoking cc1 directly.

llvm-svn: 277401
2016-08-01 22:54:00 +00:00
Paul Robinson 78fb132af0 Add FIXMEs for MSVC 2013 hacks in r277211. NFC.
llvm-svn: 277396
2016-08-01 22:12:46 +00:00
Saleem Abdulrasool 4a7130a8fb CodeGen: simplify the CC handling for TLS wrappers
Use the calling convention of the wrapper directly to set the calling convention
to ensure that the calling convention matches.  Incorrectly setting the calling
convention results in the code path being entirely nullified as InstCombine +
SimplifyCFG will prune the mismatched CC calls.

llvm-svn: 277390
2016-08-01 21:31:24 +00:00
Erik Pilkington 3f3fbf6b6c [ObjC Availability] Fix partial-availability false positive introduced in r277058
Thanks to Nico Weber for pointing this out!

Differential revision: https://reviews.llvm.org/D23024

llvm-svn: 277378
2016-08-01 20:19:49 +00:00
Reid Kleckner 755220bcef [codeview] Skip injected class names in nested record emission
We were already trying to do this, but our check wasn't quite right.

Fixes PR28790

llvm-svn: 277367
2016-08-01 18:56:13 +00:00
Evandro Menezes ec133b3d20 [AArch64] Add support for Samsung Exynos M2 (NFC).
llvm-svn: 277365
2016-08-01 18:39:55 +00:00
David Majnemer 6ac7dd19f7 [Parse] Let declarations follow labels in -fms-extensions mode
MSVC permits declarations in these places as conforming extension (it is
a constraint violation otherwise).

This fixes PR28782.

llvm-svn: 277352
2016-08-01 16:39:29 +00:00
Martin Bohme 78bac52e14 Make RecursiveASTVisitor visit lambda capture initialization expressions
Summary:
Lambda capture initializations are part of the explicit source code and
therefore should be visited by default but, so far, RecursiveASTVisitor does not
visit them.

This appears to be an oversight. Because the lambda body needs custom handling
(calling TraverseLambdaBody()), the DEF_TRAVERSE_STMT for LambdaExpr sets
ShouldVisitChildren to false but then neglects to visit the lambda capture
initializations. This patch adds code to visit the expressions associated with
lambda capture initializations.

Reviewers: klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22566

llvm-svn: 277342
2016-08-01 12:15:46 +00:00
Artem Dergachev 0b9b81412f [analyzer] Fix execution permissions for the scan-build-py scripts.
Differential Revision: https://reviews.llvm.org/D22969

llvm-svn: 277338
2016-08-01 10:55:59 +00:00
Eric Liu 40ef2fb363 Implement tooling::Replacements as a class.
Summary:
- Implement clang::tooling::Replacements as a class to provide interfaces to
  control how replacements for a single file are combined and provide guarantee
  on the order of replacements being applied.
- tooling::Replacements only contains replacements for the same file now.
  Use std::map<std::string, tooling::Replacements> to represent multi-file
  replacements.
- Error handling for the interface change will be improved in followup patches.

Reviewers: djasper, klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D21748

llvm-svn: 277335
2016-08-01 10:16:37 +00:00
Yaron Keren 5c9583981b Allow .exe extension to ld to fix test with mingw.
llvm-svn: 277334
2016-08-01 10:14:54 +00:00
Sylvestre Ledru 522c0ec295 scan-build: Add an option to show the description in the list of defect
Summary:
This patch adds an option //--show-description// to add the defect description to the list of defect. This helps to get a better understanding of the defect without opening the page.

For example, this is used for Firefox:
https://people.mozilla.org/~sledru/reports/fx-scan-build/

Reviewers: rizsotto.mailinglist, zaks.anna

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D22810

llvm-svn: 277328
2016-08-01 08:04:45 +00:00
Dimitry Andric f8099f256d Add more gcc compatibility names to clang's cpuid.h
Summary:
Some cpuid bit defines are named slightly different from how gcc's
cpuid.h calls them.

Define a few more compatibility names to appease software built for gcc:

* `bit_PCLMUL`      alias of `bit_PCLMULQDQ`
* `bit_SSE4_1`      alias of `bit_SSE41`
* `bit_SSE4_2`      alias of `bit_SSE42`
* `bit_AES`         alias of `bit_AESNI`
* `bit_CMPXCHG8B`   alias of `bit_CX8`

While here, add the misssing 29th bit, `bit_F16C` (which is how gcc
calls this bit).

Reviewers: joerg, rsmith

Subscribers: bruno, cfe-commits

Differential Revision: https://reviews.llvm.org/D22010

llvm-svn: 277307
2016-07-31 20:23:23 +00:00
Faisal Vali 5e5501861a [NFC] Rearrange an example-file so the c++14 specific example is on top.
This makes it easier to add C++1z examples to the bottom, just before the #endif.

llvm-svn: 277287
2016-07-31 01:19:17 +00:00
Hubert Tong e4a0c0ec78 Reapply r276069 with workaround for MSVC 2013
llvm-svn: 277286
2016-07-30 22:33:34 +00:00
Aaron Ballman b85f5b6a28 Correcting some sphinx formatting issues so that the attribute documentation builds again.
llvm-svn: 277277
2016-07-30 20:20:03 +00:00
Devin Coughlin 1502511ca8 [analyzer] Update APIs taking user-facing strings.
Add new APIs that require localized strings and remove two APIs that were
incorrectly marked as requiring a user-facing string.

A patch by Kulpreet Chilana!

Differential Revision: https://reviews.llvm.org/D22926

llvm-svn: 277273
2016-07-30 16:16:51 +00:00
Argyrios Kyrtzidis fcfec5fdef [c-index-test] Make sure to check that clang_Cursor_getNumTemplateArguments did not return -1.
llvm-svn: 277261
2016-07-30 02:20:21 +00:00
Hans Wennborg bc1b58d086 Fix VS2013 build of CGOpenMPRuntime.cpp
It seems the compiler was getting confused by the in-class initializers
in local struct MapInfo, so moving those to a default constructor
instead.

llvm-svn: 277256
2016-07-30 00:41:37 +00:00
Chris Bieneman 7256f51b18 [Perf-Helper] Add logging for dtrace commands
Logging the dtrace command into the top of the dtrace log is useful when debugging why the order file generation is flaky.

llvm-svn: 277234
2016-07-29 22:48:17 +00:00
Eric Christopher b638558e12 Remove unused variable.
Fixes PR28761.

llvm-svn: 277221
2016-07-29 22:11:11 +00:00
Paul Robinson 15c840052e Fix CGOpenMPRuntime.cpp for VS2013. NFC.
I don't know why these changes work but they do.

llvm-svn: 277211
2016-07-29 20:46:16 +00:00
David Majnemer a6b68bf0b9 Ensure Ident_GNU_final is properly initialized in the Parser Initialize function
The recent change implementing __final forgot to initialize a variable.
This was caught by the Memory Sanitizer.

Properly initialize the value to nullptr to ensure proper memory reads.

Patch by Erich Keane!

Differential Revision: https://reviews.llvm.org/D22970

llvm-svn: 277206
2016-07-29 20:01:12 +00:00
Reid Kleckner 939119dcb2 Fix naked.cpp test on 32-bit Windows
llvm-svn: 277205
2016-07-29 19:43:28 +00:00
Saleem Abdulrasool 369f4d64a2 CodeGen: try harder to make the CFString structure RW
The previous change was insufficient to mark the content as read-write as the
structure itself was marked constant.  Adjust this and add tests to ensure that
the section is marked appropriately as being read-write.

llvm-svn: 277200
2016-07-29 19:15:51 +00:00
Yunzhong Gao 1e4426e786 Improve documentation of the type safety attributes.
1. Add description of the arguments to these attributes.
2. Add missing declarations to some of the MPI code examples.
3. Made clarifications where possible.

Based on the write-up by: Craig Flores.

Differential Revision: https://reviews.llvm.org/D22717

llvm-svn: 277192
2016-07-29 18:34:21 +00:00
Yaxun Liu 3f9e91286e [OpenCL] Add extension cl_khr_mipmap_image to clang
Adding extension cl_khr_mipmap_image to clang's OpenCL Extensions and initiated inside AMDGPU Target.

Patch by Aaron En Ye Shi.

Differential Revision: https://reviews.llvm.org/D22637

llvm-svn: 277181
2016-07-29 17:52:34 +00:00
Yaxun Liu c944e65a24 [OpenCL] Added CLK_ABGR definition for get_image_channel_order return value
Added CLK_ABGR definition for get_image_channel_order return value inside opencl-c.h file.

Patch by Aaron En Ye Shi.

Differential Revision: https://reviews.llvm.org/D22767

llvm-svn: 277179
2016-07-29 17:50:10 +00:00
Erik Pilkington 48c7cc9bc0 Reapply r277058: "[ObjC] Consider availability of context when emitting availability warnings"
llvm-svn: 277175
2016-07-29 17:37:38 +00:00
Haojian Wu 99e39a7af8 Fix a typo in document.
llvm-svn: 277174
2016-07-29 17:30:13 +00:00
Matt Masten 6731dead22 Initial vectorization support for svml calls (short vector math library).
Differential Revision: https://reviews.llvm.org/D19544

llvm-svn: 277167
2016-07-29 16:44:24 +00:00
Haojian Wu b33b02e9f0 [ASTMatcher] Add templateName matcher.
Reviewers: klimek

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D22963

llvm-svn: 277155
2016-07-29 15:45:11 +00:00
Haojian Wu d898b0982a [ASTMatcher] Add hasTemplateArgument/hasAnyTemplateArgument support in functionDecl.
Reviewers: klimek

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D22957

llvm-svn: 277142
2016-07-29 13:57:27 +00:00
Daniel Jasper fbbd9f96fe Add missing '-no-canonical-prefixes' in test.
llvm-svn: 277141
2016-07-29 13:45:03 +00:00
Benjamin Kramer b37fb4d2ca Make test not fail on hosts where the default omp library is gomp.
This is the case on some linuxes, just force libomp so we get the
desired results.

llvm-svn: 277138
2016-07-29 13:07:09 +00:00
Andrey Bokhanko 276055bb2f [GCC] Support for __final specifier
As reported in bug 28473, GCC supports "final" functionality in pre-C++11 code using the __final keyword. Clang currently supports the "final" keyword in accordance with the C++11 specification, however it ALSO supports it in pre-C++11 mode, with a warning.

This patch adds the "__final" keyword for compatibility with GCC in GCC Keywords mode (so it is enabled with existing flags), and issues a warning on its usage (suggesting switching to the C++11 keyword). This patch also adds a regression test for the functionality described. I believe this patch has minimal impact, as it simply adds a new keyword for existing behavior.

This has been validated with check-clang to avoid regressions. Patch is created in reference to revisions 276665.

Patch by Erich Keane.

Differential Revision: https://reviews.llvm.org/D22919

llvm-svn: 277134
2016-07-29 10:42:48 +00:00
Justin Lebar 41e9dad437 [Typo police] s/proccess/process/, s/auxiliary/auxilliary/.
llvm-svn: 277113
2016-07-29 05:26:58 +00:00
Erik Pilkington 4c922aba3f [Parser] Fix bug where delayed typo in conditional expression was corrected twice
Patch by David Tarditi!

Differential revision: https://reviews.llvm.org/D22930

llvm-svn: 277095
2016-07-29 00:55:40 +00:00
Wolfgang Pieb eb505f9a1c Change a test to be less prone to random failures due to
unintended matches of label numbers to debug metadata
handles in release builds.

llvm-svn: 277094
2016-07-29 00:54:13 +00:00
Vedant Kumar ae00885108 [docs] Coverage: Reference the new -output-dir option
llvm-svn: 277081
2016-07-28 23:22:42 +00:00
Vedant Kumar 3f42b13c20 [docs] Mention some new options in llvm-cov
llvm-svn: 277080
2016-07-28 23:18:48 +00:00
Erik Pilkington 376789fc73 Revert "[ObjC] Consider availability of context when emitting availability warnings"
Reverting r277058, while I fugure out why it broke internal bots.

This reverts commit e514ffa8b657416c6784bbe6da9f5de19365103d.

llvm-svn: 277070
2016-07-28 22:51:11 +00:00
Samuel Antao 102c182bca [CUDA] Unswitch enumerators in the selection of the offloading tool chain.
llvm-svn: 277064
2016-07-28 22:42:42 +00:00
Erik Pilkington 4f2dd2d4f2 [ObjC] Consider availability of context when emitting availability warnings
This means that a function marked with an availability attribute can safely
refer to a declaration that is greater than the deployment target, but less then
or equal to the context availability without -Wpartial-availability firing.

Differential revision: https://reviews.llvm.org/D22697

llvm-svn: 277058
2016-07-28 22:09:53 +00:00
Artem Dergachev d73c57c328 [analyzer] Update the web manual for checker developers.
Fix the explanation of how to run tests after migration
from autotools to cmake.

Significantly expand the "debugging" section
with more interesting stuff.

Update the table of contents accordingly.

Fix paragraphs in the overview section.

Differential Revision: https://reviews.llvm.org/D22874

llvm-svn: 277029
2016-07-28 20:13:14 +00:00
Yaxun Liu 0bc4b2d337 [OpenCL] Generate opaque type for sampler_t and function call for the initializer
Currently Clang use int32 to represent sampler_t, which have been a source of issue for some backends, because in some backends sampler_t cannot be represented by int32. They have to depend on kernel argument metadata and use IPA to find the sampler arguments and global variables and transform them to target specific sampler type.

This patch uses opaque pointer type opencl.sampler_t* for sampler_t. For each use of file-scope sampler variable, it generates a function call of __translate_sampler_initializer. For each initialization of function-scope sampler variable, it generates a function call of __translate_sampler_initializer.

Each builtin library can implement its own __translate_sampler_initializer(). Since the real sampler type tends to be architecture dependent, allowing it to be initialized by a library function simplifies backend design. A typical implementation of __translate_sampler_initializer could be a table lookup of real sampler literal values. Since its argument is always a literal, the returned pointer is known at compile time and easily optimized to finally become some literal values directly put into image read instructions.

This patch is partially based on Alexey Sotkin's work in Khronos Clang (3d4eec6162).

Differential Revision: https://reviews.llvm.org/D21567

llvm-svn: 277024
2016-07-28 19:26:30 +00:00
Devin Coughlin 5ed2b4ba1d [analyzer] Fix misleading indentation in ObjCDeallocChecker. NFC.
llvm-svn: 277009
2016-07-28 17:18:33 +00:00
John Brawn 2853269224 Revert r276973 "Adjust Registry interface to not require plugins to export a registry"
Buildbot failures when building with clang -Werror. Reverting while I try to
figure this out.

llvm-svn: 277008
2016-07-28 17:17:22 +00:00
Zachary Turner e78a34757e [Driver] Fix Windows SDK Detection
This fixes a couple of bugs in Windows SDK Detection.

1. `readFullStringValue` returns a bool, but was being compared
   with ERROR_SUCCESS.
2. `RegQueryValueExW` might return the null terminator in the
   queried value which will result in incorrect values being
   returned from `getSystemRegistryString`.

Patch By: comicfans44@gmail.com
Reviewed By: zturner
Differential Revision: http://reviews.llvm.org/D21946

llvm-svn: 277005
2016-07-28 17:13:32 +00:00
Samuel Antao 655e0edfd7 [CUDA] Remove duplicated test that should have been removed in r276995.
llvm-svn: 276996
2016-07-28 16:18:31 +00:00
Samuel Antao c5188cc3b6 [CUDA] Rename cuda_phases.cu test to cuda-phases.cu to be consistent with the other tests.
llvm-svn: 276995
2016-07-28 16:12:30 +00:00
Samuel Antao 44bcdb3731 [OpenMP] Change name of variable in mappble expression.
This attempts to fix a failure in Windows bots pottentially related with a reserved keyword.

llvm-svn: 276988
2016-07-28 15:31:29 +00:00
Samuel Antao e735a21ece [OpenMP] Fix link command pattern in offloading interoperability test.
It was causing a few bots to fail.

llvm-svn: 276983
2016-07-28 14:56:19 +00:00
Samuel Antao cf3f83e46b [OpenMP] Do not use default argument in lambda from mappable expressions handlers.
Windows bots were complaining about that.

llvm-svn: 276981
2016-07-28 14:47:35 +00:00
Samuel Antao db5f02b1c4 [OpenMP][CUDA] Do not forward OpenMP flags for CUDA device actions.
Summary:
This patch prevents OpenMP flags from being forwarded to CUDA device commands. That was causing the CUDA frontend to attempt to emit OpenMP code which is not supported.

This fixes the bug reported in https://llvm.org/bugs/show_bug.cgi?id=28723.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, tra, ABataev

Subscribers: caomhin, cfe-commits

Differential Revision: https://reviews.llvm.org/D22895

llvm-svn: 276979
2016-07-28 14:29:18 +00:00
Samuel Antao 6890b09634 [OpenMP] Code generation for the is_device_ptr clause
Summary: This patch adds support for the is_device_ptr clause. It expands SEMA to use the mappable expression logic that can only be tested with code generation in place and check conflicts with other data sharing related clauses using the mappable expressions infrastructure.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

Differential Revision: https://reviews.llvm.org/D22788

llvm-svn: 276978
2016-07-28 14:25:09 +00:00
Samuel Antao cc10b85789 [OpenMP] Codegen for use_device_ptr clause.
Summary: This patch adds support for the use_device_ptr clause. It includes changes in SEMA that could not be tested without codegen, namely, the use of the first private logic and mappable expressions support.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

Differential Revision: https://reviews.llvm.org/D22691

llvm-svn: 276977
2016-07-28 14:23:26 +00:00
John Brawn 778c3c6c61 Reapply r276856 "Adjust Registry interface to not require plugins to export a registry"
This version has two fixes compared to the original:
 * In Registry.h the template static members are instantiated before they are
   used, as clang gives an error if you do it the other way around.
 * The use of the Registry template in clang-tidy is updated in the same way as
   has been done everywhere else.

Original commit message:

Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

llvm-svn: 276973
2016-07-28 12:48:17 +00:00
Zijiao Ma 33e9521399 [AArch64] Using AArch64TargetParser in Clang.
This resubmit r270688 which broke some specific buildbots.That's because
there is incorrect indexing problem in the targetparser,and the problem is
fixed in r276957.

Differential Revision: https://reviews.llvm.org/D21277

llvm-svn: 276958
2016-07-28 06:24:48 +00:00
Devin Coughlin e434fc479b [analyzer] Add check::BeginFunction to CheckerDocumentation checks. NFC.
This was an oversight from when I added BeginFunction support in r261293.

llvm-svn: 276950
2016-07-28 00:52:10 +00:00
Nirav Dave 2e46f720fa Replace preserve-as-comments CodeGen test with driver test
llvm-svn: 276947
2016-07-28 00:36:34 +00:00
Vedant Kumar 18286cfb74 Retry: [Driver] Compute effective target triples once per job (NFCI)
Compute an effective triple once per job. Cache the triple in the
prevailing ToolChain for the duration of the job.

Clients which need effective triples now look them up in the ToolChain.
This eliminates wasteful re-computation of effective triples (e.g in
getARMFloatABI()).

While we're at it, delete MachO::ComputeEffectiveClangTriple. It was a
no-op override.

Differential Revision: https://reviews.llvm.org/D22596

llvm-svn: 276937
2016-07-27 23:02:20 +00:00
Vedant Kumar 5fb00e4bd7 Revert "[Driver] Compute effective target triples once per job (NFCI)"
This reverts commit r275895 in order to address some post-commit review
feedback from Eric Christopher (see: the list thread for r275895).

llvm-svn: 276936
2016-07-27 23:01:55 +00:00
Samuel Antao 03a3cec480 [OpenMP] Add support to map member expressions with references to pointers.
Summary: This patch add support to map pointers through references in class members. Although a reference does not have storage that a user can access, it still has to be mapped in order to get the deep copy right and the dereferencing code work properly.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

Differential Revision: https://reviews.llvm.org/D22787

llvm-svn: 276934
2016-07-27 22:52:16 +00:00
Samuel Antao 403ffd409f [OpenMP] Add support for mapping array sections through pointer references.
Summary:
This patch fixes a bug in the map of array sections whose base is a reference to a pointer. The existing mapping support was not prepared to deal with it, causing the compiler to crash.

Mapping a reference to a pointer enjoys the same characteristics of a regular pointer, i.e., it is passed by value. Therefore, the reference has to be materialized in the target region.

Reviewers: hfinkel, carlo.bertolli, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

Differential Revision: https://reviews.llvm.org/D22690

llvm-svn: 276933
2016-07-27 22:49:49 +00:00
Matthias Braun 5092dc010f Basic/Targets.cpp: Reformat aarch64 CPU list.
Having 1 entry per line and an alphabetical order is clearer and reduces
the risk of invalid merges.

llvm-svn: 276931
2016-07-27 22:47:09 +00:00
Matthias Braun 939af9c226 test/Frontend: Add a test for aarch64 target CPU names.
Nothing else checked the target cpu names for aarch64 yet.
Add a test in the spirit of x86-target-cpu.c.

llvm-svn: 276930
2016-07-27 22:47:07 +00:00
Samuel Antao 6ad11704b4 Refactor how include paths are appended to the command arguments.
Summary:
This patch aims at removing redundancy in the way include paths for the regular and offloading toolchains are appended to the arguments list in the clang tool.

This was suggested by @rsmith in response to r275931.

Reviewers: rsmith, tra

Subscribers: rsmith, cfe-commits

Differential Revision: https://reviews.llvm.org/D22518

llvm-svn: 276929
2016-07-27 22:46:31 +00:00
Justin Lebar e56360a2cd [CUDA] Align kernel launch args correctly when the LLVM type's alignment is different from the clang type's alignment.
Summary:
Before this patch, we computed the offsets in memory of args passed to
GPU kernel functions by throwing all of the args into an LLVM struct.

clang emits packed llvm structs basically whenever it feels like it, and
packed structs have alignment 1.  So we cannot rely on the llvm type's
alignment matching the C++ type's alignment.

This patch fixes our codegen so we always respect the clang types'
alignments.

Reviewers: rnk

Subscribers: cfe-commits, tra

Differential Revision: https://reviews.llvm.org/D22879

llvm-svn: 276927
2016-07-27 22:36:21 +00:00
Justin Lebar ed4f172c00 Don't crash when generating code for __attribute__((naked)) member functions.
Summary:
Previously this crashed inside EmitThisParam().  There should be no
prelude for naked functions, so just skip the whole thing.

Reviewers: majnemer

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D22715

llvm-svn: 276925
2016-07-27 22:04:24 +00:00
Nirav Dave 574a886e75 Add target triple in test
llvm-svn: 276915
2016-07-27 20:48:39 +00:00
Matt Masten 5940875a7e test commit
llvm-svn: 276912
2016-07-27 20:23:32 +00:00
Nirav Dave 993a139847 Add flags to toggle preservation of assembly comments
Summary: Add -fpreserve-as-comments and -fno-preserve-as-comments.

Reviewers: echristo, rnk

Subscribers: mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D22883

llvm-svn: 276907
2016-07-27 19:57:40 +00:00
Pirama Arumuga Nainar bb846a32e4 Adjust coercion of aggregates on RenderScript
Summary:
In RenderScript, the size of the argument or return value emitted in the
IR is expected to be the same as the size of corresponding qualified
type.  For ARM and AArch64, the coercion performed by Clang can
change the parameter or return value to a type whose size is different
(usually larger) than the original aggregate type.  Specifically, this
can happen in the following cases:
    - Aggregate parameters of size <= 64 bytes and return values smaller
      than 4 bytes on ARM
    - Aggregate parameters and return values smaller than bytes on
      AArch64

This patch coerces the cases above to an integer array that is the same
size and alignment as the original aggregate.  A new field is added to
TargetInfo to detect a RenderScript target and limit this coercion just
to that case.

Tests added to test/CodeGen/renderscript.c

Reviewers: rsmith

Subscribers: aemerson, srhines, llvm-commits

Differential Revision: https://reviews.llvm.org/D22822

llvm-svn: 276904
2016-07-27 19:01:51 +00:00
Erik Pilkington 3cdc317342 [Sema] Teach getCurrentThisType to reconize lambda in in-class initializer
Fixes PR27994, a crash on valid.

Differential revision: https://reviews.llvm.org/D21145

llvm-svn: 276900
2016-07-27 18:25:10 +00:00
Nirav Dave ebebd6d2ff Update Clang Parser test error message to match new parser errors
llvm-svn: 276896
2016-07-27 17:39:47 +00:00
Hans Wennborg 6e70f4e171 UsersManual.rst: update clang-cl option list
llvm-svn: 276891
2016-07-27 16:56:03 +00:00
Simon Pilgrim e71a1f9013 Fix unnecessary default switch warning
llvm-svn: 276889
2016-07-27 16:41:56 +00:00
Hans Wennborg d63a6620a7 Update cxx_dr_Status after 3.9 branch
llvm-svn: 276887
2016-07-27 16:39:45 +00:00
Vassil Vassilev 644ea61d2d Implement filtering for code completion of identifiers.
Patch by Cristina Cristescu and Axel Naumann!

Agreed on post commit review (D17820).

llvm-svn: 276878
2016-07-27 14:56:59 +00:00
Renato Golin 6b5596aaec [ARM] Pass thumb as architecture to the underlying tools, when targeting windows
This makes sure that the thumb section flag gets set by the assembler.

Patch by Martin Storsjö.

llvm-svn: 276869
2016-07-27 14:12:20 +00:00
John Brawn 3839263204 Revert r276856 "Adjust Registry interface to not require plugins to export a registry"
This is causing a huge pile of buildbot failures.

llvm-svn: 276857
2016-07-27 11:41:18 +00:00
John Brawn 63aff61019 Adjust Registry interface to not require plugins to export a registry
Currently the Registry class contains the vestiges of a previous attempt to
allow plugins to be used on Windows without using BUILD_SHARED_LIBS, where a
plugin would have its own copy of a registry and export it to be imported by
the tool that's loading the plugin. This only works if the plugin is entirely
self-contained with the only interface between the plugin and tool being the
registry, and in particular this conflicts with how IR pass plugins work.

This patch changes things so that instead the add_node function of the registry
is exported by the tool and then imported by the plugin, which solves this
problem and also means that instead of every plugin having to export every
registry they use instead LLVM only has to export the add_node functions. This
allows plugins that use a registry to work on Windows if
LLVM_EXPORT_SYMBOLS_FOR_PLUGINS is used.

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

llvm-svn: 276856
2016-07-27 11:18:38 +00:00
Daniel Jasper 31343832e7 clang-format: Fix incorrect detection of QT-signals access specifier.
Before:
  void f() {
  label:
    signals
    .baz();
  }

After:
  void f() {
  label:
    signals.baz();
  }

llvm-svn: 276854
2016-07-27 10:13:24 +00:00
Oliver Stannard 7921e833d5 [ARM] Pass -mimplcit-it= to integrated assembler
Differential Revision: https://reviews.llvm.org/D22761

llvm-svn: 276851
2016-07-27 08:54:13 +00:00
Jonas Hahnfeld d196fa524f Support setting default value for -rtlib at build time
This patch introduces a new cmake variable: CLANG_DEFAULT_RTLIB, thru
which we can specify a default value for -rtlib (libgcc or
compiler-rt) at build time, just like how we set the default C++
stdlib thru CLANG_DEFAULT_CXX_STDLIB.

With these two options, we can configure clang to build binaries on
Linux that have no runtime dependence on any gcc libs (libstdc++ or
libgcc_s).

Patch by Lei Zhang!

Differential Revision: https://reviews.llvm.org/D22663

llvm-svn: 276848
2016-07-27 08:15:54 +00:00
Vedant Kumar ae7e39a6e4 Fix for compiling with clang <= 3.7 and g++6 headers
Make integers explicitly unsigned, so the tuple constructor will resolve
properly when but with clang 3.6, 3.7 and gcc 6.1.1 libstdc++ headers.

Patch by Frederich Munch!

Differential Revision: https://reviews.llvm.org/D22798

llvm-svn: 276831
2016-07-27 03:43:34 +00:00
Manman Ren 4482b2a420 Modules: follow up to r276769.
In r276769, I forgot to forward the driver option, add that here.

rdar://26675801

llvm-svn: 276797
2016-07-26 19:56:12 +00:00
Artem Dergachev 96034ca10e [analyzer] Hotfix for build failure due to declaration shadowing in r276782.
CloneDetector member variable is shadowing the class with the same name,
which causes build failures on some platforms.

llvm-svn: 276791
2016-07-26 19:05:22 +00:00
Artem Dergachev ba816326f3 [analyzer] Add basic capabilities to detect source code clones.
This patch adds the CloneDetector class which allows searching source code
for clones.

For every statement or group of statements within a compound statement,
CloneDetector computes a hash value, and finds clones by detecting
identical hash values.

This initial patch only provides a simple hashing mechanism
that hashes the kind of each sub-statement.

This patch also adds CloneChecker - a simple static analyzer checker
that uses CloneDetector to report copy-pasted code.

Patch by Raphael Isemann!

Differential Revision: https://reviews.llvm.org/D20795

llvm-svn: 276782
2016-07-26 18:13:12 +00:00
Manman Ren 47a4445687 Modules: add command line option fmodules-disable-diagnostic-validation
With PCH+Module, sometimes compiler gives a hard error:
Module file ‘<some-file path>.pcm' is out of date and needs to be rebuilt

This happens when we have a pch importing a module and the module gets
overwritten by another compiler instance after we build the pch (one example is
that both compiler instances hash to the same pcm file but use different
diagnostic options). When we try to load the pch later on, the compiler notices
that the imported module is out of date (modification date, size do not match)
but it can't handle this out of date pcm (i.e it does not know how to rebuild
the pch).

This commit introduces a new command line option so for PCH + module, we can
turn on this option and if two compiler instances only differ in diagnostic
options, the latter instance will not invalidate the original pcm.

rdar://26675801
Differential Revision: http://reviews.llvm.org/D22773

llvm-svn: 276769
2016-07-26 17:12:17 +00:00
Martin Bohme edb25bdb07 Revert "Make RecursiveASTVisitor visit lambda capture initialization expressions"
This reverts commit r276755.

(Broke clang-tidy check modernize-loop-convert.)

llvm-svn: 276759
2016-07-26 16:01:55 +00:00
David Majnemer 3f5a4354db Update for LLVM changes
InstSimplify has gained the ability to remove needless bitcasts which
perturbed some clang codegen tests.

llvm-svn: 276756
2016-07-26 15:21:18 +00:00
Martin Bohme d9a3521552 Make RecursiveASTVisitor visit lambda capture initialization expressions
Summary:
Lambda capture initializations are part of the explicit source code and therefore should be visited by default but, so far, RecursiveASTVisitor does not visit them.

This appears to be an oversight. Because the lambda body needs custom handling (calling TraverseLambdaBody()), the DEF_TRAVERSE_STMT for LambdaExpr sets ShouldVisitChildren to false but then neglects to visit the lambda capture initializations. This patch adds code to visit the expressions associated with lambda capture initializations.

Reviewers: klimek

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D22566

llvm-svn: 276755
2016-07-26 15:19:10 +00:00
Eric Liu df5bcea088 [Tooling] skip anonymous namespaces when checking if typeLoc references a type decl from a different canonical namespace.
Summary:
[Tooling] skip anonymous namespaces when checking if typeLoc
references a type decl from a different canonical namespace.

Reviewers: bkramer

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D22808

llvm-svn: 276754
2016-07-26 14:53:05 +00:00
David Majnemer 12b9e76b62 Update for LLVM changes
InstSimplify has gained the ability to remove needless bitcasts which
perturbed some clang codegen tests.

llvm-svn: 276728
2016-07-26 05:52:37 +00:00
Kelvin Li 2b51f7284b [OpenMP] diagnose orphaned teams construct
The OpenMP spec mandates that 'a teams construct must be contained within a 
target construct'. Currently, this scenario is not diagnosed. This patch is 
to add check for orphaned teams construct and issue an error message.

Differential Revision: https://reviews.llvm.org/D22785

llvm-svn: 276726
2016-07-26 04:32:50 +00:00
Vedant Kumar efd319a2ad [Coverage] Do not write out coverage mappings with zero entries
After r275121, we stopped mapping regions from system headers. Lambdas
declared in regions belonging to system headers started producing empty
coverage mappings, since the files corresponding to their spelling locs
were being ignored.

The coverage reader doesn't know what to do with these empty mappings.
This commit makes sure that we don't produce them and adds a test. I'll
make the reader stricter in a follow-up commit.

llvm-svn: 276716
2016-07-26 00:24:59 +00:00
Chris Bieneman d052efc332 [CMake] Pass DYLD_LIBRARY_PATH as CMake variable instead of as envar
On OS X 10.11 System Integrity Protection prevents the DYLD environment variables from being set on system binaries. To work around this r276710 accepts DYLD_LIBRARY_PATH as a CMake variable and sets it directly on the archiver commands.

To make this work with bootstrapping we need to set DYLD_LIBRARY_PATH to the current stage's library directory and pass that into the next stage's configuration.

llvm-svn: 276711
2016-07-25 23:48:14 +00:00
Akira Hatanaka 1b07496cea [Sema][ObjC] Compute the nullability of a conditional expression based
on the nullabilities of its operands.

This commit is a follow-up to r276076 and enables
computeConditionalNullability to compute the merged nullability when
the operands are objective-c pointers.

rdar://problem/22074116

llvm-svn: 276696
2016-07-25 21:58:19 +00:00
Chris Bieneman c486541fea [CMake] Cleaning up some CMake warnings
In Bootstrap builds Clang logs some warnings. These are caused because Clang passes CLANG_STAGE and BOOTSTRAP_DEFAULT_PASSTHROUGH into the next stage's configuration.

BOOTSTRAP_DEFAULT_PASSTHROUGH shouldn't be passed, so it is renamed to _BOOTSTRAP_DEFAULT_PASSTHROUGH, to prevent passthrough.

CLANG_STAGE should be passed, so I've changed the code to log it if it is set outside the if(CLANG_ENABLE_BOOTSTRAP) block. This makes the variable always used, so the warning goes away.

llvm-svn: 276674
2016-07-25 18:54:30 +00:00
Joel Jones b89eb65b0e [cc1as] Add MCTargetOptions argument to createAsmBackend
Allow an assembler backend to get ABI options. This is to match the changes
to http://reviews.llvm.org/D16213.

Tested with "make check-clang"

Patch by: Joel Jones

Differential Revision: https://reviews.llvm.org/D16538

llvm-svn: 276655
2016-07-25 17:18:44 +00:00
Sunil Srivastava fe58327146 Support '#pragma once' in headers when using PCH
The '#pragma once' directive was erroneously ignored when encountered
in the header-file specified in generate-PCH-mode. This resulted in
compile-time errors in some cases with legal code, and also a misleading
warning being produced.

Patch by Warren Ristow!

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

llvm-svn: 276653
2016-07-25 17:17:06 +00:00
Douglas Katzman 87da5f47ac [Myriad]: better compatibility with vendor source
- Accept ma{2100,2150,2150} for -mcpu
- Define more preprocessor macros
- Don't append "le/" to little-endian lib dirs

llvm-svn: 276646
2016-07-25 16:36:02 +00:00
Alexander Kornienko c5e509316a MPI-Checker: move MPIFunctionClassifier.h
Summary:
This patch moves the MPIFunctionClassifier header to `clang/include/clang/StaticAnalyzer/Checkers`,
in order to make it accessible in other parts of the architecture.

Reviewers: dcoughlin, zaks.anna

Subscribers: alexfh, cfe-commits

Patch by Alexander Droste!

Differential Revision: https://reviews.llvm.org/D22671

llvm-svn: 276639
2016-07-25 15:27:16 +00:00
Jonas Hahnfeld ebf866213c Update description for CLANG_DEFAULT_CXX_STDLIB and add comment. NFC
We agreed to call it "platform default" instead of "architecture default".
(see D17286)

llvm-svn: 276618
2016-07-25 08:04:26 +00:00
David Majnemer 0ed275c773 Update test to account for r276604
llvm-svn: 276607
2016-07-25 04:47:45 +00:00
David Majnemer d5f7d19dc8 [MSVCToolChain] Guard hardcoded Windows paths with LLVM_ON_WIN32
Paths like C:/foo will never work on UNIX platforms, don't bother
implicitly adding them to the search path.

llvm-svn: 276606
2016-07-25 04:47:44 +00:00
George Burgess IV 21081364f8 [Sema] Replace mem_fn with lambdas. NFC.
I'm told that some optimizers like lambdas a lot more than mem_fn.
Given that the readability difference is basically nil, and we seem to
use lambdas basically everywhere else, it seems sensible to just use
lambdas.

llvm-svn: 276577
2016-07-24 23:12:40 +00:00
David Majnemer 85c25b4d50 [Driver] Switch some getenv calls to llvm::sys::Process::GetEnv
No functional change is intended.

llvm-svn: 276573
2016-07-24 17:44:03 +00:00
Craig Topper 351ed42795 [X86] Block pbroadcastq instructions on 32-bit targets instead of pbroadcastb.
Thanks to Simon Pilgrim for catching the mistake.

llvm-svn: 276564
2016-07-24 14:58:06 +00:00
Artem Dergachev 7929bf22fb [analyzer] Pring LocationContext in ExplodedGraph dumps.
Remove some FIXMEs in the surrounding code,
which have been addressed long time ago
by introducing checker-specific tags.

Differential Revision: https://reviews.llvm.org/D22622

llvm-svn: 276557
2016-07-24 08:15:58 +00:00
Xinliang David Li b65f8ae9e8 [Profile] Use a flag to enable PGO rather than the profraw filename
Patch by Jake VanAdrighem

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

llvm-svn: 276517
2016-07-23 04:28:59 +00:00