Commit Graph

73899 Commits

Author SHA1 Message Date
George Karpenkov fdbc1bf62e [analyzer] Remove accidentally committed lines.
llvm-svn: 334965
2018-06-18 17:59:03 +00:00
Tomasz Krupa 83ba6fa98d Fix a bug introduced by rL334850
Summary: All *_sqrt_round_s[s|d] intrinsics should execute a square root on
zeroth element from B (Ops[1]) and insert in to A (Ops[0]), not the other way around.

Reviewers: itaraban, craig.topper

Reviewed By: craig.topper

Subscribers: craig.topper, cfe-commits

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

llvm-svn: 334964
2018-06-18 17:57:05 +00:00
Alexey Bataev 7b55d2d554 [OPENMP, NVPTX] Emit simple reduction if requested.
If simple reduction is requested, use the simple reduction instead of
the runtime functions calls.

llvm-svn: 334962
2018-06-18 17:11:45 +00:00
Paul Robinson 7555c589af Update copyright year to 2018.
llvm-svn: 334936
2018-06-18 12:22:17 +00:00
Kristof Umann 30f086565c [analyzer] Checker for uninitialized C++ objects
This checker analyzes C++ constructor calls, and reports uninitialized fields.

Due to the nature of this problem (uninitialized fields after an object
construction), this checker doesn't search for bugs, but rather is a tool to
enforce a specific programming model where every field needs to be initialized.

This checker lands in alpha for now, and a number of followup patches will be
made to reduce false negatives and to make it easier for the user to understand
what rules the checker relies on, eg. whether a derived class' constructor is
responsible for initializing inherited data members or whether it should be
handled in the base class' constructor.

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

llvm-svn: 334935
2018-06-18 11:50:17 +00:00
David L. Jones 82e08bd776 [ASTMatchers] Add support for matching the type of a friend decl.
This allows matchers like:

  friendDecl(hasType(cxxRecordDecl(...)))
  friendDecl(hasType(asString(...)))

It seems that hasType is probably the most reasonable narrowing matcher to
overload, since it is already used to narrow to other declaration kinds.

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

Reviewers: klimek, aaron.ballman

Subscribers: cfe-commits
llvm-svn: 334930
2018-06-18 09:23:08 +00:00
David L. Jones 8f7adcd7fb [ASTMatchers] Don't assert-fail in specifiesTypeLoc().
The specifiesTypeLoc() matcher narrows a nestedNameSpecifier matcher based on a
typeloc within the NNS. However, the matcher does not guard against NNS which
are a namespace, and cause getTypeLoc to assert-fail.

llvm-svn: 334929
2018-06-18 08:59:16 +00:00
Mikhail R. Gadelha e7f703804d [analyzer] Add method to the generic SMT API to dump the SMT formula
Summary:
New method dump the SMT formula and the Z3 implementation.

There is no test because I only used it for debugging.

However, if requested, I can add an option to the static analyzer to dump the formula (whole program? per path?), maybe something like the trimmed graph but for SMT formulas.

Reviewers: NoQ, george.karpenkov, ddcc

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin

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

llvm-svn: 334891
2018-06-16 14:36:17 +00:00
Yaxun Liu a505635fdb Add RUN line for amdgcn to lit test conditional-temporaries.cpp
This is partial re-commit of r332982.

llvm-svn: 334886
2018-06-16 12:28:51 +00:00
Yaxun Liu cbd80f49d5 Call CreateTempAllocaWithoutCast for ActiveFlag
This is partial re-commit of r332982.

llvm-svn: 334879
2018-06-16 01:20:52 +00:00
Fangrui Song 4c35d598e0 [docs] -fsanitize=cfi only allowed with -fvisibility=
llvm-svn: 334870
2018-06-15 23:11:18 +00:00
Bruno Cardoso Lopes 5f11e128b0 [Modules] Improve .Private fix-its to handle 'explicit' and 'framework'
When in the context of suggestion the fix-it from .Private to _Private
for private modules, trim off the 'explicit' and add 'framework' when
appropriate.

rdar://problem/41030554

llvm-svn: 334859
2018-06-15 20:13:28 +00:00
Tomasz Krupa f1792bb3d6 [X86] Lowering sqrt intrinsics to native IR
Reviewers: craig.topper, spatel, RKSimon, igorb, uriel.k

