Commit Graph

65393 Commits

Author SHA1 Message Date
Saleem Abdulrasool 0c54dc862e CodeGen: mark ObjC cstring literals as constant
These strings are constants, mark them as such.  This doesn't matter too much in
practice on MachO since the constants are placed into a special section and not
referred to directly.

llvm-svn: 281854
2016-09-18 16:12:04 +00:00
Kostya Serebryany 8e781a888a [libFuzzer] use 'if guard' instead of 'if guard >= 0' with trace-pc; change the guard type to intptr_t; use separate array for 8-bit counters
llvm-svn: 281845
2016-09-18 04:52:23 +00:00
Eric Liu e990652542 When replacements have the same offset, make replacements with smaller length order first in the set.
Summary:
No behavioral change intended. The change makes iterating the replacements set more intuitive in Replacements class implementation. Previously, insertion is ordered before an deletion/replacement with the same offset, which is counter-intuitive for implementation, especially for a followup patch to support adding insertions around replacements.

With the current ordering, we only need to make `applyAllReplacements` iterate the replacements set reversely when applying them so that deletion/replacement is still applied before insertion with the same offset.

Reviewers: klimek, djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 281819
2016-09-17 12:26:42 +00:00
Daniel Jasper 58209dd9ad clang-format: [JS] Fix a crash in handledTemplateStrings.
llvm-svn: 281816
2016-09-17 07:20:36 +00:00
Kostya Serebryany 8ad4155745 [sanitizer-coverage] change trace-pc to use 8-byte guards
llvm-svn: 281809
2016-09-17 05:03:05 +00:00
Saleem Abdulrasool 271106cbb9 CodeGen: refactor the ObjC cstring literal creation
This refactors the cstring literal creation as mentioned in the couple of FIXMEs
littered in the various invocations to CreateMetadataVar.  This centralises the
definition of the literals, and will enable changing the literal creation to a
single site.  NFC.

llvm-svn: 281798
2016-09-16 23:41:13 +00:00
Richard Smith d8e3ac3185 Fix a couple of wrong-code bugs in switch-on-constant optimization:
* recurse through intermediate LabelStmts and AttributedStmts when checking
   whether a statement inside a switch declares a variable
 * if the end of a compound statement is reachable from the chosen case label,
   and the compound statement contains a variable declaration, it's not valid
   to just emit the contents of the compound statement -- we must emit the
   statement itself or we lose the scope (and thus end lifetimes at the wrong
   point)

llvm-svn: 281797
2016-09-16 23:30:39 +00:00
Peter Collingbourne 96dd3635bf Add REQUIRES line.
llvm-svn: 281796
2016-09-16 22:56:12 +00:00
Peter Collingbourne 0a3ede0a14 Add target triples to fix test on non-x86.
llvm-svn: 281790
2016-09-16 22:26:45 +00:00
Peter Collingbourne e1b7d2520d CodeGen: Add more checks to nobuiltin.c test, add a negative test.
llvm-svn: 281785
2016-09-16 22:05:53 +00:00
Nirav Dave e5d4a6c708 Introduce inline assembly parsing test is PR30372.
llvm-svn: 281753
2016-09-16 17:42:02 +00:00
Saleem Abdulrasool 39217d4d05 CodeGen: use pointer rather than reference in range loop
Address post-commit comments from Justin Bogner.  Explicitly indicate
that the dereferenced iterator provides a pointer rather than a
reference.  NFC.

llvm-svn: 281730
2016-09-16 14:24:26 +00:00
Neil Hickey ddfb093b72 Improve handling of floating point literals in OpenCL to only use double precision if the target supports fp64
https://reviews.llvm.org/D24235

llvm-svn: 281714
2016-09-16 10:15:06 +00:00
Eric Fiselier f9b141d16d Touch up [[clang::require_constant_initialization]] docs
* Fix an egregious comma usage.
* Remove the `static` keyword in the example since the variables should have
  external linkage.
* Use C++11 attributes in the example.

