Commit Graph

79902 Commits

Author SHA1 Message Date
Peter Collingbourne 2452d7030b IR. Change strip* family of functions to not look through aliases.
I noticed another instance of the issue where references to aliases were
being replaced with aliasees, this time in InstCombine. In the instance that
I saw it turned out to be only a QoI issue (a symbol ended up being missing
from the symbol table due to the last reference to the alias being removed,
preventing HWASAN from symbolizing a global reference), but it could easily
have manifested as incorrect behaviour.

Since this is the third such issue encountered (previously: D65118, D65314)
it seems to be time to address this common error/QoI issue once and for all
and make the strip* family of functions not look through aliases.

Includes a test for the specific issue that I saw, but no doubt there are
other similar bugs fixed here.

As with D65118 this has been tested to make sure that the optimization isn't
load bearing. I built Clang, Chromium for Linux, Android and Windows as well
as the test-suite and there were no size regressions.

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

llvm-svn: 369697
2019-08-22 19:56:14 +00:00
Alex Lorenz 7a490c5b06 Disable the ScanDepsReuseFilemanager test on Windows
Right now it fails.
I'm going to investigate it and fix it in follow-up commits.

llvm-svn: 369688
2019-08-22 19:00:08 +00:00
Aaron Ballman 18796da0cd Improve the documentation for OpenCL vector types.
This fixes some minor grammatical issues I noticed when reading the docs, and changes the recommended feature testing approach to use __has_attribute instead of __has_extension.

llvm-svn: 369687
2019-08-22 18:57:46 +00:00
Aaron Ballman 518b2266f5 Fix the nullPointerConstant() test to get bots back to green.
llvm-svn: 369686
2019-08-22 18:56:18 +00:00
Aaron Ballman 9148302a2a Implement nullPointerConstant() using a better API.
Instead of manually attempting to identify whether something is a null pointer constant, use Expr::isNullPointerConstant().

llvm-svn: 369683
2019-08-22 18:26:44 +00:00
Alex Lorenz 4dc5573acc Introduce FileEntryRef and use it when handling includes to report correct dependencies
when the FileManager is reused across invocations

This commit introduces a parallel API to FileManager's getFile: getFileEntryRef, which returns
a reference to the FileEntry, and the name that was used to access the file. In the case of
a VFS with 'use-external-names', the FileEntyRef contains the external name of the file,
not the filename that was used to access it.

The new API is adopted only in the HeaderSearch and Preprocessor for include file lookup, so that the
accessed path can be propagated to SourceManager's FileInfo. SourceManager's FileInfo now can report this accessed path, using
the new getName method. This API is then adopted in the dependency collector, which now correctly reports dependencies when a file
is included both using a symlink and a real path in the case when the FileManager is reused across multiple Preprocessor invocations.

Note that this patch does not fix all dependency collector issues, as the same problem is still present in other cases when dependencies
are obtained using FileSkipped, InclusionDirective, and HasInclude. This will be fixed in follow-up commits.

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

llvm-svn: 369680
2019-08-22 18:15:50 +00:00
Richard Smith 966eea91ad Revert "[LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)"
This reverts commit r369591, because it causes the formerly-reliable
-Wreturn-stack-address warning to start issuing false positives.
Testcase provided on the commit thread.

llvm-svn: 369677
2019-08-22 17:48:11 +00:00
Benjamin Kramer cd2bae3bd7 Retire llvm::less_ptr. llvm::deref is much more flexible.
llvm-svn: 369675
2019-08-22 17:32:16 +00:00
Alexey Bataev ebcfc9eaed [OPENMP]Generalization of handling of declare target attribute.
Used OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration instead of
direct checking of the OMPDeclareTargetDeclAttr attribute.

llvm-svn: 369668
2019-08-22 16:48:26 +00:00
Hans Wennborg 8288453f6a Revert r369402 "win: Enable /Zc:twoPhase by default if targeting MSVC 2017 update 3 or newer"
This broke compiling some ASan tests with never versions of MSVC/the Win
SDK, see https://crbug.com/996675

> MSVC 2017 update 3 (_MSC_VER 1911) enables /Zc:twoPhase by default, and
> so should clang-cl:
> https://docs.microsoft.com/en-us/cpp/build/reference/zc-twophase
>
> clang-cl takes the MSVC version it emulates from the -fmsc-version flag,
> or if that's not passed it tries to check what the installed version of
> MSVC is and uses that, and failing that it uses a default version that's
> currently 1911. So this changes the default if no -fmsc-version flag is
> passed and no installed MSVC is detected. (It also changes the default
> if -fmsc-version is passed or MSVC is detected, and either indicates
> _MSC_VER >= 1911.)
>
> As mentioned in the MSDN article, the Windows SDK header files in
> version 10.0.15063.0 (Creators Update or Redstone 2) and earlier
> versions do not work correctly with /Zc:twoPhase. If you need to use
> these old SDKs with a new clang-cl, explicitly pass /Zc:twoPhase- to get
> the old behavior.
>
> Fixes PR43032.
>
> Differential Revision: https://reviews.llvm.org/D66394

llvm-svn: 369647
2019-08-22 13:15:36 +00:00
Yaxun Liu af478e240b [OpenCL] Fix declaration of enqueue_marker
Differential Revision: https://reviews.llvm.org/D66512

llvm-svn: 369641
2019-08-22 11:18:59 +00:00
Hans Wennborg 307a73221b Revert r369458 "[DebugInfo] Add debug location to dynamic atexit destructor"
It causes the build to fail with

"inlinable function call in a function with debug info must have a !dbg location"

in Chromium. See llvm-commits thread for more info.

(This also reverts the follow-up in r369474.)

> Fixes PR43012
>
> Differential Revision: https://reviews.llvm.org/D66328

llvm-svn: 369633
2019-08-22 09:07:25 +00:00
Haojian Wu fcedc6a61b Remove an unused function, suppress -Wunused-function warning.
llvm-svn: 369629
2019-08-22 08:49:41 +00:00
Joel E. Denny 7d5bc55433 [OpenMP] Permit map with DSA on combined directive
For `map`, the following restriction changed in OpenMP 5.0:

* OpenMP 4.5 [2.15.5.1, Restrictions]: "A list item cannot appear in
  both a map clause and a data-sharing attribute clause on the same
  construct.

* OpenMP 5.0 [2.19.7.1, Restrictions]: "A list item cannot appear in
  both a map clause and a data-sharing attribute clause on the same
  construct unless the construct is a combined construct."

This patch removes this restriction in the case of combined constructs
and OpenMP 5.0, and it updates Sema not to capture a scalar by copy in
the target region when `firstprivate` and `map` appear for that scalar
on a combined target construct.

This patch also adds a fixme to a test that now reveals that a
diagnostic about loop iteration variables is dropped in the case of
OpenMP 5.0.  That bug exists regardless of this patch's changes.

Reviewed By: ABataev, jdoerfert, hfinkel, kkwli0

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

llvm-svn: 369619
2019-08-22 03:34:30 +00:00
Kristof Umann 0f9e530c0f [analyzer] Enable control dependency condition tracking by default
This patch concludes my GSoC'19 project by enabling track-conditions by default.

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

