Commit Graph

72689 Commits

Author SHA1 Message Date
Rafael Espindola 796d4a885d Always set dso_local in CodeGenModule::setDSOLocal.
This shouldn't change any results for now, but is more consistent with
how we set dllimport/dllexport and will make future changes easier.

Since clang produces IR as it parses, it can find out mid file that
something is dllimport. When that happens we have to drop
dso_local. This is not a problem right now because
CodeGenModule::setDSOLocal is called from relatively few places at
the moment.

llvm-svn: 326527
2018-03-02 01:29:51 +00:00
George Karpenkov 0ffcaf7437 [analyzer] Prevent crashing in NonNullParamChecker
https://bugs.llvm.org/show_bug.cgi?id=36381
rdar://37543426

Turns out, the type passed for the lambda capture was incorrect.
One more argument to abandon the getSVal overload which does not require the
type information.

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

llvm-svn: 326520
2018-03-02 00:55:59 +00:00
Eugene Zelenko 534673a560 [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 326519
2018-03-02 00:54:51 +00:00
George Karpenkov 7596b82102 [analyzer] [NFC] [tests] Make test more resilient to changes in exploration strategy
llvm-svn: 326518
2018-03-02 00:54:05 +00:00
Heejin Ahn 8b6af22e60 [WebAssembly] Add exception handling option
Summary: Add exception handling option to clang.

Reviewers: dschuff

Subscribers: jfb, sbc100, jgravelle-google, sunfish, cfe-commits

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

llvm-svn: 326517
2018-03-02 00:39:16 +00:00
David L. Jones 13d5a87658 [NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying r326501.)
When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc
   comments or not.
2. "Maybe-doc" comments, like <, !, etc, are saved as such, instead of marking
   them as ordinary comments. The maybe-doc type of comment is never saved
   otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Subscribers: cfe-commits
llvm-svn: 326512
2018-03-02 00:07:45 +00:00
David L. Jones e78dfe5f55 Revert r326501 due to buildbot breakage.
Original change:

[NFC] Move CommentOpts checks to the call sites that depend on it.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc comments or not.
2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of marking them as ordinary comments. The maybe-doc type of comment is never saved otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

llvm-svn: 326508
2018-03-01 23:14:00 +00:00
David L. Jones 40388bdfb9 [NFC] Move CommentOpts checks to the call sites that depend on it.
When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

 1. All comments are saved during parsing, regardless of whether they are doc
    comments or not.
 2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of
    marking them as ordinary comments. The maybe-doc type of comment is never
    saved otherwise. (Warning on these is the impetus of -Wdocumentation.)
 3. All comments are treated as doc comments in ASTContext, even if they are
    ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 326501
2018-03-01 22:41:53 +00:00
Chih-Hung Hsieh ca552b8d31 [Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS
Since LLVM r326341, default EmulatedTLS mode is decided in backend
according to target triple. Any front-end should pass -f[no]-emulated-tls
to backend and set up ExplicitEmulatedTLS only when the flags are used.

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

llvm-svn: 326499
2018-03-01 22:26:19 +00:00
Richard Smith 05ce1d3944 [modules] Don't diagnose "redefinition" of a friend with a pending definition
if the other definition is a merged copy of the same function.

llvm-svn: 326496
2018-03-01 22:20:13 +00:00
Richard Smith d9d42f9cc6 [www] Capitalize "Clang" when referring to the project, and generalize the
introduction on the front page page.

We still use the lowercase "clang" spelling when referring to the driver binary.

llvm-svn: 326493
2018-03-01 22:01:06 +00:00
Martin Storsjo 87c2ad29ee [RecordLayout] Only assert that fundamental type sizes are power of two on MSVC
Make types with sizes that aren't a power of two an error (that can
be disabled) in structs with ms_struct layout, except on mingw where
the situation is quite likely to occur and GCC handles it silently.

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

llvm-svn: 326476
2018-03-01 20:22:57 +00:00
Saleem Abdulrasool cc6238158a Driver: hoist `-fno-rtti-data` to a driver flag
This is needed for building with the GNU driver (`clang++`) when
targeting Windows and using msvcprt.  This flag is the equivalent of
`/GR-`.

llvm-svn: 326469
2018-03-01 19:13:43 +00:00
Artem Dergachev 61199443fe [analyzer] Enable cfg-temporary-dtors by default.
Don't enable c++-temp-dtor-inlining by default yet, due to this reference
counting pointe problem.

Otherwise the new mode seems stable and allows us to incrementally fix C++
problems in much less hacky ways.

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

llvm-svn: 326461
2018-03-01 18:53:13 +00:00
Ilya Biryukov 8b9b3bd07c Resubmit [analyzer] Support for naive cross translation unit analysis
Originally submitted as r326323 and r326324.
Reverted in r326432.

Reverting the commit was a mistake.
The breakage was due to invalid build files in our internal buildsystem,
CMakeLists did not have any cyclic dependencies.

llvm-svn: 326439
2018-03-01 14:54:16 +00:00
Hans Wennborg 1bab70109b UsersManual: improve the clang-cl text some more
llvm-svn: 326438
2018-03-01 14:48:19 +00:00
Hans Wennborg 69d6d7a4d8 UsersManual: beef up the clang-cl text a little
llvm-svn: 326434
2018-03-01 14:00:19 +00:00
Ilya Biryukov d49e75afbd Revert "[analyzer] Support for naive cross translation unit analysis"
Also revert "[analyzer] Fix a compiler warning"
This reverts commits r326323 and r326324.

Reason: the commits introduced a cyclic dependency in the build graph.
This happens to work with cmake, but breaks out internal integrate.

llvm-svn: 326432
2018-03-01 12:43:39 +00:00
Francois Ferrand 2a9ea781f3 [clang-format] Add SpaceBeforeColon option
Summary:
When disabled, this option allows removing the space before colon,
making it act more like the semi-colon. When enabled (default), the
current behavior is not affected.

This mostly affects C++11 loop, initializer list, inheritance list and
container literals:

  class Foo: Bar {}
  Foo::Foo(): a(a) {}
  for (auto i: myList) {}
  f({a: 1, b: 2, c: 3});

Reviewers: krasimir, djasper

Reviewed By: djasper

Subscribers: xvallspl, teemperor, karies, cfe-commits, klimek

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

llvm-svn: 326426
2018-03-01 10:09:13 +00:00
Serge Pavlov e6e534ca22 Function definition may have uninstantiated body
Current implementation of `FunctionDecl::isDefined` does not take into
account redeclarations that do not have bodies, but the bodies can be
instantiated from corresponding templated definition. This behavior does
not allow to detect function redefinition in the cases where friend
functions is defined in class templates. For instance, the code:
```
    template<typename T> struct X { friend void f() {} };
    X<int> xi;
    void f() {}
```
compiles successfully but must fail due to redefinition of `f`. The
declaration of the friend `f` is created when the containing template
`X` is instantiated, but it does not have a body as per 14.5.4p4
because `f` is not odr-used.

With this change the function `Sema::CheckForFunctionRedefinition`
considers functions with uninstantiated bodies as definitions.

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

llvm-svn: 326419
2018-03-01 07:04:11 +00:00
George Burgess IV 00f70bd933 Remove redundant casts. NFC
So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and
`dyn_cast`s for fun. This is a portion of what it found for clang; I
plan to do similar cleanups in LLVM and other subprojects when I find
time.

Because of the volume of changes, I explicitly avoided making any change
that wasn't highly local and obviously correct to me (e.g. we still have
a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading
is a thing and the cast<Bar> did actually change the type -- just up the
class hierarchy).

I also tried to leave the types we were cast<>ing to somewhere nearby,
in cases where it wasn't locally obvious what we were dealing with
before.

llvm-svn: 326416
2018-03-01 05:43:23 +00:00
George Karpenkov dc0abcb87b [analyzer] [tests] Create a directory for the log file
llvm-svn: 326408
2018-03-01 02:18:54 +00:00
Artem Dergachev 4579bad86c [analyzer] Add a checker for mmap()s which are both writable and executable.
This is a security check that warns when both PROT_WRITE and PROT_EXEC are
set during mmap(). If mmap()ed memory is both writable and executable, it makes
it easier for the attacker to execute arbitrary code when contents of this
memory are compromised. Some applications require such mmap()s though, such as
different sorts of JIT.

Re-applied after a revert in r324167.

Temporarily stays in the alpha package because it needs a better way of
determining macro values that are not immediately available in the AST.

Patch by David Carlier!

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

llvm-svn: 326405
2018-03-01 01:27:46 +00:00
Artem Dergachev 6603052235 [CFG] [analyzer] Recall that we only skip NoOp casts in construction contexts.
For now. We should also add support for ConstructorConversion casts as presented
in the attached test case, but this requires more changes because AST around
them seems different.

The check was originally present but was accidentally lost during r326021.

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

llvm-svn: 326402
2018-03-01 01:09:24 +00:00
Rafael Espindola b735004615 Start setting dllimport/dllexport in setGVProperties.
This is the next step in setting dso_local for COFF.

The patches changes setGVProperties to first set dllimport/dllexport
and changes a few cases that were setting dllimport/dllexport
manually. With this a few more GVs are marked dso_local.

llvm-svn: 326397
2018-03-01 00:35:47 +00:00
Rafael Espindola 75c649c960 Pass a GlobalDecl to SetCommonAttributes. NFC.
Part of D43900.

llvm-svn: 326392
2018-03-01 00:06:55 +00:00
Rafael Espindola e4e78135ac Inline a trivial function. NFC.
llvm-svn: 326391
2018-03-01 00:00:02 +00:00
Rafael Espindola 285271cb78 Pass a GlobalDecl to setNonAliasAttributes. NFC.
Also part of D43900.

llvm-svn: 326388
2018-02-28 23:54:23 +00:00
Rafael Espindola 51ec5a9ce3 Pass a GlobalDecl to SetInternalFunctionAttributes. NFC.
This just reduces the noise in a followup patch.

Part of D43900.

llvm-svn: 326385
2018-02-28 23:46:35 +00:00
Kostya Serebryany f19c797531 [hwasan] update the asm snippet in the docs to match the current default behaviour
llvm-svn: 326373
2018-02-28 21:58:19 +00:00
Nico Weber 926bbc0256 Attempt to fix cl-include.c on Windows.
llvm-svn: 326370
2018-02-28 20:58:06 +00:00
Carlo Bertolli 79712097c7 [OpenMP] Extend NVPTX SPMD implementation of combined constructs
Differential Revision: https://reviews.llvm.org/D43852

This patch extends the SPMD implementation to all target constructs and guards this implementation under a new flag.

llvm-svn: 326368
2018-02-28 20:48:35 +00:00
Krzysztof Parzyszek fde8b04235 [Hexagon] Add -ffixed-r19 driver option and translate it to +reserved-r19
llvm-svn: 326366
2018-02-28 20:31:55 +00:00
Saleem Abdulrasool f181f1a6a2 CodeGenObjCXX: handle inalloca appropriately for msgSend variant
objc_msgSend_stret takes a hidden parameter for the returned structure's
address for the construction.  When the function signature is rewritten
for the inalloca passing, the return type is no longer marked as
indirect but rather inalloca stret.  This enhances the test for the
indirect return to check for that case as well.  This fixes the
incorrect return classification for Windows x86.

