Skip to content

Commit 49cfcad

Browse files
committed
Merge from 'master' to 'sycl-web' (#1)
CONFLICT (content): Merge conflict in libclc/CMakeLists.txt
2 parents 373c340 + 174c41d commit 49cfcad

File tree

816 files changed

+28441
-10221
lines changed

Some content is hidden

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

816 files changed

+28441
-10221
lines changed

.arclint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"linters": {
33
"clang-format": {
44
"type": "script-and-regex",
5-
"script-and-regex.script": "utils/arcanist/clang-format.sh",
5+
"script-and-regex.script": "bash utils/arcanist/clang-format.sh",
66
"script-and-regex.regex": "/^(?P<severity>[[:alpha:]]+)\n(?P<message>[^\n]+)\n(====|(?P<line>\\d),(?P<char>\\d)\n(?P<original>.*)>>>>\n(?P<replacement>.*)<<<<\n)$/s",
77
"include": [
88
"(\\.(cc|cpp|h)$)"

clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
44
)
55

66
add_clang_library(clangTidyLLVMLibcModule
7+
CalleeNamespaceCheck.cpp
78
ImplementationInNamespaceCheck.cpp
89
LLVMLibcTidyModule.cpp
910
RestrictSystemLibcHeadersCheck.cpp
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//===-- CalleeNamespaceCheck.cpp ------------------------------------------===//
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 "CalleeNamespaceCheck.h"
10+
#include "clang/AST/ASTContext.h"
11+
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
13+
using namespace clang::ast_matchers;
14+
15+
namespace clang {
16+
namespace tidy {
17+
namespace llvm_libc {
18+
19+
// Gets the outermost namespace of a DeclContext, right under the Translation
20+
// Unit.
21+
const DeclContext *getOutermostNamespace(const DeclContext *Decl) {
22+
const DeclContext *Parent = Decl->getParent();
23+
if (Parent && Parent->isTranslationUnit())
24+
return Decl;
25+
return getOutermostNamespace(Parent);
26+
}
27+
28+
void CalleeNamespaceCheck::registerMatchers(MatchFinder *Finder) {
29+
Finder->addMatcher(
30+
declRefExpr(to(functionDecl().bind("func"))).bind("use-site"), this);
31+
}
32+
33+
void CalleeNamespaceCheck::check(const MatchFinder::MatchResult &Result) {
34+
const auto *UsageSiteExpr = Result.Nodes.getNodeAs<DeclRefExpr>("use-site");
35+
const auto *FuncDecl = Result.Nodes.getNodeAs<FunctionDecl>("func");
36+
37+
// Ignore compiler builtin functions.
38+
if (FuncDecl->getBuiltinID() != 0)
39+
return;
40+
41+
// If the outermost namespace of the function is __llvm_libc, we're good.
42+
const auto *NS = dyn_cast<NamespaceDecl>(getOutermostNamespace(FuncDecl));
43+
if (NS && NS->getName() == "__llvm_libc")
44+
return;
45+
46+
diag(UsageSiteExpr->getBeginLoc(), "%0 must resolve to a function declared "
47+
"within the '__llvm_libc' namespace")
48+
<< FuncDecl;
49+
50+
diag(FuncDecl->getLocation(), "resolves to this declaration",
51+
clang::DiagnosticIDs::Note);
52+
}
53+
54+
} // namespace llvm_libc
55+
} // namespace tidy
56+
} // namespace clang
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//===-- CalleeNamespaceCheck.h ----------------------------------*- 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+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVMLIBC_CALLEENAMESPACECHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVMLIBC_CALLEENAMESPACECHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
14+
namespace clang {
15+
namespace tidy {
16+
namespace llvm_libc {
17+
18+
/// Checks all calls resolve to functions within __llvm_libc namespace.
19+
///
20+
/// For the user-facing documentation see:
21+
/// http://clang.llvm.org/extra/clang-tidy/checks/llvmlibc-callee-namespace.html
22+
class CalleeNamespaceCheck : public ClangTidyCheck {
23+
public:
24+
CalleeNamespaceCheck(StringRef Name, ClangTidyContext *Context)
25+
: ClangTidyCheck(Name, Context) {}
26+
27+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
28+
return LangOpts.CPlusPlus;
29+
}
30+
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
31+
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
32+
};
33+
34+
} // namespace llvm_libc
35+
} // namespace tidy
36+
} // namespace clang
37+
38+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVMLIBC_CALLEENAMESPACECHECK_H

clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "../ClangTidy.h"
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
12+
#include "CalleeNamespaceCheck.h"
1213
#include "ImplementationInNamespaceCheck.h"
1314
#include "RestrictSystemLibcHeadersCheck.h"
1415

@@ -19,6 +20,8 @@ namespace llvm_libc {
1920
class LLVMLibcModule : public ClangTidyModule {
2021
public:
2122
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
23+
CheckFactories.registerCheck<CalleeNamespaceCheck>(
24+
"llvmlibc-callee-namespace");
2225
CheckFactories.registerCheck<ImplementationInNamespaceCheck>(
2326
"llvmlibc-implementation-in-namespace");
2427
CheckFactories.registerCheck<RestrictSystemLibcHeadersCheck>(

clang-tools-extra/clangd/CMakeLists.txt

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
add_subdirectory(support)
2+
13
# Configure the Features.inc file.
24
if (NOT DEFINED CLANGD_BUILD_XPC)
35
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -25,27 +27,15 @@ set(LLVM_LINK_COMPONENTS
2527
FrontendOpenMP
2628
)
2729

28-
if(CLANG_BUILT_STANDALONE)
29-
# needed to get HAVE_CXX_ATOMICS64_WITHOUT_LIB defined
30-
include(CheckAtomic)
31-
endif()
32-
33-
set(CLANGD_ATOMIC_LIB "")
34-
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
35-
list(APPEND CLANGD_ATOMIC_LIB "atomic")
36-
endif()
37-
3830
add_clang_library(clangDaemon
3931
AST.cpp
40-
Cancellation.cpp
4132
ClangdLSPServer.cpp
4233
ClangdServer.cpp
4334
CodeComplete.cpp
4435
CodeCompletionStrings.cpp
4536
CollectMacros.cpp
4637
CompileCommands.cpp
4738
Compiler.cpp
48-
Context.cpp
4939
Diagnostics.cpp
5040
DraftStore.cpp
5141
ExpectedTypes.cpp
@@ -54,7 +44,6 @@ add_clang_library(clangDaemon
5444
FileDistance.cpp
5545
Format.cpp
5646
FS.cpp
57-
FSProvider.cpp
5847
FormattedString.cpp
5948
FuzzyMatch.cpp
6049
GlobalCompilationDatabase.cpp
@@ -63,7 +52,6 @@ add_clang_library(clangDaemon
6352
Hover.cpp
6453
IncludeFixer.cpp
6554
JSONTransport.cpp
66-
Logger.cpp
6755
PathMapping.cpp
6856
Protocol.cpp
6957
Quality.cpp
@@ -73,11 +61,8 @@ add_clang_library(clangDaemon
7361
Selection.cpp
7462
SemanticHighlighting.cpp
7563
SemanticSelection.cpp
76-
Shutdown.cpp
7764
SourceCode.cpp
7865
QueryDriverDatabase.cpp
79-
Threading.cpp
80-
Trace.cpp
8166
TUScheduler.cpp
8267
URI.cpp
8368
XRefs.cpp
@@ -128,8 +113,8 @@ add_clang_library(clangDaemon
128113
clangToolingInclusions
129114
clangToolingRefactoring
130115
clangToolingSyntax
116+
clangdSupport
131117
${LLVM_PTHREAD_LIB}
132-
${CLANGD_ATOMIC_LIB}
133118
${ALL_CLANG_TIDY_CHECKS}
134119
)
135120

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "ClangdLSPServer.h"
10-
#include "Context.h"
1110
#include "Diagnostics.h"
1211
#include "DraftStore.h"
1312
#include "FormattedString.h"
@@ -16,9 +15,10 @@
1615
#include "SemanticHighlighting.h"
1716
#include "SourceCode.h"
1817
#include "TUScheduler.h"
19-
#include "Trace.h"
2018
#include "URI.h"
2119
#include "refactor/Tweak.h"
20+
#include "support/Context.h"
21+
#include "support/Trace.h"
2222
#include "clang/Basic/Version.h"
2323
#include "clang/Tooling/Core/Replacement.h"
2424
#include "llvm/ADT/ArrayRef.h"

clang-tools-extra/clangd/ClangdLSPServer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H
1111

1212
#include "ClangdServer.h"
13-
#include "Context.h"
1413
#include "DraftStore.h"
1514
#include "Features.inc"
1615
#include "FindSymbols.h"
1716
#include "GlobalCompilationDatabase.h"
18-
#include "Path.h"
1917
#include "Protocol.h"
2018
#include "Transport.h"
19+
#include "support/Context.h"
20+
#include "support/Path.h"
2121
#include "clang/Tooling/Core/Replacement.h"
2222
#include "llvm/ADT/Optional.h"
2323
#include "llvm/ADT/StringSet.h"

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
#include "FormattedString.h"
1414
#include "HeaderSourceSwitch.h"
1515
#include "Headers.h"
16-
#include "Logger.h"
1716
#include "ParsedAST.h"
1817
#include "Preamble.h"
1918
#include "Protocol.h"
2019
#include "SemanticHighlighting.h"
2120
#include "SemanticSelection.h"
2221
#include "SourceCode.h"
2322
#include "TUScheduler.h"
24-
#include "Trace.h"
2523
#include "XRefs.h"
2624
#include "index/CanonicalIncludes.h"
2725
#include "index/FileIndex.h"
2826
#include "index/Merge.h"
2927
#include "refactor/Rename.h"
3028
#include "refactor/Tweak.h"
29+
#include "support/Logger.h"
30+
#include "support/Trace.h"
3131
#include "clang/Format/Format.h"
3232
#include "clang/Frontend/CompilerInstance.h"
3333
#include "clang/Frontend/CompilerInvocation.h"

clang-tools-extra/clangd/ClangdServer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H
1111

1212
#include "../clang-tidy/ClangTidyOptions.h"
13-
#include "Cancellation.h"
1413
#include "CodeComplete.h"
15-
#include "FSProvider.h"
1614
#include "FormattedString.h"
17-
#include "Function.h"
1815
#include "GlobalCompilationDatabase.h"
1916
#include "Hover.h"
2017
#include "Protocol.h"
@@ -26,6 +23,9 @@
2623
#include "index/Index.h"
2724
#include "refactor/Rename.h"
2825
#include "refactor/Tweak.h"
26+
#include "support/Cancellation.h"
27+
#include "support/FSProvider.h"
28+
#include "support/Function.h"
2929
#include "clang/Tooling/CompilationDatabase.h"
3030
#include "clang/Tooling/Core/Replacement.h"
3131
#include "llvm/ADT/FunctionExtras.h"

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@
2626
#include "FileDistance.h"
2727
#include "FuzzyMatch.h"
2828
#include "Headers.h"
29-
#include "Logger.h"
3029
#include "Preamble.h"
3130
#include "Protocol.h"
3231
#include "Quality.h"
3332
#include "SourceCode.h"
3433
#include "TUScheduler.h"
35-
#include "Threading.h"
36-
#include "Trace.h"
3734
#include "URI.h"
3835
#include "index/Index.h"
3936
#include "index/Symbol.h"
4037
#include "index/SymbolOrigin.h"
38+
#include "support/Logger.h"
39+
#include "support/Threading.h"
40+
#include "support/Trace.h"
4141
#include "clang/AST/Decl.h"
4242
#include "clang/AST/DeclBase.h"
4343
#include "clang/Basic/CharInfo.h"

clang-tools-extra/clangd/CodeComplete.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H
1717

1818
#include "Headers.h"
19-
#include "Logger.h"
20-
#include "Path.h"
2119
#include "Protocol.h"
2220
#include "Quality.h"
2321
#include "index/Index.h"
2422
#include "index/Symbol.h"
2523
#include "index/SymbolOrigin.h"
24+
#include "support/Logger.h"
25+
#include "support/Path.h"
2626
#include "clang/Sema/CodeCompleteConsumer.h"
2727
#include "clang/Sema/CodeCompleteOptions.h"
2828
#include "clang/Tooling/CompilationDatabase.h"

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "CompileCommands.h"
10-
#include "Logger.h"
10+
#include "support/Logger.h"
1111
#include "clang/Frontend/CompilerInvocation.h"
1212
#include "clang/Tooling/ArgumentsAdjusters.h"
1313
#include "llvm/Support/FileSystem.h"

clang-tools-extra/clangd/Compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "Compiler.h"
10-
#include "Logger.h"
10+
#include "support/Logger.h"
1111
#include "clang/Basic/TargetInfo.h"
1212
#include "clang/Lex/PreprocessorOptions.h"
1313
#include "clang/Serialization/PCHContainerOperations.h"

clang-tools-extra/clangd/Diagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include "Diagnostics.h"
1010
#include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
1111
#include "Compiler.h"
12-
#include "Logger.h"
1312
#include "Protocol.h"
1413
#include "SourceCode.h"
14+
#include "support/Logger.h"
1515
#include "clang/Basic/AllDiagnostics.h"
1616
#include "clang/Basic/Diagnostic.h"
1717
#include "clang/Basic/DiagnosticIDs.h"

clang-tools-extra/clangd/Diagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H
1111

12-
#include "Path.h"
1312
#include "Protocol.h"
13+
#include "support/Path.h"
1414
#include "clang/Basic/Diagnostic.h"
1515
#include "clang/Basic/LangOptions.h"
1616
#include "llvm/ADT/ArrayRef.h"

clang-tools-extra/clangd/DraftStore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "DraftStore.h"
10-
#include "Logger.h"
1110
#include "SourceCode.h"
11+
#include "support/Logger.h"
1212
#include "llvm/Support/Errc.h"
1313

1414
namespace clang {

clang-tools-extra/clangd/DraftStore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H
1111

12-
#include "Path.h"
1312
#include "Protocol.h"
13+
#include "support/Path.h"
1414
#include "clang/Basic/LLVM.h"
1515
#include "llvm/ADT/StringMap.h"
1616
#include <mutex>

clang-tools-extra/clangd/FS.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H
1111

12-
#include "Path.h"
12+
#include "support/Path.h"
1313
#include "clang/Basic/LLVM.h"
1414
#include "llvm/ADT/Optional.h"
1515
#include "llvm/ADT/StringMap.h"

clang-tools-extra/clangd/FileDistance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//===-------------------------------------------------------------------------//
3232

3333
#include "FileDistance.h"
34-
#include "Logger.h"
34+
#include "support/Logger.h"
3535
#include "llvm/ADT/STLExtras.h"
3636
#include <queue>
3737

0 commit comments

Comments
 (0)