llvm-svn: 369616
2019-08-22 03:08:48 +00:00
Csaba Dabis 4d71600c11 [analyzer] CastValueChecker: Model isa(), isa_and_nonnull()
Summary: -

Reviewed By: NoQ

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

llvm-svn: 369615
2019-08-22 02:57:59 +00:00
Kristof Umann 58eb033a49 [analyzer] Don't track the condition of foreach loops
As discussed on the mailing list, notes originating from the tracking of foreach
loop conditions are always meaningless.

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

llvm-svn: 369613
2019-08-22 02:44:19 +00:00
Csaba Dabis 22dc44ff89 [analyzer] CastValueChecker: Try to fix the buildbots
llvm-svn: 369609
2019-08-22 01:41:06 +00:00
Csaba Dabis e4bf456fce [analyzer] CastValueChecker: Rewrite dead header hotfix
llvm-svn: 369607
2019-08-22 00:36:42 +00:00
Csaba Dabis 0202c3596c [analyzer] CastValueChecker: Store the dynamic types and casts
Summary:
This patch introduces `DynamicCastInfo` similar to `DynamicTypeInfo` which
is stored in `CastSets` which are storing the dynamic cast informations of
objects based on memory regions. It could be used to store and check the
casts and prevent infeasible paths.

Reviewed By: NoQ

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

llvm-svn: 369605
2019-08-22 00:20:36 +00:00
Csaba Dabis b73a5711f6 [analyzer] TrackConstraintBRVisitor: Do not track unknown values
Summary: -

Reviewers: NoQ, Szelethus

Reviewed By: NoQ, Szelethus

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

llvm-svn: 369604
2019-08-22 00:06:58 +00:00
Kristof Umann d9a81ccf05 [analyzer] Mention whether an event is about a condition in a bug report part 2
In D65724, I do a pretty thorough explanation about how I'm solving this
problem, I think that summary nails whats happening here ;)

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

llvm-svn: 369596
2019-08-21 22:38:00 +00:00
Matthias Gehre b1c7801290 [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)
Summary:
This fixes inference of gsl::Pointer on std::set::iterator with libstdc++ (the typedef for iterator
on the template is a DependentNameType - we can only put the gsl::Pointer attribute
on the underlaying record after instantiation)

inference of gsl::Pointer on std::vector::iterator with libc++ (the class was forward-declared,
we added the gsl::Pointer on the canonical decl (the forward decl), and later when the
template was instantiated, there was no attribute on the definition so it was not instantiated).

and a duplicate gsl::Pointer on some class with libstdc++ (we first added an attribute to
a incomplete instantiation, and then another was copied from the template definition
when the instantiation was completed).

We now add the attributes to all redeclarations to fix thos issues and make their usage easier.

Reviewers: gribozavr

Subscribers: Szelethus, xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 369591
2019-08-21 22:08:59 +00:00
Kristof Umann 49ac7ece16 [analyzer] Don't make ConditionBRVisitor events prunable when the condition is an interesting field
Exactly what it says on the tin! Note that we're talking about interestingness
in general, hence this isn't a control-dependency-tracking specific patch.

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

llvm-svn: 369589
2019-08-21 21:59:22 +00:00
Alex Lorenz 06abd69695 NFCI: Simplify SourceManager::translateFile by removing code path that should never be taken
I noticed that SourceManager::translateFile has code that doesn't really make sense.
In particular, if it fails to find a FileID by comparing FileEntry * values, it tries to
look through files that have the same filename, to see if they have a matching inode to try to
find the right FileID. However, the inode comparison seem redundant, as Clang's FileManager
already deduplicates FileEntry * values by inode.
Thus the comparisons between inodes should never actually succeed, and the comparison between FileEntry * values should be sufficient here.

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

llvm-svn: 369585
2019-08-21 21:37:09 +00:00
Kristof Umann fff01c8ec2 [analyzer][NFC] Add different interestingness kinds
We defined (on the mailing list and here on phabricator) 2 different cases where
retrieving information about a control dependency condition is very important:

* When the condition's last write happened in a different stack frame
* When the collapse point of the condition (when we can constrain it to be
true/false) didn't happen in the actual condition.

It seems like we solved this problem with the help of expression value tracking,
and have started working on better diagnostics notes about this process.

Expression value tracking is nothing more than registering a variety of visitors
to construct reports about it. Each of the registered visitors (ReturnVisitor,
FindLastStoreVisitor, NoStoreFuncVisitor, etc) have something to go by: a
MemRegion, an SVal, an ExplodedNode, etc. For this reason, better explaining a
last write is super simple, we can always just pass on some more information to
the visitor in question (as seen in D65575).

ConditionBRVisitor is a different beast, as it was built for a different
purpose. It is responsible for constructing events at, well, conditions, and is
registered only once, and isn't a part of the "expression value tracking
family". Unfortunately, it is also the visitor to tinker with for constructing
better diagnostics about the collapse point problem.

This creates a need for alternative way to communicate with ConditionBRVisitor
that a specific condition is being tracked for for the reason of being a control
dependency. Since at almost all PathDiagnosticEventPiece construction the
visitor checks interestingness, it makes sense to pair interestingness with a
reason as to why we marked an entity as such.

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

llvm-svn: 369583
2019-08-21 21:33:25 +00:00
Benjamin Kramer 81faa5e6a2 Use C++14 heteregenous lookup for a couple of std::map<std::string, ...>
These call find with a StringRef, heterogenous lookup saves a temporary
std::string there.

llvm-svn: 369581
2019-08-21 21:17:34 +00:00
Kristof Umann da648ab8de [analyzer] Mention whether an event is about a condition in a bug report part 1
Can't add much more to the title! This is part 1, the case where the collapse
point isn't in the condition point is the responsibility of ConditionBRVisitor,
which I'm addressing in part 2.

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