llvm-svn: 281712
2016-09-16 10:04:38 +00:00
Neil Hickey 50d1ded535 Testing commit rights. Removing trailing white space from test file.
llvm-svn: 281711
2016-09-16 09:38:11 +00:00
Stephen Hines fec73ad09e Fix unused result from sign extending an Offset.
Summary:
Offset was doubled in size, but the assignment was missing. We just need
to reassign to the original variable in this case to fix it.

Reviewers: cfe-commits, echristo

Subscribers: meikeb

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

llvm-svn: 281706
2016-09-16 07:21:24 +00:00
John McCall d23b27e0d8 Alter the iOS/tvOS ARM64 C++ ABI to ignore the upper half of the
virtual table offset in a member function pointer.

We are reserving this space for future ABI use relating to alternative
v-table configurations.  In the meantime, continue to zero-initialize
this space when actually emitting a member pointer literal.

This will successfully interoperate with existing compilers.
Future versions of the compiler may place additional data in
this location, and at that point, code emitted by compilers
prior to this patch will fail if exposed to such a member pointer.
This is therefore a somewhat hard ABI break.  However, because
it is limited to an uncommon case of an uncommon language feature,
and especially because interoperation with the standard library
does not depend on member pointers, we believe that with a
sufficiently advance compiler change the impact of this break
will be minimal in practice.

llvm-svn: 281693
2016-09-16 02:40:45 +00:00
Stephen Hines 648c369ef2 Do not warn about format strings that are indexed string literals.
Summary:
The warning for a format string not being a string literal and therefore
being potentially insecure is overly strict for indices into string
literals. This fix checks if the index into the string literal is
precomputable. If that's the case it will check if the suffix of that
string literal is a valid format string string literal. It will still
issue the aforementioned warning for out of range indices into the
string literal.

Patch by Meike Baumgärtner (meikeb)

Reviewers: rsmith

Subscribers: srhines, cfe-commits

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

llvm-svn: 281686
2016-09-16 01:07:04 +00:00
Akira Hatanaka d542ccfc97 [CodeGen][ObjC] Block captures should inherit the type of the captured
field in the enclosing lambda or block.

This patch fixes a bug in code-gen where it uses the type of the
declared variable rather than the type of the capture of the enclosing
lambda or block for the block capture. For example, in the following
function, code-gen currently uses i32* for the block capture "a" because
"a" is passed to foo1 as a reference, but it should use i32 since the
enclosing lambda captures "a" by value.

void foo1(int &a) {
  auto lambda = [a]{
    auto block1 = ^{
      i = a;
    };
    block1();
  };
  lambda();
}

rdar://problem/18586386

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

llvm-svn: 281682
2016-09-16 00:02:06 +00:00
Justin Lebar 6efbc73c25 [CUDA] Don't try to run sanitizers on NVPTX.
Summary:
Sanitizers aren't supported on NVPTX -- don't try to run them.

This lets you e.g. pass -fsanitize=address and get asan on your host
code.

Reviewers: kcc

Subscribers: cfe-commits, tra, jhen

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

llvm-svn: 281680
2016-09-15 23:44:13 +00:00
Akira Hatanaka 819867191f [Sema] Allow shifting a scalar operand by a vector operand.
r278501 inadvertently introduced a bug in which it disallowed shifting
scalar operands by vector operands when not compiling for OpenCL. This
commit fixes it.

Patch by Vladimir Yakovlev.

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

