Skip to content

Commit

Permalink
merge master into amd-stg-open
Browse files Browse the repository at this point in the history
Change-Id: I6f653e1d1b96b4a40bd15a4694a03bd721c30829
  • Loading branch information
Jenkins committed Apr 29, 2020
2 parents 213053b + 1c12a95 commit 38be7af
Show file tree
Hide file tree
Showing 517 changed files with 7,631 additions and 3,074 deletions.
1 change: 1 addition & 0 deletions clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
)

add_clang_library(clangTidyLLVMLibcModule
CalleeNamespaceCheck.cpp
ImplementationInNamespaceCheck.cpp
LLVMLibcTidyModule.cpp
RestrictSystemLibcHeadersCheck.cpp
Expand Down
56 changes: 56 additions & 0 deletions clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//===-- CalleeNamespaceCheck.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "CalleeNamespaceCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"

using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace llvm_libc {

// Gets the outermost namespace of a DeclContext, right under the Translation
// Unit.
const DeclContext *getOutermostNamespace(const DeclContext *Decl) {
const DeclContext *Parent = Decl->getParent();
if (Parent && Parent->isTranslationUnit())
return Decl;
return getOutermostNamespace(Parent);
}

void CalleeNamespaceCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
declRefExpr(to(functionDecl().bind("func"))).bind("use-site"), this);
}

void CalleeNamespaceCheck::check(const MatchFinder::MatchResult &Result) {
const auto *UsageSiteExpr = Result.Nodes.getNodeAs<DeclRefExpr>("use-site");
const auto *FuncDecl = Result.Nodes.getNodeAs<FunctionDecl>("func");

// Ignore compiler builtin functions.
if (FuncDecl->getBuiltinID() != 0)
return;

// If the outermost namespace of the function is __llvm_libc, we're good.
const auto *NS = dyn_cast<NamespaceDecl>(getOutermostNamespace(FuncDecl));
if (NS && NS->getName() == "__llvm_libc")
return;

diag(UsageSiteExpr->getBeginLoc(), "%0 must resolve to a function declared "
"within the '__llvm_libc' namespace")
<< FuncDecl;

diag(FuncDecl->getLocation(), "resolves to this declaration",
clang::DiagnosticIDs::Note);
}

} // namespace llvm_libc
} // namespace tidy
} // namespace clang
38 changes: 38 additions & 0 deletions clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//===-- CalleeNamespaceCheck.h ----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVMLIBC_CALLEENAMESPACECHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVMLIBC_CALLEENAMESPACECHECK_H

#include "../ClangTidyCheck.h"

