Commit Graph

65625 Commits

Author SHA1 Message Date
Chris Bieneman 2c4d54f326 [CMake] Pass CLANG_VERSION_* variables into later stages
When supporting overriding clang versions we also need to pass those through to the next stage so they remain overridden.

llvm-svn: 282109
2016-09-21 20:43:43 +00:00
Albert Gutowski 8bfb2ef98f Add -Wignored-pragma-intrinsic flag
Summary: People might want to receive warnings about pragmas but not about intrinsics that are implemented in intrin.h.

Reviewers: thakis, hans

Subscribers: cfe-commits

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

llvm-svn: 282108
2016-09-21 20:19:21 +00:00
Teresa Johnson 8de63464b8 [docs] Add ThinLTO user documentation
Summary: Add some user facing documentation on ThinLTO and how to use it.

Reviewers: mehdi_amini

Subscribers: mehdi_amini, cfe-commits

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

llvm-svn: 282089
2016-09-21 16:57:03 +00:00
Cameron McInally 923ad2cd01 [AVX512] Fix return types on __builtin_ia32_gather3XivXdi builtins
The return types on the AVX512 __builtin_ia32_gather3XivXdi builtins are incorrect. The return type should match the type of the pass through vector.

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

-This line, and those below, will be ignored--

M    include/clang/Basic/BuiltinsX86.def

llvm-svn: 282082
2016-09-21 16:07:40 +00:00
Dmitry Polukhin fda467b252 PR30401: Fix substitutions for functions with abi_tag
llvm-svn: 282059
2016-09-21 08:27:03 +00:00
Martin Probst 6f99d2433b clang-format: [JS] do not wrapp @returns tags.
Summary: @returns is incorrect code, the standard is @return. However wrapping it can still confuse users.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 282056
2016-09-21 06:56:38 +00:00
Anna Zaks c154f7bc37 [analyzer] Add a checker that detects blocks in critical sections
This checker should find the calls to blocking functions (for example: sleep, getc, fgets,read,recv etc.) inside a critical section. When sleep(x) is called while a mutex is held, other threads cannot lock the same mutex. This might take some time, leading to bad performance or even deadlock.

Example:

mutex_t m;

void f() {
  sleep(1000); // Error: sleep() while m is locked! [f() is called from foobar() while m is locked]
  // do some work
}

void foobar() {
  lock(m);
  f();
  unlock(m);
}

A patch by zdtorok (Zoltán Dániel Török)!

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

llvm-svn: 282011
2016-09-20 20:28:50 +00:00
Eric Christopher 07a791643b Remove some boilerplate comments that don't explain anything.
llvm-svn: 282007
2016-09-20 19:45:06 +00:00
Zachary Turner c4815d4f42 Fix a regex error breaking tests.
llvm-svn: 282004
2016-09-20 19:10:56 +00:00
Chris Bieneman ebfc680685 [CMake] Support overriding CLANG_VERSION_*
As with how we handle LLVM_VERSION_* variables we should support
overriding clang version variables.

llvm-svn: 282003
2016-09-20 19:09:21 +00:00
Zachary Turner e848a7363f Add some entropy to the folder name in Driver/warning-options.cpp.
It was trying to check that things behave correctly when a
non-existant folder was specified for -isysroot.  Incidentally,
I have a folder named FOO in the root of my drive, so this test
was failing.  Make this impossible by using %T to refer to a
definitely non-existant folder.:

llvm-svn: 281998
2016-09-20 18:41:19 +00:00
Saleem Abdulrasool 82f6added3 CodeGen: further merge cstring literal construction
Use the new CreateCStringLiteral in an additional site.  Now all the C string
literals are created in one function.  Furthermore, mark the additional literal
as an `unnamed_addr constant`.

llvm-svn: 281997
2016-09-20 18:38:54 +00:00
Nick Lewycky d8d498657a Fix typo in documentation.
Since this is a header it will break links to this section.

llvm-svn: 281996
2016-09-20 18:37:25 +00:00
Alexander Shaposhnikov c937026e7e [cleanup] Remove excessive padding from TextTokenRetokenizer::Position
Reorder the fields of the struct TextTokenRetokenizer::Position to remove excessive padding.
Test plan: make -j8 check-clang

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

llvm-svn: 281995
2016-09-20 18:32:48 +00:00
Vedant Kumar 6fe6eae7f7 [docs] Extend the code coverage docs some more
Flesh out the section on interpreting coverage reports, mention the
coverage export feature, and add notes on how to build llvm with
coverage turned on.

llvm-svn: 281988
2016-09-20 17:11:18 +00:00
Nick Lewycky d9bce5062e Replace 'isProvablyNonNull' with existing utility llvm::IsKnownNonNull which handles more cases. Noticed by inspection.
Because of how the IR generation works, this isn't expected to cause an observable difference.

llvm-svn: 281979
2016-09-20 15:49:58 +00:00
Simon Dardis 3d9c763816 [mips] MSA intrinsics header file
This patch adds the msa.h header file containing the shorter names for the
MSA instrinsics, e.g. msa_sll_b for builtin_msa_sll_b.

Reviewers: vkalintiris, zoran.jovanovic

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

llvm-svn: 281975
2016-09-20 15:07:36 +00:00
Gabor Horvath 7304027c6d [analyzer] Calculate extent size for memory regions allocated by new expression.
ArrayBoundChecker did not detect out of bounds memory access errors in case an
array was allocated by the new expression. This patch resolves this issue.

Patch by Daniel Krupp!

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