llvm-svn: 326362
2018-02-28 20:16:12 +00:00
Nico Weber 07f0a52c7f [clang-cl] Implement /X
/X makes cl stop looking in %INCLUDE%. Implement this for clang-cl.

As it turns out, the return in ToolChains/MSVC.cpp, AddClangSystemIncludeArgs()
for -nostdlibinc is already in the right place (but -nostdlibinc isn't exposed
by clang-cl), so just alias /X to that.

https://reviews.llvm.org/D43888

llvm-svn: 326357
2018-02-28 19:49:07 +00:00
Nico Weber b3897eb6f2 Fix gcc -Wreturn-type warnings after r326307.
llvm-svn: 326355
2018-02-28 19:28:47 +00:00
Jonas Hahnfeld e768132f94 [CUDA] Include single GPU binary, NFCI.
Binaries for multiple architectures are combined by fatbinary,
so the current code was effectively not needed.

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

llvm-svn: 326342
2018-02-28 17:53:46 +00:00
Joel E. Denny 6053ec22eb Test commit access: apply clang-format suggestion
llvm-svn: 326332
2018-02-28 16:57:33 +00:00
Gabor Horvath 7260932459 [analyzer] Fix a compiler warning
llvm-svn: 326324
2018-02-28 14:01:48 +00:00
Gabor Horvath eb0584bee4 [analyzer] Support for naive cross translation unit analysis
The aim of this patch is to be minimal to enable incremental development of
the feature on the top of the tree. This patch should be an NFC when the
feature is turned off. It is turned off by default and still considered as
experimental.

Technical details are available in the EuroLLVM Talk: 
http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#7

Note that the initial prototype was done by A. Sidorin et al.: http://lists.llvm.org/pipermail/cfe-dev/2015-October/045730.html

Contributions to the measurements and the new version of the code: Peter Szecsi, Zoltan Gera, Daniel Krupp, Kareem Khazem.

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

llvm-svn: 326323
2018-02-28 13:23:10 +00:00
Akira Hatanaka 7275da0f2e [ObjC] Allow declaring __strong pointer fields in structs in Objective-C
ARC mode.

Declaring __strong pointer fields in structs was not allowed in
Objective-C ARC until now because that would make the struct non-trivial
to default-initialize, copy/move, and destroy, which is not something C
was designed to do. This patch lifts that restriction.

Special functions for non-trivial C structs are synthesized that are
needed to default-initialize, copy/move, and destroy the structs and
manage the ownership of the objects the __strong pointer fields point
to. Non-trivial structs passed to functions are destructed in the callee
function.

rdar://problem/33599681

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

llvm-svn: 326307
2018-02-28 07:15:55 +00:00
Richard Smith 77a9c60aa6 Fix a couple of cases where we would fail to correctly parse deduced class template specialization types.
Specifically, we would not properly parse these types within template arguments
(for non-type template parameters), and in tentative parses. Fixing both of
these essentially requires that we parse deduced template specialization types
as types in all contexts, even in template argument lists -- in particular,
tentative parsing may look ahead and annotate a deduced template specialization
type before we figure out that we're actually supposed to treat the tokens as a
template-name. We deal with this by simply permitting deduced template
specialization types when parsing template arguments, and converting them to
template template arguments.

llvm-svn: 326299
2018-02-28 03:02:23 +00:00
Richard Smith c1a40220b4 Update cxx_status to mark "SVN" items as "Clang 6" instead.
llvm-svn: 326298
2018-02-28 03:02:07 +00:00
George Karpenkov 3f560daf37 [analyzer] [tests] Write to logfile instead of stdout while updating
reference results

llvm-svn: 326295
2018-02-28 01:55:23 +00:00
Eugene Zelenko 5bc81eb980 [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 326292
2018-02-28 01:10:04 +00:00
Konstantin Zhuravlyov 419889e266 AMDGPU: Move run and check lines around to match processor order in AMDGPU.h
llvm-svn: 326278
2018-02-28 00:27:00 +00:00
Rafael Espindola bb333c26ed Inline trivial function. NFC.
llvm-svn: 326272
2018-02-28 00:14:18 +00:00
Rafael Espindola fa2fc906d2 Pass a GlobalDecl to setAliasAttributes. NFC.
This just makes a followup change easier to read.

llvm-svn: 326270
2018-02-28 00:06:01 +00:00
Aaron Ballman 48a533d005 Improve the way attribute argument printing happens for omitted optional arguments when pretty printing.
Patch by Joel Denny.

llvm-svn: 326266
2018-02-27 23:49:28 +00:00
Rafael Espindola 64393cfca0 Pass a GlobalDecl to setFunctionDefinitionAttributes. NFC.
This just makes a followup patch easier to read.

llvm-svn: 326265
2018-02-27 23:44:36 +00:00
Artem Dergachev f119bf99e5 [analyzer] UndefinedAssignmentChecker: Better warning message in implicit ctors.
When a class forgets to initialize a field in the constructor, and then gets
copied around, a warning is emitted that the value assigned to a specific field
is undefined.

When the copy/move constructor is implicit (not written out in the code) but not
trivial (is not a trivial memory copy, eg. because members have an explicit copy
constructor), the body of such constructor is auto-generated in the AST.
In this case the checker's warning message is squeezed at the top of
the class declaration, and it gets hard to guess which field is at fault.

Fix the warning message to include the name of the field.

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

llvm-svn: 326258
2018-02-27 22:05:55 +00:00
Konstantin Zhuravlyov d6b3453bdb AMDGPU: Define FP_FAST_FMA{F} macros for amdgcn
- Expand GK_*s (i.e. GFX6 -> GFX600, GFX601, etc.)
  - This allows us to choose features correctly in some cases (for example, fast fmaf is available on gfx600, but not gfx601)
- Move HasFMAF, HasFP64, HasLDEXPF to GPUInfo tables
- Add HasFastFMA, HasFastFMAF to GPUInfo tables
- Add missing tests

llvm-svn: 326254
2018-02-27 21:48:05 +00:00
Alexey Bataev 95c23e72da [OPENMP] Emit warning for non-trivial types in map clauses.
If the mapped type is non-trivial, the warning message is emitted for
better user experience.

llvm-svn: 326251
2018-02-27 21:31:11 +00:00
Artem Dergachev 5337efc69c [analyzer] MallocChecker: Suppress false positives in shared pointers.
Throw away MallocChecker warnings that occur after releasing a pointer within a
destructor (or its callees) after performing C11 atomic fetch_add or fetch_sub
within that destructor (or its callees).

This is an indication that the destructor's class is likely a
reference-counting pointer. The analyzer is not able to understand that the
original reference count is usually large enough to avoid most use-after-frees.

Even when the smart pointer is a local variable, we still have these false
positives that this patch suppresses, because the analyzer doesn't currently
support atomics well enough.

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

llvm-svn: 326249
2018-02-27 21:19:33 +00:00
Artem Dergachev 4449e7f008 [analyzer] Fix trivial copy for empty objects.
The SVal for any empty C++ object is an UnknownVal. Because RegionStore does
not have binding extents, binding an empty object to an UnknownVal may
potentially overwrite existing bindings at the same offset.

Therefore, when performing a trivial copy of an empty object, don't try to
take the value of the object and bind it to the copy. Doing nothing is accurate
enough, and it doesn't screw any existing bindings.

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

llvm-svn: 326247
2018-02-27 21:10:08 +00:00
Artem Dergachev 1e3dbd7a17 [analyzer] Track temporaries without construction contexts for destruction.
Sometimes it is not known at compile time which temporary objects will be
constructed, eg. 'x ? A() : B()' or 'C() || D()'. In this case we track which
temporary was constructed to know how to properly call the destructor.

Once the construction context for temporaries was introduced, we moved the
tracking code to the code that investigates the construction context.

Bring back the old mechanism because construction contexts are not always
available yet - eg. in the case where a temporary is constructed without a
constructor expression, eg. returned from a function by value. The mechanism
should still go away eventually.

Additionally, fix a bug in the temporary cleanup code for the case when
construction contexts are not available, which could lead to temporaries
staying in the program state and increasing memory consumption.

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

llvm-svn: 326246
2018-02-27 21:02:58 +00:00
Artem Dergachev f01831ebe9 [analyzer] Don't crash when dynamic type of a variable is set via placement new.
If a variable or an otherwise a concrete typed-value region is being
placement-new'ed into, its dynamic type may change in arbitrary manners. And
when the region is used, there may be a third type that's different from both
the static and the dynamic type. It cannot be *completely* different from the
dynamic type, but it may be a base class of the dynamic type - and in this case
there isn't (and shouldn't be) any indication anywhere in the AST that there is
a derived-to-base cast from the dynamic type to the third type.

Perform a generic cast (evalCast()) from the third type to the dynamic type
in this case. From the point of view of the SVal hierarchy, this would have
produced non-canonical SVals if we used such generic cast in the normal case,
but in this case there doesn't seem to be a better option.

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

llvm-svn: 326245
2018-02-27 20:54:40 +00:00
Artem Dergachev 8cd7961a0a [analyzer] Disable constructor inlining when lifetime extending through a field.
Automatic destructors are missing in the CFG in situations like

  const int &x = C().x;

For now it's better to disable construction inlining, because inlining
constructors while doing nothing on destructors is very bad.

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

llvm-svn: 326240
2018-02-27 20:14:06 +00:00
Artem Dergachev b7f53df0c2 [analyzer] Self-debug: Dump dynamic type info and taint with the program state.
Useful for debugging problems with dynamic type info and taint.

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

llvm-svn: 326239
2018-02-27 20:06:20 +00:00
Artem Dergachev 4068481bdb [CFG] NFC: Refactor ConstructionContext into a finite set of cases.
ConstructionContext is moved into a separate translation unit and is separated
into multiple classes. The "old" "raw" ConstructionContext is renamed into
ConstructionContextLayer - which corresponds to the idea of building the context
gradually layer-by-layer, but it isn't easy to use in the clients. Once
CXXConstructExpr is reached, layers that we've gathered so far are transformed
into the actual, "new-style" "flat" ConstructionContext, which is put into the
CFGConstructor element and has no layers whatsoever (until it actually needs
them, eg. aggregate initialization). The new-style ConstructionContext is
instead presented as a variety of sub-classes that enumerate different ways of
constructing an object in C++. There are 5 of these supported for now,
which is around a half of what needs to be supported.

The layer-by-layer buildup process is still a little bit weird, but it hides
all the weirdness in one place, that sounds like a good thing.

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

llvm-svn: 326238
2018-02-27 20:03:35 +00:00
Artem Dergachev 308e27ee9d [analyzer] Introduce correct lifetime extension behavior in simple cases.
This patch uses the reference to MaterializeTemporaryExpr stored in the
construction context since r326014 in order to model that expression correctly.

When modeling MaterializeTemporaryExpr, instead of copying the raw memory
contents from the sub-expression's rvalue to a completely new temporary region,
that we conjure up for the lack of better options, we now have the better
option to recall the region into which the object was originally constructed
and declare that region to be the value of the expression, which is semantically
correct.

This only works when the construction context is available, which is worked on
independently.

The temporary region's liveness (in the sense of removeDeadBindings) is extended
until the MaterializeTemporaryExpr is resolved, in order to keep the store
bindings around, because it wouldn't be referenced from anywhere else in the
program state.

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