Reviewed By: craig.topper

Subscribers: tkrupa, cfe-commits

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

llvm-svn: 334850
2018-06-15 18:05:59 +00:00
Craig Topper 4217d170aa [X86] __builtin_ia32_prord512_mask, __builtin_ia32_prorq512_mask, __builtin_ia32_shufpd should only accept an ICE constant.
The rotates also need to check for the immediate to fit in 8-bits. Shufpd already checks its immediate range.

llvm-svn: 334847
2018-06-15 17:40:37 +00:00
Craig Topper 03a1d48a41 [X86] The immediate argument to getmantpd*_mask should be an ICE and it should only be 4 bits wide.
We already checked this for the scalar version, but missed the vector version somehow.

llvm-svn: 334846
2018-06-15 17:03:32 +00:00
Yonghong Song 6927cf0c2a bpf: recognize target specific option -mattr=dwarfris in clang
The following is the usage example with clang:
  bash-4.2$ clang -target bpf -O2 -g -c -Xclang -target-feature -Xclang +dwarfris t.c
  bash-4.2$ llvm-objdump -S -d t.o

  t.o:    file format ELF64-BPF

  Disassembly of section .text:
  test:
  ; int test(void) {
       0:       b7 00 00 00 00 00 00 00         r0 = 0
  ; return 0;
         1:       95 00 00 00 00 00 00 00         exit
  bash-4.2$ cat t.c
  int test(void) {
    return 0;
  }
  bash-4.2$

Signed-off-by: Yonghong Song <yhs@fb.com>
llvm-svn: 334839
2018-06-15 15:53:31 +00:00
Yaxun Liu aefdb8ed34 [NFC] Add CreateMemTempWithoutCast and CreateTempAllocaWithoutCast
This is partial re-commit of r332982

llvm-svn: 334837
2018-06-15 15:33:22 +00:00
Luke Geeson da2b2e8c26 [AArch64] Reverted rC334696 with Clang VCVTA test fix
llvm-svn: 334820
2018-06-15 10:10:45 +00:00
Adam Balogh e4192a86dc [ASTImporter] Corrected diagnostic client handling in tests.
ASTImporter tests may produce source file related warnings, the diagnostic
client should be in correct state to handle it. Added 'beginSourceFile' to set
the client state.

Patch by: Balázs Kéri

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

llvm-svn: 334804
2018-06-15 06:45:39 +00:00
David L. Jones 5de2272174 [Format] Do not use a global static value for EOF within ScopedMacroState.
ScopedMacroState injects its own EOF token under certain conditions, and the
returned token may be modified in several different locations. If multiple
reformat operations are started in different threads, then they will both see
the same fake EOF token, and may both try to modify it. This is a data race.

This bug was caught with tsan.

Reviewers: klimek

Subscribers: cfe-commits

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

llvm-svn: 334801
2018-06-15 06:08:54 +00:00
Shoaib Meenai fce4616189 [cmake] Add linker detection for Apple platforms
LLVM currently assumes that Apple platforms will always use ld64. In the
future, LLD Mach-O might also be supported, so add the beginnings of
linker detection support. ld64 is currently the only detected linker,
since `ld64.lld -v` doesn't yield any useful version output, but we can
add that detection later, and in the meantime it's still useful to have
the ld64 identification.

Switch clang's order file check to use this new detection rather than
just checking for the presence of an ld64 executable.

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

llvm-svn: 334780
2018-06-14 23:26:33 +00:00
David Blaikie bc023c968c Modules: Fix implicit output file for .cppm to .pcm instead of stdout
This code was introduced back in r178148, a change to introduce
-module-file-info - which still exists & seems like it's still tested (&
this change didn't cause any of those tests to fail).

It doesn't look like this change was necessary there - since it's about
pcm output, whereas -module-file-info looks like it's for pcm /input/.
So I'm not really sure what the original motivation was.

I'm open to ideas though, if it turns out the original change was
necessary/useful.

llvm-svn: 334778
2018-06-14 23:09:06 +00:00
Craig Topper 31730ae761 [X86] Rename __builtin_ia32_pslldqi128 to __builtin_ia32_pslldqi128_byteshift and similar for other sizes. Remove the multiply by 8 from the header files.
The previous names took the shift amount in bits to match gcc and required a multiply by 8 in the header. This creates a misleading error message when we check the range of the immediate to the builtin since the allowed range also got multiplied by 8.

This commit changes the builtins to use a byte shift amount to match the underlying instruction and the Intel intrinsic.

Fixes the remaining issue from PR37795.

llvm-svn: 334773
2018-06-14 22:02:35 +00:00
Richard Smith c00e44656d [c++17] If a class inherits virtual functions from a base class, it is
not an aggregtae.

llvm-svn: 334763
2018-06-14 20:03:22 +00:00
Craig Topper b521dc3acf [X86] Add inline assembly versions of _InterlockedExchange_HLEAcquire/Release and _InterlockedCompareExchange_HLEAcquire/Release for MSVC compatibility.
Clang/LLVM doesn't have a way to pass an HLE hint through to the X86 backend to emit HLE prefixed instructions. So this is a good short term fix.

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

llvm-svn: 334751
2018-06-14 18:43:52 +00:00
Bruno Cardoso Lopes f56ef90e26 [CMAKE][c-index-test] Honor CMAKE_OSX_SYSROOT to compute include dir for libxml2
On MacOS, if CMAKE_OSX_SYSROOT is used and the user has command line tools
installed, we currently get the include path for libxml2 as
/usr/include/libxml2, instead of ${CMAKE_OSX_SYSROOT}/usr/include/libxml2.

Make it consistent on MacOS by prefixing ${CMAKE_OSX_SYSROOT} when
possible.

rdar://problem/41103601

llvm-svn: 334747
2018-06-14 18:20:04 +00:00
Tomasz Krupa 82aa42af49 [X86] Lowering Mask Scalar intrinsics to native IR (Clang part)
Summary: Lowering add, sub, mul, and div mask scalar intrinsic calls
to native IR.

Reviewers: craig.topper, RKSimon, spatel, sroland

Reviewed By: craig.topper

Subscribers: cfe-commits

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

llvm-svn: 334741
2018-06-14 17:36:23 +00:00
Ben Hamilton 1ab722ed17 [clang-format] Disable AlwaysBreakBeforeMultilineStrings in Google style for Objective-C 📜
Contributed by @stephanemoore.

Reviewers: benhamilton, jolesiak, djasper

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

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

llvm-svn: 334739
2018-06-14 17:30:10 +00:00
Leonard Chan ab80f3c8b7 [Fixed Point Arithmetic] Addition of the remaining fixed point types and their saturated equivalents
This diff includes changes for the remaining _Fract and _Sat fixed point types.

```
signed short _Fract s_short_fract;
signed _Fract s_fract;
signed long _Fract s_long_fract;
unsigned short _Fract u_short_fract;
unsigned _Fract u_fract;
unsigned long _Fract u_long_fract;

// Aliased fixed point types
short _Accum short_accum;
_Accum accum;
long _Accum long_accum;
short _Fract short_fract;
_Fract fract;
long _Fract long_fract;

// Saturated fixed point types
_Sat signed short _Accum sat_s_short_accum;
_Sat signed _Accum sat_s_accum;
_Sat signed long _Accum sat_s_long_accum;
_Sat unsigned short _Accum sat_u_short_accum;
_Sat unsigned _Accum sat_u_accum;
_Sat unsigned long _Accum sat_u_long_accum;
_Sat signed short _Fract sat_s_short_fract;
_Sat signed _Fract sat_s_fract;
_Sat signed long _Fract sat_s_long_fract;
_Sat unsigned short _Fract sat_u_short_fract;
_Sat unsigned _Fract sat_u_fract;
_Sat unsigned long _Fract sat_u_long_fract;

// Aliased saturated fixed point types
_Sat short _Accum sat_short_accum;
_Sat _Accum sat_accum;
_Sat long _Accum sat_long_accum;
_Sat short _Fract sat_short_fract;
_Sat _Fract sat_fract;
_Sat long _Fract sat_long_fract;
```

This diff only allows for declaration of these fixed point types. Assignment and other operations done on fixed point types according to http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf will be added in future patches.

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

llvm-svn: 334718
2018-06-14 14:53:51 +00:00
Francois Ferrand 767e152165 clang-format: Fix documentation generation
Summary:
It seems that the changes done to `ClangFormatStyleOptions.rst` @334408 are causing the generation of the documentation to fail, with the following error:

  Warning, treated as error:
    /llvm/tools/clang/docs/ClangFormatStyleOptions.rst:1060: WARNING: Definition list ends without a blank line; unexpected unindent.

This is due to missing indent in some code block, and fixed by this patch.

Reviewers: krasimir, djasper, klimek

Reviewed By: krasimir

Subscribers: cfe-commits

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

llvm-svn: 334709
2018-06-14 13:32:14 +00:00
Sven van Haastregt e6e76fd839 [OpenCL] Support new/delete in Sema
Reject uses of the default new/delete operators with a diagnostic
instead of a crash in OpenCL C++ mode and accept user-defined forms.

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

llvm-svn: 334700
2018-06-14 09:51:54 +00:00
Luke Geeson bb399f8013 [AArch64] reverting rC334693 due to build failures
llvm-svn: 334696
2018-06-14 08:59:33 +00:00
Luke Geeson 010bbbf390 [AArch64] Added support for the vcvta_u16_f16 instrinsic for FP16 Armv8.2-A
llvm-svn: 334693
2018-06-14 08:28:56 +00:00
Hans Wennborg bfc3406530 [clang-format] Add SpaceBeforeCpp11BracedList option.
WebKit C++ style for object initialization is as follows:

  Foo foo { bar };

Yet using clang-format -style=webkit changes this to:

  Foo foo{ bar };

As there is no existing combination of rules that will ensure a space
before a braced list in this fashion, this patch adds a new
SpaceBeforeCpp11BracedList rule.

Patch by Ross Kirsling!

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

llvm-svn: 334692
2018-06-14 08:01:09 +00:00
Artem Dergachev f28d7f1721 [analyzer] Re-enable C++17-specific RVO construction contexts.
Not contexts themselves, but rather support for them in the analyzer.

Such construction contexts appear when C++17 mandatory copy elision occurs
while returning an object from a function, and presence of a destructor causes
a CXXBindTemporaryExpr to appear in the AST.

Additionally, such construction contexts may be chained, because a return-value
construction context doesn't really explain where the object is being returned
into, but only points to the parent stack frame, where the object may be
consumed by literally anything including another return statement. This
behavior is now modeled correctly by the analyzer as long as the object is not
returned beyond the boundaries of the analysis.

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

llvm-svn: 334684
2018-06-14 01:59:35 +00:00
Artem Dergachev 53b8ce0edb [analyzer] Re-enable C++17-specific variable and member construction contexts.
Not contexts themselves, but rather support for them in the analyzer.

Such construction contexts appear when C++17 mandatory copy elision occurs
during initialization, and presence of a destructor causes a
CXXBindTemporaryExpr to appear in the AST.

Similar C++17-specific constructors for return values are still to be supported.

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

llvm-svn: 334683
2018-06-14 01:54:21 +00:00
Artem Dergachev a84374dc0e [analyzer] Track class member initializer constructors path-sensitively.
The reasoning behind this change is similar to the previous commit, r334681.
Because members are already in scope when construction occurs, we are not
suffering from liveness problems, but we still want to figure out if the object
was constructed with construction context, because in this case we'll be able
to avoid trivial copy, which we don't always model perfectly. It'd also have
more importance when copy elision is implemented.

This also gets rid of the old CFG look-behind mechanism.

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

llvm-svn: 334682
2018-06-14 01:40:49 +00:00
Artem Dergachev 1fe52474d2 [analyzer] pr37270: Track constructor target region, even if just a variable.
The very idea of construction context implies that first the object is
constructed, and then later, in a separate moment of time, the constructed
object goes into scope, i.e. becomes "live".

Most construction contexts require path-sensitive tracking of the constructed
object region in order to compute the outer expressions accordingly before
the object becomes live.

Semantics of simple variable construction contexts don't immediately require
that such tracking happens in path-sensitive manner, but shortcomings of the
analyzer force us to track it path-sensitively as well. Namely, whether
construction context was available at all during construction is a
path-sensitive information. Additionally, path-sensitive tracking takes care of
our liveness problems that kick in as the temporal gap between construction and
going-into-scope becomes larger (eg., due to copy elision).

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

llvm-svn: 334681
2018-06-14 01:32:46 +00:00
Artem Dergachev 239452ca3e [analyzer] NFC: Merge code for finding and tracking construction target.
When analyzing C++ code, a common operation in the analyzer is to discover
target region for object construction by looking at CFG metadata ("construction
contexts"), and then track the region path-sensitively until object construction
is resolved, where the amount of information, again, depends on construction
context.

Scan construction context only once for both purposes.

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

llvm-svn: 334678
2018-06-14 01:20:12 +00:00
Richard Smith 20eb9baa6d P0096R5, P0941R2: Update to match latest feature test macro specification.
llvm-svn: 334677
2018-06-14 00:40:20 +00:00
Richard Smith 3e3e2e9f82 [www] Update cxx_status page for Rapperswil motions.
llvm-svn: 334674
2018-06-14 00:05:28 +00:00
Peter Collingbourne d86ca94901 Driver: De-duplicate some code. NFCI.
llvm-svn: 334673
2018-06-14 00:03:41 +00:00
Peter Collingbourne b8b248cf2e docs: Add a missing LTO visibility reference.
llvm-svn: 334671
2018-06-13 23:21:02 +00:00
Peter Collingbourne 282ad770ce docs: Correct some misstatements in the control flow integrity docs.
These were true at one point but haven't been true for a long time.

llvm-svn: 334669
2018-06-13 23:18:26 +00:00
Erich Keane 436e5cc0f1 Simplify test from r334650
No reason to have the 'bool' as an intermediary value,
simply use the fact that curley braces enforce eval order.

llvm-svn: 334652
2018-06-13 20:47:12 +00:00
Erich Keane 00958270aa Implement constexpr __builtin_*_overflow
As requested here:https://bugs.llvm.org/show_bug.cgi?id=37633
permit the __builtin_*_overflow builtins in constexpr functions.

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

llvm-svn: 334650
2018-06-13 20:43:27 +00:00
Mandeep Singh Grang 2d28383097 [COFF] Add ARM64 intrinsics: __yield, __wfe, __wfi, __sev, __sevl
Summary: These intrinsics result in hint instructions. They are provided here for MSVC ARM64 compatibility.

Reviewers: mstorsjo, compnerd, javed.absar

Reviewed By: mstorsjo

Subscribers: kristof.beyls, chrib, cfe-commits

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

llvm-svn: 334639
2018-06-13 18:49:35 +00:00
George Karpenkov 0cba5549ef [analyzer] Fix offset overflow check in MemRegion
rdar://39593879
https://bugs.llvm.org/show_bug.cgi?id=37142

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

llvm-svn: 334636
2018-06-13 18:32:19 +00:00
Sanjay Patel 1d7ed94439 [CodeGen] make nan builtins pure rather than const (PR37778)
https://bugs.llvm.org/show_bug.cgi?id=37778
...shows a miscompile resulting from marking nan builtins as 'const'.

The nan libcalls/builtins take a pointer argument:
http://www.cplusplus.com/reference/cmath/nan-function/
...and the chars dereferenced by that arg are used to fill in the NaN constant payload bits.

"const" means that the pointer argument isn't dereferenced. That's translated to "readnone" in LLVM.
"pure" means that the pointer argument may be dereferenced. That's translated to "readonly" in LLVM.

This change prevents the IR optimizer from killing the lead-up to the nan call here:

double a() {
  char buf[4];
  buf[0] = buf[1] = buf[2] = '9';
  buf[3] = '\0';
  return __builtin_nan(buf);
}

...the optimizer isn't currently able to simplify this to a constant as we might hope, 
but this patch should solve the miscompile.

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

llvm-svn: 334628
2018-06-13 17:54:52 +00:00
Benjamin Kramer ffe60e0403 [Basic] Fix -Wreorder warning
Just use field initializers that don't suffer from this problem

llvm-svn: 334619
2018-06-13 16:45:12 +00:00