llvm-svn: 369574
2019-08-21 20:43:27 +00:00
Leonard Chan 19ec31d1a5 [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1 under the new pass manager
Match the behavior of D65009 under the new pass manager. This addresses
the test clang/test/CodeGen/split-lto-unit.c when running under the new
PM.

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

llvm-svn: 369550
2019-08-21 17:24:14 +00:00
Nico Weber 138a815a00 clang: Fix typo in comment
llvm-svn: 369542
2019-08-21 15:52:44 +00:00
Nico Weber f64918d092 clang: Fix typo in comment
(Sorry for all these commits; trying to sort out why svn doesn't want to store
my password.)

llvm-svn: 369540
2019-08-21 15:49:21 +00:00
Nico Weber 3ad6cea9bb clang: Fix typo in comment
llvm-svn: 369539
2019-08-21 15:41:29 +00:00
Nico Weber f56e8991f4 clang: Fix typo in comment
llvm-svn: 369536
2019-08-21 15:37:27 +00:00
Dmitri Gribenko 6b9d7c9da5 Removed some dead code in BugReporter and related files
Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 369504
2019-08-21 08:48:24 +00:00
David Zarzycki b08884554f [PPC Docs] Remove duplicate info about __builtin_setrnd()
This looks like a combination of a copy-and-paste (and paste and paste)
error and a commit without reviewing the diff first error.

llvm-svn: 369496
2019-08-21 06:48:11 +00:00
Reid Kleckner ed757305b8 Add triple to new test to try to pacify bots
llvm-svn: 369474
2019-08-20 23:32:51 +00:00
Alexandre Ganea be6c079419 [DebugInfo] Add debug location to dynamic atexit destructor
Fixes PR43012

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

llvm-svn: 369458
2019-08-20 22:09:49 +00:00
Artem Dergachev 3fdc427f0b [analyzer] NFC: Remove the BugTypes set from BugReporter.
Its only purpose was to avoid a bug that's caused by
making a virtual call in BugReporter's destructor.

llvm-svn: 369451
2019-08-20 21:41:20 +00:00
Artem Dergachev 8eb7a74b78 [analyzer] Fix a crash when destroying a non-region.
Add defensive check that prevents a crash when we try to evaluate a destructor
whose this-value is a concrete integer that isn't a null.

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

llvm-svn: 369450
2019-08-20 21:41:17 +00:00
Artem Dergachev d3971fe97b [analyzer] Improve VirtualCallChecker and enable parts of it by default.
Calling a pure virtual method during construction or destruction
is undefined behavior. It's worth it to warn about it by default.
That part is now known as the cplusplus.PureVirtualCall checker.

Calling a normal virtual method during construction or destruction
may be fine, but does behave unexpectedly, as it skips virtual dispatch.
Do not warn about this by default, but let projects opt in into it
by enabling the optin.cplusplus.VirtualCall checker manually.

Give the two parts differentiated warning text:

  Before:

    Call to virtual function during construction or destruction:
    Call to pure virtual function during construction

    Call to virtual function during construction or destruction:
    Call to virtual function during destruction

  After:

    Pure virtual method call:
    Call to pure virtual method 'X::foo' during construction
        has undefined behavior

    Unexpected loss of virtual dispatch:
    Call to virtual method 'Y::bar' during construction
        bypasses virtual dispatch

Also fix checker names in consumers that support them (eg., clang-tidy)
because we now have different checker names for pure virtual calls and
regular virtual calls.

Also fix capitalization in the bug category.

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

llvm-svn: 369449
2019-08-20 21:41:14 +00:00
Leonard Chan b0a7544ee2 [NewPM] Run ubsan-coroutines test under the legacy pass manager only
The passes that lower the llvm.coro.* instrinsics have not yet been ported,
so only run under the legacy PM for now.

See https://bugs.llvm.org/show_bug.cgi?id=42867

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

llvm-svn: 369442
2019-08-20 20:55:36 +00:00
Alexey Bataev 9fd495be1f [OPENMP]Fix delayed diagnostics for standalone declare target directive.
If the function is marked as declare target in a standalone directive,
the delayed diagnostics is not emitted. Patch fixes this problem.

llvm-svn: 369432
2019-08-20 19:50:13 +00:00
David Goldman fd4d77707f [Sema][Typo] Fix assertion failure for expressions with multiple typos
Summary:
As Typo Resolution can create new TypoExprs while resolving typos,
it is necessary to recurse through the expression to search for more
typos.

This should fix the assertion failure in `clang::Sema::~Sema()`:
  `DelayedTypos.empty() && "Uncorrected typos!"`

Notes:
- In case some TypoExprs are created but thrown away, Sema
  now has a Vector that is used to keep track of newly created
  typos.
- For expressions with multiple typos, we only give suggestions
  if we are able to resolve all typos in the expression
- This patch is similar to D37521 except that it does not eagerly
  commit to a correction for the first typo in the expression.
  Instead, it will search for corrections which fix all of the
  typos in the expression.

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 369427
2019-08-20 19:03:15 +00:00
Alexey Bataev c4299553f0 Fix name of the error message, NFC.
llvm-svn: 369418
2019-08-20 17:50:13 +00:00
Nathan Huckleberry 1e0affb6e5 [Attr] Support _attribute__ ((fallthrough))
Summary: Fixed extraneous matches of non-NullStmt

Reviewers: aaron.ballman, rsmith, efriedma, xbolva00

Reviewed By: aaron.ballman, rsmith, xbolva00

Subscribers: riccibruno, arphaman, ziangwan, ojeda, xbolva00, nickdesaulniers, cfe-commits

Tags: #clang

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

llvm-svn: 369414
2019-08-20 17:16:49 +00:00
Gabor Horvath eaee4de503 [LifetimeAnalysis] Add support for free functions
Differential Revision: https://reviews.llvm.org/D66303

llvm-svn: 369408
2019-08-20 16:45:06 +00:00
Nico Weber fe91b9d6da win: Enable /Zc:twoPhase by default if targeting MSVC 2017 update 3 or newer
MSVC 2017 update 3 (_MSC_VER 1911) enables /Zc:twoPhase by default, and
so should clang-cl:
https://docs.microsoft.com/en-us/cpp/build/reference/zc-twophase

clang-cl takes the MSVC version it emulates from the -fmsc-version flag,
or if that's not passed it tries to check what the installed version of
MSVC is and uses that, and failing that it uses a default version that's
currently 1911. So this changes the default if no -fmsc-version flag is
passed and no installed MSVC is detected. (It also changes the default
if -fmsc-version is passed or MSVC is detected, and either indicates
_MSC_VER >= 1911.)

As mentioned in the MSDN article, the Windows SDK header files in
version 10.0.15063.0 (Creators Update or Redstone 2) and earlier
versions do not work correctly with /Zc:twoPhase. If you need to use
these old SDKs with a new clang-cl, explicitly pass /Zc:twoPhase- to get
the old behavior.

Fixes PR43032.

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

llvm-svn: 369402
2019-08-20 16:28:11 +00:00
Jan Kratochvil 95b5f42de8 [clang] Use the new Regex::isValid() with no parameter
Differential Revision: https://reviews.llvm.org/D66463

llvm-svn: 369397
2019-08-20 16:07:31 +00:00
Johan Vikstrom 6687fde07a [Syntax] Added function to get macro expansion tokens to TokenBuffer.
Summary:
Returns the first token in every mapping where the token is an identifier.
This API is required to be able to highlight macro expansions in clangd.

Reviewers: hokein, ilya-biryukov

Subscribers: kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 369385
2019-08-20 13:34:01 +00:00
Dmitri Gribenko dee011b7f4 Removed the 'id' AST matcher, which is superseded by '.bind()'
Summary:
The 'id' matcher is not even included in the AST Matchers Reference
document, so I don't expect there to be a significant number of users.

There's no reason to provide two ways to do the exact same thing that
only have a minor syntactic difference.

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 369380
2019-08-20 13:02:28 +00:00
Sven van Haastregt cc0ba28cf0 [OpenCL] Add const, volatile and pointer builtin handling
Const, volatile, and pointer types were previously available, but not
working.  This patch adds handling for OpenCL builtin functions.

Add TableGen definitions for some atomic and asynchronous builtins to
make use of the new functionality.

Patch by Pierre Gondois and Sven van Haastregt.

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

llvm-svn: 369373
2019-08-20 12:21:03 +00:00
Stephan Bergmann 982b105d2f Rudimentary support for Doxygen \retval command
...so that at least a preceding \param etc. that lacks a description gets a
-Wdocumentation warning (instead of erroneously treating the \retval ... text as
its paragraph).

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

llvm-svn: 369345
2019-08-20 08:36:21 +00:00
Artem Dergachev 8cf3dfea54 [CallGraph] Take into accound calls that aren't within any function bodies.
This patch improves Clang call graph analysis by adding in expressions
that are not found in regular function bodies, such as default arguments
or member initializers.

Patch by Joshua Cranmer!

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

llvm-svn: 369321
2019-08-20 02:22:37 +00:00
Artem Dergachev ee92f12fd1 [analyzer] NFC: Rename GRBugReporter to PathSensitiveBugReporter.
The GR prefix is super ancient.

llvm-svn: 369320
2019-08-20 02:15:50 +00:00
Artem Dergachev 48786cf8d3 [analyzer] NFC: Drop support for extra text attached to bug reports.
It was introduced in 2011 but never used since then.

llvm-svn: 369319
2019-08-20 02:15:47 +00:00
Anton Afanasyev 3f3a2573c3 [Support][Time profiler] Make FE codegen blocks to be inside frontend blocks
Summary:
Add `Frontend` time trace entry to `HandleTranslationUnit()` function.
Add test to check all codegen blocks are inside frontend blocks.
Also, change `--time-trace-granularity` option a bit to make sure very small
time blocks are outputed to json-file when using `--time-trace-granularity=0`.

This fixes http://llvm.org/pr41969

Reviewers: russell.gallop, lebedev.ri, thakis

Reviewed By: russell.gallop

Subscribers: vsapsai, aras-p, lebedev.ri, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 369308
2019-08-19 22:58:26 +00:00
Erich Keane a8abe1f828 Fix poorly formatted HTML in the cxx_status.html file caused by adding
1668.

llvm-svn: 369286
2019-08-19 18:14:22 +00:00
Erich Keane f04d246d7d Fix test where diagnostics changed in P1668 implementation
llvm-svn: 369284
2019-08-19 18:08:52 +00:00
Erich Keane ab00f237ac Update cxx_status.html with P1668 status.
llvm-svn: 369282
2019-08-19 17:57:27 +00:00
Erich Keane 62b072d413 Implement P1668R1
Allow inline assembly statements in unexecuted branches of constexpr
functions.

llvm-svn: 369281
2019-08-19 17:39:59 +00:00
Aaron Ballman b6ab533b93 Don't keep stale pointers to LoopInfos.
CGLoopInfo was keeping pointers to parent loop LoopInfos, but when the loop info vector grew, it reallocated the storage and invalidated all of the parent pointers, causing use-after-free. Manage the lifetimes of the LoopInfos separately so that the pointers aren't stale.

Patch by Bevin Hansson.

llvm-svn: 369259
2019-08-19 13:37:41 +00:00
Sven van Haastregt b21a3654f0 [OpenCL] Add generic type handling for builtin functions
Generic types are an abstraction of type sets.  It mimics the way
functions are defined in the OpenCL specification.  For example,
floatN can abstract all the vector sizes of the float type.

This allows to
 * stick more closely to the specification, which uses generic types;
 * factorize definitions of functions with numerous prototypes in the
   tablegen file; and
 * reduce the memory impact of functions with many overloads.

Patch by Pierre Gondois and Sven van Haastregt.

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

llvm-svn: 369253
2019-08-19 11:56:03 +00:00
Anastasia Stulova eb801abd58 [OpenCL] Fix addr space deduction for pointers/references to arrays.
Rewrite the logic for detecting if we are deducing addr space of
a pointee type to take into account special logic for arrays. For
pointers/references to arrays we can have any number of parentheses
expressions as well as nested pointers.

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

llvm-svn: 369251
2019-08-19 11:43:16 +00:00
David Bolvansky 920890e268 [Diagnostics] Diagnose misused xor as pow
Summary:
Motivation:
https://twitter.com/jfbastien/status/1139298419988549632
https://twitter.com/mikemx7f/status/1139335901790625793
https://codesearch.isocpp.org/cgi-bin/cgi_ppsearch?q=10+%5E&search=Search

Reviewers: jfb, rsmith, regehr, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: lebedev.ri, Quuxplusone, erik.pilkington, riccibruno, dexonsmith, cfe-commits

Tags: #clang

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

llvm-svn: 369217
2019-08-18 19:14:14 +00:00
Owen Pan 37860d524e [clang-format] Fix a bug that joins template closer and =
Also fixes the documentation for SpaceBeforeAssignmentOperators.

See discussions at https://reviews.llvm.org/D66332

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

llvm-svn: 369214
2019-08-18 18:51:39 +00:00
David Bolvansky b4806822d2 [Diagnostics] Improve -Wsizeof-pointer-div
Emit diag note with a location of pointer declaration.
Revisited/added tests.

llvm-svn: 369206
2019-08-18 10:10:09 +00:00
Tan S. B. 8fd6aa5ed2 [SemaDeclCXX] Allow inheriting constructor declaration to specify a cv-qualified type
Differential Revision: https://reviews.llvm.org/D47419

llvm-svn: 369196
2019-08-17 20:57:52 +00:00
Kristof Umann 032e1fdcd4 [analyzer] Turn an assert into an if condition
Shocker, turns out that terminator conditions that are binary operators
aren't always logical operators.

llvm-svn: 369195
2019-08-17 16:49:54 +00:00
Troy A. Johnson c0d70bca0f [X86] Support -mlong-double-80
Add an option group for all of the -mlong-double-* options and make
-mlong-double-80 restore the default long double behavior for X86.  The
motivations are that GNU accepts the -mlong-double-80 option and that complex
Makefiles often need a way of undoing earlier options. Prior to this commit, if
one chooses 64-bit or 128-bit long double for X86, there is no way to undo that
choice and restore the 80-bit behavior.

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

llvm-svn: 369183
2019-08-17 04:20:24 +00:00
Jian Cai 16fa8b0970 Reland "[ARM] push LR before __gnu_mcount_nc"
This relands r369147 with fixes to unit tests.

https://reviews.llvm.org/D65019

llvm-svn: 369173
2019-08-16 23:30:16 +00:00
Troy A. Johnson 0dd9494d47 Revert "[X86] Support -mlong-double-80"
This reverts commit 250aafa2c4.
Caused buildbot failures -- still investigating.

llvm-svn: 369170
2019-08-16 23:18:22 +00:00
Richard Smith 87869b398d [doc] Fix some minor formatting issues.
llvm-svn: 369161
2019-08-16 22:08:39 +00:00
Owen Pan ac67414618 [clang-format] Fix the bug that joins template closer and > or >>
Also fixes a buggy test case.

See PR42404

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

llvm-svn: 369157
2019-08-16 21:49:17 +00:00
Troy A. Johnson 250aafa2c4 [X86] Support -mlong-double-80
Add an option group for all of the -mlong-double-* options and make
-mlong-double-80 restore the default long double behavior for X86.  The
motivations are that GNU accepts the -mlong-double-80 option and that complex
Makefiles often need a way of undoing earlier options. Prior to this commit, if
one chooses 64-bit or 128-bit long double for X86, there is no way to undo that
choice and restore the 80-bit behavior.

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

llvm-svn: 369152
2019-08-16 21:00:22 +00:00
Jian Cai 2d957cfe02 Revert "[ARM] push LR before __gnu_mcount_nc"
This reverts commit f4cf3b9593.

llvm-svn: 369149
2019-08-16 20:40:21 +00:00
Troy A. Johnson 856608c30a [Test Commit] Fix typo in diagtool.rst
Test commit after obtaining commit access.

llvm-svn: 369148
2019-08-16 20:26:48 +00:00
Jian Cai f4cf3b9593 [ARM] push LR before __gnu_mcount_nc
Push LR register before calling __gnu_mcount_nc as it expects the value of LR register to be the top value of
the stack on ARM32.

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

llvm-svn: 369147
2019-08-16 20:21:08 +00:00
Alexey Bataev 217ff1e445 [OPENMP5.0]Diagnose global variables in lambda not marked as declare
target.

According to OpenMP 5.0, if a lambda declaration and definition appears between a declare target directive and the matching end declare target directive, all variables that are captured by the lambda expression must also appear in a to clause.

llvm-svn: 369146
2019-08-16 20:15:02 +00:00
Richard Smith 2e3ed4a852 Stop abusing SuppressAllDiagnostics when speculatively determining
whether an expression would be valid during error recovery.

llvm-svn: 369145
2019-08-16 19:53:22 +00:00
Gabor Marton b9a8ac74f1 Fix typos in LibASTImporter.rst
llvm-svn: 369099
2019-08-16 12:21:49 +00:00
Balazs Keri e13e836480 [ASTImporter] Import ctor initializers after setting flags.
Summary:
Code to import "ctor initializers" at import of functions
is moved to be after the flags in the newly created function
are imported. This fixes an error when the already created but
incomplete (flags are not set) function declaration is accessed.

Reviewers: martong, shafik, a_sidorin, a.sidorin

Reviewed By: shafik

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

llvm-svn: 369098
2019-08-16 12:10:03 +00:00
Lewis Revill 1653ebee3f [RISCV] Add inline asm constraint A for RISC-V
This allows the constraint A to be used in inline asm for RISC-V, which
allows an address held in a register to be used.

This patch adds the minimal amount of code required to get operands with
the right constraints to compile.

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

llvm-svn: 369093
2019-08-16 10:23:56 +00:00
Csaba Dabis a079a42708 [analyzer] Analysis: Silence checkers
Summary:
This patch introduces a new `analyzer-config` configuration:
`-analyzer-config silence-checkers`
which could be used to silence the given checkers.

It accepts a semicolon separated list, packed into quotation marks, e.g:
`-analyzer-config silence-checkers="core.DivideZero;core.NullDereference"`

It could be used to "disable" core checkers, so they model the analysis as
before, just if some of them are too noisy it prevents to emit reports.

This patch also adds support for that new option to the scan-build.
Passing the option `-disable-checker core.DivideZero` to the scan-build
will be transferred to `-analyzer-config silence-checkers=core.DivideZero`.

Reviewed By: NoQ, Szelethus

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

llvm-svn: 369078
2019-08-16 01:53:14 +00:00
Joel E. Denny 9be6d7edb2 [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug
I'd like to add these comments to warn others of problems I
encountered when trying to use `RemoveLineIfEmpty`.  I originally
tried to fix the problem, but I realized I could implement the
functionality more easily and efficiently in my calling code where I
can make the simplifying assumption that there are no prior edits to
the line from which text is being removed.  While I've lost the
motivation to write a fix, which doesn't look easy, I figure a warning
to others is better than silence.

I've added a unit test to demonstrate the problem.  I don't know how
to mark it as an expected failure, so I just marked it disabled.

Reviewed By: jkorous

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

llvm-svn: 369049
2019-08-15 21:17:48 +00:00
Alexey Bataev deb49a6217 Mark the test as unsupported on darwin, NFC.
The bundler may fail on darwin, mark the test as not compatible.

llvm-svn: 369044
2019-08-15 20:31:47 +00:00
Reid Kleckner ed399a69e2 [Sema] Implement DR2386 for C++17 structured binding
Allow implementations to provide complete definitions of
std::tuple_size<T>, but to omit the 'value' member to signal that T is
not tuple-like. The Microsoft standard library implements
std::tuple_size<const T> this way.

If the value member exists, clang still validates that it is an ICE, but
if it does not, then the type is considered to not be tuple-like.

Fixes PR33236

Reviewers: rsmith

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

llvm-svn: 369043
2019-08-15 19:45:28 +00:00
Guanzhong Chen 82bfd1d257 [WebAssembly] Correctly handle va_arg of zero-sized structures
Summary:
D66168 passes size 0 structs indirectly, while the wasm backend expects it to
be passed directly. This causes subsequent variadic arguments to be read
incorrectly.

This diff changes it so that size 0 structs are passed directly.

Reviewers: dschuff, tlively, sbc100

Reviewed By: dschuff

Subscribers: jgravelle-google, aheejin, sunfish, cfe-commits

Tags: #clang

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

llvm-svn: 369042
2019-08-15 19:33:36 +00:00
Aaron Ballman ce1750d964 Rename this file from cx2.c to c2x.c; NFC.
llvm-svn: 369035
2019-08-15 18:37:30 +00:00
Aaron Ballman 2ed4573e8f Allow standards-based attributes to have leading and trailing underscores.
This gives library implementers a way to use standards-based attributes that do not conflict with user-defined macros of the same name. Attributes in C2x require this behavior normatively (C2x 6.7.11p4), but there's no reason to not have the same behavior in C++, especially given that such attributes may be used by a C library consumed by a C++ compilation.

llvm-svn: 369033
2019-08-15 18:35:44 +00:00
Alexey Bataev 1c3a5d78bd Fix the test, NFC.
llvm-svn: 369028
2019-08-15 17:53:49 +00:00
George Karpenkov e7fdf7cb71 Test commit #2.
llvm-svn: 369020
2019-08-15 17:17:21 +00:00
Alexey Bataev 4fb80d56db [Driver][Bundler] Improve bundling of object files.
Summary:
Previously, object files were bundled using partial linking. It resulted
in the following structure of the bundled objects:
```
<host_code>
clang-offload-bundle
__CLANG_OFFLOAD_BUNDLE__<target>
<target_code>
```
But when we tried to unbundle object files, it worked correctly only for
the target objects. The host object remains bundled. It produced a lot of
junk sections in the host object files and in some cases may caused
incorrect linking.

Patch improves bundling of the object files. After this patch the
bundled object looks like this:

```
<host_code>
clang-offload-bundle
__CLANG_OFFLOAD_BUNDLE__<target>
<target_code>
__CLANG_OFFLOAD_BUNDLE__<host>
<host_code>
```

With this structure we are able to unbundle the host object files too so
that after unbundling they are the same as were before.
The host section is bundled twice. The bundled section is used to
unbundle the original host section.

Reviewers: yaxunl, tra, jlebar, hfinkel, jdoerfert

Subscribers: caomhin, kkwli0, cfe-commits

Tags: #clang

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

llvm-svn: 369019
2019-08-15 17:15:35 +00:00
Alexey Bataev b2df99cd95 [BUNDLER]Improve the test, NFC.
Summary:
Make the test more portable and do not rely on the pre-bundled object
file.

Reviewers: Hahnfeld, hfinkel, jdoerfert

Subscribers: caomhin, kkwli0, cfe-commits

Tags: #clang

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

llvm-svn: 369015
2019-08-15 16:28:24 +00:00
Benjamin Kramer 37508d3dd9 Replace llvm::integer_sequence and friends with the C++14 standard version
The implementation in libc++ takes O(1) compile time, ours was O(n).

llvm-svn: 368990
2019-08-15 10:56:05 +00:00
Russell Gallop 2601cdd3ae Revert rL368939 "Remove LVALUE / RVALUE workarounds"
This reverts commit cad8356d69.

To unbreak Windows bots

llvm-svn: 368985
2019-08-15 10:12:11 +00:00
Kristof Umann a1aef90bdd [analyzer] Warn about -analyzer-configs being meant for development purposes only
This is more of a temporary fix, long term, we should convert AnalyzerOptions.def
into the universally beloved (*coughs*) TableGen format, where they can more
easily be separated into developer-only, alpha, and user-facing configs.

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

llvm-svn: 368980
2019-08-15 08:53:16 +00:00
Kristof Umann e6e133b700 [analyzer] Add docs for cplusplus.InnerPointer
Differential Revision: https://reviews.llvm.org/D60281

llvm-svn: 368979
2019-08-15 08:52:10 +00:00
Sjoerd Meijer 90374f7557 [clang] Loop pragma parsing. NFC.
Just a refactoring and a tidy up.

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

llvm-svn: 368976
2019-08-15 07:39:05 +00:00
Sjoerd Meijer 535efab2e5 [Clang] Pragma vectorize_predicate implies vectorize
New pragma "vectorize_predicate(enable)" now implies "vectorize(enable)",
and it is ignored when vectorization is disabled with e.g.
"vectorize(disable) vectorize_predicate(enable)".

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

llvm-svn: 368970
2019-08-15 06:24:40 +00:00
Craig Topper 803e849cbf [X86] Add test cases for _mm_movepi64_pi64 and _mm_movpi64_epi64.
llvm-svn: 368969
2019-08-15 06:20:33 +00:00
David L. Jones 4ed5521cad [Tooling] Add a hack to work around issues with matcher binding in r368681.
The change in r368681 contains a (probably unintentional) behavioral change for
rewrite rules with a single matcher. Previously, the single matcher would not
need to be bound (`joinCaseMatchers` returned it directly), even though a final
DynTypeMatcher was created and bound by `buildMatcher`. With the new change, a
single matcher will be bound, in addition to the final binding (which is now in
`buildMatchers`, but happens roughly at the same point in the overall flow).

This patch simply duplicates the "final matcher" trick: it creates an extra
DynTypedMatcher for each rewrite rule case matcher, and unconditionally makes it
bindable. This is probably not the right long-term fix, but it does allow
existing code to continue to work with this interface.

Subscribers: cfe-commits, gribozavr, ymandel

Tags: #clang

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

llvm-svn: 368958
2019-08-15 04:10:11 +00:00
Jonas Devlieghere d24e9eb9d2 [NFC] Update doc comment to fix warning.
This fixes the warning: parameter 'EnableNullFPSuppression' not found in
the function declaration [-Wdocumentation]

llvm-svn: 368954
2019-08-15 03:59:30 +00:00
Alex Langford 0630bbc7fe [NFCI] Always initialize BugReport const fields
Summary:
Some compilers require that const fields of an object must be explicitly
initialized by the constructor. I ran into this issue building with clang
3.8 on Ubuntu 16.04.

Reviewers: compnerd, Szelethus, NoQ

Subscribers: cfe-commits, llvm-commits

Tags: #clang

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

llvm-svn: 368950
2019-08-15 00:58:51 +00:00
Jonas Devlieghere 2b3d49b610 [Clang] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

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

llvm-svn: 368942
2019-08-14 23:04:18 +00:00
Richard Smith 5cd312d352 [www] Update DR status page to match latest version of CWG issues list.
llvm-svn: 368941
2019-08-14 22:57:51 +00:00
Richard Smith 9e77f524b5 Fix handling of class member access into a vector type.
When handling a member access into a non-class, non-ObjC-object type, we
would perform a lookup into the surrounding scope as if for an
unqualified lookup. If the member access was followed by a '<' and this
lookup (or the typo-correction for it) found a template name, we'd treat
the member access as naming that template.

Now we treat such accesses as never naming a template if the type of the
object expression is of vector type, so that vector component accesses
are never misinterpreted as naming something else. This is not entirely
correct, since it is in fact valid to name a template from the enclosing
scope in this context, when invoking a pseudo-destructor for the vector
type via an alias template, but that's very much a corner case, and this
change leaves that case only as broken as the corresponding case for
Objective-C types is.

This incidentally adds support for dr2292, which permits a 'template'
keyword at the start of a member access naming a pseudo-destructor.

llvm-svn: 368940
2019-08-14 22:57:50 +00:00
JF Bastien cad8356d69 Remove LVALUE / RVALUE workarounds
Summary: LLVM_HAS_RVALUE_REFERENCE_THIS and LLVM_LVALUE_FUNCTION shouldn't be needed anymore because the minimum compiler versions support them.

Subscribers: jkorous, dexonsmith, cfe-commits, llvm-commits, hans, thakis, chandlerc, rnk

Tags: #clang, #llvm

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

llvm-svn: 368939
2019-08-14 22:48:12 +00:00
Matthias Gehre 1bebc22bd9 [LifetimeAnalysis] Support std::stack::top() and std::optional::value()
Summary: Diagnose dangling pointers that come from std::stack::top() and std::optional::value().

Reviewers: gribozavr

Subscribers: cfe-commits, xazax.hun

Tags: #clang

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

llvm-svn: 368929
2019-08-14 21:55:57 +00:00
Stanislav Mekhanoshin c17705b7fb [AMDGPU] Do not assume a default GCN target
Differential Revision: https://reviews.llvm.org/D66246

llvm-svn: 368917
2019-08-14 20:55:15 +00:00
Alexey Bataev f8be476f0c [OPENMP]Support for non-rectangular loops.
Added basic support for non-rectangular loops. It requires an additional
analysis of min/max boundaries for non-rectangular loops. Since only
linear dependency is allowed, we can do this analysis.

llvm-svn: 368903
2019-08-14 19:30:06 +00:00
Kristof Umann 92541e359e [CFG] Introduce CFGElementRef, a wrapper that knows it's position in a CFGBlock
Previously, collecting CFGElements in a set was practially impossible, because
both CFGBlock::operator[] and both the iterators returned it by value. One
workaround would be to collect the iterators instead, but they don't really
capture the concept of an element, and elements from different iterator types are incomparable.

This patch introduces CFGElementRef, a wrapper around a (CFGBlock, Index) pair,
and a variety of new iterators and iterator ranges to solve this problem.

I guess you could say that this patch took a couple iterations to get right :^)

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

llvm-svn: 368883
2019-08-14 17:05:55 +00:00
Puyan Lotfi 740f69b91b [NFC][clang] Moving argument handling: Driver::BuildActions -> handleArguments
This patch simply moves code that already exists into a new function.
Specifically I think it will make the BuildActions code for building a clang
job pipeline easier to read and work with.

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

llvm-svn: 368881
2019-08-14 17:02:21 +00:00
Erik Pilkington aa3855694f [Sema][ObjC] Fix a -Wformat false positive with localizedStringForKey
Only honour format_arg attributes on -[NSBundle localizedStringForKey] when its
argument has a format specifier in it, otherwise its likely to just be a key to
fetch localized strings.

Fixes rdar://23622446

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

llvm-svn: 368878
2019-08-14 16:57:11 +00:00
David Bolvansky 8f5c1c0148 [NFC] Updated tests after r368875
llvm-svn: 368876
2019-08-14 16:50:34 +00:00
Chris Bieneman a80a3a2b23 Document clang-cpp in the release notes for clang
This patch adds a line in the release notes about the new clang-cpp library and the CMake option to force clang to link against it.

llvm-svn: 368874
2019-08-14 16:49:52 +00:00
Gabor Horvath bfe0c37601 [LifetimeAnalysis] Fix false negatives of statement local lifetime analysis for some STL implementation
Differential Revision: https://reviews.llvm.org/D66152

llvm-svn: 368871
2019-08-14 16:34:56 +00:00
David Bolvansky bffa4a2b17 [NFC] Fix testcase for ARMs
llvm-svn: 368863
2019-08-14 15:35:40 +00:00
Yitzhak Mandelbaum 385a451844 [libTooling] Fix code to avoid unused-function warning after r368681.
llvm-svn: 368862
2019-08-14 15:20:06 +00:00
Kristof Umann 571c52af58 [analyzer][NFC] Prove that we only track the evaluated part of the condition
...because we're working with a BugReporterVisitor, and the non-evaluated part
of the condition isn't in the bugpath.

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

llvm-svn: 368853
2019-08-14 13:51:52 +00:00
Shaurya Gupta 36ca1e6399 [Tooling] Added DeclStmtClass to ExtractionSemicolonPolicy
Since the DeclStmt range includes the semicolon, it doesn't need a
semicolon at the end during extraction

llvm-svn: 368850
2019-08-14 13:37:39 +00:00
Kristof Umann dd53bdbfde [analyzer][CFG] Don't track the condition of asserts
Well, what is says on the tin I guess!

Some more changes:

* Move isInevitablySinking() from BugReporter.cpp to CFGBlock's interface
* Rename and move findBlockForNode() from BugReporter.cpp to
ExplodedNode::getCFGBlock()

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

llvm-svn: 368836
2019-08-14 12:20:08 +00:00
Dmitri Gribenko 030409020c Removed ToolExecutor::isSingleProcess, it is not used by anything
Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 368832
2019-08-14 11:35:04 +00:00
David Bolvansky 544c2e3f8b [NFC] Make test more robust
Currently fails on ARMs

llvm-svn: 368828
2019-08-14 11:13:10 +00:00
Dmitri Gribenko 175261c9ec Improved the doc comment for getCommentsInFile
Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 368827
2019-08-14 11:11:52 +00:00
George Rimar a11d302fa0 [clang] - An update after LLVM change.
SectionRef::getName() was changed to return Expected<> (D66089)

llvm-svn: 368825
2019-08-14 11:10:01 +00:00
Sven van Haastregt 15e26d1fe9 Fix _WIN32 / _WIN64 Wundef warnings
For these macros it is the definedness that matters rather than
the value.  Make new uses of these macros consistent with existing
uses.

llvm-svn: 368822
2019-08-14 10:30:18 +00:00
Balazs Keri c509594319 [ASTImporter] Import default expression of param before creating the param.
Summary:
The default expression of a parameter variable should be imported before
the parameter variable object is created. Otherwise the function is created
with an incomplete parameter variable (default argument is nullptr) and in
this intermediary state the expression is imported. This import can have
a reference to the incomplete parameter variable that causes crash.

Reviewers: martong, a.sidorin, shafik

Reviewed By: martong

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

llvm-svn: 368818
2019-08-14 09:41:39 +00:00
Kristof Umann 967583bc08 [analyzer] Note last writes to a condition only in a nested stackframe
Exactly what it says on the tin! The comments in the code detail this a
little more too.

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

llvm-svn: 368817
2019-08-14 09:39:38 +00:00
David Bolvansky b0a8a25442 [Codegen] Updated test for D66158
Reviewers: jdoerfert

Reviewed By: jdoerfert

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 368809
2019-08-14 08:32:31 +00:00
Haojian Wu ec25edc17a Fix the -Wunused-variable warning.
llvm-svn: 368808
2019-08-14 08:20:42 +00:00
Dmitri Gribenko 1427226fe8 Removed dead code from clang/tools/libclang/CXIndexDataConsumer.{cpp,h}
Reviewers: jkorous

Subscribers: dexonsmith, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 368805
2019-08-14 07:32:51 +00:00
Taewook Oh d4c50f7326 [NewPM][PassInstrumentation] IR printing support from clang driver
Summary: https://reviews.llvm.org/D50923 enabled the IR printing support for the new pass manager, but only for the case when `opt` tool is used as a driver. This patch is to enable the IR printing when `clang` is used as a driver.

Reviewers: fedor.sergeev, philip.pfaffe

Subscribers: cfe-commits, yamauchi, llvm-commits

Tags: #clang

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

llvm-svn: 368804
2019-08-14 07:11:09 +00:00
John McCall 5f60b68c68 Remove unreachable blocks before splitting a coroutine.
The suspend-crossing algorithm is not correct in the presence of uses
that cannot be reached on some successor path from their defs.

llvm-svn: 368796
2019-08-14 03:54:13 +00:00
Richard Smith dac3ea4eb3 Add __has_builtin support for builtin function-like type traits.
Summary:
Previously __has_builtin(__builtin_*) would return false for
__builtin_*s that we modeled as keywords rather than as functions
(because they take type arguments). With this patch, all builtins
that are called with function-call-like syntax return true from
__has_builtin (covering __builtin_* and also the __is_* and __has_* type
traits and the handful of similar builtins without such a prefix).

Update the documentation on __has_builtin and on type traits to match.
While doing this I noticed the type trait documentation was out of date
and incomplete; that's fixed here too.

Reviewers: aaron.ballman

Subscribers: jfb, kristina, cfe-commits

Tags: #clang

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

llvm-svn: 368785
2019-08-14 02:30:11 +00:00
Alex Langford 21872bc9bf [analyzer] Don't delete TaintConfig copy constructor
Summary:
Explicitly deleting the copy constructor makes compiling the function
`ento::registerGenericTaintChecker` difficult with some compilers. When we
construct an `llvm::Optional<TaintConfig>`, the optional is constructed with a
const TaintConfig reference which it then uses to invoke the deleted TaintConfig
copy constructor.

I've observered this failing with clang 3.8 on Ubuntu 16.04.

Reviewers: compnerd, Szelethus, boga95, NoQ, alexshap

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, Charusso, llvm-commits, cfe-commits

Tags: #clang

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

llvm-svn: 368779
2019-08-14 01:09:07 +00:00
Douglas Yung 5ee4d7a859 [ORC] Fix clang-interpreter example code broken by r368707.
llvm-svn: 368778
2019-08-14 01:03:35 +00:00
Kristof Umann 3f7c66d551 [analyzer][NFC] Prepare visitors for different tracking kinds
When we're tracking a variable that is responsible for a null pointer
dereference or some other sinister programming error, we of course would like to
gather as much information why we think that the variable has that specific
value as possible. However, the newly introduced condition tracking shows that
tracking all values this thoroughly could easily cause an intolerable growth in
the bug report's length.

There are a variety of heuristics we discussed on the mailing list[1] to combat
this, all of them requiring to differentiate in between tracking a "regular
value" and a "condition".

This patch introduces the new `bugreporter::TrackingKind` enum, adds it to
several visitors as a non-optional argument, and moves some functions around to
make the code a little more coherent.

[1] http://lists.llvm.org/pipermail/cfe-dev/2019-June/062613.html

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

llvm-svn: 368777
2019-08-14 00:48:57 +00:00
Kristof Umann 0df9c8c578 [analyzer] Track the right hand side of the last store regardless of its value
Summary:
The following code snippet taken from D64271#1572188 has an issue: namely,
because `flag`'s value isn't undef or a concrete int, it isn't being tracked.

int flag;
bool coin();

void foo() {
  flag = coin();
}

void test() {
  int *x = 0;
  int local_flag;
  flag = 1;

  foo();
  local_flag = flag;
  if (local_flag)
    x = new int;

  foo();
  local_flag = flag;
  if (local_flag)
    *x = 5;
}

This, in my opinion, makes no sense, other values may be interesting too.
Originally added by rC185608.

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

llvm-svn: 368773
2019-08-13 23:48:10 +00:00
Kristof Umann 46929df723 [analyzer] Prune calls to functions with linear CFGs that return a non-zero constrained value
During the evaluation of D62883, I noticed a bunch of totally
meaningless notes with the pattern of "Calling 'A'" -> "Returning value"
-> "Returning from 'A'", which added no value to the report at all.

This patch (not only affecting tracked conditions mind you) prunes
diagnostic messages to functions that return a value not constrained to
be 0, and are also linear.

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

llvm-svn: 368771
2019-08-13 23:22:33 +00:00
Artem Dergachev daf41722bd [analyzer] exploded-graph-rewriter: Implement displaying Store pointers.
They're useful when trying to understand what's going on
inside your LazyCompoundValues.

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

llvm-svn: 368769
2019-08-13 23:04:56 +00:00
Artem Dergachev 9289681ea3 [analyzer] exploded-graph-rewriter: Implement manual graph trimming.
When -trim-egraph is unavailable (say, when you're debugging a crash on
a real-world code that takes too long to reduce), it makes sense to view
the untrimmed graph up to the crashing node's predecessor, then dump the ID
(or a pointer) of the node in the attached debugger, and then trim
the dumped graph in order to keep only paths from the root to the node.

The newly added --to flag does exactly that:

$ exploded-graph-rewriter.py ExprEngine.dot --to 0x12229acd0

Multiple nodes can be specified. Stable IDs of nodes can be used
instead of pointers.

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

llvm-svn: 368768
2019-08-13 23:04:53 +00:00
Artem Dergachev 0b26891f3f [analyzer] exploded-graph-rewriter: NFC: Refactor explorers into trimmers.
Explorers aren't the right abstraction. For the purposes of displaying svg files
we don't care in which order do we explore the nodes. We may care about this for
other analyses, but we're not there yet.

The function of cutting out chunks of the graph is performed poorly by
the explorers, because querying predecessors/successors on the explored nodes
yields original successors/predecessors even if they aren't being explored.

Introduce a new entity, "trimmers", that do one thing but to it right: cut out
chunks of the graph. Trimmers mutate the graph, so stale edges aren't even
visible to their consumers in the pipeline. Additionally, trimmers are
intrinsically composable: multiple trimmers can be applied to the graph
sequentially.

Refactor the single-path explorer into the single-path trimmer.
Rename the test file for consistency.

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

llvm-svn: 368767
2019-08-13 23:04:50 +00:00
Artem Dergachev e9e3635453 [analyzer] exploded-graph-rewriter: Open the converted graph immediately.
Change the default behavior: the tool no longer dumps the rewritten .dot file
to stdout, but instead it automatically converts it into an .html file
(which essentially wraps an .svg file) and immediately opens it with
the default web browser.

This means that the tool should now be fairly easy to use:

  $ exploded-graph-rewriter.py /tmp/ExprEngine.dot

The benefits of wrapping the .svg file into an .html file are:

    - It'll open in a web browser, which is the intended behavior.
      An .svg file would be open with an image viewer/editor instead.
    - It avoids the white background around the otherwise dark svg area
      in dark mode.

The feature can be turned off by passing a flag '--rewrite-only'.
The LIT substitution is updated to enforce the old mode because
we don't want web browsers opening on our buildbots.

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

llvm-svn: 368766
2019-08-13 23:04:47 +00:00
Artem Dergachev f5a60e590f [analyzer] Disable the checker-plugins test on Darwin.
Fixes a buildbot.

llvm-svn: 368765
2019-08-13 23:04:44 +00:00
Jan Korous 9a13852eab [clang][DirectoryWatcher] Fix Windows stub after LLVM change
r367979 changed DirectoryWatcher::Create to return an llvm::Expected.
Adjust the Windows stub accordingly.

(upstreamed from github.com/apple/swift-clang)

llvm-svn: 368762
2019-08-13 22:39:50 +00:00
Jan Korous b724f3d4b3 [clang] DirectoryWatcher for Windows stubs (to fix build break).
This is just a code skeleton for DirectoryWatcher-windows.cpp so the
build on Windows stops breaking.

(upstreamed from github.com/apple/swift-clang)

llvm-svn: 368761
2019-08-13 22:39:26 +00:00
Kristof Umann e1117addd6 [analyzer][NFC] Make sure that the BugReport is not modified during the construction of non-visitor pieces
I feel this is kinda important, because in a followup patch I'm adding different
kinds of interestingness, and propagating the correct kind in BugReporter.cpp is
just one less thing to worry about.

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

llvm-svn: 368755
2019-08-13 22:03:08 +00:00
Erik Pilkington 6c97f88986 Add a missing header comment, NFC
llvm-svn: 368754
2019-08-13 22:01:39 +00:00
Kristof Umann 6c1b19ac9e [analyzer][NFC] Refactoring BugReporter.cpp P6.: Completely get rid of interestingness propagation
Apparently this does literally nothing.

When you think about this, it makes sense. If something is really important,
we're tracking it anyways, and that system is sophisticated enough to mark
actually interesting statements as such. I wouldn't say that it's even likely
that subexpressions are also interesting (array[10 - x + x]), so I guess even
if this produced any effects, its probably undesirable.

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

llvm-svn: 368752
2019-08-13 21:48:17 +00:00
Guanzhong Chen 8a503e439d [WebAssembly] Make clang emit correct va_arg code for structs
Summary:
In the WebAssembly backend, when lowering variadic function calls, non-single
member aggregate type arguments are always passed by pointer.

However, when emitting va_arg code in clang, the arguments are instead read as
if they are passed directly. This results in the pointer being read as the
actual structure.

Fixes https://github.com/emscripten-core/emscripten/issues/9042.

Reviewers: tlively, sbc100, kripken, aheejin, dschuff

Reviewed By: dschuff

Subscribers: dschuff, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

llvm-svn: 368750
2019-08-13 21:41:11 +00:00