llvm-svn: 281934
2016-09-19 20:39:52 +00:00
Samuel Antao 1197a1612d Reorder initializers in CallStackFrame so that we don't get a warning.
llvm-svn: 281923
2016-09-19 18:13:13 +00:00
Yaxun Liu 042acb2cf7 [OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled
llvm-svn: 281915
2016-09-19 17:11:22 +00:00
Dehao Chen dd6f8cab08 Remove InstructionCombining and its related pass from sample pgo passes as we can handle "invoke" correctly.
Summary: We previously relies on InstructionCombining pass to remove invoke instructions. Now that we can inline invoke instructions correctly, we do not need these passes any more.

Reviewers: dnovillo

Subscribers: llvm-commits

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

llvm-svn: 281910
2016-09-19 16:02:52 +00:00
Alexander Shaposhnikov fbcf29bc5a Remove excessive padding from the struct CallStackFrame
The struct CallStackFrame is in lib/AST/ExprConstant.cpp
inside anonymous namespace.
This diff reorders the fields and removes excessive padding.
Test plan: make -j8 check-clang

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

llvm-svn: 281907
2016-09-19 15:57:29 +00:00
Yaxun Liu 6aaa01b58e [OpenCL] Diagnose assignment to dereference of half type pointer
Differential Revision: https://reviews.llvm.org/D24626

llvm-svn: 281904
2016-09-19 14:54:41 +00:00
Neil Hickey eb62b17d8f Reverting r281714 due to causing an assert when calling builtins that expect a double, from CL
llvm-svn: 281899
2016-09-19 11:42:14 +00:00
Eric Liu 9df9b6fd6d Recommit r281457 "Supports adding insertion around non-insertion replacements".
Summary:
Diff to r281457:
- added a test case `CalculateRangesOfInsertionAroundReplacement`.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 281891
2016-09-19 08:40:42 +00:00
Martin Probst 63014581aa clang-format: [JS] Fix line breaks before comments when sorting imports.
Summary:
Previously, clang-format would always insert an additional line break after the
import block if the main body started with a comment, due to loosing track of
the first non-import line.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 281888
2016-09-19 07:02:34 +00:00
Vedant Kumar 9ed5802680 [docs] Touch up the code coverage doc
llvm-svn: 281881
2016-09-19 01:42:38 +00:00
Devin Coughlin 0dfc6f0809 [analyzer] SATestBuild.py: Treat '#' as comment in projectMap.csv
Treat lines in projectMap.csv that start with '#' as comments. This enables a
workflow where projects can be temporarily disabled with a comment describing
when they should be turned back on.

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

llvm-svn: 281880
2016-09-19 01:36:40 +00:00
Dean Michael Berris eeee3b17f3 [XRay] ARM 32-bit no-Thumb support in Clang
Just a test for now, adapted from x86_64 tests of XRay.
This is one of 3 commits to different repositories of XRay ARM port. The other 2 are:

https://reviews.llvm.org/D23931 (LLVM)
https://reviews.llvm.org/D23933 (compiler-rt)

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

llvm-svn: 281879
2016-09-19 00:59:19 +00:00
Martin Probst fbbe75b1fe clang-format: [JS] Do not wrap taze annotation comments.
Summary:
`// taze: ... from ...` comments are used help tools where a
specific global symbol comes from.

Before:
    // taze: many, different, symbols from
    // 'some_long_location_here'

After:
    // taze: many, different, symbols from 'some_long_location_here'

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 281857
2016-09-18 17:33:51 +00:00
Martin Probst b9316ff849 clang-format: [JS] ASI insertion after boolean literals.
Summary:
Before when a semicolon was missing after a boolean literal:
    a = true
    return 1;

clang-format would parse this as one line and format as:
    a = true return 1;

It turns out that C++ does not consider `true` and `false` to be literals, we
have to check for that explicitly.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 281856
2016-09-18 17:21:52 +00:00
Saleem Abdulrasool 3f307518f8 CodeGen: mark ObjC cstring literals as unnamed_addr
These are all emitted into a section with a cstring_literal attribute.  The
attribute permits the linker to coalesce the string contents.  The address of
the strings are not important.

llvm-svn: 281855
2016-09-18 16:12:14 +00:00
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
Kostya Serebryany 60cdd6113f [sanitizer-coverage] add yet another flavour of coverage instrumentation: trace-pc-guard. The intent is to eventually replace all of {bool coverage, 8bit-counters, trace-pc} with just this one. Clang part
llvm-svn: 281432
2016-09-14 01:39:49 +00:00
Nico Weber d58c26090d Follow-up to r281367: Compare uuids case-insensitively.
llvm-svn: 281430
2016-09-14 01:16:54 +00:00
Richard Smith 1c16d1b576 [modules] When merging one definition into another, propagate the list of
re-exporting modules from the discarded definition to the retained definition.

llvm-svn: 281429
2016-09-14 01:05:35 +00:00
Richard Smith 9d5f86b694 Color warnings purple rather than orange, to match actual Clang output.
llvm-svn: 281427
2016-09-14 00:35:56 +00:00
Richard Smith 1291166c11 Missed update from r281412.
llvm-svn: 281415
2016-09-13 23:03:41 +00:00
Hans Wennborg 1b3aee7ff9 Also don't inline dllimport functions referring to non-dllimport constructors.
The AST walker wasn't visiting CXXConstructExprs before.

This is a follow-up to r281395.

llvm-svn: 281413
2016-09-13 22:51:42 +00:00
Richard Smith 45d56c2211 Warning flag updates:
-Wdiv-by-zero may as well be an alias for -Wdivision-by-zero rather than a GCC-compatibility no-op.
-Wno-shadow should disable -Wshadow-ivar.
-Weffc++ may as well enable -Wnon-virtual-dtor like it does in GCC.

llvm-svn: 281412
2016-09-13 22:51:09 +00:00
Reid Kleckner 003bb09e78 Fix a FIXME about MSVC 2013 in the diagnostic doc generation code
Ultimately it boiled down to adding a move constructor.

llvm-svn: 281408
2016-09-13 22:22:56 +00:00
Artem Belevich bed18e9cc4 [CUDA] Do not merge CUDA target attributes.
CUDA target attributes are used for function overloading and must not be merged.

This fixes a bug where attributes were inherited during function template
specialization in CUDA and made it impossible for specialized function
to provide its own target attributes.

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

llvm-svn: 281406
2016-09-13 22:16:30 +00:00
Akira Hatanaka 255abad9b1 [CodeGen] Fix an assert in EmitNullConstant.
r235815 changed CGRecordLowering::accumulateBases to ignore non-virtual
bases of size 0, which prevented adding those non-virtual bases to
CGRecordLayout's NonVirtualBases. This caused clang to assert when
CGRecordLayout::getNonVirtualBaseLLVMFieldNo was called in
EmitNullConstant. This commit fixes the bug by ignoring zero-sized
non-virtual bases in EmitNullConstant.

rdar://problem/28100139

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

llvm-svn: 281405
2016-09-13 22:13:02 +00:00
Manman Ren d33b4a6292 ObjectiveC Generics: follow-up commit to r281355.
Correct getExtraLocalDataSize for ObjCTypeParamTypeLoc.

rdar://24619481
rdar://25060179

llvm-svn: 281404
2016-09-13 21:57:28 +00:00
Albert Gutowski fc19fa3721 Temporary fix for MS _Interlocked intrinsics
llvm-svn: 281401
2016-09-13 21:51:37 +00:00
Albert Gutowski 9918cb6573 Reverse commit 281375 (breaks building Chromium)
llvm-svn: 281399
2016-09-13 21:24:51 +00:00
Hans Wennborg 93f7547260 Try harder to not inline dllimport functions referencing non-dllimport functions
In r246338, code was added to check for this, but it failed to take into
account implicit destructor invocations because those are not reflected
in the AST. This adds a separate check for them.

llvm-svn: 281395
2016-09-13 21:08:20 +00:00
Alexander Shaposhnikov 024bb4b136 Remove excessive padding from PTHWriter
The class PTHWriter is in lib/Frontend/CacheTokens.cpp 
inside the anonymous namespace.
This diff changes the order of fields an removes excessive padding.
Test plan: make -j8 check-clang

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

llvm-svn: 281385
2016-09-13 20:17:57 +00:00
Bruno Cardoso Lopes 218c8743c8 [SemaObjC] Be more strict while parsing type arguments and protocols
Fix a crash-on-invalid.

When parsing type arguments and protocols,
parseObjCTypeArgsOrProtocolQualifiers() calls ParseTypeName(), which tries to
find matching tokens for '[', '(', etc whenever they appear among potential
type names. If unmatched, ParseTypeName() yields a tok::eof token stream. This
leads to crashes since the parsing at this point is not expected to go beyond
the param list closing '>'.

Fix that by properly handling tok::eof in
parseObjCTypeArgsOrProtocolQualifiers() callers.

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

rdar://problem/25063557

llvm-svn: 281383
2016-09-13 20:04:35 +00:00
Richard Smith 85edca95c6 Work around MSVC 2013's inability to default move special members.
llvm-svn: 281382
2016-09-13 20:00:02 +00:00
Albert Gutowski ce7a9a47b2 Add bunch of _Interlocked builtins
Reviewers: compnerd, thakis, Prazek, majnemer, rnk

Subscribers: cfe-commits

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

llvm-svn: 281378
2016-09-13 19:43:33 +00:00
Albert Gutowski ae3fb3113f Add some MS aliases for existing intrinsics
Reviewers: thakis, compnerd, majnemer, rsmith, rnk

Subscribers: cfe-commits

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

llvm-svn: 281375
2016-09-13 19:26:42 +00:00
Alexander Shaposhnikov 6956d29034 [analyzer] Fix ExprEngine::VisitMemberExpr
AST may contain intermediate ParenExpr nodes
between MemberExpr and ArrayToPointerDecay.
This diff adjusts the check in ExprEngine::VisitMemberExpr accordingly.
Test plan: make -j8 check-clang-analysis

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

llvm-svn: 281373
2016-09-13 19:17:20 +00:00
Nico Weber 88f5ed9430 [clang-cl] Diagnose duplicate uuids.
This mostly behaves cl.exe's behavior, even though clang-cl is stricter in some
corner cases and more lenient in others (see the included test).

To make the uuid declared previously here diagnostic work correctly, tweak
stripTypeAttributesOffDeclSpec() to keep attributes in the right order.

https://reviews.llvm.org/D24469

llvm-svn: 281367
2016-09-13 18:55:26 +00:00
Richard Smith ffa0241a03 Work around a GCC 4.7-specific issue: due to implementing older rules for
implicit declarations of move operations, GCC 4.7 would find that SelectPiece
has neither a move constructor nor a copy constructor. The copy constructor was
(correctly) deleted because the class has a member of move-only type, and the
move constructor was (incorrectly, per current C++ rules) not provided because
the class has a copy-only base class (in turn because it explicitly declares a
destructor).

llvm-svn: 281363
2016-09-13 18:35:34 +00:00
Manman Ren c5705bae05 ObjectiveC Generics: Start using ObjCTypeParamType.
For ObjC type parameter, we used to have TypedefType that is canonicalized to
id or the bound type. We can't represent "T <protocol>" and thus will lose
the type information in the following example:
@interface MyMutableDictionary<KeyType, ObjectType> : NSObject
- (void)setObject:(ObjectType)obj forKeyedSubscript:(KeyType <NSCopying>)key;
@end
MyMutableDictionary<NSString *, NSString *> *stringsByString;
NSNumber *n1, *n2;
stringsByString[n1] = n2;
--> no warning on type mismatch of the key.

To fix the problem, we introduce a new type ObjCTypeParamType that supports
a list of protocol qualifiers.

We create ObjCTypeParamType for ObjCTypeParamDecl when we create
ObjCTypeParamDecl. We also substitute ObjCTypeParamType instead of TypedefType
on an ObjCTypeParamDecl.

rdar://24619481
rdar://25060179

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

llvm-svn: 281358
2016-09-13 17:41:05 +00:00
Yaxun Liu d3e85b98be AMDGPU: Fix target options fp32/64-denormals
Fix target options for fp32/64-denormals so that

+fp64-denormals is set if fp64 is supported
-fp32-denormals if fp32 denormals is not supported, or -cl-denorms-are-zero is set
+fp32-denormals if fp32 denormals is supported and -cl-denorms-are-zero is not set

If target feature fp32/64-denormals is explicitly set, they will override default options and options deduced from -cl-denorms-are-zero.

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

llvm-svn: 281357
2016-09-13 17:37:09 +00:00
Manman Ren e6be26c8d4 ObjectiveC generics: Add ObjCTypeParamType in the type system.
We also need to add ObjCTypeParamTypeLoc. ObjCTypeParamType supports the
representation of "T <protocol>" where T is a type parameter. Before this,
we use TypedefType to represent the type parameter for ObjC.

ObjCTypeParamType has "ObjCTypeParamDecl *OTPDecl" and it extends from
ObjCProtocolQualifiers. It is a non-canonical type and is canonicalized
to the underlying type with the protocol qualifiers.

rdar://24619481
rdar://25060179

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

llvm-svn: 281355
2016-09-13 17:25:08 +00:00
Manman Ren 3569eb5267 ObjectiveC: Refactor applyObjCProtocolQualifiers.
To construct the canonical type of ObjCTypeParamType, we need to apply
qualifiers on ObjCObjectPointerType. The updated applyObjCProtocolQualifiers
handles this case by merging the protocol lists, constructing a new
ObjCObjectType, then a new ObjCObjectPointerType.

rdar://24619481
rdar://25060179

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

llvm-svn: 281353
2016-09-13 17:03:12 +00:00
Manman Ren 00943d2dc9 Add a class ObjCProtocolQualifiers to wrap APIs for ObjC protocol list.
Now ObjCObjectType extends from ObjCProtocolQualifiers. We save number of
protocols in ObjCProtocolQualifiers.

This is in preparation of adding a new type class ObjCTypeParamType that
can take protocol qualifiers.

rdar://24619481
rdar://25060179

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

llvm-svn: 281351
2016-09-13 16:45:29 +00:00
Nico Weber 6339f1a028 Traversing template paramter lists of DeclaratorDecls and/or TagDecls.
The unit tests in this patch demonstrate the need to traverse template
parameter lists of DeclaratorDecls (e.g. VarDecls, CXXMethodDecls) and
TagDecls (e.g. EnumDecls, RecordDecls).

Fixes PR29042.
https://reviews.llvm.org/D24268

Patch from Lukasz
Łukasz Anforowicz <lukasza@chromium.org>!

llvm-svn: 281345
2016-09-13 15:05:04 +00:00
Eric Liu 2574d15c5b Remove redundant comma around parenthesis in parameter list.
Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 281344
2016-09-13 15:02:43 +00:00
Vassil Vassilev b4829e4e0c Revert accidentally checked in change in r281315.
llvm-svn: 281316
2016-09-13 10:38:26 +00:00
Vassil Vassilev e5fe5e98e5 Simplify. NFC.
llvm-svn: 281315
2016-09-13 10:36:12 +00:00
Nikola Smiljanic 98d2e59d72 Allow register variables in naked functions.
llvm-svn: 281298
2016-09-13 07:02:02 +00:00
Stephen Hines 815e9bbdbd clang-format: Add Java detection to git-clang-format.
Summary: This change adds "java" to the list of known extensions that clang-format supports.

Patch by Luis Hector Chavez

Reviewers: djasper

Subscribers: srhines, cfe-commits

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

llvm-svn: 281294
2016-09-13 05:00:20 +00:00
Adam Nemet 1eea3e577d Reapply r281276 with passing -emit-llvm in one of the tests
Original commit message:

Add -fdiagnostics-show-hotness

Summary:
I've recently added the ability for optimization remarks to include the
hotness of the corresponding code region.  This uses PGO and allows
filtering of the optimization remarks by relevance.  The idea was first
discussed here:
http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334

The general goal is to produce a YAML file with the remarks.  Then, an
external tool could dynamically filter these by hotness and perhaps by
other things.

That said it makes sense to also expose this at the more basic level
where we just include the hotness info with each optimization remark.
For example, in D22694, the clang flag was pretty useful to measure the
overhead of the additional analyses required to include hotness.
(Without the flag we don't even run the analyses.)

For the record, Hal has already expressed support for the idea of this
patch on IRC.

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

llvm-svn: 281293
2016-09-13 04:32:40 +00:00
Richard Trieu f3b7766266 Handle empty message in static_asserts.
llvm-svn: 281287
2016-09-13 01:37:01 +00:00
Richard Trieu ffa532d7a1 Fix interaction between serialization and c++1z feature.
In c++1z, static_assert is not required to have a StringLiteral message, where
previously it was required.  Update the AST Reader to be able to handle a
null StringLiteral.

llvm-svn: 281286
2016-09-13 01:20:40 +00:00
Peter Collingbourne eeb56abe64 Update Clang for D20147 ("DebugInfo: New metadata representation for global variables.")
Differential Revision: http://reviews.llvm.org/D20415

llvm-svn: 281285
2016-09-13 01:13:19 +00:00
Adam Nemet f2b6883ac8 Revert "Add -fdiagnostics-show-hotness"
This reverts commit r281276.

Many bots are failing.

llvm-svn: 281279
2016-09-13 00:16:49 +00:00
Reid Kleckner 6c7b1c6212 [DebugInfo] Deduplicate debug info limiting logic
We should be doing the same checks when a type is completed as we do
when a complete type is used during emission. Previously, we duplicated
the logic, and it got out of sync. This could be observed with
dllimported classes.

Also reduce a test case for this slightly.

Implementing review feedback from David Blaikie on r281057.

llvm-svn: 281278
2016-09-13 00:01:23 +00:00
George Burgess IV f8f6324983 [Sema] Fix PR30346: relax __builtin_object_size checks.
This patch makes us act more conservatively when trying to determine
the objectsize for an array at the end of an object. This is in
response to code like the following:

```
struct sockaddr {
  /* snip */
  char sa_data[14];
};

void foo(const char *s) {
  size_t slen = strlen(s) + 1;
  size_t added_len = slen <= 14 ? 0 : slen - 14;
  struct sockaddr *sa = malloc(sizeof(struct sockaddr) + added_len);
  strcpy(sa->sa_data, s);
  // ...
}
```

`__builtin_object_size(sa->sa_data, 1)` would return 14, when there
could be more than 14 bytes at `sa->sa_data`.

Code like this is apparently not uncommon. FreeBSD's manual even
explicitly mentions this pattern:
https://www.freebsd.org/doc/en/books/developers-handbook/sockets-essential-functions.html
(section 7.5.1.1.2).

In light of this, we now just give up on any array at the end of an
object if we can't find the object's initial allocation.

I lack numbers for how much more conservative we actually become as a
result of this change, so I chose the fix that would make us as
compatible with GCC as possible. If we want to be more aggressive, I'm
happy to consider some kind of whitelist or something instead.

llvm-svn: 281277
2016-09-12 23:50:35 +00:00
Adam Nemet a340eff335 Add -fdiagnostics-show-hotness
Summary:
I've recently added the ability for optimization remarks to include the
hotness of the corresponding code region.  This uses PGO and allows
filtering of the optimization remarks by relevance.  The idea was first
discussed here:
http://thread.gmane.org/gmane.comp.compilers.llvm.devel/98334

The general goal is to produce a YAML file with the remarks.  Then, an
external tool could dynamically filter these by hotness and perhaps by
other things.

That said it makes sense to also expose this at the more basic level
where we just include the hotness info with each optimization remark.
For example, in D22694, the clang flag was pretty useful to measure the
overhead of the additional analyses required to include hotness.
(Without the flag we don't even run the analyses.)

For the record, Hal has already expressed support for the idea of this
patch on IRC.

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

llvm-svn: 281276
2016-09-12 23:48:16 +00:00
Adam Nemet d2a4da09ad Fix a long comment line
llvm-svn: 281275
2016-09-12 23:48:11 +00:00
Saleem Abdulrasool 62c07eb2fa CodeGen: use some range-based for loops
Use range-based for loops to simplify the logic.  Add an explicit check for
MachO as the inline asm uses MachO specific directives.

llvm-svn: 281261
2016-09-12 21:15:23 +00:00
Richard Smith 7707c4a109 Add a couple of test files missed in r281258.
llvm-svn: 281259
2016-09-12 21:07:09 +00:00
Richard Smith 6561f92b62 [modules] When we merge two definitions of a function, mark the retained
definition as visible in the discarded definition's module, as we do for
other kinds of definition.

llvm-svn: 281258
2016-09-12 21:06:40 +00:00
Richard Smith ac20531203 Diagnostics reference: "error:" should be red, not orange.
llvm-svn: 281241
2016-09-12 17:55:49 +00:00
Jonathan Roelofs 96cb94b2a9 Trivial documentation fix regarding Obj-C ARC objc_arc_weak_reference_unavailable
Fixed incorrect docs that referred to:
  objc_arc_weak_unavailable
when it should be:
  objc_arc_weak_reference_unavailable

Patch by: Sean McBride!

llvm-svn: 281227
2016-09-12 16:14:52 +00:00
Daniel Jasper c6a123111a clang-format: Make emacs integration work with narrowed buffers.
Use (call-process region nil ...) instead of (point-min) so that the
call works in narrowed buffers.

Patch by Philipp Stephani, thank you!

llvm-svn: 281203
2016-09-12 10:02:46 +00:00
Martin Bohme 0eb4403f24 [CFG] Add iterator_ranges to CFG and CFGBlock.
Summary: (Needed for D23353.)

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 281200
2016-09-12 08:28:21 +00:00
Richard Smith 67462ffce9 Add virtual destructor (necessary due to the switch to shared_ptr).
llvm-svn: 281198
2016-09-12 06:51:11 +00:00
Richard Smith 94a2fe5c8d Attempt #3 to placate MSVC.
llvm-svn: 281197
2016-09-12 06:38:31 +00:00
Richard Smith c14994f290 Attempt #2 to placate MSVC
llvm-svn: 281195
2016-09-12 06:23:26 +00:00
Richard Smith cd608d1a20 Attempt to placate MSVC.
llvm-svn: 281194
2016-09-12 06:13:44 +00:00
Richard Smith b6a3b4ba61 Add a mode to clang-tblgen to generate reference documentation for warning and
remark flags. For now I'm checking in a copy of the built documentation, but we
can replace this with a placeholder (as we do for the attributes reference
documentation) once we enable building this server-side.

llvm-svn: 281192
2016-09-12 05:58:29 +00:00
David Majnemer cb60a4305b [MS ABI] Add /include directives for dynamic TLS
MSVC emits /include directives in the .drective section for the
__dyn_tls_init function (decorated as ___dyn_tls_init@12 for 32-bit).

This fixes PR30347.

llvm-svn: 281189
2016-09-12 02:51:43 +00:00
Saleem Abdulrasool 4fab7454c5 CodeGen: remove unnecessary else case
Refactor the assignment so that its much more clear that the if-clause contains
the lookup, and once cached is directly used.  NFC.

llvm-svn: 281150
2016-09-11 01:25:15 +00:00
Nico Weber b5bdf3410e Add missing test coverage for an inheritance model attrib merge diag.
Without this, no tests fail if I remove the Diag() in the first if in
Sema::mergeMSInheritanceAttr().

llvm-svn: 281136
2016-09-10 13:03:59 +00:00
Akira Hatanaka 3d17313734 [tablegen] Check that an optional IdentifierArgument of an attribute is
provided before trying to print it.

This fixes a segfault that occurs when function printPretty generated by
tablegen tries to print an optional argument of attribute
objc_bridge_related.

rdar://problem/28155469

llvm-svn: 281132
2016-09-10 03:29:43 +00:00
Manman Ren ec315f1002 Modules: for ObjectiveC try to keep the definition invariant.
When deserializing ObjCInterfaceDecl with definition data, if we already have
a definition, try to keep the definition invariant; also pull in the
categories even if it is not what getDefinition returns (this effectively
combines categories).

rdar://27926200
rdar://26708823

llvm-svn: 281119
2016-09-09 23:48:27 +00:00
Adrian Prantl 432d3d2619 Debug info: Bump the default DWARF version on Darwin to 4.
This is a spiritual re-commit of r201375 with only a brief delay
for upgrading the green dragon builders.

llvm-svn: 281094
2016-09-09 21:10:35 +00:00
Justin Lebar 5057f17716 [CUDA] Make __GCC_ATOMIC_XXX_LOCK_FREE macros the same on host/device.
Summary:
This fixes a bug where we were unable to compile the following CUDA
file with libstdc++ (didn't try libc++):

  #include <future>
  void foo() { std::shared_future<int> x; }

The problem is that <future> only defines std::shared_future if
__GCC_ATOMIC_INT_LOCK_FREE > 1.  When we compiled this file for device,
the macro was set to 1, and then the class didn't exist at all.

Reviewers: tra

Subscribers: cfe-commits, jhen

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

llvm-svn: 281089
2016-09-09 20:35:43 +00:00
Manman Ren 7d2f5c4a91 Modules: revert r280728.
In post-commit review, Richard suggested a better way to fix this.
rdar://27926200

llvm-svn: 281078
2016-09-09 19:03:07 +00:00
Douglas Katzman 3972f9e6df Myriad: nominally "support" ASAN.
Doesn't work, but needs to be enabled in order to get there.

llvm-svn: 281071
2016-09-09 18:20:49 +00:00
Eric Liu 01426ff875 Also cleanup comments around redundant colons/commas in format::cleanup.
Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 281064
2016-09-09 17:50:49 +00:00
Reid Kleckner 22466a92e1 [DebugInfo] Ensure complete type is emitted with -fstandalone-debug
The logic for upgrading a class from a forward decl to a complete type
was not checking the debug info emission level before applying the
vtable optimization. This meant we ended up without debug info for a
class which was required to be complete. I noticed it because it
triggered an assertion during CodeView emission, but that's a separate
issue.

llvm-svn: 281057
2016-09-09 17:03:53 +00:00
Reid Kleckner b6bee5164d Make -fstandalone-debug and -flimit-debug-info available in clang-cl
Our limited debug info optimizations are breaking down at DLL
boundaries, so we're going to evaluate the size impact of these
settings, and possibly change the default.

Users should be able to override our settings, though.

llvm-svn: 281056
2016-09-09 16:42:50 +00:00
Reid Kleckner c9404e1039 [codeview] Extend the heuristic for detecting classes imported from DLLs
If a dynamic class contains a dllimport method, then assume the class
may not be constructed in this DLL, and therefore the vtable will live
in a different PDB.

This heuristic is still incomplete, and will miss things like abstract
base classes that are only constructed on one side of the DLL interface.
That said, this heuristic does detect some cases that are currently
problematic, and may be useful to other projects that don't use many
DLLs.

llvm-svn: 281053
2016-09-09 16:27:04 +00:00
Amaury Sechet 21f51b3a32 Update clang for D21514. NFC
Summary: As per title.

Reviewers: ahatanak, bkramer, whitequark, mehdi_amini, void

Subscribers: cfe-commits

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

llvm-svn: 281018
2016-09-09 04:42:49 +00:00
George Burgess IV 5104e30590 [Docs] Fix typos, remove trailing whitespace.
Avoided wrapping NullabilityDocs at 80cols, since that would've made
this diff much bigger, and never-ending lines seems to be the style for
many of the null-related docs.

llvm-svn: 281017
2016-09-09 02:45:48 +00:00
Richard Smith 8df390f9eb C++ Modules TS: Add parsing and some semantic analysis support for
export-declarations. These don't yet have an effect on name visibility;
we still export everything by default.

llvm-svn: 280999
2016-09-08 23:14:54 +00:00
Vedant Kumar 10037b93e9 [Driver] Report invalid -mtune/-mcpu parameters when -arch=arm64
Differential Revision: https://reviews.llvm.org/D23643

llvm-svn: 280998
2016-09-08 22:53:19 +00:00
Albert Gutowski b6a11acb53 Implement MS _rot intrinsics
Reviewers: thakis, Prazek, compnerd, rnk

Subscribers: majnemer, cfe-commits

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

llvm-svn: 280997
2016-09-08 22:32:19 +00:00
Vassil Vassilev 714b81c40a [modules] Apply ODR merging for function scoped tags only in C++ mode.
In C mode, if we have a visible declaration but not a visible definition, a tag
defined in the declaration should be have a visible definition. In C++ we rely
on the ODR merging, whereas in C we cannot because each declaration of a
function gets its own set of declarations in its prototype scope.

Patch developed in collaboration with Richard Smith!

llvm-svn: 280984
2016-09-08 20:34:41 +00:00
Renato Golin 0f1fcd6fc6 Revert "[XRay] ARM 32-bit no-Thumb support in Clang"
This reverts commit r280889, as the original LLVM commits broke the thumb
buildbots.

llvm-svn: 280968
2016-09-08 17:12:32 +00:00
Simon Pilgrim 4acc49e58d Moved unreachable to appease msvc, gcc and clang
llvm-svn: 280921
2016-09-08 11:03:41 +00:00
Simon Pilgrim 48c32b1504 Fixed a 'not all control paths return a value' warning on MSVC builds
llvm-svn: 280917
2016-09-08 09:59:58 +00:00
Peter Collingbourne f3fe5a7445 Add explicit casts to size_t to try to appease MSVC.
llvm-svn: 280899
2016-09-08 01:45:28 +00:00
Peter Collingbourne e53683f97b CodeGen: Clean up implementation of vtable initializer builder. NFC.
- Simplify signature of CreateVTableInitializer function.
- Move vtable component builder to a separate function.
- Remove unnecessary accessors from VTableLayout class.

This is in preparation for a future change that will alter the type of the
vtable initializer.

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

llvm-svn: 280897
2016-09-08 01:14:39 +00:00
Dean Michael Berris 6f2622e253 [XRay] ARM 32-bit no-Thumb support in Clang
Just a test for now, adapted from x86_64 tests of XRay.
This is one of 3 commits to different repositories of XRay ARM port. The
other 2 are:

1. https://reviews.llvm.org/D23931 (LLVM)
2. https://reviews.llvm.org/D23933 (compiler-rt)

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

llvm-svn: 280889
2016-09-08 00:23:28 +00:00
Daniel Jasper 28d8a5ab43 clang-format: [JavaScript] Change default AllowShortFunctionsOnASingleLine
for Google style to "empty".

llvm-svn: 280878
2016-09-07 23:01:13 +00:00
Daniel Jasper 496c199959 clang-format: [JavaScript] Do requoting in a separate pass
The attempt to fix requoting behavior in r280487 after changes to
tooling::Replacements are incomplete. We essentially need to add to
replacements at the same position, one to insert a line break and one to
change the quoting and that's incompatible with the new
tooling::Replacement API, which does not allow for order-dependent
Replacements. To make the order clear, Replacements::merge() has to be
used, but that requires the merged Replacement to actually refer to the
changed text, which is hard to reproduce for the requoting.

This change fixes the behavior by moving the requoting to a completely
separate pass. The added benefit is that no weird ColumnWidth
calculations are necessary anymore and this should just work even if we
implement string literal splitting in the future.

llvm-svn: 280874
2016-09-07 22:48:53 +00:00
Eugene Zelenko e95e7d5d64 Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D24115

llvm-svn: 280870
2016-09-07 21:53:17 +00:00
George Burgess IV 2da19a5a08 Move CHECK right before the function it describes.
llvm-svn: 280852
2016-09-07 20:15:03 +00:00
George Burgess IV fbad5b2f1b [Sema] Compare bad conversions in overload resolution.
r280553 introduced an issue where we'd emit ambiguity errors for code
like:

```
void foo(int *, int);
void foo(unsigned int *, unsigned int);

void callFoo() {
  unsigned int i;
  foo(&i, 0); // ambiguous: int->unsigned int is worse than int->int,
              // but unsigned int*->unsigned int* is better than
              // int*->int*.
}
```

This patch fixes this issue by changing how we handle ill-formed (but
valid) implicit conversions. Candidates with said conversions now always
rank worse than candidates without them, and two candidates are
considered to be equally bad if they both have these conversions for
the same argument.

Additionally, this fixes a case in C++11 where we'd complain about an
ambiguity in a case like:

```
void f(char *, int);
void f(const char *, unsigned);
void g() { f("abc", 0); }
```

...Since conversion to char* from a string literal is considered
ill-formed in C++11 (and deprecated in C++03), but we accept it as an
extension.

llvm-svn: 280847
2016-09-07 20:03:19 +00:00
Nico Weber 82f729bf4e Add a few more test for []-style uuid attributes.
- Should diag on a function (clang-cl warns; it's an error in cl)
- Test the attribute on nested classes (clang-cl is more permissive and more
  self-consistent than cl here)

llvm-svn: 280845
2016-09-07 19:41:35 +00:00
Yaxun Liu 43712e05ea Do not validate pch when -fno-validate-pch is set
There is a bug causing pch to be validated even though -fno-validate-pch is set. This patch fixes it.

ASTReader relies on ASTReaderListener to initialize SuggestedPredefines, which is required for compilations using PCH. Before this change, PCHValidator is the default ASTReaderListener. After this change, when -fno-validate-pch is set, PCHValidator is disabled, but we need a replacement ASTReaderListener to initialize SuggestedPredefines. Class SimpleASTReaderListener is implemented for this purpose.

This change only affects -fno-validate-pch. There is no functional change if -fno-validate-pch is not set.

If -fno-validate-pch is not set, conflicts in predefined macros between pch and current compiler instance causes error.

If -fno-validate-pch is set, predefine macros in current compiler override those in pch so that compilation can continue.

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

llvm-svn: 280842
2016-09-07 18:40:20 +00:00
Ismail Pazarbasi 4a00774e59 Try contextually converting condition of constexpr if to Boolean value
Summary:
C++1z 6.4.1/p2:
 If the if statement is of the form if constexpr, the value of the
 condition shall be a contextually converted constant expression of type
 bool [...]
C++1z 5.20/p4:
 [...] A contextually converted constant expression of type bool is an
 expression, contextually converted to bool (Clause4), where the
 converted expression is a constant expression and the conversion
 sequence contains only the conversions above. [...]

Contextually converting result of an expression `e` to a Boolean value
requires `bool t(e)` to be well-formed.

An explicit conversion function is only considered as a user-defined
conversion for direct-initialization, which is essentially what
//contextually converted to bool// requires.

Also, fixes PR28470.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 280838
2016-09-07 18:24:54 +00:00
Reid Kleckner e5a321b5e8 [MS] Fix prologue this adjustment when 'this' is passed indirectly
Move the logic for doing this from the ABI argument lowering into
EmitParmDecl, which runs for all parameters. Our codegen is slightly
suboptimal in this case, as we may leave behind a dead store after
optimization, but it's 32-bit inalloca, and this fixes the bug in a
robust way.

Fixes PR30293

llvm-svn: 280836
2016-09-07 18:21:30 +00:00
Eugene Zelenko 2fe1cc482b [clang-offload-bundler] Fix some Clang-tidy modernize-use-override and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D24165

llvm-svn: 280828
2016-09-07 17:37:28 +00:00
Vassil Vassilev 73e5d89de5 Add missing include. White space.
llvm-svn: 280827
2016-09-07 17:30:50 +00:00
Reid Kleckner 5de2bcdcf6 Add MS __nop intrinsic to intrin.h
Summary: There was no definition for __nop function - added inline
assembly.

Patch by Albert Gutowski!

Reviewers: rnk, thakis

Subscribers: cfe-commits

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

llvm-svn: 280826
2016-09-07 16:55:12 +00:00
Reid Kleckner 3f1ec62a83 Parsing MS pragma intrinsic
Parse pragma intrinsic, display warning if the function isn't a builtin
function in clang and suggest including intrin.h.

Patch by Albert Gutowski!

Reviewers: aaron.ballman, rnk

Subscribers: aaron.ballman, cfe-commits

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

llvm-svn: 280825
2016-09-07 16:38:32 +00:00
Reid Kleckner 034e727001 [MS] Fix 'this' type when calling virtual methods with inalloca
If the virtual method comes from a secondary vtable, then the type of
the 'this' parameter should be i8*, and not a pointer to the complete
class. In the MS ABI, the 'this' parameter on entry points to the vptr
containing the virtual method that was called, so we use i8* instead of
the normal type. We had a mismatch where the CGFunctionInfo of the call
didn't match the CGFunctionInfo of the declaration, and this resulted in
some assertions, but now both sides agree the type of 'this' is i8*.

Fixes one issue raised in PR30293

llvm-svn: 280815
2016-09-07 15:15:51 +00:00
Sagar Thakur c9113e4863 [EfficiencySanitizer] [MIPS64] Enables esan clang driver options for MIPS64
Reviewed by bruening
Differential: D23800

llvm-svn: 280806
2016-09-07 12:23:15 +00:00
Alexey Bader af17c7959e [OpenCL] Fix pipe built-in functions return type.
By default return type of call expressions calling built-in
functions is set to bool.

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

Reviewers: Anastasia

Subscribers: dmitry, cfe-commits, yaxunl

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

llvm-svn: 280800
2016-09-07 10:32:03 +00:00
Matt Arsenault f333de3752 OpenCL: Defining __ENDIAN_LITTLE__ and fix target endianness
OpenCL requires __ENDIAN_LITTLE__ be set for little endian targets.
The default for targets was also apparently big endian, so AMDGPU
was incorrectly reported as big endian. Set this from the triple
so targets don't have another place to set the endianness.

llvm-svn: 280787
2016-09-07 07:08:02 +00:00
Matt Arsenault 8afb5cd894 Fix whitespace issues
^M and extra space

llvm-svn: 280786
2016-09-07 07:07:59 +00:00
Richard Smith 7c2bcc9eb0 Fix clang's handling of the copy performed in the second phase of class
copy-initialization. We previously got this wrong in a couple of ways:
 - we only looked for copy / move constructors and constructor templates for
   this copy, and thus would fail to copy in cases where doing so should use
   some other constructor (but see core issue 670),
 - we mishandled the special case for disabling user-defined conversions that
   blocks infinite recursion through repeated application of a copy constructor
   (applying it in slightly too many cases) -- though as far as I can tell,
   this does not ever actually affect the result of overload resolution, and
 - we misapplied the special-case rules for constructors taking a parameter
   whose type is a (reference to) the same class type by incorrectly assuming
   that only happens for copy/move constructors (it also happens for
   constructors instantiated from templates and those inherited from base
   classes).

These changes should only affect strange corner cases (for instance, where the
copy constructor exists but has a non-const-qualified parameter type), so for
the most part it only causes us to produce more 'candidate' notes, but see the
test changes for other cases whose behavior is affected.

llvm-svn: 280776
2016-09-07 02:14:33 +00:00
Devin Coughlin 80e74cdc68 [scan-build-py] Increase precision of timestamp in report directory name
This commit improves compatibility with the perl version of scan-build.

The perl version of scan-build produces output report directories with
increasing lexicographic ordering. This ordering is relied on by the CmpRuns.py
tool in utils/analyzer when comparing results for build commands with multiple
steps. That tool tries to line up the output directory for each step between
different runs of the analyzer based on the increasing directory name.

The python version of scan-build uses file.mkdtemp() with a time stamp
prefix to create report directories. The timestamp has a 1-second precision.
This means that when analysis of a single build step takes less than a second
the ordering property that CmpRuns.py expects will sometimes not hold,
depending on the timing and the random suffix generated by mkdtemp(). Ultimately
this causes CmpRuns to incorrectly correlate results from build steps and report
spurious differences between runs.

This commit increases the precision of the timestamp used in scan-build-py to
the microsecond level. This approach still has the same underlying issue -- but
in practice analysis of any build step is unlikely to take less than a
millisecond.

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

llvm-svn: 280768
2016-09-06 23:42:51 +00:00
Martin Probst 34ecf42bff clang-format: [JS] whitespace required between ! and as.
Summary:
Before:
    x!as string
After:
    x! as string

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 280731
2016-09-06 18:55:34 +00:00
Martin Probst 56ff7aaacb clang-format: [JS] ignore comments when wrapping returns.
Summary:
When code contains a comment between `return` and the value:

    return /* lengthy comment here */ (
        lengthyValueComesHere);

Do not wrap before the comment, as that'd break the code through JS' automatic
semicolon insertion.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 280730
2016-09-06 18:39:30 +00:00
Manman Ren c748359c14 Modules: Fix an assertion in DeclContext::buildLookup.
When calling getMostRecentDecl, we can pull in more definitions from
a module. We call getPrimaryContext afterwards to make sure that
we buildLookup on a primary context.

rdar://27926200

llvm-svn: 280728
2016-09-06 18:16:54 +00:00
Leny Kholodov df050fd585 Formatting with clang-format patch r280701
llvm-svn: 280718
2016-09-06 17:06:14 +00:00
Pierre Gousseau 209b6e2e78 [clang-cl] Check that we are in clang cl mode before enabling support for the CL environment variable.
Checking for the type of the command line tokenizer should not be the criteria to enable support for the CL environment variable, this change checks that we are in clang-cl mode instead.

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

llvm-svn: 280702
2016-09-06 10:48:27 +00:00
Leny Kholodov 80c047d2c4 DebugInfo: use llvm::DINode::DIFlags type for debug info flags
Use llvm::DINode::DIFlags type (strongly typed enum) for debug flags instead of unsigned int to avoid problems on platforms with sizeof(int) < 4: we already have flags with values > (1 << 16).

Patch by: Victor Leschuk <vleschuk@gmail.com>

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

llvm-svn: 280701
2016-09-06 10:48:04 +00:00
Alexey Bader 3e0b817b91 [OpenCL] Remove access qualifiers on images in arg info metadata.
Summary:
Remove access qualifiers on images in arg info metadata:
 * kernel_arg_type
 * kernel_arg_base_type

Image access qualifiers are inseparable from type in clang implementation,
but OpenCL spec provides a special query to get access qualifier
via clGetKernelArgInfo with CL_KERNEL_ARG_ACCESS_QUALIFIER.

Besides that OpenCL conformance test_api get_kernel_arg_info expects
image types without access qualifier.

Patch by Evgeniy Tyurin.

Reviewers: bader, yaxunl, Anastasia

Subscribers: cfe-commits

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

llvm-svn: 280699
2016-09-06 10:10:28 +00:00
Ed Schouten c6d1a730a6 Add support for targeting armv6-unknown-cloudabi-eabihf.
I'm in the progress of adding ARMv6 support to CloudABI. On the compiler
side, everything seems to work properly with this tiny change applied.

llvm-svn: 280672
2016-09-05 18:38:34 +00:00
NAKAMURA Takumi f852ac88f3 clang/test/Modules/compiler_builtins_x86.c: Fix r280658.
llvm-svn: 280659
2016-09-05 13:14:54 +00:00
James Molloy 3ddbb81ea0 Attempt to fix buildbots not targetting x86
r280613 introduced failures for all builds that don't target x86 by default. Add an explicit target to avoid a missing feature diagnostic.

llvm-svn: 280658
2016-09-05 12:28:49 +00:00
Craig Topper 2dfab63bb3 [AVX-512] Remove 128-bit and 256-bit masked floating point add/sub/mul/div builtins and replace with native operations.
We can't do the 512-bit ones because they take a rounding mode argument that we can't represent.

llvm-svn: 280635
2016-09-04 18:30:17 +00:00
Joerg Sonnenberger 9bd9d98929 Test case for r280607 to check presence and sanity of the *_LOCK_FREE
macros.

llvm-svn: 280622
2016-09-04 11:21:27 +00:00
Elad Cohen fb6358d2b5 [Modules] Add 'freestanding' to the 'requires-declaration' feature-list.
This adds support for modules that require (non-)freestanding
environment, such as the compiler builtin mm_malloc submodule.

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

llvm-svn: 280613
2016-09-04 06:00:42 +00:00
Joerg Sonnenberger b50b2fac9f Trailing dot that shouldn't have been committed.
llvm-svn: 280609
2016-09-04 00:51:02 +00:00
Joerg Sonnenberger 82216f0faa PR 27200: Fix names of the atomic lock-free macros.
llvm-svn: 280607
2016-09-04 00:44:10 +00:00
Craig Topper f43e4a1728 [AVX-512] Remove masked integer mullo builtins and replace with native IR.
llvm-svn: 280597
2016-09-03 19:19:49 +00:00
Craig Topper 0e18976b8d [AVX-512] Remove masked integer add/sub builtins and replace with native IR.
llvm-svn: 280596
2016-09-03 18:29:35 +00:00
Aaron Ballman bb18e91cdf Fix the attribute documentation build.
llvm-svn: 280591
2016-09-03 15:36:52 +00:00
Niels Ole Salscheider b28cc458c3 Replace the Radeon GCN GPU family names by more descriptive ones
Differential Revision: https://reviews.llvm.org/D23957

llvm-svn: 280587
2016-09-03 07:13:54 +00:00
Nico Weber 55fbe483d6 Add a test Aaron asked for that I forgot to add before landing r280578.
llvm-svn: 280580
2016-09-03 04:27:14 +00:00
Nico Weber 05e1dadac6 [ms] Add support for parsing uuid as a Microsoft attribute.
Some Windows SDK classes, for example
Windows::Storage::Streams::IBufferByteAccess, use the ATL way of spelling
attributes:

  [uuid("....")] class IBufferByteAccess {};

To be able to use __uuidof() to grab the uuid off these types, clang needs to
support uuid as a Microsoft attribute. There was already code to skip Microsoft
attributes, extend that to look for uuid and parse it.  Use the new "Microsoft"
attribute type added in r280575 (and r280574, r280576) for this.

Final part of https://reviews.llvm.org/D23895

llvm-svn: 280578
2016-09-03 03:25:22 +00:00
Nico Weber 32a0fc7987 Let Microsoft attributes apply to the type, not the variable.
There was already a function that moved attributes off the declspec into
an attribute list for attributes applying to the type, teach that function to
also move Microsoft attributes around and rename it to match its new broader
role.

Nothing uses Microsoft attributes yet, so no behavior change.

Part of https://reviews.llvm.org/D23895

llvm-svn: 280576
2016-09-03 03:01:32 +00:00
Nico Weber 20e08048ec Add plumbing for new attribute type "Microsoft".
This is for attributes in []-delimited lists preceding a class, like e.g.
`[uuid("...")] class Foo {};`  Not used by anything yet, so no behavior change.
Part of https://reviews.llvm.org/D23895

llvm-svn: 280575
2016-09-03 02:55:10 +00:00
Nico Weber 8452327f2d Move calls of MaybeParseMicrosoftAttributes() before ParseExternalDeclaration()
into ParseDeclOrFunctionDefInternal() (which is called by
MaybeParseMicrosoftAttributes()), so that the attributes can be stored in
the DeclSpec.  No behavior change yet, part of https://reviews.llvm.org/D23895

llvm-svn: 280574
2016-09-03 02:48:03 +00:00
Nico Weber cb7f722ffa Remove function name from comment.
The comment starting with "ParseDeclarationOrFunctionDefinition -" is above
a function called ParseDeclOrFunctionDefInternal.  Fix the comment by not
mentioning a function name, like the style guide requests nowadays.  No behavior
change.

llvm-svn: 280572
2016-09-03 02:41:17 +00:00
George Burgess IV 6098fd1989 [Sema] Fix how we set implicit conversion kinds.
We have invariants we like to guarantee for the
`ImplicitConversionKind`s in a `StandardConversionSequence`. These
weren't being upheld in code that r280553 touched, so Richard suggested
that we should fix that. See D24113.

I'm not entirely sure how to go about testing this, so no test case is
included. Suggestions welcome.

llvm-svn: 280562
2016-09-03 00:28:25 +00:00
Yunzhong Gao f4903a3675 (clang part) Implement MASM-flavor intel syntax behavior for inline MS asm block.
Clang tests for verifying the following syntaxes:
1. 0xNN and NNh are accepted as valid hexadecimal numbers, but 0xNNh is not.     
   0xNN and NNh may come with optional U or L suffix.                            
2. NNb is accepted as a valid binary (base-2) number, but 0bNN is not.           
   NNb may come with optional U or L suffix.                                     
                                                                                 
Differential Revision: https://reviews.llvm.org/D22112

llvm-svn: 280556
2016-09-02 23:16:06 +00:00
George Burgess IV 2099b54102 [Sema] Relax overloading restrictions in C.
This patch allows us to perform incompatible pointer conversions when
resolving overloads in C. So, the following code will no longer fail to
compile (though it will still emit warnings, assuming the user hasn't
opted out of them):

```
void foo(char *) __attribute__((overloadable));
void foo(int) __attribute__((overloadable));

void callFoo() {
  unsigned char bar[128];
  foo(bar); // selects the char* overload.
}
```

These conversions are ranked below all others, so:

  A. Any other viable conversion will win out
  B. If we had another incompatible pointer conversion in the example
     above (e.g. `void foo(int *)`), we would complain about
     an ambiguity.

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

llvm-svn: 280553
2016-09-02 22:59:57 +00:00
Eric Fiselier 341e825eae Implement __attribute__((require_constant_initialization)) for safe static initialization.
Summary:
This attribute specifies expectations about the initialization of static and
thread local variables. Specifically that the variable has a
[constant initializer](http://en.cppreference.com/w/cpp/language/constant_initialization)
according to the rules of [basic.start.static]. Failure to meet this expectation
will result in an error.

Static objects with constant initializers avoid hard-to-find bugs caused by
the indeterminate order of dynamic initialization. They can also be safely
used by other static constructors across translation units.

This attribute acts as a compile time assertion that the requirements
for constant initialization have been met. Since these requirements change
between dialects and have subtle pitfalls it's important to fail fast instead
of silently falling back on dynamic initialization.

```c++
  // -std=c++14
  #define SAFE_STATIC __attribute__((require_constant_initialization)) static
  struct T {
    constexpr T(int) {}
    ~T();
  };
  SAFE_STATIC T x = {42}; // OK.
  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer
  // copy initialization is not a constant expression on a non-literal type.
```
This attribute can only be applied to objects with static or thread-local storage
duration.

Reviewers: majnemer, rsmith, aaron.ballman

Subscribers: jroelofs, cfe-commits

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

llvm-svn: 280525
2016-09-02 18:53:31 +00:00
Eric Fiselier bcdcbd11ba Revert r280516 since it contained accidental changes.
llvm-svn: 280521
2016-09-02 18:43:25 +00:00
Aaron Ballman 8b871d96d7 Based on post-commit feedback over IRC with dblaikie, ideally, we should have a SmallVector constructor that accepts anything which can supply a range via ADL begin()/end() calls so that we can construct the SmallVector directly from anything range-like.
Since that doesn't exist right now, use a local variable instead of calling getAssocExprs() twice; NFC.

llvm-svn: 280520
2016-09-02 18:31:31 +00:00
Eric Fiselier 92f8935e63 Implement __attribute__((require_constant_initialization)) for safe static initialization.
Summary:
This attribute specifies expectations about the initialization of static and
thread local variables. Specifically that the variable has a
[constant initializer](http://en.cppreference.com/w/cpp/language/constant_initialization)
according to the rules of [basic.start.static]. Failure to meet this expectation
will result in an error.

Static objects with constant initializers avoid hard-to-find bugs caused by
the indeterminate order of dynamic initialization. They can also be safely
used by other static constructors across translation units.

This attribute acts as a compile time assertion that the requirements
for constant initialization have been met. Since these requirements change
between dialects and have subtle pitfalls it's important to fail fast instead
of silently falling back on dynamic initialization.

```c++
  // -std=c++14
  #define SAFE_STATIC __attribute__((require_constant_initialization)) static
  struct T {
    constexpr T(int) {}
    ~T();
  };
  SAFE_STATIC T x = {42}; // OK.
  SAFE_STATIC T y = 42; // error: variable does not have a constant initializer
  // copy initialization is not a constant expression on a non-literal type.
```
This attribute can only be applied to objects with static or thread-local storage
duration.

Reviewers: majnemer, rsmith, aaron.ballman

Subscribers: jroelofs, cfe-commits

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

llvm-svn: 280516
2016-09-02 18:25:29 +00:00
Martin Probst a9855afedf clang-format: [JS] merge requoting replacements.
Summary:
When formatting source code that needs both requoting and reindentation,
merge the replacements to avoid erroring out for conflicting replacements.

Also removes the misleading Replacements parameter from the
TokenAnalyzer API.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 280487
2016-09-02 14:29:48 +00:00
Martin Probst 6918dcafe8 clang-format: [JS] handle default bindings in imports.
Summary:
Default imports appear outside of named bindings in curly braces:

  import A from 'a';
  import A, {symbol} from 'a';

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 280486
2016-09-02 14:06:32 +00:00
Martin Probst b480ffbcef clang-format: [JS] Sort all JavaScript imports if any changed.
Summary:
User feedback is that they expect *all* imports to be sorted if any import was
affected by a change, not just imports up to the first non-affected line, as
clang-format currently does.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 280485
2016-09-02 14:01:17 +00:00
Aaron Ballman ff7bd8bacd Allow a C11 generic selection expression to select a function with the overloadable attribute as the result expression without crashing. This fixes PR30201.
llvm-svn: 280483
2016-09-02 13:45:40 +00:00
Richard Smith 3bd6d7fb78 Clean up handling of reading module files from stdin. Don't bother trying to
look for a corresponding file, since we're not going to read it anyway.

No observable behavior change (though we now avoid pointlessly trying to stat
or open a file named "-").

llvm-svn: 280436
2016-09-02 00:18:05 +00:00
Richard Smith 3b99db5566 Refactor to avoid holding a reference to a container element that could go away
during this function, and to avoid rolling back changes to the module manager's
data structures. Instead, we defer registering the module file until after we
have successfully finished loading it.

llvm-svn: 280434
2016-09-02 00:10:28 +00:00
Alexander Shaposhnikov 3087b2cf2b Remove excessive padding from MismatchingNewDeleteDetector
The class MismatchingNewDeleteDetector is in 
lib/Sema/SemaExprCXX.cpp inside the anonymous namespace.
This diff reorders the fields and removes the excessive padding.
Test plan: make -j8 check-clang

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

llvm-svn: 280426
2016-09-01 23:18:00 +00:00
Derek Schuff acdc8e6355 [WebAssembly] Change wasm SizeType to match asmjs
Summary:
We want wasm and asmjs to have matching ABIs, and right now asmjs uses
unsigned int for its size_t. This causes exported symbols in libcxx to
not match and can cause weird breakage where libcxx doesn't get linked
as a result.  Long-term we probably want wasm32, wasm64, and asmjs to
all use unsigned long, but that would cause unnecessary ABI churn for
asmjs so defer that until we can make all the ABI changes at once.

Patch by Jacob Gravelle

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

llvm-svn: 280420
2016-09-01 22:38:37 +00:00
Richard Smith 30fc9a9339 When we reach the end of a #include of a header of a local submodule that we
textually included, create an ImportDecl just as we would if we reached a
#include of any other modular header. This is necessary in order to correctly
determine the set of variables to initialize for an imported module.

This should hopefully make the modules selfhost buildbot green again.

llvm-svn: 280409
2016-09-01 20:15:25 +00:00
Chris Bieneman 3b1a4ee7b1 [CMake] Properly connecting Compiler-RT check and test-depends
This correctly connects compiler-rt-test-depends to test-depends and
check-compiler-rt to check-all.

Based on LLVM r280392, and Compiler-RT r280393.

llvm-svn: 280394
2016-09-01 18:28:49 +00:00
Aleksei Sidorin 29afb1937b [analyzer] ExprEngine: remove second call to PreStmt<CastExpr>
This patch also introduces AnalysisOrderChecker which is intended for testing
of callback call correctness.

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

llvm-svn: 280367
2016-09-01 13:55:38 +00:00
Aleksei Sidorin e1beaf1ee7 [analyzer] Add more FileIDs to PlistDiagnostic map to avoid assertion
Some FileIDs that may be used by PlistDiagnostics were not added while building
a list of pieces. This caused assertion violation in GetFID() function.
This patch adds some missing FileIDs to avoid the assertion. It also contains
small refactoring of PlistDiagnostics::FlushDiagnosticsImpl().

Patch by Aleksei Sidorin, Ilya Palachev.

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

llvm-svn: 280360
2016-09-01 12:25:16 +00:00
Honggyu Kim 2b0e424b2f [Frontend] Fix mcount inlining bug
Since some profiling tools, such as gprof, ftrace, and uftrace, use
-pg option to generate a mcount function call at the entry of each
function. Function invocation can be detected by this hook function.

But mcount insertion is done before function inlining phase in clang,
sometime a function that already has a mcount call can be inlined in the
middle of another function.

This patch adds an attribute "counting-function" to each function
rather than emitting the mcount call directly in frontend so that this
attribute can be processed in backend. Then the mcount calls can be
properly inserted in backend after all the other optimizations are
completed.

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

Reviewers: hans, rjmccall, hfinkel, rengolin, compnerd

Subscribers: shenhan, cfe-commits

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

llvm-svn: 280355
2016-09-01 11:29:21 +00:00
Aleksei Sidorin 689457659b [analyzer][test commit] ExprEngine.cpp: Remove training whitespace; NFC
llvm-svn: 280352
2016-09-01 11:11:46 +00:00
Honggyu Kim 2bbdeacf31 Remove whitespace to test commit access
llvm-svn: 280337
2016-09-01 06:14:45 +00:00
George Burgess IV 52d07de058 Fix typos in comments.
llvm-svn: 280333
2016-09-01 01:26:58 +00:00
Akira Hatanaka 3e34cfe8b6 [Sema] Don't diagnose an array type mismatch when the new or previous
declaration has a dependent type.

This fixes a bug where clang errors out on a valid code.

rdar://problem/28051467

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

llvm-svn: 280330
2016-09-01 01:03:21 +00:00
Richard Smith 53851923d5 Fix all tests under test/CXX (and test/Analysis) to pass if clang's default
C++ language standard is not C++98.

llvm-svn: 280309
2016-08-31 23:24:08 +00:00
Richard Smith e4caa48dbb DR259: Demote the pedantic error for an explicit instantiation after an
explicit specialization to a warning for C++98 mode (this is a defect report
resolution, so per our informal policy it should apply in C++98), and turn
the warning on by default for C++11 and later. In all cases where it fires, the
right thing to do is to remove the pointless explicit instantiation.

llvm-svn: 280308
2016-08-31 23:23:25 +00:00
Nick Lewycky 97e49ac59e Add -fprofile-dir= to clang.
-fprofile-dir=path allows the user to specify where .gcda files should be
emitted when the program is run. In particular, this is the first flag that
causes the .gcno and .o files to have different paths, LLVM is extended to
support this. -fprofile-dir= does not change the file name in the .gcno (and
thus where lcov looks for the source) but it does change the name in the .gcda
(and thus where the runtime library writes the .gcda file). It's different from
a GCOV_PREFIX because a user can observe that the GCOV_PREFIX_STRIP will strip
paths off of -fprofile-dir= but not off of a supplied GCOV_PREFIX.

To implement this we split -coverage-file into -coverage-data-file and
-coverage-notes-file to specify the two different names. The !llvm.gcov
metadata node grows from a 2-element form {string coverage-file, node dbg.cu}
to 3-elements, {string coverage-notes-file, string coverage-data-file, node
dbg.cu}. In the 3-element form, the file name is already "mangled" with
.gcno/.gcda suffixes, while the 2-element form left that to the middle end
pass.

llvm-svn: 280306
2016-08-31 23:04:32 +00:00
David Blaikie 37dcf6bf97 DebugInfo: Fix -gsplit-dwarf + -fno-split-dwarf-inlining
I tested the cases involving split-dwarf + gmlt +
no-split-dwarf-inlining, but didn't verify the simpler case without
gmlt.

The logic is, admittedly, a little hairy, but seems about as simple as I
could wrangle it.

llvm-svn: 280290
2016-08-31 20:54:35 +00:00
Richard Smith e3ea001ec8 Don't diagnoes a mismatch between implicit and explicit exception
specifications under -fno-exceptions, just as we don't diagnose other exception
specification mismatch errors.

llvm-svn: 280289
2016-08-31 20:38:32 +00:00
Richard Smith 0786d5b9e6 Fix mishandling of deletedness for assignment operators of classes with
indirect virtual bases. We don't need to be able to invoke such an assignment
operator from the derived class, and we shouldn't delete the derived assignment
op if we can't do so.

llvm-svn: 280288
2016-08-31 20:37:39 +00:00
Reid Kleckner 598124296b [codeview] Don't emit vshape info for classes without vfptrs
Classes with no virtual methods or whose virtual methods were all
inherited from virtual bases don't have a vfptr at offset zero. We were
crashing attempting to get the layout of that non-existent vftable.

We don't need any vshape info in this case because the debugger can
infer it from the base class information. The current class may not
introduce any virtual methods if we are in this situation.

llvm-svn: 280287
2016-08-31 20:35:01 +00:00
Saleem Abdulrasool 667d630b05 Revert "Driver: use the canonical static library naming"
This breaks chromium and its unclear if this is actually a modern convention.

This reverts SVN r280169.

llvm-svn: 280281
2016-08-31 19:27:07 +00:00
George Burgess IV 58892a65f4 Fix a typo in a comment.
llvm-svn: 280269
2016-08-31 18:14:15 +00:00
Tim Shen 48f814e8a3 s/static inline/static/ for headers I have changed in r279475. NFC.
llvm-svn: 280257
2016-08-31 16:48:13 +00:00
Reid Kleckner dc124996d2 [codeview] Pass through vftable shape information
The shape is really just the number of methods in the vftable, since we
don't support 16 bit far calls. All calls are near. Encode this number
in the size of the artificial __vtbl_ptr_type DIDerivedType that we
generate. For DWARF, this will be a normal pointer, but for codeview
this will be a wide pointer that gets pattern matched into a
VFTableShape record. Insert this type into the element list of all
dynamic classes when emitting CodeView, so that the backend can emit the
shape even if the vptr lives in a primary base class.

Fixes PR28150

llvm-svn: 280255
2016-08-31 16:11:43 +00:00
Daniel Jasper 3042713b4b clang-format: Set default WebKit style to use C++11.
The WebKit style page says to use nullptr, so this should be fine:
https://webkit.org/code-style-guidelines/

This fixes: llvm.org/PR30220

llvm-svn: 280245
2016-08-31 14:05:56 +00:00
Luke Drummond ff7c77f906 [clang-format-vim] Support vim linked against py3
clang-format.py previously only worked in vim compiled against python2.

This patch adds the necessary syntax changes to make this work with vim
linked against python3, which is now shipped by default for at least Ubuntu16 and Arch.

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

Subscribers: cfe-commits
llvm-svn: 280240
2016-08-31 13:36:36 +00:00
Sjoerd Meijer f2392f69d5 Revision r280064 adds new options -fdenormal-fp-math and passes through option
-ffast-math to CC1, but it included a wrong llvm regression tests which was
removed in r280065.  Although regression test noexceptionsfpmath.c makes sure
-fno-trapping-math ends up as a function attribute, this adds a test that
explicitly checks the driver output for -fno-trapping-math.

llvm-svn: 280227
2016-08-31 12:31:03 +00:00
James Molloy 75b1fb9b9e Attempt to pacify buildbots after r280217
These clang tests check diagnostics from the backend by giving it an unvectorizable loop. This loop is now vectorized :/

Make it really unvectorizable by making it unprofitable to ifconvert.

llvm-svn: 280220
2016-08-31 11:01:41 +00:00
Igor Kudrin fc05ee344c [Coverage] Suppress creating a code region if the same area is covered by an expansion region.
In most cases these code regions are just redundant, but sometimes they
could be assigned to the counter of the parent code region instead of
the counter of the nested block.

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

llvm-svn: 280199
2016-08-31 07:04:16 +00:00
Craig Topper a815f488d5 [AVX-512] Implement masked floating point logical operations with native IR and remove the builtins.
llvm-svn: 280197
2016-08-31 05:38:58 +00:00
Craig Topper d0681d528d [X86] Use v2i64 vectors to implement _mm_and/andn/or/xor_pd.
These will be reused when removing some builtins from avx512vldqintrin.h and this will make the tests for that change show a better number of vector elements.

llvm-svn: 280196
2016-08-31 05:38:55 +00:00
Richard Smith 54f18e8a85 PR12298 et al: don't recursively instantiate a template specialization from
within the instantiation of that same specialization. This could previously
happen for eagerly-instantiated function templates, variable templates,
exception specifications, default arguments, and a handful of other cases.

We still have an issue here for default template arguments that recursively
make use of themselves and likewise for substitution into the type of a
non-type template parameter, but in those cases we're producing a different
entity each time, so they should instead be caught by the instantiation depth
limit. However, currently we will typically run out of stack before we reach
it. :(

llvm-svn: 280190
2016-08-31 02:15:21 +00:00
Richard Trieu 5ed6fe739f Concatenate two FileCheck lines in a test.
'cc1' is a valid sequence of hexadecimal and sometimes can occur in the path
when testing.  This can lead to FileCheck matching the incorrect occurance
of the 'cc1' string and causing a test failure.  Join two adjacent flags
together into one check to prevent this.

llvm-svn: 280189
2016-08-31 01:57:12 +00:00