Skip to content

Commit 38217f4

Browse files
committed
Merge branch 'private/dvodopya/update-oneapi-and-intel-extensions' of https://github.com/dm-vodopyanov/llvm into private/dvodopya/update-oneapi-and-intel-extensions
2 parents 8315b01 + 4b29cf5 commit 38217f4

File tree

2,184 files changed

+128576
-49605
lines changed

Some content is hidden

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

2,184 files changed

+128576
-49605
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ sycl/include/CL/sycl/swizzles.def @turinevgeny
7575
sycl/include/CL/sycl/types.hpp @turinevgeny
7676

7777
# XPTI instrumentation utilities
78-
xpti/ @tovinkere @andykaylor
79-
xptifw/ @tovinkere @andykaylor
78+
xpti/ @tovinkere @andykaylor @alexbatashev
79+
xptifw/ @tovinkere @andykaylor @alexbatashev
8080

8181
# DPC++ tools
8282
llvm/**/append-file/ @mdtoguchi @AGindinson

.mailmap

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
<qiucofan@cn.ibm.com> <qiucf@cn.ibm.com>
2929
<rnk@google.com> <reid@kleckner.net>
3030
<thakis@chromium.org> <nicolasweber@gmx.de>
31-
Jon Roelofs <jonathan_roelofs@apple.com> Jon Roelofs <jroelofs@jroelofs.com>
32-
Jon Roelofs <jonathan_roelofs@apple.com> Jonathan Roelofs <jonathan@codesourcery.com>
33-
Jon Roelofs <jonathan_roelofs@apple.com> Jonathan Roelofs <jroelofs@jroelofs.com>
31+
Jon Roelofs <jonathan_roelofs@apple.com> <jonathan@codesourcery.com>
32+
Jon Roelofs <jonathan_roelofs@apple.com> <jroelofs@jroelofs.com>
3433
LLVM GN Syncbot <llvmgnsyncbot@gmail.com>
3534
Martin Storsjö <martin@martin.st>
36-
Saleem Abdulrasool <compnerd@compnerd.org> <compnerd@compnerd.org>
35+
Saleem Abdulrasool <compnerd@compnerd.org>

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,17 +433,25 @@ void ProTypeMemberInitCheck::checkMissingMemberInitializer(
433433
[&](const FieldDecl *F) { OrderedFields.push_back(F); });
434434

435435
// Collect all the fields we need to initialize, including indirect fields.
436+
// It only includes fields that have not been fixed
436437
SmallPtrSet<const FieldDecl *, 16> AllFieldsToInit;
437-
forEachField(ClassDecl, FieldsToInit,
438-
[&](const FieldDecl *F) { AllFieldsToInit.insert(F); });
439-
if (AllFieldsToInit.empty())
438+
forEachField(ClassDecl, FieldsToInit, [&](const FieldDecl *F) {
439+
if (!HasRecordClassMemberSet.contains(F)) {
440+
AllFieldsToInit.insert(F);
441+
HasRecordClassMemberSet.insert(F);
442+
}
443+
});
444+
if (FieldsToInit.empty())
440445
return;
441446

442447
DiagnosticBuilder Diag =
443448
diag(Ctor ? Ctor->getBeginLoc() : ClassDecl.getLocation(),
444449
"%select{|union }0constructor %select{does not|should}0 initialize "
445450
"%select{|one of }0these fields: %1")
446-
<< IsUnion << toCommaSeparatedString(OrderedFields, AllFieldsToInit);
451+
<< IsUnion << toCommaSeparatedString(OrderedFields, FieldsToInit);
452+
453+
if (AllFieldsToInit.empty())
454+
return;
447455

448456
// Do not propose fixes for constructors in macros since we cannot place them
449457
// correctly.

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_TYPE_MEMBER_INIT_H
1111

1212
#include "../ClangTidyCheck.h"
13+
#include "llvm/ADT/DenseSet.h"
1314

