Skip to content

Commit

Permalink
Merge from 'main' to 'sycl-web' (#6)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in llvm/unittests/Support/CMakeLists.txt
  • Loading branch information
dm-vodopyanov committed Feb 15, 2021
2 parents e5ec68f + 656ead1 commit e4796aa
Show file tree
Hide file tree
Showing 513 changed files with 13,155 additions and 6,586 deletions.
21 changes: 7 additions & 14 deletions clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,18 @@ void InaccurateEraseCheck::registerMatchers(MatchFinder *Finder) {
callExpr(
callee(functionDecl(hasAnyName("remove", "remove_if", "unique"))),
hasArgument(
1,
anyOf(cxxConstructExpr(has(ignoringImplicit(
cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"))))
.bind("end")))),
anything())))
1, optionally(cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"))))
.bind("end"))))
.bind("alg");

const auto DeclInStd = type(hasUnqualifiedDesugaredType(
tagType(hasDeclaration(decl(isInStdNamespace())))));
Finder->addMatcher(
traverse(
TK_AsIs,
cxxMemberCallExpr(
on(anyOf(hasType(DeclInStd), hasType(pointsTo(DeclInStd)))),
callee(cxxMethodDecl(hasName("erase"))), argumentCountIs(1),
hasArgument(0, has(ignoringImplicit(anyOf(
EndCall, has(ignoringImplicit(EndCall)))))),
unless(isInTemplateInstantiation()))
.bind("erase")),
cxxMemberCallExpr(
on(anyOf(hasType(DeclInStd), hasType(pointsTo(DeclInStd)))),
callee(cxxMethodDecl(hasName("erase"))), argumentCountIs(1),
hasArgument(0, EndCall))
.bind("erase"),
this);
}

Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/InaccurateEraseCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class InaccurateEraseCheck : public ClangTidyCheck {
}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
return TK_IgnoreUnlessSpelledInSource;
}
};

} // namespace bugprone
Expand Down
49 changes: 19 additions & 30 deletions clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,37 @@ StaticAssertCheck::StaticAssertCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}

void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
auto NegatedString = unaryOperator(
hasOperatorName("!"), hasUnaryOperand(ignoringImpCasts(stringLiteral())));
auto NegatedString =
unaryOperator(hasOperatorName("!"), hasUnaryOperand(stringLiteral()));
auto IsAlwaysFalse =
expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
cxxNullPtrLiteralExpr(), gnuNullExpr(), NegatedString))
.bind("isAlwaysFalse");
auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
IsAlwaysFalse, cStyleCastExpr(has(ignoringParenImpCasts(IsAlwaysFalse)))
.bind("castExpr")));
auto AssertExprRoot = anyOf(
binaryOperator(
hasAnyOperatorName("&&", "=="),
hasEitherOperand(ignoringImpCasts(stringLiteral().bind("assertMSG"))),
anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)),
anything()))
.bind("assertExprRoot"),
IsAlwaysFalse);
auto IsAlwaysFalseWithCast =
anyOf(IsAlwaysFalse, cStyleCastExpr(has(IsAlwaysFalse)).bind("castExpr"));
auto AssertExprRoot =
anyOf(binaryOperator(
hasAnyOperatorName("&&", "=="),
hasEitherOperand(stringLiteral().bind("assertMSG")),
anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)),
anything()))
.bind("assertExprRoot"),
IsAlwaysFalse);
auto NonConstexprFunctionCall =
callExpr(hasDeclaration(functionDecl(unless(isConstexpr()))));
auto AssertCondition =
expr(
anyOf(expr(ignoringParenCasts(anyOf(
AssertExprRoot, unaryOperator(hasUnaryOperand(
ignoringParenCasts(AssertExprRoot)))))),
anything()),
unless(findAll(NonConstexprFunctionCall)))
expr(optionally(expr(anyOf(AssertExprRoot,
unaryOperator(hasUnaryOperand(AssertExprRoot))))),
unless(findAll(NonConstexprFunctionCall)))
.bind("condition");
auto Condition =
anyOf(ignoringParenImpCasts(callExpr(
hasDeclaration(functionDecl(hasName("__builtin_expect"))),
hasArgument(0, AssertCondition))),
anyOf(callExpr(traverse(TK_AsIs, callExpr(hasDeclaration(functionDecl(
hasName("__builtin_expect"))))),
hasArgument(0, AssertCondition)),
AssertCondition);

Finder->addMatcher(conditionalOperator(hasCondition(Condition),
unless(isInTemplateInstantiation()))
.bind("condStmt"),
this);

Finder->addMatcher(
ifStmt(hasCondition(Condition), unless(isInTemplateInstantiation()))
.bind("condStmt"),
this);
mapAnyOf(ifStmt, conditionalOperator).with(hasCondition(Condition)).bind("condStmt"), this);
}

