Skip to content

Commit acb88e7

Browse files
author
Valery N Dmitriev
committed
Merge from 'master' to 'sycl-web' (#1)
Note: pulled in commit intel/llvm@fe7885c to fix build failure.
2 parents 977e15f + d8ba622 commit acb88e7

File tree

350 files changed

+6029
-2623
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

350 files changed

+6029
-2623
lines changed

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "llvm/ADT/STLExtras.h"
3232
#include "llvm/ADT/SmallString.h"
3333
#include "llvm/ADT/StringMap.h"
34+
#include "llvm/Support/ErrorHandling.h"
3435
#include "llvm/Support/FormatVariadic.h"
3536
#include "llvm/Support/Regex.h"
3637
#include <tuple>
@@ -590,6 +591,7 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
590591
// An event can be either the begin or the end of an interval.
591592
enum EventType {
592593
ET_Begin = 1,
594+
ET_Insert = 0,
593595
ET_End = -1,
594596
};
595597

@@ -621,10 +623,17 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
621623
// one will be processed before, disallowing the second one, and the
622624
// end point of the first one will also be processed before,
623625
// disallowing the first one.
624-
if (Type == ET_Begin)
626+
switch (Type) {
627+
case ET_Begin:
625628
Priority = std::make_tuple(Begin, Type, -End, -ErrorSize, ErrorId);
626-
else
629+
break;
630+
case ET_Insert:
631+
Priority = std::make_tuple(Begin, Type, -End, ErrorSize, ErrorId);
632+
break;
633+
case ET_End:
627634
Priority = std::make_tuple(End, Type, -Begin, ErrorSize, ErrorId);
635+
break;
636+
}
628637
}
629638

630639
bool operator<(const Event &Other) const {
@@ -662,19 +671,19 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
662671
}
663672

664673
// Build events from error intervals.
665-
std::map<std::string, std::vector<Event>> FileEvents;
674+
llvm::StringMap<std::vector<Event>> FileEvents;
666675
for (unsigned I = 0; I < ErrorFixes.size(); ++I) {
667676
for (const auto &FileAndReplace : *ErrorFixes[I].second) {
668677
for (const auto &Replace : FileAndReplace.second) {
669678
unsigned Begin = Replace.getOffset();
670679
unsigned End = Begin + Replace.getLength();
671-
const std::string &FilePath = std::string(Replace.getFilePath());
672-
// FIXME: Handle empty intervals, such as those from insertions.
673-
if (Begin == End)
674-
continue;
675-
auto &Events = FileEvents[FilePath];
676-
Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
677-
Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
680+
auto &Events = FileEvents[Replace.getFilePath()];
681+
if (Begin == End) {
682+
Events.emplace_back(Begin, End, Event::ET_Insert, I, Sizes[I]);
683+
} else {
684+
Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
685+
Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
686+
}
678687
}
679688
}
680689
}
@@ -686,14 +695,20 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
686695
llvm::sort(Events);
687696
int OpenIntervals = 0;
688697
for (const auto &Event : Events) {
689-
if (Event.Type == Event::ET_End)
690-
--OpenIntervals;
691-
// This has to be checked after removing the interval from the count if it
692-
// is an end event, or before adding it if it is a begin event.
693-
if (OpenIntervals != 0)
694-
Apply[Event.ErrorId] = false;
695-
if (Event.Type == Event::ET_Begin)
696-
++OpenIntervals;
698+
switch (Event.Type) {
699+
case Event::ET_Begin:
700+
if (OpenIntervals++ != 0)
701+
Apply[Event.ErrorId] = false;
702+
break;
703+
case Event::ET_Insert:
704+
if (OpenIntervals != 0)
705+
Apply[Event.ErrorId] = false;
706+
break;
707+
case Event::ET_End:
708+
if (--OpenIntervals != 0)
709+
Apply[Event.ErrorId] = false;
710+
break;
711+
}
697712
}
698713
assert(OpenIntervals == 0 && "Amount of begin/end points doesn't match");
699714
}

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,9 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
114114
Options.SystemHeaders = false;
115115
Options.FormatStyle = "none";
116116
Options.User = llvm::None;
117-
unsigned Priority = 0;
118117
for (const ClangTidyModuleRegistry::entry &Module :
119118
ClangTidyModuleRegistry::entries())
120-
Options =
121-
Options.mergeWith(Module.instantiate()->getModuleOptions(), ++Priority);
119+
Options = Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
122120
return Options;
123121
}
124122

clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,18 @@ void RedundantStringCStrCheck::registerMatchers(
9292
callee(memberExpr().bind("member")),
9393
callee(cxxMethodDecl(hasAnyName("c_str", "data"))))
9494
.bind("call");
95-
95+
const auto HasRValueTempParent =
96+
hasParent(materializeTemporaryExpr(unless(isBoundToLValue())));
9697
// Detect redundant 'c_str()' calls through a string constructor.
9798
// If CxxConstructExpr is the part of some CallExpr we need to
9899
// check that matched ParamDecl of the ancestor CallExpr is not rvalue.
99100
Finder->addMatcher(
100-
traverse(ast_type_traits::TK_AsIs,
101-
cxxConstructExpr(StringConstructorExpr,
102-
hasArgument(0, StringCStrCallExpr),
103-
unless(hasParent(materializeTemporaryExpr(
104-
unless(isBoundToLValue())))))),
101+
traverse(
102+
ast_type_traits::TK_AsIs,
103+
cxxConstructExpr(
104+
StringConstructorExpr, hasArgument(0, StringCStrCallExpr),
105+
unless(anyOf(HasRValueTempParent, hasParent(cxxBindTemporaryExpr(
106+
HasRValueTempParent)))))),
105107
this);
106108

107109
// Detect: 's == str.c_str()' -> 's == str'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables,readability-isolate-declaration %t
2+
3+
void foo() {
4+
int A, B, C;
5+
// CHECK-MESSAGES-DAG: :[[@LINE-1]]:7: warning: variable 'A' is not initialized
6+
// CHECK-MESSAGES-DAG: :[[@LINE-2]]:10: warning: variable 'B' is not initialized
7+
// CHECK-MESSAGES-DAG: :[[@LINE-3]]:13: warning: variable 'C' is not initialized
8+
// CHECK-MESSAGES-DAG: :[[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
9+
10+
// Only the isolate declarations fix-it should be applied
11+
12+
// CHECK-FIXES: int A;
13+
// CHECK-FIXES-NEXT: int B;
14+
// CHECK-FIXES-NEXT: int C;
15+
}

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ struct basic_string {
1515
basic_string();
1616
basic_string(const C *p, const A &a = A());
1717

18+
~basic_string();
19+
1820
const C *c_str() const;
1921
const C *data() const;
2022

clang/docs/OpenMPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ want to help with the implementation.
264264
+==============================+==============================================================+==========================+=======================================================================+
265265
| misc extension | user-defined function variants with #ifdef protection | :part:`worked on` | D71179 |
266266
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
267-
| misc extension | default(firstprivate) & default(private) | :part:`worked on` | |
267+
| misc extension | default(firstprivate) & default(private) | :part:`partial` | firstprivate done: D75591 |
268268
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
269269
| loop extension | Loop tiling transformation | :part:`claimed` | |
270270
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+

0 commit comments

Comments
 (0)