Skip to content

Commit

Permalink
Manually merged master:09c8f38924d into amd-gfx:3207753660b
Browse files Browse the repository at this point in the history
Local branch amd-gfx 3207753 Merged master:c8f0d27ef37 into amd-gfx:80e004f6b88
Remote branch master 09c8f38 [X86] Add isel patterns for X86VBroadcast with i16 truncates from i16->i64 zextload/extload.

Change-Id: I01b619a207074d8145b303e0b448d06e58504658
  • Loading branch information
Sw authored and piotrAMD committed Mar 13, 2020
2 parents 3207753 + 09c8f38 commit d8c450e
Show file tree
Hide file tree
Showing 1,038 changed files with 30,481 additions and 14,415 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "HeaderMapCollector.h"
#include "PathConfig.h"
#include "SymbolInfo.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/MacroInfo.h"
Expand Down
2 changes: 2 additions & 0 deletions clang-tools-extra/clang-tidy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ add_subdirectory(google)
add_subdirectory(hicpp)
add_subdirectory(linuxkernel)
add_subdirectory(llvm)
add_subdirectory(llvmlibc)
add_subdirectory(misc)
add_subdirectory(modernize)
if(CLANG_ENABLE_STATIC_ANALYZER)
Expand All @@ -75,6 +76,7 @@ set(ALL_CLANG_TIDY_CHECKS
clangTidyHICPPModule
clangTidyLinuxKernelModule
clangTidyLLVMModule
clangTidyLLVMLibcModule
clangTidyMiscModule
clangTidyModernizeModule
clangTidyObjCModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "clang/Tooling/Core/Diagnostic.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Regex.h"
#include <tuple>
#include <vector>
using namespace clang;
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Timer.h"

namespace llvm {
class Regex;
}

namespace clang {

class ASTContext;
Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ extern volatile int LLVMModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
LLVMModuleAnchorSource;

// This anchor is used to force the linker to link the LLVMLibcModule.
extern volatile int LLVMLibcModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED LLVMLibcModuleAnchorDestination =
LLVMLibcModuleAnchorSource;

// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
extern volatile int CppCoreGuidelinesModuleAnchorSource;
static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//===----------------------------------------------------------------------===//

#include "ExpandModularHeadersPPCallbacks.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Serialization/ASTReader.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
#include "clang/Lex/Preprocessor.h"
#include "llvm/ADT/DenseSet.h"

namespace llvm {
namespace vfs {
class OverlayFileSystem;
class InMemoryFileSystem;
} // namespace vfs
} // namespace llvm

namespace clang {
class CompilerInstance;

Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "StringIntegerAssignmentCheck.h"
#include "StringLiteralWithEmbeddedNulCheck.h"
#include "SuspiciousEnumUsageCheck.h"
#include "SuspiciousIncludeCheck.h"
#include "SuspiciousMemsetUsageCheck.h"
#include "SuspiciousMissingCommaCheck.h"
#include "SuspiciousSemicolonCheck.h"
Expand Down Expand Up @@ -140,6 +141,8 @@ class BugproneModule : public ClangTidyModule {
"bugprone-string-literal-with-embedded-nul");
CheckFactories.registerCheck<SuspiciousEnumUsageCheck>(
"bugprone-suspicious-enum-usage");
CheckFactories.registerCheck<SuspiciousIncludeCheck>(
"bugprone-suspicious-include");
CheckFactories.registerCheck<SuspiciousMemsetUsageCheck>(
"bugprone-suspicious-memset-usage");
CheckFactories.registerCheck<SuspiciousMissingCommaCheck>(
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ add_clang_library(clangTidyBugproneModule
StringIntegerAssignmentCheck.cpp
StringLiteralWithEmbeddedNulCheck.cpp
SuspiciousEnumUsageCheck.cpp
SuspiciousIncludeCheck.cpp
SuspiciousMemsetUsageCheck.cpp
SuspiciousMissingCommaCheck.cpp
SuspiciousSemicolonCheck.cpp
Expand Down
108 changes: 108 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
//===--- SuspiciousIncludeCheck.cpp - clang-tidy --------------------------===//
//
// 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 "SuspiciousIncludeCheck.h"
#include "clang/AST/ASTContext.h"

namespace clang {
namespace tidy {
namespace bugprone {

namespace {
class SuspiciousIncludePPCallbacks : public PPCallbacks {
public:
explicit SuspiciousIncludePPCallbacks(SuspiciousIncludeCheck &Check,
const SourceManager &SM,
Preprocessor *PP)
: Check(Check), PP(PP) {}

void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange, const FileEntry *File,
StringRef SearchPath, StringRef RelativePath,
const Module *Imported,
SrcMgr::CharacteristicKind FileType) override;

private:
SuspiciousIncludeCheck &Check;
Preprocessor *PP;
};
} // namespace

SuspiciousIncludeCheck::SuspiciousIncludeCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
"HeaderFileExtensions", utils::defaultHeaderFileExtensions())),
RawStringImplementationFileExtensions(Options.getLocalOrGlobal(
"ImplementationFileExtensions",
utils::defaultImplementationFileExtensions())) {
if (!utils::parseFileExtensions(RawStringImplementationFileExtensions,
ImplementationFileExtensions,
utils::defaultFileExtensionDelimiters())) {
llvm::errs() << "Invalid implementation file extension: "
<< RawStringImplementationFileExtensions << "\n";
}

if (!utils::parseFileExtensions(RawStringHeaderFileExtensions,
HeaderFileExtensions,
utils::defaultFileExtensionDelimiters())) {
llvm::errs() << "Invalid header file extension: "
<< RawStringHeaderFileExtensions << "\n";
}
}

void SuspiciousIncludeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "ImplementationFileExtensions",
RawStringImplementationFileExtensions);
Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions);
}

void SuspiciousIncludeCheck::registerPPCallbacks(
const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
PP->addPPCallbacks(
::std::make_unique<SuspiciousIncludePPCallbacks>(*this, SM, PP));
}

void SuspiciousIncludePPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
SrcMgr::CharacteristicKind FileType) {
if (IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import)
return;

SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1);

const Optional<StringRef> IFE =
utils::getFileExtension(FileName, Check.ImplementationFileExtensions);
if (!IFE)
return;

Check.diag(DiagLoc, "suspicious #%0 of file with '%1' extension")
<< IncludeTok.getIdentifierInfo()->getName() << *IFE;

for (const auto &HFE : Check.HeaderFileExtensions) {
SmallString<128> GuessedFileName(FileName);
llvm::sys::path::replace_extension(GuessedFileName,
(HFE.size() ? "." : "") + HFE);

const DirectoryLookup *CurDir;
Optional<FileEntryRef> File =
PP->LookupFile(DiagLoc, GuessedFileName, IsAngled, nullptr, nullptr,
CurDir, nullptr, nullptr, nullptr, nullptr, nullptr);
if (File) {
Check.diag(DiagLoc, "did you mean to include '%0'?", DiagnosticIDs::Note)
<< GuessedFileName;
}
}
}

} // namespace bugprone
} // namespace tidy
} // namespace clang
57 changes: 57 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//===--- SuspiciousIncludeCheck.h - clang-tidy ------------------*- 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_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H

