Skip to content

Commit d8c450e

Browse files
SwpiotrAMD
Sw
authored andcommitted
Manually merged master:09c8f38924d into amd-gfx:3207753660b
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
2 parents 3207753 + 09c8f38 commit d8c450e

File tree

1,038 files changed

+30481
-14415
lines changed

Some content is hidden

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

1,038 files changed

+30481
-14415
lines changed

clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllMacros.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "HeaderMapCollector.h"
1111
#include "PathConfig.h"
1212
#include "SymbolInfo.h"
13+
#include "clang/Basic/FileManager.h"
1314
#include "clang/Basic/IdentifierTable.h"
1415
#include "clang/Basic/SourceManager.h"
1516
#include "clang/Lex/MacroInfo.h"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ add_subdirectory(google)
5151
add_subdirectory(hicpp)
5252
add_subdirectory(linuxkernel)
5353
add_subdirectory(llvm)
54+
add_subdirectory(llvmlibc)
5455
add_subdirectory(misc)
5556
add_subdirectory(modernize)
5657
if(CLANG_ENABLE_STATIC_ANALYZER)
@@ -75,6 +76,7 @@ set(ALL_CLANG_TIDY_CHECKS
7576
clangTidyHICPPModule
7677
clangTidyLinuxKernelModule
7778
clangTidyLLVMModule
79+
clangTidyLLVMLibcModule
7880
clangTidyMiscModule
7981
clangTidyModernizeModule
8082
clangTidyObjCModule

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "clang/Tooling/Core/Diagnostic.h"
2727
#include "llvm/ADT/STLExtras.h"
2828
#include "llvm/ADT/SmallString.h"
29+
#include "llvm/Support/Regex.h"
2930
#include <tuple>
3031
#include <vector>
3132
using namespace clang;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
#include "llvm/ADT/StringMap.h"
2020
#include "llvm/Support/Timer.h"
2121

22+
namespace llvm {
23+
class Regex;
24+
}
25+
2226
namespace clang {
2327

2428
class ASTContext;

clang-tools-extra/clang-tidy/ClangTidyForceLinker.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ extern volatile int LLVMModuleAnchorSource;
4545
static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
4646
LLVMModuleAnchorSource;
4747

48+
// This anchor is used to force the linker to link the LLVMLibcModule.
49+
extern volatile int LLVMLibcModuleAnchorSource;
50+
static int LLVM_ATTRIBUTE_UNUSED LLVMLibcModuleAnchorDestination =
51+
LLVMLibcModuleAnchorSource;
52+
4853
// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
4954
extern volatile int CppCoreGuidelinesModuleAnchorSource;
5055
static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =

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

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

99
#include "ExpandModularHeadersPPCallbacks.h"
10+
#include "clang/Basic/FileManager.h"
11+
#include "clang/Basic/TargetInfo.h"
1012
#include "clang/Frontend/CompilerInstance.h"
1113
#include "clang/Lex/PreprocessorOptions.h"
1214
#include "clang/Serialization/ASTReader.h"

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
#include "clang/Lex/Preprocessor.h"
1414
#include "llvm/ADT/DenseSet.h"
1515

16+
namespace llvm {
17+
namespace vfs {
18+
class OverlayFileSystem;
19+
class InMemoryFileSystem;
20+
} // namespace vfs
21+
} // namespace llvm
22+
1623
namespace clang {
1724
class CompilerInstance;
1825

clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "StringIntegerAssignmentCheck.h"
4646
#include "StringLiteralWithEmbeddedNulCheck.h"
4747
#include "SuspiciousEnumUsageCheck.h"
48+
#include "SuspiciousIncludeCheck.h"
4849
#include "SuspiciousMemsetUsageCheck.h"
4950
#include "SuspiciousMissingCommaCheck.h"
5051
#include "SuspiciousSemicolonCheck.h"
@@ -140,6 +141,8 @@ class BugproneModule : public ClangTidyModule {
140141
"bugprone-string-literal-with-embedded-nul");
141142
CheckFactories.registerCheck<SuspiciousEnumUsageCheck>(
142143
"bugprone-suspicious-enum-usage");
144+
CheckFactories.registerCheck<SuspiciousIncludeCheck>(
145+
"bugprone-suspicious-include");
143146
CheckFactories.registerCheck<SuspiciousMemsetUsageCheck>(
144147
"bugprone-suspicious-memset-usage");
145148
CheckFactories.registerCheck<SuspiciousMissingCommaCheck>(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ add_clang_library(clangTidyBugproneModule
3737
StringIntegerAssignmentCheck.cpp
3838
StringLiteralWithEmbeddedNulCheck.cpp
3939
SuspiciousEnumUsageCheck.cpp
40+
SuspiciousIncludeCheck.cpp
4041
SuspiciousMemsetUsageCheck.cpp
4142
SuspiciousMissingCommaCheck.cpp
4243
SuspiciousSemicolonCheck.cpp
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
//===--- SuspiciousIncludeCheck.cpp - clang-tidy --------------------------===//
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 "SuspiciousIncludeCheck.h"
10+
#include "clang/AST/ASTContext.h"
11+
12+
namespace clang {
13+
namespace tidy {
14+
namespace bugprone {
15+
16+
namespace {
17+
class SuspiciousIncludePPCallbacks : public PPCallbacks {
18+
public:
19+
explicit SuspiciousIncludePPCallbacks(SuspiciousIncludeCheck &Check,
20+
const SourceManager &SM,
21+
Preprocessor *PP)
22+
: Check(Check), PP(PP) {}
23+
24+
void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
25+
StringRef FileName, bool IsAngled,
26+
CharSourceRange FilenameRange, const FileEntry *File,
27+
StringRef SearchPath, StringRef RelativePath,
28+
const Module *Imported,
29+
SrcMgr::CharacteristicKind FileType) override;
30+
31+
private:
32+
SuspiciousIncludeCheck &Check;
33+
Preprocessor *PP;
34+
};
35+
} // namespace
36+
37+
SuspiciousIncludeCheck::SuspiciousIncludeCheck(StringRef Name,
38+
ClangTidyContext *Context)
39+
: ClangTidyCheck(Name, Context),
40+
RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
41+
"HeaderFileExtensions", utils::defaultHeaderFileExtensions())),
42+
RawStringImplementationFileExtensions(Options.getLocalOrGlobal(
43+
"ImplementationFileExtensions",
44+
utils::defaultImplementationFileExtensions())) {
45+
if (!utils::parseFileExtensions(RawStringImplementationFileExtensions,
46+
ImplementationFileExtensions,
47+
utils::defaultFileExtensionDelimiters())) {
48+
llvm::errs() << "Invalid implementation file extension: "
49+
<< RawStringImplementationFileExtensions << "\n";
50+
}
51+
52+
if (!utils::parseFileExtensions(RawStringHeaderFileExtensions,
53+
HeaderFileExtensions,
54+
utils::defaultFileExtensionDelimiters())) {
55+
llvm::errs() << "Invalid header file extension: "
56+
<< RawStringHeaderFileExtensions << "\n";
57+
}
58+
}
59+
60+
void SuspiciousIncludeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
61+
Options.store(Opts, "ImplementationFileExtensions",
62+
RawStringImplementationFileExtensions);
63+
Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions);
64+
}
65+
66+
void SuspiciousIncludeCheck::registerPPCallbacks(
67+
const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
68+
PP->addPPCallbacks(
69+
::std::make_unique<SuspiciousIncludePPCallbacks>(*this, SM, PP));
70+
}
71+
72+
void SuspiciousIncludePPCallbacks::InclusionDirective(
73+
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
74+
bool IsAngled, CharSourceRange FilenameRange, const FileEntry *File,
75+
StringRef SearchPath, StringRef RelativePath, const Module *Imported,
76+
SrcMgr::CharacteristicKind FileType) {
77+
if (IncludeTok.getIdentifierInfo()->getPPKeywordID() == tok::pp_import)
78+
return;
79+
80+
SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1);
81+
82+
const Optional<StringRef> IFE =
83+
utils::getFileExtension(FileName, Check.ImplementationFileExtensions);
84+
if (!IFE)
85+
return;
86+
87+
Check.diag(DiagLoc, "suspicious #%0 of file with '%1' extension")
88+
<< IncludeTok.getIdentifierInfo()->getName() << *IFE;
89+
90+
for (const auto &HFE : Check.HeaderFileExtensions) {
91+
SmallString<128> GuessedFileName(FileName);
92+
llvm::sys::path::replace_extension(GuessedFileName,
93+
(HFE.size() ? "." : "") + HFE);
94+
95+
const DirectoryLookup *CurDir;
96+
Optional<FileEntryRef> File =
97+
PP->LookupFile(DiagLoc, GuessedFileName, IsAngled, nullptr, nullptr,
98+
CurDir, nullptr, nullptr, nullptr, nullptr, nullptr);
99+
if (File) {
100+
Check.diag(DiagLoc, "did you mean to include '%0'?", DiagnosticIDs::Note)
101+
<< GuessedFileName;
102+
}
103+
}
104+
}
105+
106+
} // namespace bugprone
107+
} // namespace tidy
108+
} // namespace clang
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//===--- SuspiciousIncludeCheck.h - clang-tidy ------------------*- 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_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
11+
12+
#include "../ClangTidyCheck.h"
13+
#include "../utils/FileExtensionsUtils.h"
14+
15+
namespace clang {
16+
namespace tidy {
17+
namespace bugprone {
18+
19+
/// Warns on inclusion of files whose names suggest that they're implementation
20+
/// files, instead of headers. E.g:
21+
///
22+
/// #include "foo.cpp" // warning
23+
/// #include "bar.c" // warning
24+
/// #include "baz.h" // no diagnostic
25+
///
26+
/// The check supports these options:
27+
/// - `HeaderFileExtensions`: a semicolon-separated list of filename
28+
/// extensions of header files (The filename extensions should not contain
29+
/// "." prefix) ";h;hh;hpp;hxx" by default. For extension-less header
30+
/// files, using an empty string or leaving an empty string between ";" if
31+
/// there are other filename extensions.
32+
///
33+
/// - `ImplementationFileExtensions`: likewise, a semicolon-separated list of
34+
/// filename extensions of implementation files. "c;cc;cpp;cxx" by default.
35+
///
36+
/// For the user-facing documentation see:
37+
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-include.html
38+
class SuspiciousIncludeCheck : public ClangTidyCheck {
39+
public:
40+
SuspiciousIncludeCheck(StringRef Name, ClangTidyContext *Context);
41+
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
42+
Preprocessor *ModuleExpanderPP) override;
43+
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
44+
45+
utils::FileExtensionsSet HeaderFileExtensions;
46+
utils::FileExtensionsSet ImplementationFileExtensions;
47+
48+
private:
49+
const std::string RawStringHeaderFileExtensions;
50+
const std::string RawStringImplementationFileExtensions;
51+
};
52+
53+
} // namespace bugprone
54+
} // namespace tidy
55+
} // namespace clang
56+
57+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H

clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "DefaultOperatorNewAlignmentCheck.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
#include "clang/Basic/TargetInfo.h"
1213

1314
using namespace clang::ast_matchers;
1415

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ add_clang_library(clangTidyFuchsiaModule
66
FuchsiaTidyModule.cpp
77
MultipleInheritanceCheck.cpp
88
OverloadedOperatorCheck.cpp
9-
RestrictSystemIncludesCheck.cpp
109
StaticallyConstructedObjectsCheck.cpp
1110
TrailingReturnCheck.cpp
1211
VirtualInheritanceCheck.cpp

clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "DefaultArgumentsDeclarationsCheck.h"
1515
#include "MultipleInheritanceCheck.h"
1616
#include "OverloadedOperatorCheck.h"
17-
#include "RestrictSystemIncludesCheck.h"
1817
#include "StaticallyConstructedObjectsCheck.h"
1918
#include "TrailingReturnCheck.h"
2019
#include "VirtualInheritanceCheck.h"
@@ -39,8 +38,6 @@ class FuchsiaModule : public ClangTidyModule {
3938
"fuchsia-multiple-inheritance");
4039
CheckFactories.registerCheck<OverloadedOperatorCheck>(
4140
"fuchsia-overloaded-operator");
42-
CheckFactories.registerCheck<RestrictSystemIncludesCheck>(
43-
"fuchsia-restrict-system-includes");
4441
CheckFactories.registerCheck<StaticallyConstructedObjectsCheck>(
4542
"fuchsia-statically-constructed-objects");
4643
CheckFactories.registerCheck<TrailingReturnCheck>(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set(LLVM_LINK_COMPONENTS support)
2+
3+
add_clang_library(clangTidyLLVMLibcModule
4+
LLVMLibcTidyModule.cpp
5+
RestrictSystemLibcHeadersCheck.cpp
6+
7+
LINK_LIBS
8+
clangAST
9+
clangASTMatchers
10+
clangBasic
11+
clangLex
12+
clangTidy
13+
clangTidyUtils
14+
clangTooling
15+
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===--- LLVMLibcTidyModule.cpp - clang-tidy ------------------------------===//
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 "../ClangTidy.h"
10+
#include "../ClangTidyModule.h"
11+
#include "../ClangTidyModuleRegistry.h"
12+
#include "RestrictSystemLibcHeadersCheck.h"
13+
14+
namespace clang {
15+
namespace tidy {
16+
namespace llvm_libc {
17+
18+
class LLVMLibcModule : public ClangTidyModule {
19+
public:
20+
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
21+
CheckFactories.registerCheck<RestrictSystemLibcHeadersCheck>(
22+
"llvmlibc-restrict-system-libc-headers");
23+
}
24+
};
25+
26+
// Register the LLVMLibcTidyModule using this statically initialized variable.
27+
static ClangTidyModuleRegistry::Add<LLVMLibcModule>
28+
X("llvmlibc-module", "Adds LLVM libc standards checks.");
29+
30+
} // namespace llvm_libc
31+
32+
// This anchor is used to force the linker to link in the generated object file
33+
// and thus register the LLVMLibcModule.
34+
volatile int LLVMLibcModuleAnchorSource = 0;
35+
36+
} // namespace tidy
37+
} // namespace clang

0 commit comments

Comments
 (0)