llvm-svn: 326236
2018-02-27 19:47:49 +00:00
Martin Storsjo ca4a24eb72 [MinGW, CrossWindows] Allow passing -static together with -shared
In these combinations, link a DLL as usual, but pass -Bstatic instead
of -Bdynamic to indicate prefering static libraries.

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

llvm-svn: 326235
2018-02-27 19:42:19 +00:00
George Karpenkov d1400213f5 [analyzer] Remove redundant check
There is no point in assigning void just to crash on it in the next line

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

llvm-svn: 326234
2018-02-27 19:28:52 +00:00
George Karpenkov 53c1c10beb [analyzer] Only attempt to get the value of locations of known type
Fixes https://bugs.llvm.org/show_bug.cgi?id=36474

In general, getSVal API should be changed so that it does not crash on
some non-obvious conditions.
It should either be updated to require a type, or to return Optional<SVal>.

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

llvm-svn: 326233
2018-02-27 19:28:52 +00:00
George Karpenkov 482bf0f531 [analyzer] Quickfix: don't crash when runtime definition is not available.
llvm-svn: 326230
2018-02-27 19:19:49 +00:00
George Karpenkov fa5d70e623 [analyzer] Logging test quickfix #2.
llvm-svn: 326229
2018-02-27 19:19:43 +00:00
Krasimir Georgiev 0aa4b4cb2e [clang-format] Format operator key in protos
Summary: This fixes a glitch where ``operator: value`` in a text proto would mess up the underlying formatting since it gets parsed as a kw_operator instead of an identifier.

Subscribers: klimek, cfe-commits

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

llvm-svn: 326227
2018-02-27 19:07:47 +00:00
Kamil Rytarowski 9b1996ec86 Handle the NetBSD case in ToolChain::getOSLibName()
Return a new CompilerRT Path on NetBSD: "netbsd", instead of
getOS(), which returns a string like "netbsd8.9.12".

Sponsored by <The NetBSD Foundation>

llvm-svn: 326219
2018-02-27 18:16:47 +00:00
Alexey Bataev 2819260b35 [OPENMP] Allow multiple mappings for member expressions for pointers.
If several member expressions are mapped and they reference the same
address as a base, but access different members, this must be allowed.

llvm-svn: 326212
2018-02-27 17:42:00 +00:00
Ben Hamilton 6e066350d8 [clang-format] Tidy up new API guessLanguage()
Summary:
This fixes a few issues djasper@ brought up in his review of D43522.

Test Plan:
  make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 326205
2018-02-27 15:56:40 +00:00
Roman Lebedev 497fd98af2 Revert "[Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>"
This reverts commit rL326201

This broke gcc4.8 builds, compiler just segfaults:¬
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14909¬
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/22673¬