namespace clang {
namespace tidy {
namespace llvm_libc {

/// Checks all calls resolve to functions within __llvm_libc namespace.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/llvmlibc-callee-namespace.html
class CalleeNamespaceCheck : public ClangTidyCheck {
public:
CalleeNamespaceCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}

bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace llvm_libc
} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVMLIBC_CALLEENAMESPACECHECK_H
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "CalleeNamespaceCheck.h"
#include "ImplementationInNamespaceCheck.h"
#include "RestrictSystemLibcHeadersCheck.h"

Expand All @@ -19,6 +20,8 @@ namespace llvm_libc {
class LLVMLibcModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<CalleeNamespaceCheck>(
"llvmlibc-callee-namespace");
CheckFactories.registerCheck<ImplementationInNamespaceCheck>(
"llvmlibc-implementation-in-namespace");
CheckFactories.registerCheck<RestrictSystemLibcHeadersCheck>(
Expand Down
22 changes: 3 additions & 19 deletions clang-tools-extra/clangd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(support)

# Configure the Features.inc file.
if (NOT DEFINED CLANGD_BUILD_XPC)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
Expand Down Expand Up @@ -25,27 +27,15 @@ set(LLVM_LINK_COMPONENTS
FrontendOpenMP
)

if(CLANG_BUILT_STANDALONE)
# needed to get HAVE_CXX_ATOMICS64_WITHOUT_LIB defined
include(CheckAtomic)
endif()

set(CLANGD_ATOMIC_LIB "")
if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
list(APPEND CLANGD_ATOMIC_LIB "atomic")
endif()

add_clang_library(clangDaemon
AST.cpp
Cancellation.cpp
ClangdLSPServer.cpp
ClangdServer.cpp
CodeComplete.cpp
CodeCompletionStrings.cpp
CollectMacros.cpp
CompileCommands.cpp
Compiler.cpp
Context.cpp
Diagnostics.cpp
DraftStore.cpp
ExpectedTypes.cpp
Expand All @@ -54,7 +44,6 @@ add_clang_library(clangDaemon
FileDistance.cpp
Format.cpp
FS.cpp
FSProvider.cpp
FormattedString.cpp
FuzzyMatch.cpp
GlobalCompilationDatabase.cpp
Expand All @@ -63,7 +52,6 @@ add_clang_library(clangDaemon
Hover.cpp
IncludeFixer.cpp
JSONTransport.cpp
Logger.cpp
PathMapping.cpp
Protocol.cpp
Quality.cpp
Expand All @@ -73,11 +61,8 @@ add_clang_library(clangDaemon
Selection.cpp
SemanticHighlighting.cpp
SemanticSelection.cpp
Shutdown.cpp
SourceCode.cpp
QueryDriverDatabase.cpp
Threading.cpp
Trace.cpp
TUScheduler.cpp
URI.cpp
XRefs.cpp
Expand Down Expand Up @@ -128,8 +113,7 @@ add_clang_library(clangDaemon
clangToolingInclusions
clangToolingRefactoring
clangToolingSyntax
${LLVM_PTHREAD_LIB}
${CLANGD_ATOMIC_LIB}
clangdSupport
${ALL_CLANG_TIDY_CHECKS}
)

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/ClangdLSPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

#include "ClangdLSPServer.h"
#include "Context.h"
#include "Diagnostics.h"
#include "DraftStore.h"
#include "FormattedString.h"
Expand All @@ -16,9 +15,10 @@
#include "SemanticHighlighting.h"
#include "SourceCode.h"
#include "TUScheduler.h"
#include "Trace.h"
#include "URI.h"
#include "refactor/Tweak.h"
#include "support/Context.h"
#include "support/Trace.h"
#include "clang/Basic/Version.h"
#include "clang/Tooling/Core/Replacement.h"
#include "llvm/ADT/ArrayRef.h"
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/ClangdLSPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDLSPSERVER_H

#include "ClangdServer.h"
#include "Context.h"
#include "DraftStore.h"
#include "Features.inc"
#include "FindSymbols.h"
#include "GlobalCompilationDatabase.h"
#include "Path.h"
#include "Protocol.h"
#include "Transport.h"
#include "support/Context.h"
#include "support/Path.h"
#include "clang/Tooling/Core/Replacement.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringSet.h"
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/ClangdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
#include "FormattedString.h"
#include "HeaderSourceSwitch.h"
#include "Headers.h"
#include "Logger.h"
#include "ParsedAST.h"
#include "Preamble.h"
#include "Protocol.h"
#include "SemanticHighlighting.h"
#include "SemanticSelection.h"
#include "SourceCode.h"
#include "TUScheduler.h"
#include "Trace.h"
#include "XRefs.h"
#include "index/CanonicalIncludes.h"
#include "index/FileIndex.h"
#include "index/Merge.h"
#include "refactor/Rename.h"
#include "refactor/Tweak.h"
#include "support/Logger.h"
#include "support/Trace.h"
#include "clang/Format/Format.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/CompilerInvocation.h"
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clangd/ClangdServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CLANGDSERVER_H

#include "../clang-tidy/ClangTidyOptions.h"
#include "Cancellation.h"
#include "CodeComplete.h"
#include "FSProvider.h"
#include "FormattedString.h"
#include "Function.h"
#include "GlobalCompilationDatabase.h"
#include "Hover.h"
#include "Protocol.h"
Expand All @@ -26,6 +23,9 @@
#include "index/Index.h"
#include "refactor/Rename.h"
#include "refactor/Tweak.h"
#include "support/Cancellation.h"
#include "support/FSProvider.h"
#include "support/Function.h"
#include "clang/Tooling/CompilationDatabase.h"
#include "clang/Tooling/Core/Replacement.h"
#include "llvm/ADT/FunctionExtras.h"
Expand Down
6 changes: 3 additions & 3 deletions clang-tools-extra/clangd/CodeComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
#include "FileDistance.h"
#include "FuzzyMatch.h"
#include "Headers.h"
#include "Logger.h"
#include "Preamble.h"
#include "Protocol.h"
#include "Quality.h"
#include "SourceCode.h"
#include "TUScheduler.h"
#include "Threading.h"
#include "Trace.h"
#include "URI.h"
#include "index/Index.h"
#include "index/Symbol.h"
#include "index/SymbolOrigin.h"
#include "support/Logger.h"
#include "support/Threading.h"
#include "support/Trace.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "clang/Basic/CharInfo.h"
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/CodeComplete.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_CODECOMPLETE_H

#include "Headers.h"
#include "Logger.h"
#include "Path.h"
#include "Protocol.h"
#include "Quality.h"
#include "index/Index.h"
#include "index/Symbol.h"
#include "index/SymbolOrigin.h"
#include "support/Logger.h"
#include "support/Path.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Sema/CodeCompleteOptions.h"
#include "clang/Tooling/CompilationDatabase.h"
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/CompileCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//

#include "CompileCommands.h"
#include "Logger.h"
#include "support/Logger.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "clang/Tooling/ArgumentsAdjusters.h"
#include "llvm/Support/FileSystem.h"
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//

#include "Compiler.h"
#include "Logger.h"
#include "support/Logger.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Serialization/PCHContainerOperations.h"
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
#include "Diagnostics.h"
#include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
#include "Compiler.h"
#include "Logger.h"
#include "Protocol.h"
#include "SourceCode.h"
#include "support/Logger.h"
#include "clang/Basic/AllDiagnostics.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticIDs.h"
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/Diagnostics.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H

#include "Path.h"
#include "Protocol.h"
#include "support/Path.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LangOptions.h"
#include "llvm/ADT/ArrayRef.h"
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/DraftStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//

#include "DraftStore.h"
#include "Logger.h"
#include "SourceCode.h"
#include "support/Logger.h"
#include "llvm/Support/Errc.h"

namespace clang {
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/DraftStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DRAFTSTORE_H

#include "Path.h"
#include "Protocol.h"
#include "support/Path.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/StringMap.h"
#include <mutex>
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/FS.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FS_H

#include "Path.h"
#include "support/Path.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringMap.h"
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/FileDistance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//===-------------------------------------------------------------------------//

#include "FileDistance.h"
#include "Logger.h"
#include "support/Logger.h"
#include "llvm/ADT/STLExtras.h"
#include <queue>

Expand Down
Loading

0 comments on commit 38be7af

Please sign in to comment.