void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) {
Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-tidy/misc/StaticAssertCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class StaticAssertCheck : public ClangTidyCheck {
}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
return TK_IgnoreUnlessSpelledInSource;
}

private:
SourceLocation getLastParenLoc(const ASTContext *ASTCtx,
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/ClangdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ ClangdServer::Options::operator TUScheduler::Options() const {
ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
const ThreadsafeFS &TFS, const Options &Opts,
Callbacks *Callbacks)
: CDB(CDB), TFS(TFS), Modules(Opts.Modules),
: CDB(CDB), TFS(TFS),
DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
ClangTidyProvider(Opts.ClangTidyProvider),
WorkspaceRoot(Opts.WorkspaceRoot),
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clangd/ClangdServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ class ClangdServer {

const GlobalCompilationDatabase &CDB;
const ThreadsafeFS &TFS;
ModuleSet *Modules = nullptr;

Path ResourceDir;
// The index used to look up symbols. This could be:
Expand Down
14 changes: 2 additions & 12 deletions clang-tools-extra/clangd/tool/ClangdMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,6 @@ opt<bool> EnableClangTidy{
init(true),
};

opt<std::string> ClangTidyChecks{
"clang-tidy-checks",
cat(Features),
desc("List of clang-tidy checks to run (this will override "
".clang-tidy files). Only meaningful when -clang-tidy flag is on"),
init(""),
};

opt<CodeCompleteOptions::CodeCompletionParse> CodeCompletionParse{
"completion-parse",
cat(Features),
Expand Down Expand Up @@ -287,6 +279,7 @@ RetiredFlag<bool> RecoveryASTType("recovery-ast-type");
RetiredFlag<bool> AsyncPreamble("async-preamble");
RetiredFlag<bool> CollectMainFileRefs("collect-main-file-refs");
RetiredFlag<bool> CrossFileRename("cross-file-rename");
RetiredFlag<std::string> ClangTidyChecks("clang-tidy-checks");

opt<int> LimitResults{
"limit-results",
Expand Down Expand Up @@ -826,10 +819,7 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
Providers.push_back(provideClangTidyFiles(TFS));
if (EnableConfig)
Providers.push_back(provideClangdConfig());
if (!ClangTidyChecks.empty())
Providers.push_back(addTidyChecks(ClangTidyChecks));
else
Providers.push_back(provideDefaultChecks());
Providers.push_back(provideDefaultChecks());
Providers.push_back(disableUnusableChecks());
ClangTidyOptProvider = combine(std::move(Providers));
Opts.ClangTidyProvider = ClangTidyOptProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// RUN: %check_clang_tidy -std=c++11,c++14 %s bugprone-inaccurate-erase %t
// FIXME: Fix the checker to work in C++17 mode.
// RUN: %check_clang_tidy %s bugprone-inaccurate-erase %t

namespace std {
template <typename T> struct vec_iterator {
Expand Down
9 changes: 9 additions & 0 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ the configuration (without a prefix: ``Auto``).
* ``GNU``
A style complying with the `GNU coding standards
<https://www.gnu.org/prep/standards/standards.html>`_
* ``InheritParentConfig``
Not a real style, but allows to use the ``.clang-format`` file from the
parent directory (or its parent if there is none). If there is no parent
file found it falls back to the ``fallback`` style, and applies the changes
to that.

With this option you can overwrite some parts of your main style for your
subdirectories. This is also possible through the command line, e.g.:
``--style={BasedOnStyle: InheritParentConfig, ColumnLimit: 20}``

.. START_FORMAT_STYLE_OPTIONS
Expand Down
8 changes: 7 additions & 1 deletion clang/docs/LibASTMatchersReference.html
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ <h2 id="traverse-mode">Traverse Mode</h2>
<pre>
binaryOperator(
hasOperatorName("&lt;"),
hasRHS(integerLiteral(equals(0)))
hasRHS(hasDescendant(integerLiteral(equals(0))))
)
</pre>
given:
Expand All @@ -529,6 +529,12 @@ <h2 id="traverse-mode">Traverse Mode</h2>
</td>
<td>
1 match found.

<pre>
return a < b;
^~~~~
</pre>

</td>
<td>
No match found.
Expand Down
4 changes: 4 additions & 0 deletions clang/docs/RAVFrontendAction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ following CMakeLists.txt to link it:

::

set(LLVM_LINK_COMPONENTS
Support
)

add_clang_executable(find-class-decls FindClassDecls.cpp)

target_link_libraries(find-class-decls
Expand Down
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ clang-format
#include "B/A.h"
#include "B/a.h"

- ``BasedOnStyle: InheritParentConfig`` allows to use the ``.clang-format`` of
the parent directories to overwrite only parts of it.

libclang
--------

Expand Down
18 changes: 16 additions & 2 deletions clang/docs/SourceBasedCodeCoverage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ the exported data at a high level in the llvm-cov source code.
Interpreting reports
====================

There are four statistics tracked in a coverage summary:
There are five statistics tracked in a coverage summary:

* Function coverage is the percentage of functions which have been executed at
least once. A function is considered to be executed if any of its
Expand All @@ -260,7 +260,8 @@ There are four statistics tracked in a coverage summary:
* Instantiation coverage is the percentage of function instantiations which
have been executed at least once. Template functions and static inline
functions from headers are two kinds of functions which may have multiple
instantiations.
instantiations. This statistic is hidden by default in reports, but can be
enabled via the ``-show-instantiation-summary`` option.

* Line coverage is the percentage of code lines which have been executed at
least once. Only executable lines within function bodies are considered to be
Expand Down Expand Up @@ -305,6 +306,19 @@ Format compatibility guarantees
minor version increment is for added functionality, and patch version
increments are for bugfixes.

Impact of llvm optimizations on coverage reports
================================================

llvm optimizations (such as inlining or CFG simplification) should have no
impact on coverage report quality. This is due to the fact that the mapping
from source regions to profile counters is immutable, and is generated before
the llvm optimizer kicks in. The optimizer can't prove that profile counter
instrumentation is safe to delete (because it's not: it affects the profile the
program emits), and so leaves it alone.

Note that this coverage feature does not rely on information that can degrade
during the course of optimization, such as debug info line tables.

Using the profiling runtime without static initializers
=======================================================

Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer.
CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.

/// Treat loops as finite: language, always, never.
ENUM_CODEGENOPT(FiniteLoops, FiniteLoopsKind, 2, FiniteLoopsKind::Language)

/// Attempt to use register sized accesses to bit-fields in structures, when
/// possible.
CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0)
Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/Basic/CodeGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
All, // Keep all frame pointers.
};

enum FiniteLoopsKind {
Language, // Not specified, use language standard.
Always, // All loops are assumed to be finite.
Never, // No loop is assumed to be finite.
};

/// The code model to use (-mcmodel).
std::string CodeModel;

Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2539,6 +2539,11 @@ def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group<f_Group>,
defm reroll_loops : BoolFOption<"reroll-loops",
CodeGenOpts<"RerollLoops">, DefaultFalse,
PosFlag<SetTrue, [CC1Option], "Turn on loop reroller">, NegFlag<SetFalse>>;
def ffinite_loops: Flag<["-"], "ffinite-loops">, Group<f_Group>,
HelpText<"Assume all loops are finite.">, Flags<[CC1Option]>;
def fno_finite_loops: Flag<["-"], "fno-finite-loops">, Group<f_Group>,
HelpText<"Do not assume that any loop is finite.">, Flags<[CC1Option]>;

def ftrigraphs : Flag<["-"], "ftrigraphs">, Group<f_Group>,
HelpText<"Process trigraph sequences">, Flags<[CC1Option]>;
def fno_trigraphs : Flag<["-"], "fno-trigraphs">, Group<f_Group>,
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ std::error_code make_error_code(ParseError e);
/// The ``FormatStyle`` is used to configure the formatting to follow
/// specific guidelines.
struct FormatStyle {
// If the BasedOn: was InheritParentConfig and this style needs the file from
// the parent directories. It is not part of the actual style for formatting.
// Thus the // instead of ///.
bool InheritsParentConfig;

/// The extra indent or outdent of access modifiers, e.g. ``public:``.
int AccessModifierOffset;

Expand Down
11 changes: 5 additions & 6 deletions clang/lib/CodeGen/CGLoopInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,10 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes &Attrs,
Args.push_back(nullptr);
Args.append(LoopProperties.begin(), LoopProperties.end());

// Setting vectorize.predicate
// Setting vectorize.predicate when it has been specified and vectorization
// has not been disabled.
bool IsVectorPredicateEnabled = false;
if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified &&
Attrs.VectorizeEnable != LoopAttributes::Disable &&
Attrs.VectorizeWidth < 1) {

if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified) {
IsVectorPredicateEnabled =
(Attrs.VectorizePredicateEnable == LoopAttributes::Enable);

Expand Down Expand Up @@ -305,7 +303,8 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes &Attrs,
// explicitly requested fixed-width vectorization, i.e.
// vectorize.scalable.enable is false.
if (Attrs.VectorizeEnable != LoopAttributes::Unspecified ||
IsVectorPredicateEnabled || Attrs.VectorizeWidth > 1 ||
(IsVectorPredicateEnabled && Attrs.VectorizeWidth != 1) ||
Attrs.VectorizeWidth > 1 ||
Attrs.VectorizeScalable == LoopAttributes::Enable ||
(Attrs.VectorizeScalable == LoopAttributes::Disable &&
Attrs.VectorizeWidth != 1)) {
Expand Down
11 changes: 11 additions & 0 deletions clang/lib/CodeGen/CodeGenFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,23 @@ class CodeGenFunction : public CodeGenTypeCache {

/// True if the C++ Standard Requires Progress.
bool CPlusPlusWithProgress() {
if (CGM.getCodeGenOpts().getFiniteLoops() ==
CodeGenOptions::FiniteLoopsKind::Never)
return false;

return getLangOpts().CPlusPlus11 || getLangOpts().CPlusPlus14 ||
getLangOpts().CPlusPlus17 || getLangOpts().CPlusPlus20;
}

/// True if the C Standard Requires Progress.
bool CWithProgress() {
if (CGM.getCodeGenOpts().getFiniteLoops() ==
CodeGenOptions::FiniteLoopsKind::Always)
return true;
if (CGM.getCodeGenOpts().getFiniteLoops() ==
CodeGenOptions::FiniteLoopsKind::Never)
return false;

return getLangOpts().C11 || getLangOpts().C17 || getLangOpts().C2x;
}

Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5820,6 +5820,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (A->getOption().matches(options::OPT_freroll_loops))
CmdArgs.push_back("-freroll-loops");

Args.AddLastArg(CmdArgs, options::OPT_ffinite_loops,
options::OPT_fno_finite_loops);

Args.AddLastArg(CmdArgs, options::OPT_fwritable_strings);
Args.AddLastArg(CmdArgs, options::OPT_funroll_loops,
options::OPT_fno_unroll_loops);
Expand Down
Loading

0 comments on commit e4796aa

Please sign in to comment.