]> granicus.if.org Git - clang/log
clang
5 years agoReplace llvm::integer_sequence and friends with the C++14 standard version
Benjamin Kramer [Thu, 15 Aug 2019 10:56:05 +0000 (10:56 +0000)]
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).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368990 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert rL368939 "Remove LVALUE / RVALUE workarounds"
Russell Gallop [Thu, 15 Aug 2019 10:12:11 +0000 (10:12 +0000)]
Revert rL368939 "Remove LVALUE / RVALUE workarounds"

This reverts commit cad8356d699b36c73abb267f65db575ddacbd652.

To unbreak Windows bots

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368985 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Warn about -analyzer-configs being meant for development purposes only
Kristof Umann [Thu, 15 Aug 2019 08:53:16 +0000 (08:53 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368980 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Add docs for cplusplus.InnerPointer
Kristof Umann [Thu, 15 Aug 2019 08:52:10 +0000 (08:52 +0000)]
[analyzer] Add docs for cplusplus.InnerPointer

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368979 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang] Loop pragma parsing. NFC.
Sjoerd Meijer [Thu, 15 Aug 2019 07:39:05 +0000 (07:39 +0000)]
[clang] Loop pragma parsing. NFC.

Just a refactoring and a tidy up.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368976 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Clang] Pragma vectorize_predicate implies vectorize
Sjoerd Meijer [Thu, 15 Aug 2019 06:24:40 +0000 (06:24 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368970 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Add test cases for _mm_movepi64_pi64 and _mm_movpi64_epi64.
Craig Topper [Thu, 15 Aug 2019 06:20:33 +0000 (06:20 +0000)]
[X86] Add test cases for _mm_movepi64_pi64 and _mm_movpi64_epi64.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368969 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Tooling] Add a hack to work around issues with matcher binding in r368681.
David L. Jones [Thu, 15 Aug 2019 04:10:11 +0000 (04:10 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368958 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Update doc comment to fix warning.
Jonas Devlieghere [Thu, 15 Aug 2019 03:59:30 +0000 (03:59 +0000)]
[NFC] Update doc comment to fix warning.

This fixes the warning: parameter 'EnableNullFPSuppression' not found in
the function declaration [-Wdocumentation]

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368954 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFCI] Always initialize BugReport const fields
Alex Langford [Thu, 15 Aug 2019 00:58:51 +0000 (00:58 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368950 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Clang] Migrate llvm::make_unique to std::make_unique
Jonas Devlieghere [Wed, 14 Aug 2019 23:04:18 +0000 (23:04 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368942 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[www] Update DR status page to match latest version of CWG issues list.
Richard Smith [Wed, 14 Aug 2019 22:57:51 +0000 (22:57 +0000)]
[www] Update DR status page to match latest version of CWG issues list.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368941 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix handling of class member access into a vector type.
Richard Smith [Wed, 14 Aug 2019 22:57:50 +0000 (22:57 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368940 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove LVALUE / RVALUE workarounds
JF Bastien [Wed, 14 Aug 2019 22:48:12 +0000 (22:48 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368939 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[LifetimeAnalysis] Support std::stack::top() and std::optional::value()
Matthias Gehre [Wed, 14 Aug 2019 21:55:57 +0000 (21:55 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368929 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AMDGPU] Do not assume a default GCN target
Stanislav Mekhanoshin [Wed, 14 Aug 2019 20:55:15 +0000 (20:55 +0000)]
[AMDGPU] Do not assume a default GCN target

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368917 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Support for non-rectangular loops.
Alexey Bataev [Wed, 14 Aug 2019 19:30:06 +0000 (19:30 +0000)]
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368903 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CFG] Introduce CFGElementRef, a wrapper that knows it's position in a CFGBlock
Kristof Umann [Wed, 14 Aug 2019 17:05:55 +0000 (17:05 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368883 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC][clang] Moving argument handling: Driver::BuildActions -> handleArguments
Puyan Lotfi [Wed, 14 Aug 2019 17:02:21 +0000 (17:02 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368881 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema][ObjC] Fix a -Wformat false positive with localizedStringForKey
Erik Pilkington [Wed, 14 Aug 2019 16:57:11 +0000 (16:57 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368878 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Updated tests after r368875
David Bolvansky [Wed, 14 Aug 2019 16:50:34 +0000 (16:50 +0000)]
[NFC] Updated tests after r368875

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368876 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoDocument clang-cpp in the release notes for clang
Chris Bieneman [Wed, 14 Aug 2019 16:49:52 +0000 (16:49 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368874 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[LifetimeAnalysis] Fix false negatives of statement local lifetime analysis for some...
Gabor Horvath [Wed, 14 Aug 2019 16:34:56 +0000 (16:34 +0000)]
[LifetimeAnalysis] Fix false negatives of statement local lifetime analysis for some STL implementation

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368871 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Fix testcase for ARMs
David Bolvansky [Wed, 14 Aug 2019 15:35:40 +0000 (15:35 +0000)]
[NFC] Fix testcase for ARMs

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368863 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[libTooling] Fix code to avoid unused-function warning after r368681.
Yitzhak Mandelbaum [Wed, 14 Aug 2019 15:20:06 +0000 (15:20 +0000)]
[libTooling] Fix code to avoid unused-function warning after r368681.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368862 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Prove that we only track the evaluated part of the condition
Kristof Umann [Wed, 14 Aug 2019 13:51:52 +0000 (13:51 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368853 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Tooling] Added DeclStmtClass to ExtractionSemicolonPolicy
Shaurya Gupta [Wed, 14 Aug 2019 13:37:39 +0000 (13:37 +0000)]
[Tooling] Added DeclStmtClass to ExtractionSemicolonPolicy

Since the DeclStmt range includes the semicolon, it doesn't need a
semicolon at the end during extraction

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368850 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][CFG] Don't track the condition of asserts
Kristof Umann [Wed, 14 Aug 2019 12:20:08 +0000 (12:20 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368836 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemoved ToolExecutor::isSingleProcess, it is not used by anything
Dmitri Gribenko [Wed, 14 Aug 2019 11:35:04 +0000 (11:35 +0000)]
Removed ToolExecutor::isSingleProcess, it is not used by anything

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368832 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Make test more robust
David Bolvansky [Wed, 14 Aug 2019 11:13:10 +0000 (11:13 +0000)]
[NFC] Make test more robust

Currently fails on ARMs

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368828 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoImproved the doc comment for getCommentsInFile
Dmitri Gribenko [Wed, 14 Aug 2019 11:11:52 +0000 (11:11 +0000)]
Improved the doc comment for getCommentsInFile

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368827 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang] - An update after LLVM change.
George Rimar [Wed, 14 Aug 2019 11:10:01 +0000 (11:10 +0000)]
[clang] - An update after LLVM change.

SectionRef::getName() was changed to return Expected<> (D66089)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368825 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix _WIN32 / _WIN64 Wundef warnings
Sven van Haastregt [Wed, 14 Aug 2019 10:30:18 +0000 (10:30 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368822 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTImporter] Import default expression of param before creating the param.
Balazs Keri [Wed, 14 Aug 2019 09:41:39 +0000 (09:41 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368818 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Note last writes to a condition only in a nested stackframe
Kristof Umann [Wed, 14 Aug 2019 09:39:38 +0000 (09:39 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368817 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Codegen] Updated test for D66158
David Bolvansky [Wed, 14 Aug 2019 08:32:31 +0000 (08:32 +0000)]
[Codegen] Updated test for D66158

Reviewers: jdoerfert

Reviewed By: jdoerfert

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368809 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix the -Wunused-variable warning.
Haojian Wu [Wed, 14 Aug 2019 08:20:42 +0000 (08:20 +0000)]
Fix the -Wunused-variable warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368808 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemoved dead code from clang/tools/libclang/CXIndexDataConsumer.{cpp,h}
Dmitri Gribenko [Wed, 14 Aug 2019 07:32:51 +0000 (07:32 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368805 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NewPM][PassInstrumentation] IR printing support from clang driver
Taewook Oh [Wed, 14 Aug 2019 07:11:09 +0000 (07:11 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368804 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove unreachable blocks before splitting a coroutine.
John McCall [Wed, 14 Aug 2019 03:54:13 +0000 (03:54 +0000)]
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368796 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd __has_builtin support for builtin function-like type traits.
Richard Smith [Wed, 14 Aug 2019 02:30:11 +0000 (02:30 +0000)]
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368785 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Don't delete TaintConfig copy constructor
Alex Langford [Wed, 14 Aug 2019 01:09:07 +0000 (01:09 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368779 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ORC] Fix clang-interpreter example code broken by r368707.
Douglas Yung [Wed, 14 Aug 2019 01:03:35 +0000 (01:03 +0000)]
[ORC] Fix clang-interpreter example code broken by r368707.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368778 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Prepare visitors for different tracking kinds
Kristof Umann [Wed, 14 Aug 2019 00:48:57 +0000 (00:48 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368777 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Track the right hand side of the last store regardless of its value
Kristof Umann [Tue, 13 Aug 2019 23:48:10 +0000 (23:48 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368773 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Prune calls to functions with linear CFGs that return a non-zero constrain...
Kristof Umann [Tue, 13 Aug 2019 23:22:33 +0000 (23:22 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368771 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: Implement displaying Store pointers.
Artem Dergachev [Tue, 13 Aug 2019 23:04:56 +0000 (23:04 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368769 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: Implement manual graph trimming.
Artem Dergachev [Tue, 13 Aug 2019 23:04:53 +0000 (23:04 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368768 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: NFC: Refactor explorers into trimmers.
Artem Dergachev [Tue, 13 Aug 2019 23:04:50 +0000 (23:04 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368767 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: Open the converted graph immediately.
Artem Dergachev [Tue, 13 Aug 2019 23:04:47 +0000 (23:04 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368766 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Disable the checker-plugins test on Darwin.
Artem Dergachev [Tue, 13 Aug 2019 23:04:44 +0000 (23:04 +0000)]
[analyzer] Disable the checker-plugins test on Darwin.

Fixes a buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368765 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang][DirectoryWatcher] Fix Windows stub after LLVM change
Jan Korous [Tue, 13 Aug 2019 22:39:50 +0000 (22:39 +0000)]
[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)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368762 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang] DirectoryWatcher for Windows stubs (to fix build break).
Jan Korous [Tue, 13 Aug 2019 22:39:26 +0000 (22:39 +0000)]
[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)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368761 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Make sure that the BugReport is not modified during the construction...
Kristof Umann [Tue, 13 Aug 2019 22:03:08 +0000 (22:03 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368755 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd a missing header comment, NFC
Erik Pilkington [Tue, 13 Aug 2019 22:01:39 +0000 (22:01 +0000)]
Add a missing header comment, NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368754 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Refactoring BugReporter.cpp P6.: Completely get rid of interestingnes...
Kristof Umann [Tue, 13 Aug 2019 21:48:17 +0000 (21:48 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368752 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[WebAssembly] Make clang emit correct va_arg code for structs
Guanzhong Chen [Tue, 13 Aug 2019 21:41:11 +0000 (21:41 +0000)]
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368750 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove the extra `;`.
Michael Liao [Tue, 13 Aug 2019 21:26:42 +0000 (21:26 +0000)]
Remove the extra `;`.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368748 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Address inlines of D65484
Kristof Umann [Tue, 13 Aug 2019 20:42:48 +0000 (20:42 +0000)]
[analyzer][NFC] Address inlines of D65484

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368745 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Refactor] Moving SourceExtraction header from lib to include
Shaurya Gupta [Tue, 13 Aug 2019 20:21:00 +0000 (20:21 +0000)]
[Refactor] Moving SourceExtraction header from lib to include

Summary:
- Moved the SourceExtraction header from lib to include so that it can be used in clangd.

Reviewers: arphaman

Subscribers: ilya-biryukov, dexonsmith, kadircet, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368743 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoDon't use std::errc
Alexey Bataev [Tue, 13 Aug 2019 19:32:36 +0000 (19:32 +0000)]
Don't use std::errc

Summary:
As noted on Errc.h:

// * std::errc is just marked with is_error_condition_enum. This means that
//   common patters like AnErrorCode == errc::no_such_file_or_directory take
//   4 virtual calls instead of two comparisons.

And on some libstdc++ those virtual functions conclude that

------------------------
int main() {
  std::error_code foo = std::make_error_code(std::errc::no_such_file_or_directory);
  return foo == std::errc::no_such_file_or_directory;
}
-------------------------

should exit with 0.

Reviewers: thakis, rnk, jfb

Reviewed By: thakis

Subscribers: lebedev.ri, dexonsmith, xbolva00, cfe-commits, caomhin

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368739 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "Fix crash on switch conditions of non-integer types in templates"
Dmitri Gribenko [Tue, 13 Aug 2019 19:07:28 +0000 (19:07 +0000)]
Revert "Fix crash on switch conditions of non-integer types in templates"

This reverts commit r368706. It broke ClangTidy tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368738 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Refactoring BugReporter.cpp P5.: Compact mile long function invocatio...
Kristof Umann [Tue, 13 Aug 2019 19:01:33 +0000 (19:01 +0000)]
[analyzer][NFC] Refactoring BugReporter.cpp P5.: Compact mile long function invocations into objects

In D65379, I briefly described the construction of bug paths from an
ExplodedGraph. This patch is about refactoring the code processing the bug path
into a bug report.

A part of finding a valid bug report was running all visitors on the bug path,
so we already have a (possibly empty) set of diagnostics for each ExplodedNode
in it.
Then, for each diagnostic consumer, we construct non-visitor diagnostic pieces.

* We first construct the final diagnostic piece (the warning), then
* We start ascending the bug path from the error node's predecessor (since the
error node itself was used to construct the warning event). For each node
  * We check the location (whether its a CallEnter, CallExit) etc. We simultaneously
  keep track of where we are with the execution by pushing CallStack when we see a
  CallExit (keep in mind that everything is happening in reverse!), popping it
  when we find a CallEnter, compacting them into a single PathDiagnosticCallEvent.

void f() {
  bar();
}

void g() {
  f();
  error(); // warning
}

=== The bug path ===

(root) -> f's CallEnter -> bar() -> f's CallExit -> (error node)

=== Constructed report ===

  f's CallEnter -> bar() -> f's CallExit
           ^               /
            \             V
(root) --->  f's CallEvent --> (error node)

  * We also keep track of different PathPieces different location contexts
  * (CallEvent::path in the above example has f's LocationContext, while the
  CallEvent itself is in g's context) in a LocationContextMap object. Construct
  whatever piece, if any, is needed for the note.
  * If we need to generate edges (or arrows) do so. Make sure to also connect
  these pieces with the ones that visitors emitted.
  * Clean up the constructed PathDiagnostic by making arrows nicer, pruning
  function calls, etc.

So I complained about mile long function invocations with seemingly the same
parameters being passed around. This problem, as I see it, a natural candidate
for creating classes and tying them all together.

I tried very hard to make the implementation feel natural, like, rolling off the
tongue. I introduced 2 new classes: PathDiagnosticBuilder (I mean, I kept the
name but changed almost everything in it) contains every contextual information
(owns the bug path, the diagnostics constructed but the visitors, the BugReport
itself, etc) needed for constructing a PathDiagnostic object, and is pretty much
completely immutable. BugReportContruct is the object containing every
non-contextual information (the PathDiagnostic object we're constructing, the
current location in the bug path, the location context map and the call stack I
meantioned earlier), and is passed around all over the place as a single entity
instead of who knows how many parameters.

I tried to used constness, asserts, limiting visibility of fields to my
advantage to clean up the code big time and dramatically improve safety. Also,
whenever I found the code difficult to understand, I added comments and/or
examples.

Here's a complete list of changes and my design philosophy behind it:

* Instead of construcing a ReportInfo object (added by D65379) after finding a
valid bug report, simply return an optional PathDiagnosticBuilder object straight
away. Move findValidReport into the class as a static method. I find
GRBugReporter::generatePathDiagnostics a joy to look at now.
* Rename generatePathDiagnosticForConsumer to generate (maybe not needed, but
felt that way in the moment) and moved it to PathDiagnosticBuilder. If we don't
need to generate diagnostics, bail out straight away, like we always should have.
After that, construct a BugReportConstruct object, leaving the rest of the logic
untouched.
* Move all static methods that would use contextual information into
PathDiagnosticBuilder, reduce their parameter count drastically by simply
passing around a BugReportConstruct object.
* Glance at the code I removed: Could you tell what the original
PathDiagnosticBuilder::LC object was for? It took a gooood long while for me to
realize that nothing really. It is always equal with the LocationContext
associated with our current position in the bug path. Remove it completely.
* The original code contains the following expression quite a bit:
LCM[&PD.getActivePath()], so what does it mean? I said that we collect the
contexts associated with different PathPieces, but why would we ever modify that,
shouldn't it be set? Well, theoretically yes, but in the implementation, the
address of PathDiagnostic::getActivePath doesn't change if we move to an outer,
previously unexplored function. Add both descriptive method names and
explanations to BugReportConstruct to help on this.
* Add plenty of asserts, both for safety and as a poor man's documentation.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368737 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Refactoring BugReporter.cpp P4.: If it can be const, make it const
Kristof Umann [Tue, 13 Aug 2019 18:48:08 +0000 (18:48 +0000)]
[analyzer][NFC] Refactoring BugReporter.cpp P4.: If it can be const, make it const

When I'm new to a file/codebase, I personally find C++'s strong static type
system to be a great aid. BugReporter.cpp is still painful to read however:
function calls are made with mile long parameter lists, seemingly all of them
taken with a non-const reference/pointer. This patch fixes nothing but this:
make a few things const, and hammer it until it compiles.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368735 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC][clang] Adding argument based Phase list filtering to getComplicationPhases
Puyan Lotfi [Tue, 13 Aug 2019 18:42:03 +0000 (18:42 +0000)]
[NFC][clang] Adding argument based Phase list filtering to getComplicationPhases

This patch removes usage of FinalPhase from anywhere outside of the scope where
it is used to do argument handling.  It also adds argument based trimming of
the Phase list pulled out of the Types.def table.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368734 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang] Refactor doc comments to Decls attribution
Jan Korous [Tue, 13 Aug 2019 18:11:44 +0000 (18:11 +0000)]
[clang] Refactor doc comments to Decls attribution

- Create ASTContext::attachCommentsToJustParsedDecls so we don't have to load external comments in Sema when trying to attach existing comments to just parsed Decls.
- Keep comments ordered and cache their decomposed location - faster SourceLoc-based searching.
- Optimize work with redeclarations.
- Keep one comment per redeclaration chain (represented by canonical Decl) instead of comment per redeclaration.
- For redeclaration chains with no comment attached keep just the last declaration in chain that had no comment instead of every comment-less redeclaration.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368732 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoclang: Don't warn on unused momit-leaf-frame-pointer when frame pointers are off.
Nico Weber [Tue, 13 Aug 2019 17:37:09 +0000 (17:37 +0000)]
clang: Don't warn on unused momit-leaf-frame-pointer when frame pointers are off.

This fixes a regression from r365860: As that commit message
states, there are 3 valid states targeted by the combination of
-f(no-)omit-frame-pointer and -m(no-)omit-leaf-frame-pointer.

After r365860 it's impossible to get from state 10 (omit just
leaf frame pointers) to state 11 (omit all frame pointers)
in a single command line without getting a warning.

This change restores that functionality.

Fixes PR42966.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368728 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Updated tests after r368724
David Bolvansky [Tue, 13 Aug 2019 17:19:16 +0000 (17:19 +0000)]
[NFC] Updated tests after r368724

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368725 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Refactoring BugReporter.cpp P3.: std::shared_pointer<PathDiagnosticPi...
Kristof Umann [Tue, 13 Aug 2019 16:45:48 +0000 (16:45 +0000)]
[analyzer][NFC] Refactoring BugReporter.cpp P3.: std::shared_pointer<PathDiagnosticPiece> -> PathDiagnosticPieceRef

find clang/ -type f -exec sed -i 's/std::shared_ptr<PathDiagnosticPiece>/PathDiagnosticPieceRef/g' {} \;
git diff -U3 --no-color HEAD^ | clang-format-diff-6.0 -p1 -i

Just as C++ is meant to be refactored, right?

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368717 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix crash on switch conditions of non-integer types in templates
Elizabeth Andrews [Tue, 13 Aug 2019 15:53:19 +0000 (15:53 +0000)]
Fix crash on switch conditions of non-integer types in templates

Clang currently crashes for switch statements inside a template when
the condition is a non-integer field. The crash is due to incorrect
type-dependency of field. Type-dependency of member expressions is
currently set based on the containing class. This patch changes this for
'members of the current instantiation' to set the type dependency based
on the member's type instead.

A few lit tests started to fail once I applied this patch because errors
are now diagnosed earlier (does not wait till instantiation). I've modified
these tests in this patch as well.

Patch fixes PR#40982

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368706 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoEnable memtag sanitizer in all AArch64 toolchains
Momchil Velikov [Tue, 13 Aug 2019 14:20:23 +0000 (14:20 +0000)]
Enable memtag sanitizer in all AArch64 toolchains

That sanitizer does not have runtime library or other dependencies.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368697 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AArch64] Make the memtag sanitizer require the memtag extension
Momchil Velikov [Tue, 13 Aug 2019 14:20:06 +0000 (14:20 +0000)]
[AArch64] Make the memtag sanitizer require the memtag extension

... or otherwise we get an ICE.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368696 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Refactoring BugReporter.cpp P2.: Clean up the construction of bug...
Kristof Umann [Tue, 13 Aug 2019 13:56:12 +0000 (13:56 +0000)]
[analyzer][NFC] Refactoring BugReporter.cpp P2.: Clean up the construction of bug paths and finding a valid report

This patch refactors the utility functions and classes around the construction
of a bug path.

At a very high level, this consists of 3 steps:

* For all BugReports in the same BugReportEquivClass, collect all their error
nodes in a set. With that set, create a new, trimmed ExplodedGraph whose leafs
are all error nodes.
* Until a valid report is found, construct a bug path, which is yet another
ExplodedGraph, that is linear from a given error node to the root of the graph.
* Run all visitors on the constructed bug path. If in this process the report
got invalidated, start over from step 2.

Now, to the changes within this patch:

* Do not allow the invalidation of BugReports up to the point where the trimmed
graph is constructed. Checkers shouldn't add bug reports that are known to be
invalid, and should use visitors and argue about the entirety of the bug path if
needed.
* Do not calculate indices. I may be biased, but I personally find code like
this horrible. I'd like to point you to one of the comments in the original code:

SmallVector<const ExplodedNode *, 32> errorNodes;
for (const auto I : bugReports) {
  if (I->isValid()) {
    HasValid = true;
    errorNodes.push_back(I->getErrorNode());
  } else {
    // Keep the errorNodes list in sync with the bugReports list.
    errorNodes.push_back(nullptr);
  }
}

Not on my watch. Instead, use a far easier to follow trick: store a pointer to
the BugReport in question, not an index to it.

* Add range iterators to ExplodedGraph's successors and predecessors, and a
visitor range to BugReporter.
* Rename TrimmedGraph to BugPathGetter. Because that is what it has always been:
no sane graph type should store an iterator-like state, or have an interface not
exposing a single graph-like functionalities.
* Rename ReportGraph to BugPathInfo, because it is only a linear path with some
other context.
* Instead of having both and out and in parameter (which I think isn't ever
excusable unless we use the out-param for caching), return a record object with
descriptive getter methods.
* Where descriptive names weren't sufficient, compliment the code with comments.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368694 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix -Wdocumentation typo. NFCI.
Simon Pilgrim [Tue, 13 Aug 2019 13:52:20 +0000 (13:52 +0000)]
Fix -Wdocumentation typo. NFCI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368692 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AIX][test/Index] Set/propagate AIXTHREAD_STK for AIX
Hubert Tong [Tue, 13 Aug 2019 13:38:15 +0000 (13:38 +0000)]
[AIX][test/Index] Set/propagate AIXTHREAD_STK for AIX

Summary:
Some tests perform deep recursion, which requires a larger pthread stack
size than the relatively low default of 192 KiB for 64-bit processes on
AIX. The `AIXTHREAD_STK` environment variable provides a non-intrusive
way to request a larger pthread stack size for the tests. The required
pthread stack size depends on the build configuration.

A 4 MiB default is generous compared to the 512 KiB of macOS; however,
it is known that some compilers on AIX produce code that uses
comparatively more stack space.

Reviewers: xingxue, daltenty, jasonliu

Reviewed By: daltenty

Subscribers: arphaman, jfb, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368690 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][NFC] Refactoring BugReporter.cpp P1.: Store interesting symbols/regions...
Kristof Umann [Tue, 13 Aug 2019 13:09:48 +0000 (13:09 +0000)]
[analyzer][NFC] Refactoring BugReporter.cpp P1.: Store interesting symbols/regions in a simple set

The goal of this refactoring effort was to better understand how interestingness
was propagated in BugReporter.cpp, which eventually turned out to be a dead end,
but with such a twist, I wouldn't even want to spoil it ahead of time. However,
I did get to learn a lot about how things are working in there.

In these series of patches, as well as cleaning up the code big time, I invite
you to study how BugReporter.cpp operates, and discuss how we could design this
file to reduce the horrible mess that it is.

This patch reverts a great part of rC162028, which holds the title "Allow
multiple PathDiagnosticConsumers to be used with a BugReporter at the same
time.". This, however doesn't imply that there's any need for multiple "layers"
or stacks of interesting symbols and regions, quite the contrary, I would argue
that we would like to generate the same amount of information for all output
types, and only process them differently.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368689 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[libTooling] In Transformer, generalize `applyFirst` to admit rules with incompatible...
Yitzhak Mandelbaum [Tue, 13 Aug 2019 12:31:29 +0000 (12:31 +0000)]
[libTooling] In Transformer, generalize `applyFirst` to admit rules with incompatible matchers.

Summary:
This patch removes an (artificial) limitation of `applyFirst`, which requires
that all of the rules' matchers can be grouped together in a single `anyOf()`.
This change generalizes the code to group the matchers into separate `anyOf`s
based on compatibility. Correspondingly, `buildMatcher` is changed to
`buildMatchers`, to allow for returning a set of matchers rather than just one.

Reviewers: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368681 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CodeGen] Disable UBSan for coroutine functions
Brian Gesiak [Tue, 13 Aug 2019 12:02:25 +0000 (12:02 +0000)]
[CodeGen] Disable UBSan for coroutine functions

Summary:
As explained in http://lists.llvm.org/pipermail/llvm-dev/2018-March/121924.html,
the LLVM coroutines transforms are not yet able to move the
instructions for UBSan null checking past coroutine suspend boundaries.
For now, disable all UBSan checks when generating code for coroutines
functions.

I also considered an approach where only '-fsanitize=null' would be disabled,
However in practice this led to other LLVM errors when writing object files:
"Cannot represent a difference across sections". For now, disable all
UBSan checks until coroutine transforms are updated to handle them.

Test Plan:
1. check-clang
2. Compile the program in https://gist.github.com/modocache/54a036c3bf9c06882fe85122e105d153
   using the '-fsanitize=null' option and confirm it does not crash
   during LLVM IR generation.

Reviewers: GorNishanov, vsk, eric_niebler, lewissbaker

Reviewed By: vsk

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368675 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Updated tests after r368657
David Bolvansky [Tue, 13 Aug 2019 09:12:07 +0000 (09:12 +0000)]
[NFC] Updated tests after r368657

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368658 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTImporter] Import additional flags for functions.
Balazs Keri [Tue, 13 Aug 2019 08:04:06 +0000 (08:04 +0000)]
[ASTImporter] Import additional flags for functions.

Summary:
At AST import of function delcarations import the flags for defaulted
and deleted.

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: a_sidorin

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

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368655 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoclang-scan-deps: do not spawn threads when LLVM_ENABLE_THREADS is disabled
Alex Lorenz [Tue, 13 Aug 2019 00:36:35 +0000 (00:36 +0000)]
clang-scan-deps: do not spawn threads when LLVM_ENABLE_THREADS is disabled

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368640 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Remove 'Server' from Tigerlake description comments.
Craig Topper [Tue, 13 Aug 2019 00:00:27 +0000 (00:00 +0000)]
[X86] Remove 'Server' from Tigerlake description comments.

Tigerlake is a client CPU not a server CPU.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368635 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang] Update isDerivedFrom to support Objective-C classes 🔍
Stephane Moore [Mon, 12 Aug 2019 23:23:35 +0000 (23:23 +0000)]
[clang] Update isDerivedFrom to support Objective-C classes 🔍

Summary:
This change updates `isDerivedFrom` to support Objective-C classes by
converting it to a polymorphic matcher.

Notes:
The matching behavior for Objective-C classes is modeled to match the
behavior of `isDerivedFrom` with C++ classes. To that effect,
`isDerivedFrom` matches aliased types of derived Objective-C classes,
including compatibility aliases. To achieve this, the AST visitor has
been updated to map compatibility aliases to their underlying
Objective-C class.

`isSameOrDerivedFrom` also provides similar behaviors for C++ and
Objective-C classes. The behavior that
`cxxRecordDecl(isSameOrDerivedFrom("X"))` does not match
`class Y {}; typedef Y X;` is mirrored for Objective-C in that
`objcInterfaceDecl(isSameOrDerivedFrom("X"))` does not match either
`@interface Y @end typedef Y X;` or
`@interface Y @end @compatibility_alias X Y;`.

Test Notes:
Ran clang unit tests.

Reviewers: aaron.ballman, jordan_rose, rjmccall, klimek, alexfh, gribozavr

Reviewed By: aaron.ballman, gribozavr

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368632 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema] Check __builtin_bit_cast operand for completeness before materializing it.
Erik Pilkington [Mon, 12 Aug 2019 19:29:43 +0000 (19:29 +0000)]
[Sema] Check __builtin_bit_cast operand for completeness before materializing it.

This shouldn't be observable, but it doesn't make sense to materialize an
incomplete type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368610 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema] Require a complete type for __builtin_bit_cast operands
Erik Pilkington [Mon, 12 Aug 2019 18:31:27 +0000 (18:31 +0000)]
[Sema] Require a complete type for __builtin_bit_cast operands

Fixes llvm.org/PR42936

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368600 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTDump] Add is_anonymous to VisitCXXRecordDecl
Shafik Yaghmour [Mon, 12 Aug 2019 17:07:49 +0000 (17:07 +0000)]
[ASTDump] Add is_anonymous to VisitCXXRecordDecl

Summary:
Adding is_anonymous the ASTDump for CXXRecordDecl. This turned out to be useful when debugging some problems with how LLDB creates ASTs from DWARF.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368591 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix multiple lifetime warning messages for range based for loop
Gabor Horvath [Mon, 12 Aug 2019 16:19:39 +0000 (16:19 +0000)]
Fix multiple lifetime warning messages for range based for loop

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368588 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CrossTU] User docs: remove temporary limiation with macro expansion
Gabor Marton [Mon, 12 Aug 2019 12:46:28 +0000 (12:46 +0000)]
[CrossTU] User docs: remove temporary limiation with macro expansion

D65064, D64635, D64638 pathces solve the issue with macor expansion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368562 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL] Ignore parentheses for sampler initialization
Sven van Haastregt [Mon, 12 Aug 2019 12:44:26 +0000 (12:44 +0000)]
[OpenCL] Ignore parentheses for sampler initialization

The sampler handling logic in SemaInit.cpp would inadvertently treat
parentheses around sampler arguments as an implicit cast, leading to
an unreachable "can't implicitly cast lvalue to rvalue with
this cast kind".  Fix by ignoring parentheses once we are in the
sampler initializer case.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368561 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL] Fix lang mode predefined macros for C++ mode.
Anastasia Stulova [Mon, 12 Aug 2019 10:44:07 +0000 (10:44 +0000)]
[OpenCL] Fix lang mode predefined macros for C++ mode.

In C++ mode we should only avoid adding __OPENCL_C_VERSION__,
all other predefined macros about the language mode are still
valid.

This change also fixes the language version check in the
headers accordingly.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368552 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTImporter] Fix for import of friend class template with definition.
Balazs Keri [Mon, 12 Aug 2019 10:07:38 +0000 (10:07 +0000)]
[ASTImporter] Fix for import of friend class template with definition.

Summary:
If there is a friend class template "prototype" (forward declaration)
and later a definition for it in the existing code, this existing
definition may be not found by ASTImporter because it is not linked
to the prototype (under the friend AST node). The problem is fixed by
looping over all found matching decls instead of break after the first
found one.

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: a_sidorin

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

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368551 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CrossTU] Fix problem with CrossTU AST load limit and progress messages.
Balazs Keri [Mon, 12 Aug 2019 07:15:29 +0000 (07:15 +0000)]
[CrossTU] Fix problem with CrossTU AST load limit and progress messages.

Summary:
Number of loaded ASTs is to be incremented only if the AST was really loaded
but not if it was returned from cache. At the same place the message about
a loaded AST is displayed.

Reviewers: martong, gamesh411

Reviewed By: martong

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

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368545 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86] Support -march=tigerlake
Pengfei Wang [Mon, 12 Aug 2019 01:29:46 +0000 (01:29 +0000)]
[X86] Support -march=tigerlake

Support -march=tigerlake for x86.
Compare with Icelake Client, It include 4 more new features ,they are
avx512vp2intersect, movdiri, movdir64b, shstk.

Patch by Xiang Zhang (xiangzhangllvm)

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368543 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] Expand AllowShortBlocksOnASingleLine for WebKit
Owen Pan [Sun, 11 Aug 2019 17:48:36 +0000 (17:48 +0000)]
[clang-format] Expand AllowShortBlocksOnASingleLine for WebKit

See PR40840

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368539 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoProperly detect temporary gsl::Owners through reference initialization chains.
Gabor Horvath [Sun, 11 Aug 2019 14:39:42 +0000 (14:39 +0000)]
Properly detect temporary gsl::Owners through reference initialization chains.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368534 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoProperly handle reference initialization when detecting gsl::Pointer initialization...
Gabor Horvath [Sun, 11 Aug 2019 08:05:28 +0000 (08:05 +0000)]
Properly handle reference initialization when detecting gsl::Pointer initialization chains

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368528 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang] Fixed x86 cpuid NSC signature
Raphael Isemann [Sat, 10 Aug 2019 10:14:01 +0000 (10:14 +0000)]
[clang] Fixed x86 cpuid NSC signature

Summary:
The signature "Geode by NSC" for NSC vendor is wrong.
In lib/Headers/cpuid.h, signature_NSC_edx and signature_NSC_ecx constants are inverted (cpuid signature order is ebx # edx # ecx).

Reviewers: teemperor, rsmith, craig.topper

Reviewed By: teemperor, craig.topper

Subscribers: craig.topper, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368510 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[modulemap] Add AArch64SVEACLETypes.def
Kristina Brooks [Sat, 10 Aug 2019 08:21:14 +0000 (08:21 +0000)]
[modulemap] Add AArch64SVEACLETypes.def

Update modulemap with a new textual header.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368508 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-format] Add SpaceInEmptyBlock option for WebKit
Owen Pan [Sat, 10 Aug 2019 07:51:21 +0000 (07:51 +0000)]
[clang-format] Add SpaceInEmptyBlock option for WebKit

See PR40840

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368507 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix a false positive warning when initializing members with gsl::Owners.
Gabor Horvath [Sat, 10 Aug 2019 00:32:29 +0000 (00:32 +0000)]
Fix a false positive warning when initializing members with gsl::Owners.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368501 91177308-0d34-0410-b5e6-96231b3b80d8