1415
namespace clang {
1516
namespace tidy {
@@ -72,6 +73,10 @@ class ProTypeMemberInitCheck : public ClangTidyCheck {
7273
// instead of brace initialization. Only effective in C++11 mode. Default is
7374
// false.
7475
bool UseAssignment;
76+
77+
// Record the member variables that have been initialized to prevent repeated
78+
// initialization.
79+
llvm::DenseSet<const FieldDecl *> HasRecordClassMemberSet;
7580
};
7681

7782
} // namespace cppcoreguidelines

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ BracesAroundStatementsCheck::findRParenLoc(const IfOrWhileStmt *S,
186186
bool BracesAroundStatementsCheck::checkStmt(
187187
const MatchFinder::MatchResult &Result, const Stmt *S,
188188
SourceLocation InitialLoc, SourceLocation EndLocHint) {
189+
190+
while (const auto *AS = dyn_cast<AttributedStmt>(S))
191+
S = AS->getSubStmt();
192+
189193
// 1) If there's a corresponding "else" or "while", the check inserts "} "
190194
// right before that token.
191195
// 2) If there's a multi-line block comment starting on the same line after

clang-tools-extra/clangd/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ add_clang_library(clangDaemon
8383
HeaderSourceSwitch.cpp
8484
HeuristicResolver.cpp
8585
Hover.cpp
86+
IncludeCleaner.cpp
8687
IncludeFixer.cpp
8788
InlayHints.cpp
8889
JSONTransport.cpp

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ const llvm::Optional<std::string> detectSysroot() {
127127
if (::getenv("SDKROOT"))
128128
return llvm::None;
129129
return queryXcrun({"xcrun", "--show-sdk-path"});
130-
return llvm::None;
131130
}
132131

133132
std::string detectStandardResourceDir() {
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
//===--- IncludeCleaner.cpp - Unused/Missing Headers Analysis ---*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "IncludeCleaner.h"
10+
#include "support/Logger.h"
11+
#include "clang/AST/RecursiveASTVisitor.h"
12+
#include "clang/Basic/SourceLocation.h"
13+
14+
namespace clang {
15+
namespace clangd {
16+
namespace {
17+
18+
/// Crawler traverses the AST and feeds in the locations of (sometimes
19+
/// implicitly) used symbols into \p Result.
20+
class ReferencedLocationCrawler
21+
: public RecursiveASTVisitor<ReferencedLocationCrawler> {
22+
public:
23+
ReferencedLocationCrawler(ReferencedLocations &Result) : Result(Result) {}
24+
25+
bool VisitDeclRefExpr(DeclRefExpr *DRE) {
26+
add(DRE->getDecl());
27+
add(DRE->getFoundDecl());
28+
return true;
29+
}
30+
31+
bool VisitMemberExpr(MemberExpr *ME) {
32+
add(ME->getMemberDecl());
33+
add(ME->getFoundDecl().getDecl());
34+
return true;
35+
}
36+
37+
bool VisitTagType(TagType *TT) {
38+
add(TT->getDecl());
39+
return true;
40+
}
41+
42+
bool VisitCXXConstructExpr(CXXConstructExpr *CCE) {
43+
add(CCE->getConstructor());
44+
return true;
45+
}
46+
47+
bool VisitTemplateSpecializationType(TemplateSpecializationType *TST) {
48+
if (isNew(TST)) {
49+
add(TST->getTemplateName().getAsTemplateDecl()); // Primary template.
50+
add(TST->getAsCXXRecordDecl()); // Specialization
51+
}
52+
return true;
53+
}
54+
55+
bool VisitTypedefType(TypedefType *TT) {
56+
add(TT->getDecl());
57+
return true;
58+
}
59+
60+
// Consider types of any subexpression used, even if the type is not named.
61+
// This is helpful in getFoo().bar(), where Foo must be complete.
62+
// FIXME(kirillbobyrev): Should we tweak this? It may not be desirable to
63+
// consider types "used" when they are not directly spelled in code.
64+
bool VisitExpr(Expr *E) {
65+
TraverseType(E->getType());
66+
return true;
67+
}
68+
69+
bool TraverseType(QualType T) {
70+
if (isNew(T.getTypePtrOrNull())) { // don't care about quals
71+
Base::TraverseType(T);
72+
}
73+
return true;
74+
}
75+
76+
bool VisitUsingDecl(UsingDecl *D) {
77+
for (const auto *Shadow : D->shadows()) {
78+
add(Shadow->getTargetDecl());
79+
}
80+
return true;
81+
}
82+
83+
private:
84+
using Base = RecursiveASTVisitor<ReferencedLocationCrawler>;
85+
86+
void add(const Decl *D) {
87+
if (!D || !isNew(D->getCanonicalDecl())) {
88+
return;
89+
}
90+
for (const Decl *Redecl : D->redecls()) {
91+
Result.insert(Redecl->getLocation());
92+
}
93+
}
94+
95+
bool isNew(const void *P) { return P && Visited.insert(P).second; }
96+
97+
ReferencedLocations &Result;
98+
llvm::DenseSet<const void *> Visited;
99+
};
100+
101+
} // namespace
102+
103+
ReferencedLocations findReferencedLocations(ParsedAST &AST) {
104+
ReferencedLocations Result;
105+
ReferencedLocationCrawler Crawler(Result);
106+
Crawler.TraverseAST(AST.getASTContext());
107+
// FIXME(kirillbobyrev): Handle macros.
108+
return Result;
109+
}
110+
111+
} // namespace clangd
112+
} // namespace clang
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//===--- IncludeCleaner.h - Unused/Missing Headers Analysis -----*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
///
9+
/// \file
10+
/// Include Cleaner is clangd functionality for providing diagnostics for misuse
11+
/// of transitive headers and unused includes. It is inspired by
12+
/// Include-What-You-Use tool (https://include-what-you-use.org/). Our goal is
13+
/// to provide useful warnings in most popular scenarios but not 1:1 exact
14+
/// feature compatibility.
15+
///
16+
/// FIXME(kirillbobyrev): Add support for IWYU pragmas.
17+
/// FIXME(kirillbobyrev): Add support for standard library headers.
18+
///
19+
//===----------------------------------------------------------------------===//
20+
21+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INCLUDE_CLEANER_H
22+
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INCLUDE_CLEANER_H
23+
24+
#include "Headers.h"
25+
#include "ParsedAST.h"
26+
#include "clang/Basic/SourceLocation.h"
27+
#include "llvm/ADT/DenseSet.h"
28+
29+
namespace clang {
30+
namespace clangd {
31+
32+
using ReferencedLocations = llvm::DenseSet<SourceLocation>;
33+
/// Finds locations of all symbols used in the main file.
34+
///
35+
/// Uses RecursiveASTVisitor to go through main file AST and computes all the
36+
/// locations used symbols are coming from. Returned locations may be macro
37+
/// expansions, and are not resolved to their spelling/expansion location. These
38+
/// locations are later used to determine which headers should be marked as
39+
/// "used" and "directly used".
40+
///
41+
/// We use this to compute unused headers, so we:
42+
///
43+
/// - cover the whole file in a single traversal for efficiency
44+
/// - don't attempt to describe where symbols were referenced from in
45+
/// ambiguous cases (e.g. implicitly used symbols, multiple declarations)
46+
/// - err on the side of reporting all possible locations
47+
ReferencedLocations findReferencedLocations(ParsedAST &AST);
48+
49+
} // namespace clangd
50+
} // namespace clang
51+
52+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INCLUDE_CLEANER_H

clang-tools-extra/clangd/InlayHints.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "clang/AST/ExprCXX.h"
1414
#include "clang/AST/RecursiveASTVisitor.h"
1515
#include "clang/Basic/SourceManager.h"
16+
#include "llvm/Support/raw_ostream.h"
1617

1718
namespace clang {
1819
namespace clangd {
@@ -314,6 +315,10 @@ class InlayHintVisitor : public RecursiveASTVisitor<InlayHintVisitor> {
314315
toHalfOpenFileRange(AST.getSourceManager(), AST.getLangOpts(), R);
315316
if (!FileRange)
316317
return;
318+
// The hint may be in a file other than the main file (for example, a header
319+
// file that was included after the preamble), do not show in that case.
320+
if (!AST.getSourceManager().isWrittenInMainFile(FileRange->getBegin()))
321+
return;
317322
Results.push_back(InlayHint{
318323
Range{
319324
sourceLocToPosition(AST.getSourceManager(), FileRange->getBegin()),

clang-tools-extra/clangd/unittests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ add_unittest(ClangdUnitTests ClangdTests
5858
HeadersTests.cpp
5959
HeaderSourceSwitchTests.cpp
6060
HoverTests.cpp
61+
IncludeCleanerTests.cpp
6162
IndexActionTests.cpp
6263
IndexTests.cpp
6364
InlayHintTests.cpp

0 commit comments

Comments
 (0)