llvm-svn: 281669
2016-09-15 22:19:25 +00:00
David L. Jones 2f7545228d Simplify Clang's version number configuration in CMake.
Currently, the Clang version is computed as follows:

 1. LLVM defines major, minor, and patch versions, all statically set. Today,
    these are 4, 0, and 0, respectively.
 2. The static version numbers are combined into PACKAGE_VERSION along with a
    suffix, so the result today looks like "4.0.0svn".
 3. Clang extracts CLANG_VERSION from PACKAGE_VERSION using a regexp. The regexp
    allows the patch level to omitted, and drops any non-digit trailing values.
    Today, this result looks like "4.0.0".
 4. CLANG_VERSION is then split further into CLANG_VERSION_MAJOR and
    CLANG_VERSION_MINOR. Today, these resolve to 4 and 0, respectively.
 5. If CLANG_VERSION matches a regexp with three version components, then
    CLANG_VERSION_PATCHLEVEL is extracted and the CLANG_HAS_VERSION_PATCHLEVEL
    variable is set to 1. Today, these values are 0 and 1, respectively.
 6. The CLANG_VERSION_* variables (and CLANG_HAS_VERSION_PATCHLEVEL) are
    configured into [llvm/tools/clang/]include/clang/Basic/Version.inc
    verbatim by CMake.
 7. In [llvm/tools/clang/]include/clang/Basic/Version.h, macros are defined
    conditionally, based on CLANG_HAS_VERSION_PATCHLEVEL, to compute
    CLANG_VERSION_STRING as either a two- or three-level version number. Today,
    this value is "4.0.0", because despite the patchlevel being 0, it was
    matched by regexp and is thus "HAS"ed by the preprocessor. This string is
    then used wherever Clang's "version" is needed [*].

[*] Including, notably, by compiler-rt, for computing its installation path.

This change collapses steps 2-5 by defaulting Clang to use LLVM's (non-string)
version components for the Clang version (see [*] for why not PACKAGE_VERSION),
and collapses steps 6 and 7 by simply writing CLANG_VERSION_STRING into
Version.inc. The Clang version today always uses the patchlevel form, so the
collapsed Version.inc does not have logic for a version without a patch level.

