forked from GPUOpen-Drivers/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
1,038 changed files
with
30,481 additions
and
14,415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
57
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
37
clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.