llvm-svn: 326204
2018-02-27 15:54:55 +00:00
Roman Lebedev 6017bf4f31 [Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>
Summary:
Noticed during review of D41102.

I'm not sure whether there are any principal reasons why it returns raw owning pointer,
or it is just a old code that was not updated post-C++11.

I'm not too sure what testing i should do, because `check-all` is not error clean here for some reason,
but it does not //appear// asif those failures are related to these changes.

This is clang part.
Clang-tools-extra part is D43780.

Reviewers: klimek, bkramer, alexfh, pcc

Reviewed By: alexfh

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 326201
2018-02-27 15:19:20 +00:00
Hans Wennborg 72c00dfa74 AttrDocs.td: fix some bad code-blocks
llvm-svn: 326195
2018-02-27 13:48:50 +00:00
Hans Wennborg 67a2f1e4dc AttrDocs.td: fix bad bullet list
llvm-svn: 326194
2018-02-27 13:48:47 +00:00
Hans Wennborg 7f58ee5792 AttrDocs.td: fix bad indent and code block
llvm-svn: 326193
2018-02-27 13:48:41 +00:00
Francois Ferrand a2484b251b clang-format: use AfterControlStatement to format ObjC control blocks
ObjC defines `@autoreleasepool` and `@synchronized` control blocks. These
used to be formatted according to the `AfterObjCDeclaration` brace-
wrapping flag, which is not very consistent.

This patch changes the behavior to use the `AfterControlStatement` flag
instead. This should not affect the behavior unless a custom brace
wrapping mode is used.

Reviewers: krasimir, djasper, klimek, benhamilton

Subscribers: cfe-commits

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

llvm-svn: 326192
2018-02-27 13:48:27 +00:00
Francois Ferrand ba91c3de38 clang-format: fix formatting of ObjC @synchronized blocks
Summary:
The blocks used to be formatted using the "default" behavior, and would
thus be mistaken for function calls followed by blocks: this could lead
to unexpected inlining of the block and extra line-break before the
opening brace.

They are now formatted similarly to `@autoreleasepool` blocks, as
expected:

  @synchronized(self) {
      f();
  }

Reviewers: krasimir, djasper, klimek

Subscribers: cfe-commits

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

llvm-svn: 326191
2018-02-27 13:48:21 +00:00
Martin Storsjo f9b3c67956 [test] Extend the Driver/mingw-msvcrt.c test with a -SAME check. NFC.
llvm-svn: 326180
2018-02-27 08:35:35 +00:00
Martin Storsjo 96b01bcfb6 [RecordLayout] Don't align to non-power-of-2 sizes when using -mms-bitfields
When targeting GNU/MinGW for i386, the size of the "long double" data
type is 12 bytes (while it is 8 bytes in MSVC). When building
with -mms-bitfields to have struct layouts match MSVC, data types
are laid out in a struct with alignment according to their size.
However, this doesn't make sense for the long double type, since
it doesn't match MSVC at all, and aligning to a non-power-of-2
size triggers other asserts later.

This matches what GCC does, aligning a long double to 4 bytes
in structs on i386 even when -mms-bitfields is specified.

This fixes asserts when using the max_align_t data type when
building for MinGW/i386 with the -mms-bitfields flag.

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

llvm-svn: 326173
2018-02-27 06:27:06 +00:00
Shoaib Meenai 80396248cf [Driver] Fix codeview-column-info on macOS
macOS home directory paths begin with /Users, and clang-cl interprets
the /U portion as a macro undefine rather than a path, causing test
failures on macOS. Use a -- to explicitly treat the input file as a path
and fix the test.

This effectively reverts r326168 and adds an alternative fix.

llvm-svn: 326171
2018-02-27 06:04:23 +00:00
Adam Nemet eec8221d4b Attempt to fix greendragon bot after r326141
llvm-svn: 326168
2018-02-27 04:49:26 +00:00
Artem Dergachev d8b7d893a5 [analyzer] Fix an uninitialized field.
Found by the analyzer!

llvm-svn: 326165
2018-02-27 02:53:30 +00:00
Igor Kudrin a49182aa5a [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.
clang used to require adding an ".exe" suffix when targeting ELF systems on Windows.

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

llvm-svn: 326164
2018-02-27 02:51:30 +00:00
George Karpenkov 06b7bd61f4 [analyzer] Switch the default exploration strategy to priority queue based on coverage
After the investigation it seems safe to flip the switch.

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

llvm-svn: 326157
2018-02-27 01:31:56 +00:00
George Karpenkov 31254d4366 [analyzer] Logging test typo quickfix.
llvm-svn: 326156
2018-02-27 01:31:06 +00:00
George Karpenkov dac9a881ef [analyzer] Logging test quickfix.
llvm-svn: 326155
2018-02-27 01:13:28 +00:00
George Karpenkov 50339a2e84 Revert "Revert "[analyzer] Quickfix: do not overflow in calculating offset in RegionManager""
This reverts commit c4cc41166d93178a3ddd4b2b5a685cf74a459247.

Revert and fix uninitialized read.

llvm-svn: 326152
2018-02-27 00:05:04 +00:00
Petr Hosek a459dab937 [Driver] Add SafeStack to a map of incompatible sanitizers
This allows reporting an error when user tries to use SafeStack with
incompatible sanitizers.

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

llvm-svn: 326151
2018-02-27 00:01:26 +00:00
Eugene Zelenko e580d8317e [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 326146
2018-02-26 23:15:52 +00:00
Volodymyr Sapsai dade327773 Fix which Darwin versions have ObjC runtime with full subscripting support.
Update min deployment target in some tests so that they don't try
to link against libarclite and don't fail when it's not available.

rdar://problem/29253617

Reviewers: vsk, kubamracek

Reviewed By: vsk

Subscribers: jkorous-apple, cfe-commits

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

llvm-svn: 326145
2018-02-26 23:10:23 +00:00
Reid Kleckner a54daa6d97 Fix codeview-column-info.c test with a triple
llvm-svn: 326144
2018-02-26 23:06:40 +00:00
Reid Kleckner 54af3e7e14 Re-land "Emit proper CodeView when -gcodeview is passed without the cl driver."
Reverts r326116 and re-lands r326113 with a fix to ASan so that it
enables column info in its test suite.

llvm-svn: 326141
2018-02-26 22:55:33 +00:00
George Karpenkov 6dcbc1dbb3 [analyzer] Exploration strategy prioritizing unexplored nodes first
See D42775 for discussion.  Turns out, just exploring nodes which
weren't explored first is not quite enough, as e.g. the first quick
traversal resulting in a report can mark everything as "visited", and
then subsequent traversals of the same region will get all the pitfalls
of DFS.
Priority queue-based approach in comparison shows much greater
increase in coverage and even performance, without sacrificing memory.

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

llvm-svn: 326136
2018-02-26 22:14:18 +00:00
George Karpenkov 1d3e49e781 [analyzer] Do not analyze bison-generated files
Bison/YACC generated files result in a very large number of (presumably)
false positives from the analyzer.
These false positives are "true" in a sense of the information analyzer
sees: assuming that the lexer can return any token at any point a number
of uninitialized reads does occur.
(naturally, the analyzer can not capture a complex invariant that
certain tokens can only occur under certain conditions).

Current fix simply stops analysis on those files.
I have examined a very large number of such auto-generated files, and
they do all start with such a comment.
Conversely, user code is very unlikely to contain such a comment.

rdar://33608161

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

llvm-svn: 326135
2018-02-26 22:14:16 +00:00
George Karpenkov 5d3b0e38d6 Revert "[analyzer] Quickfix: do not overflow in calculating offset in RegionManager"
This reverts commit df306c4c5ab4a6b8d3c47432346d1f9b90c328b4.

Reverting until I can figured out the reasons for failures.

llvm-svn: 326131
2018-02-26 21:32:57 +00:00
George Karpenkov 585dc5db13 [analyzer] Quickfix: do not overflow in calculating offset in RegionManager
Addresses https://bugs.llvm.org/show_bug.cgi?id=36206

rdar://37159026

A proper fix would be much harder, and would involve changing the
appropriate code in ExprEngine to be aware of the size limitations of
the type used for addressing.

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

llvm-svn: 326122
2018-02-26 21:03:06 +00:00
Zachary Turner 13e3520d49 Revert "Emit proper CodeView when -gcodeview is passed without the cl driver."
This reverts commit e17911006548518634fad66bb8648bcad49a1d64.

This is failing on ASAN bots because asan expects column info,
and it's also failing on some linux bots for unknown reasons which
i need to investigate.

llvm-svn: 326116
2018-02-26 19:51:29 +00:00
Zachary Turner 9eee7bb7e5 Emit proper CodeView when -gcodeview is passed without the cl driver.
Windows debuggers don't work properly when column info is emitted
with lines.  We handled this by checking if the driver mode was
cl, but it's possible to cause the gcc driver to emit codeview as
well, and in that path we were emitting column info with codeview.

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

llvm-svn: 326113
2018-02-26 19:25:39 +00:00
David Zarzycki b0c752d3c1 Fix for LLVM r326109
llvm-svn: 326110
2018-02-26 18:42:30 +00:00
Adam Nemet a456db3ea3 [Driver] Forward opt-remark hotness threshold to LTO
llvm-svn: 326108
2018-02-26 18:38:11 +00:00
Scott Linder a2fbcef8ee [DebugInfo] Support DWARF v5 source code embedding extension
In DWARF v5 the Line Number Program Header is extensible, allowing values with
new content types. This vendor extension to DWARF v5 allows source text to be
embedded directly in the line tables of the debug line section.

Add new flag (-g[no-]embed-source) to Driver and CC1 which indicates
that source should be passed through to LLVM during CodeGen.

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

llvm-svn: 326102
2018-02-26 17:32:31 +00:00
Scott Linder 39ceac1ceb [CodeGen][DebugInfo] Refactor duplicated code, NFC
llvm-svn: 326099
2018-02-26 16:31:08 +00:00
Jonas Devlieghere 560ce2c70f Re-land: "[Support] Replace HashString with djbHash."
This patch removes the HashString function from StringExtraces and
replaces its uses with calls to djbHash from DJB.h.

This change is *almost* NFC. While the algorithm is identical, the
djbHash implementation in StringExtras used 0 as its default seed while
the implementation in DJB uses 5381. The latter has been shown to result
in less collisions and improved avalanching and is used by the DWARF
accelerator tables.

Because some test were implicitly relying on the hash order, I've
reverted to using zero as a seed for the following two files:

  lld/include/lld/Core/SymbolTable.h
  llvm/lib/Support/StringMap.cpp

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

llvm-svn: 326091
2018-02-26 15:16:42 +00:00
Hans Wennborg 83665e6d36 Re-commit r324991 "Fix for PR32992. Static const classes not exported."
Fix for PR32992. Static const classes not exported.

Patch by zahiraam!

(This re-lands the commit, but using S.MarkVariableReferenced instead of
S.PendingInstantiations.push_back, and with an additional test.)

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

llvm-svn: 326089
2018-02-26 15:03:59 +00:00
Bjorn Pettersson 0b2f774be6 Resolve build bot problems in unittests/Format/FormatTest.cpp
Summary:
Make the new GetStyleWithEmptyFileName test case independent
of the file system used when running the test. Since the
test is supposed to use the fallback "Google" style we now
use a InMemoryFileSystem to make sure that we do not accidentaly
find a .clang-format file in the real file system. That could
for example happen when having the build directory inside the
llvm och clang repo (as there is a .clang-format file inside
the repos).

Reviewers: vsapsai, jolesiak, krasimir, benhamilton

Reviewed By: krasimir

Subscribers: uabelho, twoh, klimek, cfe-commits

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

llvm-svn: 326086
2018-02-26 14:14:11 +00:00
Ilya Biryukov 861201a262 Explicitly initialize ForceEnableInt128 to avoid UB
This fixes an uninitialized value read found by msan.

llvm-svn: 326083
2018-02-26 12:06:05 +00:00
Jonas Devlieghere 370bf3ef49 Revert "[Support] Replace HashString with djbHash."
It looks like some of our tests depend on the ordering of hashed values.
I'm reverting my changes while I try to reproduce and fix this locally.

Failing builds:

  lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/18388
  lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/6743
  lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/15607

llvm-svn: 326082
2018-02-26 12:05:18 +00:00
Jonas Devlieghere b9ad175935 [Support] Replace HashString with djbHash.
This removes the HashString function from StringExtraces and replaces
its uses with calls to djbHash from DJB.h

This is *almost* NFC. While the algorithm is identical, the djbHash
implementation in StringExtras used 0 as its seed while the
implementation in DJB uses 5381. The latter has been shown to result in
less collisions and improved avalanching.

https://reviews.llvm.org/D43615
(cherry picked from commit 77f7f965bc9499a9ae768a296ca5a1f7347d1d2c)

llvm-svn: 326081
2018-02-26 11:30:13 +00:00
Devin Coughlin c0ffd637b9 [www] Update link to analyzer's "Building a Checker in 24 hours" video
The video is now uploaded to YouTube.

llvm-svn: 326062
2018-02-26 00:39:25 +00:00
Aaron Ballman 836684aff3 When diagnosing the arguments to alloc_size, report the failing argument using a 1-based index instead of a 0-based index for consistency.
Patch by Joel Denny.

llvm-svn: 326058
2018-02-25 20:40:06 +00:00
Aaron Ballman bd0f656631 Fix a failing assertion with the pointer_with_type_tag attribute when the function the attribute appertains to is variadic.
Patch by Joel Denny.

llvm-svn: 326057
2018-02-25 20:28:10 +00:00
Aaron Ballman fabe1b3b7d Switch the default behavior of the Clang<> spelling to opt-in to the C2x attribute spellings. NFC to the attribute spellings themselves.
The Clang<> spelling helper generates a spelling for C++11, GNU, and C2x attribute spellings. Previously, users had to manually opt in to the C2x spelling while we cautiously added attributes to that spelling. Now that majority of attributes are exposed in C2x, we can switch the default.

llvm-svn: 326055
2018-02-25 15:34:17 +00:00
Aaron Ballman d15a39b469 Document why the consumed attributes (consumable, callable_when, et al) are not exposed with a C2x spelling. NFC.
llvm-svn: 326054
2018-02-25 14:54:25 +00:00
Aaron Ballman 99bfe26a1e Add a C2x spelling for the external_source_symbol and internal_linkage attributes in the clang vendor namespace.
Both of these attributes have existing meaning in C code, so there was no reason to exclude them from using the new spelling.

llvm-svn: 326053
2018-02-25 14:43:45 +00:00
Aaron Ballman a26d8ee559 Add a C++11 and C2x spelling for the type safety attribute (argument_with_type_tag, pointer_with_type_tag, and type_tag_for_datatype) in the clang vendor namespace.
The TypeTagForDatatype attribute had custom parsing rules that previously prevented it from being supported with square bracket notation. The ArgumentWithTypeTag attribute previously had unnecessary custom parsing that could be handled declaratively.

llvm-svn: 326052
2018-02-25 14:01:04 +00:00
Mandeep Singh Grang ac24bb53bb [RISCV] Enable __int128_t and __uint128_t through clang flag
Summary:
If the flag -fforce-enable-int128 is passed, it will enable support for __int128_t and __uint128_t types.
This flag can then be used to build compiler-rt for RISCV32.

Reviewers: asb, kito-cheng, apazos, efriedma

Reviewed By: asb, efriedma

Subscribers: shiva0217, efriedma, jfb, dschuff, sdardis, sbc100, jgravelle-google, aheejin, rbar, johnrusso, simoncook, jordy.potman.lists, sabuasal, niosHD, cfe-commits

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

llvm-svn: 326045
2018-02-25 03:58:23 +00:00
Craig Topper 21f66a3f6b [X86] Remove some masked cvt builtins that can be replaced with legacy sse/avx buiiltins and a select.
llvm-svn: 326039
2018-02-24 18:55:13 +00:00
Aaron Ballman c248b0fb83 Add a C++11 and C2x spelling for the objc_bridge_related attribute in the clang vendor namespace.
This attribute has custom parsing rules that previously prevented it from being supported with square bracket notation.

llvm-svn: 326038
2018-02-24 17:37:37 +00:00
Aaron Ballman 38bbc16a8b Add a C++11 and C2x spelling for the availability attribute in the clang vendor namespace.
This attribute has custom parsing rules that previously prevented it from being supported with square bracket notation. Rework the clang attribute argument parsing to be more easily extended for other custom-parsed attributes.

llvm-svn: 326036
2018-02-24 17:16:42 +00:00
Daniel Jasper d8cea35360 Remove unused variable. We should be warning-free.
llvm-svn: 326024
2018-02-24 06:57:47 +00:00
Daniel Jasper 4ea330c8c3 Make module use diagnostics refer to the top-level module
All use declarations need to be directly placed in the top-level module
anyway, knowing the submodule doesn't really help. The header that has
the offending #include can easily be seen in the diagnostics source
location.

Review: https://reviews.llvm.org/D43673
llvm-svn: 326023
2018-02-24 06:54:09 +00:00
Craig Topper 5dc6ca8e5b [X86] Remove __builtin_ia32_permvarsf256_mask and __builtin_ia32_permvarsi256_mask and use the avx2 unmasked versions and a select instead.
llvm-svn: 326022
2018-02-24 06:46:42 +00:00
Artem Dergachev 1c6ed3add6 [CFG] Keep speculatively working around an MSVC compiler crash.
Replace if() with a switch(). Because random changes in the code seem to
suppress the crash.

Story so far:
r325966 - Crash introduced.
r325969 - Speculative fix had no effect.
r325978 - Tried to bisect the offending function, crash suddenly disappeared.
r326016 - After another random change in the code, bug appeared again.

llvm-svn: 326021
2018-02-24 03:54:22 +00:00
Artem Dergachev a6d91d5b30 [CFG] Provide construction contexts for temporaries in conditional operators.
When a lifetime-extended temporary is on a branch of a conditional operator,
materialization of such temporary occurs after the condition is resolved.

This change allows us to understand, by including the MaterializeTemporaryExpr
in the construction context, the target for temporary materialization in such
cases.

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

llvm-svn: 326019
2018-02-24 03:10:15 +00:00
Artem Dergachev 8cc55e9f16 [CFG] Provide construction contexts for temporaries bound to const references.
In order to bind a temporary to a const lvalue reference, a no-op cast is added
to make the temporary itself const, and only then the reference is taken
(materialized). Skip the no-op cast when looking for the construction context.

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

llvm-svn: 326016
2018-02-24 02:07:50 +00:00
Artem Dergachev ceb7d91a48 [CFG] Provide construction contexts for functional cast-like constructors.
When a constructor of a temporary with a single argument is treated
as a functional cast expression, skip the functional cast expression
and provide the correct construction context for the temporary.

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

llvm-svn: 326015
2018-02-24 02:05:11 +00:00
Artem Dergachev f43ac4c9ac [CFG] Provide construction contexts for lifetime-extended temporaries.
When constructing a temporary that is going to be lifetime-extended through a
MaterializeTemporaryExpr later, CFG elements for the respective constructor
can now be queried to obtain the reference to that MaterializeTemporaryExpr
and therefore gain information about lifetime extension.

This may produce multi-layered construction contexts when information about
both temporary destruction and lifetime extension is available.

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

llvm-svn: 326014
2018-02-24 02:00:30 +00:00
Richard Smith b7a9bedfcd Add another test for PR36157.
llvm-svn: 325998
2018-02-24 00:00:58 +00:00
Volodymyr Sapsai e8f1ffb50a [ExprConstant] Fix crash when initialize an indirect field with another field.
When indirect field is initialized with another field, you have
MemberExpr with CXXThisExpr that corresponds to the field's immediate
anonymous parent. But 'this' was referring to the non-anonymous parent.
So when we were building LValue Designator, it was incorrect as it had
wrong starting point. Usage of such designator would cause unexpected
APValue changes and crashes.

The fix is in adjusting 'this' for indirect fields from non-anonymous
parent to the field's immediate parent.

Discovered by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4985

rdar://problem/36359187

Reviewers: rsmith, efriedma

Reviewed By: rsmith

Subscribers: cfe-commits, jkorous-apple

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

llvm-svn: 325997
2018-02-23 23:59:20 +00:00
Yonghong Song 8b1e93b7d6 bpf: Hook target feature "alu32" with LLVM
LLVM has supported a new target feature "alu32" which could be enabled or
disabled by "-mattr=[+|-]alu32" when using llc.

This patch link Clang with it, so it could be also done by passing related
options to Clang, for example:

  -Xclang -target-feature -Xclang +alu32

Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Reviewed-by: Yonghong Song <yhs@fb.com>
llvm-svn: 325996
2018-02-23 23:55:29 +00:00
Alex Lorenz a9c966d0a9 [Sema][ObjC] Process category attributes before checking protocol uses
This ensures that any availability attributes are attached to the
category before the availability for the referenced protocols is checked.

rdar://37829755

llvm-svn: 325994
2018-02-23 23:49:43 +00:00
Artem Dergachev c1b07bdde9 [CFG] Try to narrow down MSVC compiler crash via binary search.
Split the presumably offending function in two to see which part of it causes
the crash to occur.

The crash was introduced in r325966.
r325969 did not help.

llvm-svn: 325978
2018-02-23 23:38:41 +00:00
George Karpenkov 60c206e0bd [analyzer] Relax the assert used when traversing the node graph.
The assertion gets exposed when changing the exploration order.
This is a quick hacky fix, but the intention is that if the nodes do
merge, it should not matter which predecessor should be traverse.
A proper fix would be not to traverse predecessors at all, as all
information relevant for any decision should be avilable locally.

rdar://37540480

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

llvm-svn: 325977
2018-02-23 23:26:57 +00:00
George Karpenkov e15451a9c0 [analyzer] mark returns of functions where the region passed as parameter was not initialized
In the wild, many cases of null pointer dereference, or uninitialized
value read occur because the value was meant to be initialized by the
inlined function, but did not, most often due to error condition in the
inlined function.
This change highlights the return branch taken by the inlined function,
in order to help user understand the error report and see why the value
was uninitialized.

rdar://36287652

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

llvm-svn: 325976
2018-02-23 23:26:56 +00:00
George Karpenkov 80e4ba24b9 [analyzer] Consider switch- and goto- labels when constructing the set of executed lines
When viewing the report in the collapsed mode the label signifying where
did the execution go is often necessary for properly understanding the
context.

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

llvm-svn: 325975
2018-02-23 23:26:54 +00:00
Artem Dergachev 5e2f6ba51e [CFG] NFC: Speculative attempt to fix MSVC internal compiler error on buildbot.
Don't use fancy initialization and member access in a DenseMap.

llvm-svn: 325969
2018-02-23 22:49:25 +00:00
Artem Dergachev 783a4578c1 [CFG] [analyzer] NFC: Allow more complicated construction contexts.
ConstructionContexts introduced in D42672 are an additional piece of information
included with CFGConstructor elements that help the client of the CFG (such as
the Static Analyzer) understand where the newly constructed object is stored.

The patch refactors the ConstructionContext class to prepare for including
multi-layered contexts that are being constructed gradually, layer-by-layer,
as the AST is traversed.

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

llvm-svn: 325966
2018-02-23 22:20:39 +00:00
Sriraman Tallam 80af005a48 Set Module Metadata "RtLibUseGOT" when fno-plt is used.
Differential Revision: https://reviews.llvm.org/D42217

llvm-svn: 325961
2018-02-23 21:27:33 +00:00
Petr Hosek bf45ecef66 [Driver] Make -fno-common default for Fuchsia
We never want to generate common symbols on Fuchsia.

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

llvm-svn: 325945
2018-02-23 20:10:14 +00:00
Rafael Espindola 2a639a4c11 Really fix test on windows.
Sorry for the noise.

llvm-svn: 325943
2018-02-23 19:38:41 +00:00
Rafael Espindola f43c2ff84b Fix one last test on a windows host.
llvm-svn: 325942
2018-02-23 19:36:20 +00:00
Rafael Espindola 922f2aa9b2 Bring r325915 back.
The tests that failed on a windows host have been fixed.

Original message:

Start setting dso_local for COFF.

With this there are still some GVs where we don't set dso_local
because setGVProperties is never called. I intend to fix that in
followup commits. This is just the bare minimum to teach
shouldAssumeDSOLocal what it should do for COFF.

llvm-svn: 325940
2018-02-23 19:30:48 +00:00
Rafael Espindola 9b1d63df37 Convert test to FileCheck. NFC.
llvm-svn: 325930
2018-02-23 18:18:01 +00:00
Rafael Espindola 43ce3a3a4d Revert "Start setting dso_local for COFF."
This reverts commit r325915.

It will take some time to fix the failures on a windows host.

llvm-svn: 325929
2018-02-23 18:09:29 +00:00
Paul Robinson fba2044e73 Revert "[Darwin] Add a test to check clang produces accelerator tables."
This reverts commit 7e24e5f8bff77b7e78da3bfcc68abf42457a66c9.
aka r325850.  Clang should not have end-to-end tests.

llvm-svn: 325920
2018-02-23 16:36:48 +00:00
Rafael Espindola 004d240b6a Start setting dso_local for COFF.
With this there are still some GVs where we don't set dso_local
because setGVProperties is never called. I intend to fix that in
followup commits. This is just the bare minimum to teach
shouldAssumeDSOLocal what it should do for COFF.

llvm-svn: 325915
2018-02-23 15:32:32 +00:00
Hans Wennborg d43f40df1c Support for the mno-stack-arg-probe flag
Adds support for this flag. There is also another piece for llvm
(separate review). More info:
https://bugs.llvm.org/show_bug.cgi?id=36221

By Ruslan Nikolaev!

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

llvm-svn: 325901
2018-02-23 13:47:36 +00:00
Stefan Maksimovic c30034e574 [mips] Revert r325872
There are still outstanding issues with byVal arguments
that prevent this from being committed. Revert for now.

llvm-svn: 325899
2018-02-23 13:46:14 +00:00
Stefan Maksimovic 3cd76b1448 [mips] Reland r310704
Recommit this change which was previously reverted
for the 5.0.0 release since the failures identified
were dealt with in r325782.

llvm-svn: 325872
2018-02-23 08:37:48 +00:00
Richard Smith 9ff1bfe480 Add a test to ensure we don't permit mutable access on temporaries outside the evaluation in which they were created.
llvm-svn: 325854
2018-02-23 02:03:26 +00:00
Davide Italiano 7b16df0a72 [Darwin] Add a test to check clang produces accelerator tables.
This test was previously in lldb, and was only checking that clang
was emitting the correct section. So, it belongs here and not
in the debugger.

llvm-svn: 325850
2018-02-23 01:25:03 +00:00
Rafael Espindola 3dd4981298 Simplify setting dso_local. NFC.
The value of dso_local can be computed from just IR properties and
global information (object file type, command line options, etc).

With this patch we no longer pass in the Decl. It was almost unused
and making it fully unused guarantees that dso_local is consistent
with the rest of the IR.

llvm-svn: 325846
2018-02-23 00:22:15 +00:00
Eugene Zelenko 82eb70f0d9 [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 325834
2018-02-22 22:35:17 +00:00
Carlo Bertolli beda214996 [OpenMP] Limit reduction support for pragma 'distribute' when combined with pragma 'simd'
Differential Revision: https://reviews.llvm.org/D43513

This is a bug fix that removes the emission of reduction support for pragma 'distribute' when found alone or in combinations without simd.
Pragma 'distribute' does not have a reduction clause, but when combined with pragma 'simd' we need to emit the support for simd's reduction clause as part of code generation for distribute. This guard is similar to the one used for reduction support earlier in the same code gen function.

llvm-svn: 325822
2018-02-22 19:38:14 +00:00
Artem Belevich df38f155ec [CUDA] Added missing functions.
Initial commit missed sincos(float), llabs() and few atomics that we
used to pull in from device_functions.hpp, which we no longer include.

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

llvm-svn: 325814
2018-02-22 18:40:52 +00:00
Alexey Bataev 7ef47a67a5 [OPENMP] Require valid SourceLocation in function call, NFC.
Removed default empty SourceLocation argument from `emitCall` function
and require valid location.

llvm-svn: 325812
2018-02-22 18:33:31 +00:00
Jonas Hahnfeld a180fc4503 [docs] Regenerate command line reference
llvm-svn: 325807
2018-02-22 17:10:28 +00:00
Jonas Hahnfeld 1b15be7262 [docs] Improve help for OpenMP options, NFC.
* Add HelpText for -fopenmp so that it appears in clang --help.
 * Hide -fno-openmp-simd, only list the positive option.
 * Hide -fopenmp-relocatable-target and -fopenmp-use-tls from
   clang --help and from ClangCommandLineReference.
 * Improve MetaVarName for -Xopenmp-target=<...>.

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

llvm-svn: 325806
2018-02-22 17:06:35 +00:00
Jonas Hahnfeld 3c7b136a82 [docs] Fix duplicate arguments for JoinedAndSeparate
We can't see how many arguments are in the meta var name, so just
assume that it is the right number.

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

llvm-svn: 325805
2018-02-22 17:06:27 +00:00
Alexey Sotkin 20f65928e1 [OpenCL] Add '-cl-uniform-work-group-size' compile option
Summary:
OpenCL 2.0 specification defines '-cl-uniform-work-group-size' option,
which requires that the global work-size be a multiple of the work-group
size specified to clEnqueueNDRangeKernel and allows optimizations that
are made possible by this restriction.

The patch introduces the support of this option.

To keep information about whether an OpenCL kernel has uniform work
group size or not, clang generates 'uniform-work-group-size' function
attribute for every kernel:
- "uniform-work-group-size"="true" for OpenCL 1.2 and lower,
- "uniform-work-group-size"="true" for OpenCL 2.0 and higher if
 '-cl-uniform-work-group-size' option was specified,
- "uniform-work-group-size"="false" for OpenCL 2.0 and higher if no
 '-cl-uniform-work-group-size' options was specified.

If the function is not an OpenCL kernel, 'uniform-work-group-size'
attribute isn't generated.

Patch by: krisb

Reviewers: yaxunl, Anastasia, b-sumner

Reviewed By: yaxunl, Anastasia

Subscribers: nhaehnle, yaxunl, Anastasia, cfe-commits

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

llvm-svn: 325771
2018-02-22 11:54:14 +00:00
Hiroshi Inoue 971514dd3e [NFC] fix trivial typos in comments
"a a"->"a"

llvm-svn: 325753
2018-02-22 07:49:13 +00:00
Kamil Rytarowski 966642d5bb Revert part of D43378 in this file
It causes failure on clang-x86_64-debian-fast.

llvm-svn: 325749
2018-02-22 07:00:29 +00:00
Kamil Rytarowski 30c0a37526 Revert part of r. 325746 D43378
test/Driver/XRay/xray-shared-noxray.cpp fails on !Linux hosts.

llvm-svn: 325748
2018-02-22 06:48:34 +00:00
Kamil Rytarowski 3e4e74cbe5 FreeBSD driver / Xray flags moving pthread to compile flags.
Summary:
- Using -lpthread instead, with -pthread the linkage does not work.
-Warning about the -fxray-instrument usage outside of the working cases.

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka, dberris, emaste

Reviewed By: krytarowski, emaste

Subscribers: srhines, emaste, cfe-commits

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

llvm-svn: 325746
2018-02-22 06:31:40 +00:00
Richard Trieu 0ac2eb7369 [ODRHash] Fix hashing for friend functions.
When hashing a templated function, use the hash of the function it was
instantiated from.

llvm-svn: 325742
2018-02-22 05:50:29 +00:00
Richard Trieu f65efae5c4 [ODRHash] Handle some template weirdness.
Build the index off of DeclarationName instead of Decl pointers.  When finding
an UnresolvedLookupExprClass, hash it as if it were a DeclRefExpr.  This will
allow methods to be hashed.

llvm-svn: 325741
2018-02-22 05:32:25 +00:00
Dan Albert e12561dd1a [Driver] Generate .eh_frame_hdr for static executables too.
Summary: libgcc won't unwind without an .eh_frame_hdr section.

Reviewers: srhines, chandlerc

Reviewed By: chandlerc

Subscribers: chandlerc, cfe-commits

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

llvm-svn: 325733
2018-02-21 22:36:51 +00:00
Saleem Abdulrasool c1b46381db CodeGen: handle blocks correctly when inalloca'ed
When using blocks with C++ on Windows x86, it is possible to have the
block literal be pushed into the inalloca'ed parameters.  Teach IRGen to
handle the case properly by extracting the block literal from the
inalloca parameter.  This fixes the use of blocks with C++ on Windows
x86.

llvm-svn: 325724
2018-02-21 21:47:51 +00:00
Ben Hamilton 07e5836521 [clang-format] Fix regression when getStyle() called with empty filename
Summary:
D43522 caused an assertion failure when getStyle() was called with
an empty filename:

P8065

This adds a test to reproduce the failure and fixes the issue by
ensuring we never pass an empty filename to
Environment::CreateVirtualEnvironment().

Test Plan: New test added. Ran test with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests
  Before diff, test failed with P8065. Now, test passes.

Reviewers: vsapsai, jolesiak, krasimir

Reviewed By: vsapsai

Subscribers: klimek, cfe-commits

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

llvm-svn: 325722
2018-02-21 21:27:27 +00:00
Erich Keane aa782f374e Replace incorrect usage of isInvalidDecl with intended setInvalidDecl
This typo would cause an attempt to multiversion 'main' to issue an
error, but not mark the function as invalid.  This patch fixes it.

llvm-svn: 325716
2018-02-21 20:29:05 +00:00
Peter Szecsi 5184fae04e [analyzer] Prevent AnalyzerStatsChecker from crash
The checker marks the locations where the analyzer creates sinks. However, it
can happen that the sink was created because of a loop which does not contain
condition statement, only breaks in the body. The exhausted block is the block
which should contain the condition but empty, in this case.
This change only emits this marking in order to avoid the undefined behavior.

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

llvm-svn: 325693
2018-02-21 16:06:56 +00:00
David Blaikie 36362692b3 Remove use of the 'gmlt' term from the -fsplit-dwarf-inlining flag description to make it more readily legible
llvm-svn: 325692
2018-02-21 16:00:50 +00:00
Ben Hamilton 3b345c3677 [clang-format] New API guessLanguage()
Summary:
For clients which don't have a filesystem, calling getStyle() doesn't
make much sense (there's no .clang-format files to search for).

In this diff, I hoist out the language-guessing logic from getStyle()
and move it into a new API guessLanguage().

I also added support for guessing the language of files which have no
extension (they could be C++ or ObjC).

Test Plan: New tests added. Ran tests with:
  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: jolesiak, krasimir

Reviewed By: jolesiak, krasimir

Subscribers: klimek, cfe-commits, sammccall

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

llvm-svn: 325691
2018-02-21 15:54:31 +00:00
Eric Liu 09ee48e2af [ASTMatchers] Regenerate documentation after r325678
llvm-svn: 325682
2018-02-21 14:22:42 +00:00
Eric Liu 500e126155 [ASTMatchers] isTemplateInstantiation: also match explicit instantiation declaration.
Summary:
Example:
template <typename T> class X {}; class A {};
// Explicit instantiation declaration.
extern template class X<A>;

Reviewers: bkramer

Subscribers: klimek, cfe-commits

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

llvm-svn: 325678
2018-02-21 13:51:27 +00:00
Mikhail Maltsev 7b1a950c4a [Sema] Classify conversions from enum to float as narrowing
Summary:
According to [dcl.init.list]p7:
  A narrowing conversion is an implicit conversion
  - ...
  - from an integer type or unscoped enumeration type to a
    floating-point type, except where the source is a constant
    expression and the actual value after conversion will fit into
    the target type and will produce the original value when
    converted back to the original type, or
  - ...

Currently clang does not handle the 'unscoped enumeration' case. This
patch fixes the corresponding check.

Reviewers: faisalv, rsmith, rogfer01

Reviewed By: rogfer01

Subscribers: rogfer01, cfe-commits

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

llvm-svn: 325668
2018-02-21 10:08:18 +00:00
Petr Hosek 0d9c9bef4e [Fuchsia] Include libClang and clang-include-fixer in the toolchain
libClang is used by other Clang based tools such as cquery while
clang-include-fixer is generally a useful tool.

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

llvm-svn: 325665
2018-02-21 04:39:15 +00:00
Richard Smith 9defb7d6b1 In C++14 onwards, it is permitted to read mutable members in constant
expressions, if their lifetime began during the evaluation of the expression.

This is technically not allowed in C++11, though we could consider permitting
it there too, as an extension.

llvm-svn: 325663
2018-02-21 03:38:30 +00:00
Serge Pavlov 52525730a1 Clean up use of C allocation functions
If the value returned by `malloc`, `calloc` or `realloc` is not checked
for null pointer, this change replaces them for `safe_malloc`,
`safe_calloc` or `safe_realloc`, which are defined in the namespace `llvm`.
These function report fatal error on out of memory.

In the plain C files, assertion statements are added to ensure that memory
is successfully allocated.

The aim of this change is to get better diagnostics of OOM on Windows.

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

llvm-svn: 325661
2018-02-21 02:02:39 +00:00
Eugene Zelenko 9fbf64139e [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 325659
2018-02-21 01:45:26 +00:00
Craig Topper 94a940d2b4 [X86] Disable CLWB in Cannon Lake
Cannon Lake does not support CLWB, therefore it
does not include all features listed under SKX.

Patch by Gabor Buella

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

llvm-svn: 325655
2018-02-21 00:16:50 +00:00
Simon Dardis 0bc2d9b0c5 [mips] Spectre variant two mitigation for MIPSR2
This patch provides mitigation for CVE-2017-5715, Spectre variant two,
which affects the P5600 and P6600. It provides the option
-mindirect-jump=hazard, which instructs the LLVM backend to replace
indirect branches with their hazard barrier variants.

This option is accepted when targeting MIPS revision two or later.

The migitation strategy suggested by MIPS for these processors is to
use two hazard barrier instructions. 'jalr.hb' and 'jr.hb' are hazard
barrier variants of the 'jalr' and 'jr' instructions respectively.

These instructions impede the execution of instruction stream until
architecturally defined hazards (changes to the instruction stream,
privileged registers which may affect execution) are cleared. These
instructions in MIPS' designs are not speculated past.

These instructions are used with the option -mindirect-jump=hazard
when branching indirectly and for indirect function calls.

These instructions are defined by the MIPS32R2 ISA, so this mitigation
method is not compatible with processors which implement an earlier
revision of the MIPS ISA.

Implementation note: I've opted to provide this as an
-mindirect-jump={hazard,...} style option in case alternative
mitigation methods are required for other implementations of the MIPS
ISA in future, e.g. retpoline style solutions.

Reviewers: atanasyan

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

llvm-svn: 325651
2018-02-21 00:05:05 +00:00
Richard Smith 148bc6a1f7 Fix assert when template argument deduction's original call arg checking triggers class template instantiation.
llvm-svn: 325646
2018-02-20 23:47:12 +00:00
Richard Smith 6cd4861c22 When multiple sanitizers are enabled (ubsan + something else), use all relevant blacklists.
Ideally, we'd only use the ubsan blacklist for ubsan sanitizers, and only use
the other-sanitizer blacklist for its sanitizers, but this at least enables the
intended suppressions.

llvm-svn: 325640
2018-02-20 23:17:41 +00:00
Erich Keane 7399ad3f39 [NFC] In Multiversion Check function, switch to return Diag
This function did a lot of 'Diag, return true' stuff.  This resulted in needing
to introduce scopes in quite a few places.  This patch replaces useages of a
single "S.Diag" followed by return true with simply "return S.Diag".

llvm-svn: 325633
2018-02-20 22:25:28 +00:00
Artem Belevich 4dbea99137 [CUDA] Added missing __threadfence_system() function for CUDA9.
llvm-svn: 325626
2018-02-20 21:25:30 +00:00
Erich Keane 5e5baf59dd Correct multiversion unsupported target behavior, add a test.
Multiversioning SEMA failed to set the declaration as invalid on unsupported
targets.  This patch does that.

Additionally, I noticed that there is no test to validate this error message.
This patch adds one, and uses 'mips' as the test architecture.  

llvm-svn: 325610
2018-02-20 18:44:50 +00:00
David Blaikie 4b9bc239ee PR36442: Correct description of -fsplit-dwarf-inlining
llvm-svn: 325594
2018-02-20 16:35:08 +00:00
Kamil Rytarowski af1d48a2ff Stop linking sanitized applications with -lutil and -lkvm on NetBSD
The proper approach is to rebuild libutil and libkvm with a desired sanitizer.
An alternative approach to reimplement these functions (and other ones like
curses(3), editline(3) etc) does not scale and enforces linkage every single
binary with these libraries.

llvm-svn: 325593
2018-02-20 16:27:28 +00:00
Hans Wennborg b18da9b122 Revert r325375 "[MS] Make constexpr static data members implicitly inline"
This broke Clang bootstrap on Windows, PR36453.

> This handles them exactly the same way that we handle const integral
> static data members with inline definitions, which is what MSVC does.
>
> As a follow-up, now that we have a way to mark variables inline in the
> AST, we should consider marking them implicitly inline there instead of
> only treating them as inline in CodeGen. Unfortunately, this breaks a
> lot of dllimport test cases, so that is future work for now.
>
> Fixes PR36125.

llvm-svn: 325576
2018-02-20 12:43:02 +00:00
Ivan A. Kosarev 124a2187ad [CodeGen] Fix generation of TBAA tags for may-alias accesses
This patch fixes creating TBAA access descriptors for
may_alias-marked access types. Currently, for such types we
generate ordinary descriptors with char as its access type. The
patch changes this to produce proper may-alias descriptors.

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

llvm-svn: 325575
2018-02-20 12:33:04 +00:00
Hans Wennborg b8f369d636 clang-cl: Make /d1PP an alias for -dD (PR36446)
llvm-svn: 325571
2018-02-20 10:47:14 +00:00
Hans Wennborg b8bf5a6c85 clang-format plugin: Add missing semicolon in list of file extensions (PR36383)
llvm-svn: 325566
2018-02-20 09:26:38 +00:00
Craig Topper 0a70c3c7af [X86] Remove mask from 512 bit pmulhrsw/pmulhw/pmulhuw builtins.
We now use a vselect node in IR around an unmasked builtin. This makes it consistent with the 128 and 256 bit versions.

llvm-svn: 325560
2018-02-20 07:28:18 +00:00
Sam McCall 4d973862ec [Sema] Fix -Wunused-variable
llvm-svn: 325553
2018-02-20 07:21:56 +00:00
Richard Smith 0848210b74 Fix some -Wexceptions false positives.
Reimplement the "noexcept function actually throws" warning to properly handle
nested try-blocks. In passing, change 'throw;' handling to treat any enclosing
try block as being sufficient to suppress the warning rather than requiring a
'catch (...)'; the warning is intended to be conservatively-correct.

llvm-svn: 325545
2018-02-20 02:32:30 +00:00
Eugene Zelenko 711964ddc1 [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 325544
2018-02-20 02:16:28 +00:00
Richard Smith 2e8a8629d6 Fix test failure on target where size_t is long long.
llvm-svn: 325540
2018-02-19 22:50:50 +00:00
Aaron Ballman 4c4a9835a2 Add several more attributes to be parsed in C with [[]] when -fdouble-square-bracket-attributes is specified.
Also flags a few attributes that should not be available with the C spelling as they only matter in C++.

llvm-svn: 325520
2018-02-19 17:32:07 +00:00
Krasimir Georgiev 9c5ac63785 [clang-format] Fix text proto extension scope opening detection
Summary:
This fixes the detection of scope openers in text proto extensions; previously
they were not detected correctly leading to instances like:
```
msg {
  [aa.bb
] {
key: value
}
}
```

Subscribers: klimek, cfe-commits

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

llvm-svn: 325513
2018-02-19 16:00:21 +00:00
Krasimir Georgiev 9b2aa42f00 [clang-format] Fixup a case of text proto message attributes
Summary: This patch fixes a case where a proto message attribute is wrongly identified as an text proto extension.

Subscribers: klimek, cfe-commits

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

llvm-svn: 325509
2018-02-19 15:31:25 +00:00
Ilya Biryukov 3289ab20e5 [CodeComplete] Avoid name clashes of 'Kind' inside CodeCompletionContext. NFC
CodeCompletionContext had declarations of field and enum inside, both named 'Kind'.
It caused gcc 4.8 to give an incorrent warning when refering to enum as
`enum CodeCompletionContext::Kind`.

Avoid that warning by renaming the private field to CCKind.

llvm-svn: 325496
2018-02-19 13:53:49 +00:00
Keith Walker 167961f6dc [ARM] disable FPU features when using soft floating point.
To be compatible with GCC if soft floating point is in effect any FPU
specified is effectively ignored, eg,

  -mfloat-abi=soft -fpu=neon

If any floating point features which require FPU hardware are enabled
they must be disable.

There was some support for doing this for NEON, but it did not handle
VFP, nor did it prevent the backend from emitting the build attribute
Tag_FP_arch describing the generated code as using the floating point
hardware if a FPU was specified (even though soft float does not use
the FPU).

Disabling the hardware floating point features for targets which are
compiling for soft float has meant that some tests which were incorrectly
checking for hardware support also needed to be updated. In such cases,
where appropriate the tests have been updated to check compiling for
soft float and a non-soft float variant (usually softfp). This was
usually because the target specified in the test defaulted to soft float.

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

llvm-svn: 325492
2018-02-19 12:40:26 +00:00
Ilya Biryukov 27d8258576 [CodeComplete] Add a helper to print CodeCompletionContext::Kind
Summary: Will be used in clangd. See D43377.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: ioeric, cfe-commits

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

llvm-svn: 325490
2018-02-19 12:35:33 +00:00
Martin Probst 110ecc7002 clang-format: [JS] fix `of` detection.
Summary:
`of` is only a keyword when after an identifier, but not when after
an actual keyword.

Before:
    return of (a, b, c);
After:
    return of(a, b, c);

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

llvm-svn: 325489
2018-02-19 12:32:13 +00:00
Dylan McKay 8ad69f2d1f [AVR] Set the program address space in the data layout
This is accompanied by r325481 in LLVM.

llvm-svn: 325483
2018-02-19 10:46:16 +00:00
Ivan A. Kosarev e0ef348cb9 [CodeGen] Initialize large arrays by copying from a global
Currently, clang compiles explicit initializers for array
elements into series of store instructions. For large arrays of
built-in types this results in bloated output code and
significant amount of time spent on the instruction selection
phase. This patch fixes the issue by initializing such arrays
with global constants that store the binary image of the
initializer.

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

llvm-svn: 325478
2018-02-19 09:49:11 +00:00
Richard Smith 90c47cad22 [cxx_dr_status] Tests for CWG issues 641-687.
llvm-svn: 325475
2018-02-19 09:05:48 +00:00
Benjamin Kramer 690ac0f3e0 [Analyzer] Move UnexploredFirstStack into an anonymous namespace.
No functionality change intended.

llvm-svn: 325468
2018-02-18 19:08:27 +00:00
Dimitry Andric 2e3f23bbcc [X86] Add 'sahf' CPU feature to frontend
Summary:
Make clang accept `-msahf` (and `-mno-sahf`) flags to activate the
`+sahf` feature for the backend, for bug 36028 (Incorrect use of
pushf/popf enables/disables interrupts on amd64 kernels).  This was
originally submitted in bug 36037 by Jonathan Looney
<jonlooney@gmail.com>.

As described there, GCC also uses `-msahf` for this feature, and the
backend already recognizes the `+sahf` feature. All that is needed is to
teach clang to pass this on to the backend.

The mapping of feature support onto CPUs may not be complete; rather, it
was chosen to match LLVM's idea of which CPUs support this feature (see
lib/Target/X86/X86.td).

I also updated the affected test case (CodeGen/attr-target-x86.c) to
match the emitted output.

Reviewers: craig.topper, coby, efriedma, rsmith

Reviewed By: craig.topper

Subscribers: emaste, cfe-commits

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

llvm-svn: 325446
2018-02-17 21:04:35 +00:00
Eugene Zelenko 25cae5a21f [Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 325412
2018-02-16 23:40:07 +00:00
Vitaly Buka 769134dac3 [ThinLTO] Allow indexing to request backend to ignore the module
Summary:
Gold plugin does not add pass to ThinLTO modules without useful symbols.
In this case ThinLTO can't create corresponding index file and some features, like CFI,
cannot be processes by backed correctly without index.
Given that we don't need the backed output we can request it to avoid
processing the module. This is implemented by this patch using new
"SkipModuleByDistributedBackend" flag.

Reviewers: pcc, tejohnson

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

llvm-svn: 325411
2018-02-16 23:38:22 +00:00
Vitaly Buka c35ff824de [ThinLTO] Ignore object files with no ThinLTO modules if -fthinlto-index= is set
Summary:
ThinLTO compilation may decide not to split module and keep at as regular LTO.
In this can this module already processed during indexing and already a part of
merged object file. So here we can just skip it.

Reviewers: pcc, tejohnson

Reviewed By: tejohnson

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

llvm-svn: 325410
2018-02-16 23:34:16 +00:00
Alexey Bataev 8e39c3446f [OPENMP] Do not emit messages for templates in declare target
constructs.

The compiler may emit some extra warnings for functions, that are
implicit specialization of the templates, declared in the target region.

llvm-svn: 325391
2018-02-16 21:23:23 +00:00
Reid Kleckner d23e73cda9 [MS] Make constexpr static data members implicitly inline
This handles them exactly the same way that we handle const integral
static data members with inline definitions, which is what MSVC does.

As a follow-up, now that we have a way to mark variables inline in the
AST, we should consider marking them implicitly inline there instead of
only treating them as inline in CodeGen. Unfortunately, this breaks a
lot of dllimport test cases, so that is future work for now.

Fixes PR36125.

llvm-svn: 325375
2018-02-16 19:44:47 +00:00
Alexey Bataev 9a75738b2b [OPENMP] Fix PR35873: Fix data-sharing attributes for const variables.
Compiler erroneously returned wrong data-sharing attributes for the
constant variables if they have explictly specified attributes.

llvm-svn: 325373
2018-02-16 19:16:54 +00:00
Alexey Bataev 96dae81d7f [OPENMP] Fix parsing of the directives with inner directives.
The parsing may lead to compiler hanging because of the incorrect
processing of inner OpenMP pragmas.

llvm-svn: 325369
2018-02-16 18:36:44 +00:00
Erich Keane 29636aaaa6 Clean up 'target' attribute diagnostics
There were a few issues previously with the target
attribute diagnostics implementation that lead to the
attribute being added to the AST despite having an error
in it.

This patch changes that, and adds a test to ensure it
does not get added to the AST.

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

llvm-svn: 325364
2018-02-16 17:31:59 +00:00
Frederich Munch af2aee930f Use Token::isOneOf method in Parser.
Summary: Easier to read and possibly optimize.

Reviewers: rsmith, sepavloff

Reviewed By: sepavloff

Subscribers: sepavloff, cfe-commits

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

llvm-svn: 325352
2018-02-16 16:07:33 +00:00
Sjoerd Meijer e145c1d44f [ARM] Add tests for the vcvtr builtins
This adds Sema and Codegen tests for the vcvtr builtins
(because they were missing).

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

llvm-svn: 325351
2018-02-16 16:01:08 +00:00
Brian Gesiak 521b13b001 [Coroutines] Use target-agnostic size_t in test
Summary:
Fix a test failure on ARM hosts that was caused by a difference in the type of
size_t, by using a target-agnostic definiton.

Test Plan:
```
clang -cc1 -internal-isystem build/lib/clang/7.0.0/include -nostdsysteminc \
      -std=c++14 -fcoroutines-ts -verify clang/test/SemaCXX/coroutines.cpp \
      -fcxx-exceptions -fexceptions \
      -triple armeb-none-eabi
```

llvm-svn: 325342
2018-02-16 14:11:27 +00:00
Krasimir Georgiev 2fac8d94a9 [clang-format] Enable google text proto formatting in R"proto('s
llvm-svn: 325336
2018-02-16 12:10:06 +00:00
Hans Wennborg 02d3361c38 Revert r325321 "[Sema] Take into account the current context when checking the"
This broke the Chromium build, see https://crbug.com/813017

> accessibility of a class member.
>
> This fixes PR32898.
>
> rdar://problem/33737747
>
> Differential revision: https://reviews.llvm.org/D36918

llvm-svn: 325335
2018-02-16 12:06:32 +00:00
Akira Hatanaka 82443d365f [Sema] Take into account the current context when checking the
accessibility of a class member.

This fixes PR32898.

rdar://problem/33737747

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

llvm-svn: 325321
2018-02-16 08:47:37 +00:00
Vedant Kumar 3e2ae49a25 [Coverage] Handle break/continue outside of loop bodies
Teach the coverage mapping logic to handle break or continue statements
within for loop increments.

Fixes llvm.org/PR36406.

llvm-svn: 325319
2018-02-16 07:59:43 +00:00
Ekaterina Romanova f28751849e [DOXYGEN] There was a request in the review D41507 to change the notation for hex numbers in doxygen documentation from <...>h to 0x<...>. Both of these notations were used in x86 intrinsics documentation. I promised to change them to 0x<...> for consistency.
Differential Revision: https://reviews.llvm.org/D41888

llvm-svn: 325312
2018-02-16 03:11:35 +00:00
Bruno Cardoso Lopes 5bccc5270e [Modules] Extend -fmodule-name semantic for frameworks with private modules
Assume Foo.framework with two module maps and two modules Foo and
Foo_Private.

Framework authors need to skip building both Foo and Foo_Private when
using -fmodule-name=Foo, since both are part of the framework and used
interchangeably during compilation.

rdar://problem/37500098

llvm-svn: 325305
2018-02-16 00:12:57 +00:00
Alexey Bataev ea33dee38c [OPENMP] Fix PR36399: Crash on C code with ordered doacross construct.
Codegen for ordered with doacross construct might produce incorrect code
because of missing cleanup scope for the construct. Without this scope
the final runtime function call could be emitted in the wrong order that
leads to incorrect codegen.

llvm-svn: 325304
2018-02-15 23:39:43 +00:00
Alexey Bataev 17daedfd04 [OPENMP] Fix PR38398: compiler crash on standalone pragma ordered with depend sink|source clause.
Patch fixes compiler crash on standalone #pragmas ordered with
depend(sink|source) clauses.

llvm-svn: 325302
2018-02-15 22:42:57 +00:00
Aaron Ballman f884cd42cc Silence a -Wparentheses warning; NFC.
llvm-svn: 325293
2018-02-15 21:03:39 +00:00
Aaron Ballman 6f20dc8988 Silence some -Wunused-variable warnings; NFC.
llvm-svn: 325292
2018-02-15 20:56:19 +00:00
Brian Gesiak 986062219f [Coroutines] Use allocator overload when available
Summary:
Depends on https://reviews.llvm.org/D42605.

An implementation of the behavior described in `[dcl.fct.def.coroutine]/7`:
when a promise type overloads `operator new` using a "placement new"
that takes the same argument types as the coroutine function, that
overload is used when allocating the coroutine frame.

Simply passing references to the coroutine function parameters directly
to `operator new` results in invariant violations in LLVM's coroutine
splitting pass, so this implementation modifies Clang codegen to
produce allocator-specific alloc/store/loads for each parameter being
forwarded to the allocator.

Test Plan: `check-clang`

Reviewers: rsmith, GorNishanov, eric_niebler

Reviewed By: GorNishanov

Subscribers: lewissbaker, EricWF, cfe-commits

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

llvm-svn: 325291
2018-02-15 20:37:22 +00:00
Brian Gesiak 87412d95e3 [Sema] Toggle diags when finding allocators (NFCI)
Summary:
Many methods in Sema take a `bool Diagnose` parameter. Examples of such
methods include `Sema::FindDeallocationFunction` and
`Sema::SpecialMemberIsTrivial`. Calling these methods with
`Diagnose = false` allows callers to, for instance, check for the
existence of a deallocation function, without that check resulting in
error diagnostics being emitted if no matching deallocation function exists.

Add a similar `bool Diagnose` to the `Sema::FindAllocationFunctions`
method, so that checks for the existence of allocation functions can be
made without triggering error diagnostics.

This allows `SemaCoroutine.cpp`, in its implementation of the
Coroutines TS, to check for the existence of a particular `operator new`
overload, but then without error fall back to a default `operator new`
if no matching overload exists.

Test Plan: `check-clang`

Reviewers: rsmith, GorNishanov, eric_niebler

Reviewed By: GorNishanov

Subscribers: cfe-commits

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

llvm-svn: 325288
2018-02-15 20:09:25 +00:00
Artem Dergachev 543e8af99d [analyzer] Suppress temporary destructors for temporary arrays.
Array destructors, like constructors, need to be called for each element of the
array separately. We do not have any mechanisms to do this in the analyzer,
so for now all we do is evaluate a single constructor or destructor
conservatively and give up. It automatically causes the necessary invalidation
and pointer escape for the whole array, because this is how RegionStore works.

Implement this conservative behavior for temporary destructors. This fixes the
crash on the provided test.

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

llvm-svn: 325286
2018-02-15 19:34:19 +00:00
Artem Dergachev 60f5aabc64 [analyzer] Implement path notes for temporary destructors.
Temporary destructors fire at the end of the full-expression. It is reasonable
to attach the path note for entering/leaving the temporary destructor to its
CXXBindTemporaryExpr. This would not affect lifetime-extended temporaries with
their automatic destructors which aren't temporary destructors.

The path note may be confusing in the case of destructors after elidable copy
constructors.

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

llvm-svn: 325284
2018-02-15 19:28:21 +00:00
Artem Dergachev 661ab34a31 [analyzer] Compute the correct this-region for temporary destructors.
Inline them if possible - a separate flag is added to control this.
The whole thing is under the cfg-temporary-dtors flag, off by default so far.

Temporary destructors are called at the end of full-expression. If the
temporary is lifetime-extended, automatic destructors kick in instead,
which are not addressed in this patch, and normally already work well
modulo the overally broken support for lifetime extension.

The patch operates by attaching the this-region to the CXXBindTemporaryExpr in
the program state, and then recalling it during destruction that was triggered
by that CXXBindTemporaryExpr. It has become possible because
CXXBindTemporaryExpr is part of the construction context since r325210.

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

llvm-svn: 325282
2018-02-15 19:17:44 +00:00
Yaxun Liu f8ad59d99d Clean up AMDGCN tests
Differential Revision: https://reviews.llvm.org/D43340

llvm-svn: 325279
2018-02-15 19:12:41 +00:00
Artem Dergachev 5bb02f3c02 [analyzer] NFC: Eliminate ParentMap lookup in mayInlineCallKind().
Don't look at the parent statement to figure out if the cxx-allocator-inlining
flag should kick in and prevent us from inlining the constructor within
a new-expression. We now have construction contexts for that purpose.

llvm-svn: 325278
2018-02-15 19:01:55 +00:00
Matt Davis b2c508b43f [Test] Remove mangled name from test.
This line is not needed in the test, and breaks Windows testing.
Fixes the test added in r325175.

llvm-svn: 325271
2018-02-15 17:55:52 +00:00
Yaxun Liu fa13d015a3 [OpenCL] Fix __enqueue_block for block with captures
The following test case causes issue with codegen of __enqueue_block

void (^block)(void) = ^{ callee(id, out); };

enqueue_kernel(queue, 0, ndrange, block);
Clang first does codegen for block expression in the first line and deletes its block info.
Clang then tries to do codegen for the same block expression again for the second line,
and fails because the block info is gone.

The fix is to do normal codegen for both lines. Introduce an API to OpenCL runtime to
record llvm block invoke function and llvm block literal emitted for each AST block
expression, and use the recorded information for generating the wrapper kernel.

The EmitBlockLiteral APIs are cleaned up to minimize changes to the normal codegen
of blocks.

Another minor issue is that some clean up AST expression is generated for block
with captures, which can be stripped by IgnoreImplicit.

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

llvm-svn: 325264
2018-02-15 16:39:19 +00:00
Aaron Ballman 736c09b4db Amend r325256. This change was not properly merged locally before the commit happened.
llvm-svn: 325261
2018-02-15 16:28:10 +00:00
Aaron Ballman a70c6b5cc6 NFC; clean up this file based on our coding standards. The impetus was considerable use of a type name as an identifier for an object.
Changed identifier names (especially function parameters) to not clash with type names and to follow the proper naming conventions. Use of explicit type names changed to use auto where appropriate. Removed unused parameters that should have never been added in the first place. Minor formatting cleanups.

The changes were mostly mechanical and should have no functional impact.

llvm-svn: 325256
2018-02-15 16:20:20 +00:00
Krasimir Georgiev b79987a95b [clang-format] Support repeated field lists in protos
Summary:
This patch adds support for list initialization of proto repeated fields:
```
keys: [1, 2, 3]
```

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 325252
2018-02-15 15:30:22 +00:00
Kamil Rytarowski 6353ecb08a Adding msan support for FreeBSD
Summary: Enabling memory sanitiser for X86_64 arch only. To match the sanitiser counterpart.

Patch by: David CARLIER

Reviewers: krytarowski

Reviewed By: krytarowski

Subscribers: dim, emaste, cfe-commits

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

llvm-svn: 325241
2018-02-15 14:19:23 +00:00
Kamil Rytarowski 7519288e8e Add Xray instrumentation compile-time/link-time support to FreeBSD
Summary: Similarly to the GNU driver version, adding proper compile and linker flags.

Patch by: David CARLIER

Reviewers: vitalybuka, krytarowski, dberris

Reviewed By: krytarowski, dberris

Subscribers: emaste, dberris, cfe-commits

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

llvm-svn: 325238
2018-02-15 14:12:21 +00:00
Martin Bohme b5f8ca47e7 Add -no-canonical-prefixes to allow different build modes.
llvm-svn: 325236
2018-02-15 13:50:07 +00:00
Jacek Olesiak ce4f0af302 [clang-format] Improve ObjC headers detection
Summary: Detect ObjC characteristic types when they start a line and add additional keywords.

Reviewers: benhamilton

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

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

llvm-svn: 325221
2018-02-15 08:47:56 +00:00
Artem Dergachev 9af0ed4aeb [analyzer] Inline constructors for destroyable temporaries.
Since r325210, in cfg-temporary-dtors mode, we can rely on the CFG to tell us
that we're indeed constructing a temporary, so we can trivially construct a
temporary region and inline the constructor.

Much like r325202, this is only done under the off-by-default
cfg-temporary-dtors flag because the temporary destructor, even if available,
will not be inlined and won't have the correct object value (target region).
Unless this is fixed, it is quite unsafe to inline the constructor.

If the temporary is lifetime-extended, the destructor would be an automatic
destructor, which would be evaluated with a "correct" target region - modulo
the series of incorrect relocations performed during the lifetime extension.
It means that at least, values within the object are guaranteed to be properly
escaped or invalidated.

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

llvm-svn: 325211
2018-02-15 03:26:43 +00:00
Artem Dergachev 1f68d9d39e [CFG] Provide construction contexts for temproary objects.
Constructors of C++ temporary objects that have destructors now can be queried
to discover that they're indeed constructing temporary objects.

The respective CXXBindTemporaryExpr, which is also repsonsible for destroying
the temporary at the end of full-expression, is now available at the
construction site in the CFG. This is all the context we need to provide for
temporary objects that are not lifetime extended. For lifetime-extended
temporaries, more context is necessary.

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

llvm-svn: 325210
2018-02-15 03:13:36 +00:00
Artem Dergachev 168e29f6af [analyzer] Decide on inlining destructors via EvalCallOptions.
EvalCallOptions were introduced in r324018 for allowing various parts of
ExprEngine to notify the inlining mechanism, while preparing for evaluating a
function call, of possible difficulties with evaluating the call that they
foresee. Then mayInlineCall() would still be a single place for making the
decision.

Use that mechanism for destructors as well - pass the necessary flags from the
CFG-element-specific destructor handlers.

Part of this patch accidentally leaked into r324018, which led into a change in
tests; this change is reverted now, because even though the change looked
correct, the underlying behavior wasn't. Both of these commits were not intended
to introduce any function changes otherwise.

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

llvm-svn: 325209
2018-02-15 02:51:58 +00:00