Historically speaking, this technique began with the VER file in r82085 (which
survives in the form of the regexp in #3). The major, minor, and patchlevel
versions were introduced by r106863 (which remains in #4-6). The VER file itself
was deleted in favor of the LLVM version number in r106914. On the LLVM side,
the individual LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR, and PACKAGE_VERSION
weren't introduced for nearly two more years, until r150405.

llvm-svn: 281666
2016-09-15 22:12:26 +00:00
Kostya Serebryany 66a9c175bf [sanitizer-coverage] make trace-pc-guard and indirect-call work together
llvm-svn: 281665
2016-09-15 22:11:08 +00:00
Hans Wennborg 252f9bf7d3 clang-format VS plugin: upgrade the project files to VS2015
The plugin itself runs on previous VS versions, but this enables
it to be built with VS2015.

llvm-svn: 281648
2016-09-15 19:44:49 +00:00
Aaron Ballman a4f597f002 Reapply: Silence false positive diagnostics regarding passing an object of enumeration type to va_start().
The underlying type for an enumeration in C is either char, signed int, or unsigned int. In the case the underlying type is chosen to be char (such as when passing -fshort-enums or using __attribute__((packed)) on the enum declaration), the enumeration can result in undefined behavior. However, when the underlying type is signed int or unsigned int (or long long as an extension), there is no undefined behavior because the types are compatible. This patch silences diagnostics for the latter while retaining the diagnostics for the former.

This patch addresses PR29140.

llvm-svn: 281632
2016-09-15 18:07:51 +00:00
Artem Dergachev 6cc33b2239 [analyzer] Fix HTMLRewriter style sheets to support non-webkit browsers.
This fixes rounded corners and shadows of analyzer diagnostic pieces
in browsers such as Firefox.

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

llvm-svn: 281625
2016-09-15 16:25:42 +00:00
Aaron Ballman bc2bbb2e29 Reverting r281609; it caused some build bots to break.
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/20061/steps/test/logs/stdio

llvm-svn: 281612
2016-09-15 14:12:33 +00:00
Simon Dardis 9edf96ec9b [mips][ias] Enable IAS by default for N64 on Debian mips64el.
Unfortunately we can't enable it for all N64 because it is not yet possible to
distinguish N32 from N64 from the triple on other environments.

N64 has been confirmed to produce identical (within reason) objects to GAS
during stage 2 of compiler recursion on N64-abi Fedora. Unfortunately,
Fedora's triples do not distinguish N32 from N64 so I can't enable it by
default there. I'm currently repeating this testing for Debian mips64el but
it's very unlikely to produce a different result.

Patch by: Daniel Sanders

Reviewers: sdardis

Differential Review: https://reviews.llvm.org/D22679

llvm-svn: 281610
2016-09-15 14:01:55 +00:00
Aaron Ballman fc3f8f5e86 Silence false positive diagnostics regarding passing an object of enumeration type to va_start(). The underlying type for an enumeration in C is either char, signed int, or unsigned int. In the case the underlying type is chosen to be char (such as when passing -fshort-enums or using __attribute__((packed)) on the enum declaration), the enumeration can result in undefined behavior. However, when the underlying type is signed int or unsigned int (or long long as an extension), there is no undefined behavior because the types are compatible. This patch silences diagnostics for the latter while retaining the diagnostics for the former.
This patch addresses PR29140.

llvm-svn: 281609
2016-09-15 14:01:10 +00:00
Oliver Stannard 97a3c35443 [ARM] ARM-specific attributes should be accepted for big-endian
The ARM-specific C attributes (currently just interrupt) need to check
for both the big- and little-endian versions of the triples, so that
they are accepted for both big and little endian targets.

TargetWindows and TargetMicrosoftCXXABI also only use the little-endian
triples, but this is correct as windows is not supported on big-endian
ARM targets (and this is asserted in lib/Basic/Targets.cpp).

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

llvm-svn: 281596
2016-09-15 08:55:41 +00:00
Wei Mi 6582669aa9 Update clang unittests for rL281586.
The change in rL281586 is in llvm component and tests updated here are
in clang component, so I have to commit them consecutively.

llvm-svn: 281587
2016-09-15 06:31:30 +00:00
NAKAMURA Takumi d92f9cc079 Builtins.def: Explicitly undef finitef, to appease mingw. It defines finitef as alias of _finitef.
llvm-svn: 281582
2016-09-15 05:11:43 +00:00
Artem Belevich 05a4034bc3 Revert r281457 "Supports adding insertion around non-insertion replacements."
Commit was breaking our internal tests.

llvm-svn: 281557
2016-09-14 23:03:06 +00:00
Reid Kleckner a98496e6b0 [clang-cl] Accept the joined equals version of -resource-dir=
lib/Tooling injects this argument without regard for what driver syntax
is in use.

llvm-svn: 281550
2016-09-14 22:31:24 +00:00
Justin Lebar e3612a039f [CUDA] Make __clang_cuda_cmath.h compatible with libc++.
Summary:
We need to add a bunch more "using"s, which weren't necessary with
libstdc++.

Once this is in I can check in a test to the test-suite.

Reviewers: tra

Subscribers: cfe-commits

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

llvm-svn: 281544
2016-09-14 21:50:14 +00:00
Justin Lebar 5fd18d17e5 [CUDA] Add test checking our ability to take a function pointer to a __global__ function on the host side.
Summary: This functionality is used by Thrust.

Reviewers: tra

Subscribers: cfe-commits

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

llvm-svn: 281543
2016-09-14 21:50:11 +00:00
Albert Gutowski 727ab8a803 Add some MS aliases for existing intrinsics
Reviewers: thakis, compnerd, majnemer, rsmith, rnk

Subscribers: alexshap, cfe-commits

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

llvm-svn: 281540
2016-09-14 21:19:43 +00:00
Stephen Hines 6a17e5158e Revert "Do not warn about format strings that are indexed string literals."
Summary: This reverts r281527 because I messed up the attribution.

Reviewers: srhines

Subscribers: cfe-commits

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

llvm-svn: 281530
2016-09-14 20:20:14 +00:00
Stephen Hines 0535fecc40 Do not warn about format strings that are indexed string literals.
Summary:
The warning for a format string not being a sting literal and therefore
being potentially insecure is overly strict for indecies into sting
literals. This fix checks if the index into the string literal is
precomputable. If thats the case it will check if the suffix of that
sting literal is a valid format string string literal. It will still
issue the aforementioned warning for out of range indecies into the
string literal.

Reviewers: rsmith

Subscribers: srhines, cfe-commits

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

llvm-svn: 281527
2016-09-14 20:05:20 +00:00
Kirill Bobyrev 93f75c785d Correct assert text in DeclGroup::getSingleDecl()
Assert text for getSingleDecl() is inaccurate. Appears to have been copy pasted
from getDeclGroup().

Patch by Ben Taylor!

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 281525
2016-09-14 19:59:26 +00:00
Devin Coughlin aed7b8ae86 [analyzer] scan-build-py: Remove relative path hack for SATestsBuild.py
Remove the relative path hack in scan-build-py that converts a fully qualified
directory name and a fully qualified file path to a relative path before running
the analyzer on a file.

This hack is not needed: the bad interaction with SATestsBuild.py it was
intended to address is actually the same underlying problem that r280768 fixed.
Further, because the hack would always relativize paths, it caused
SATestBuild.py to be unable to properly line up issues when the build system
changed directory and then built a source file in a child directory but used a
fully-qualified path for the source file.

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

llvm-svn: 281516
2016-09-14 18:14:11 +00:00
Dehao Chen 5d4f0be5b8 Convert finite to builtin
Summary: This patch converts finite/__finite to builtin functions so that it will be inlined by compiler.

Reviewers: hfinkel, davidxl, efriedma

Subscribers: efriedma, llvm-commits

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

llvm-svn: 281509
2016-09-14 17:34:14 +00:00
Saleem Abdulrasool 7246dcc880 CodeGen: simplify the logic a slight bit
Move the definition of `getTriple()` into the header.  It would just call
`getTarget().getTriple()`.  Inline the definition to allow the compiler to see
the same amount of the layout as previously.  Remove the more verbose
`getTarget().getTriple()` in favour of `getTriple()`.

llvm-svn: 281487
2016-09-14 15:17:46 +00:00
Stephan Bergmann ac772c3c2f Fix documentation of MemberExpr::getMemberDecl
Differential Revision: https://reviews.llvm.org/D23907

llvm-svn: 281469
2016-09-14 14:03:50 +00:00
Eric Liu ac73ea34a4 Supports adding insertion around non-insertion replacements.
Summary:
Extend `tooling::Replacements::add()` to support adding order-independent replacements.

Two replacements are considered order-independent if one of the following conditions is true:
  - They do not overlap. (This is already supported.)
  - One replacement is insertion, and the other is a replacement with
    length > 0, and the insertion is adjecent to but not contained in the
    other replacement. In this case, the replacement should always change
    the original code instead of the inserted text.

Reviewers: klimek, djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 281457
2016-09-14 13:04:51 +00:00
Eric Liu 762b4887c2 Revert "[modules] When merging one definition into another, propagate the list of re-exporting modules from the discarded definition to the retained definition."
This reverts commit r281429.

llvm-svn: 281452
2016-09-14 10:05:10 +00:00
Jonas Hahnfeld 79e00930e2 Document option '-rtlib' in clang's man page and help info
This patch adds an entry for "-rtlib" in the output of `man clang` and `clang -help`.

Patch by Lei Zhang!

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

llvm-svn: 281440
2016-09-14 05:52:21 +00:00
Richard Smith 14568ff2ad [docs] Fix formatting of   characters so that tables line up properly. Add
padding around table cells so the borders of adjacent tables don't run into
each other (now that they're perfectly aligned).

llvm-svn: 281436
2016-09-14 02:24:50 +00:00
Richard Smith 8cba29181b [docs] Order diagnostic cross-references alphabetically rather than based on
order in the .td file.

llvm-svn: 281434
2016-09-14 01:55:42 +00:00
Richard Smith ce9d586fdb Update DiagnosticsReference and fix emitter to emit -Wpedantic diagnostics and groups in a deterministic order.
llvm-svn: 281433
2016-09-14 01:51:10 +00:00