#include "../ClangTidyCheck.h"
#include "../utils/FileExtensionsUtils.h"

namespace clang {
namespace tidy {
namespace bugprone {

/// Warns on inclusion of files whose names suggest that they're implementation
/// files, instead of headers. E.g:
///
/// #include "foo.cpp" // warning
/// #include "bar.c" // warning
/// #include "baz.h" // no diagnostic
///
/// The check supports these options:
/// - `HeaderFileExtensions`: a semicolon-separated list of filename
/// extensions of header files (The filename extensions should not contain
/// "." prefix) ";h;hh;hpp;hxx" by default. For extension-less header
/// files, using an empty string or leaving an empty string between ";" if
/// there are other filename extensions.
///
/// - `ImplementationFileExtensions`: likewise, a semicolon-separated list of
/// filename extensions of implementation files. "c;cc;cpp;cxx" by default.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-include.html
class SuspiciousIncludeCheck : public ClangTidyCheck {
public:
SuspiciousIncludeCheck(StringRef Name, ClangTidyContext *Context);
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
Preprocessor *ModuleExpanderPP) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;

utils::FileExtensionsSet HeaderFileExtensions;
utils::FileExtensionsSet ImplementationFileExtensions;

private:
const std::string RawStringHeaderFileExtensions;
const std::string RawStringImplementationFileExtensions;
};

} // namespace bugprone
} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "DefaultOperatorNewAlignmentCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Basic/TargetInfo.h"

using namespace clang::ast_matchers;

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ add_clang_library(clangTidyFuchsiaModule
FuchsiaTidyModule.cpp
MultipleInheritanceCheck.cpp
OverloadedOperatorCheck.cpp
RestrictSystemIncludesCheck.cpp
StaticallyConstructedObjectsCheck.cpp
TrailingReturnCheck.cpp
VirtualInheritanceCheck.cpp
Expand Down
3 changes: 0 additions & 3 deletions clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "DefaultArgumentsDeclarationsCheck.h"
#include "MultipleInheritanceCheck.h"
#include "OverloadedOperatorCheck.h"
#include "RestrictSystemIncludesCheck.h"
#include "StaticallyConstructedObjectsCheck.h"
#include "TrailingReturnCheck.h"
#include "VirtualInheritanceCheck.h"
Expand All @@ -39,8 +38,6 @@ class FuchsiaModule : public ClangTidyModule {
"fuchsia-multiple-inheritance");
CheckFactories.registerCheck<OverloadedOperatorCheck>(
"fuchsia-overloaded-operator");
CheckFactories.registerCheck<RestrictSystemIncludesCheck>(
"fuchsia-restrict-system-includes");
CheckFactories.registerCheck<StaticallyConstructedObjectsCheck>(
"fuchsia-statically-constructed-objects");
CheckFactories.registerCheck<TrailingReturnCheck>(
Expand Down
15 changes: 15 additions & 0 deletions clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(LLVM_LINK_COMPONENTS support)

add_clang_library(clangTidyLLVMLibcModule
LLVMLibcTidyModule.cpp
RestrictSystemLibcHeadersCheck.cpp

LINK_LIBS
clangAST
clangASTMatchers
clangBasic
clangLex
clangTidy
clangTidyUtils
clangTooling
)
37 changes: 37 additions & 0 deletions clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//===--- LLVMLibcTidyModule.cpp - clang-tidy ------------------------------===//
//
// 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 "../ClangTidy.h"
#include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h"
#include "RestrictSystemLibcHeadersCheck.h"

namespace clang {
namespace tidy {
namespace llvm_libc {

class LLVMLibcModule : public ClangTidyModule {
public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<RestrictSystemLibcHeadersCheck>(
"llvmlibc-restrict-system-libc-headers");
}
};

// Register the LLVMLibcTidyModule using this statically initialized variable.
static ClangTidyModuleRegistry::Add<LLVMLibcModule>
X("llvmlibc-module", "Adds LLVM libc standards checks.");

} // namespace llvm_libc

// This anchor is used to force the linker to link in the generated object file
// and thus register the LLVMLibcModule.
volatile int LLVMLibcModuleAnchorSource = 0;

} // namespace tidy
} // namespace clang
Loading

0 comments on commit d8c450e

Please sign in to comment.