Skip to content

Commit

Permalink
Merged main:02220f320498 into amd-gfx:0ef01b0bac0d
Browse files Browse the repository at this point in the history
Local branch amd-gfx 0ef01b0 Merged main:5aafdd7b88f5 into amd-gfx:29c4b66a5c55
Remote branch main 02220f3 [mlir] NFC: retire LLVM_Zero/OneResultOp from LLVM dialect ODS
  • Loading branch information
Sw authored and Sw committed Dec 15, 2020
2 parents 0ef01b0 + 02220f3 commit 07ae5c5
Show file tree
Hide file tree
Showing 154 changed files with 49,674 additions and 764 deletions.
16 changes: 9 additions & 7 deletions clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/Support/raw_ostream.h"

namespace clang {
Expand Down Expand Up @@ -108,13 +109,14 @@ ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {

static llvm::Expected<bool> getAsBool(StringRef Value,
const llvm::Twine &LookupName) {
if (Value == "true")
return true;
if (Value == "false")
return false;
bool Result;
if (!Value.getAsInteger(10, Result))
return Result;

if (llvm::Optional<bool> Parsed = llvm::yaml::parseBool(Value))
return *Parsed;
// To maintain backwards compatability, we support parsing numbers as
// booleans, even though its not supported in YAML.
long long Number;
if (!Value.getAsInteger(10, Number))
return Number != 0;
return llvm::make_error<UnparseableIntegerOptionError>(LookupName.str(),
Value.str(), true);
}
Expand Down
9 changes: 8 additions & 1 deletion clang-tools-extra/clangd/ConfigCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ConfigFragment.h"
#include "ConfigProvider.h"
#include "Features.inc"
#include "TidyProvider.h"
#include "support/Logger.h"
#include "support/Trace.h"
#include "llvm/ADT/None.h"
Expand Down Expand Up @@ -349,13 +350,19 @@ struct FragmentCompiler {

void appendTidyCheckSpec(std::string &CurSpec,
const Located<std::string> &Arg, bool IsPositive) {
StringRef Str = *Arg;
StringRef Str = StringRef(*Arg).trim();
// Don't support negating here, its handled if the item is in the Add or
// Remove list.
if (Str.startswith("-") || Str.contains(',')) {
diag(Error, "Invalid clang-tidy check name", Arg.Range);
return;
}
if (!Str.contains('*') && !isRegisteredTidyCheck(Str)) {
diag(Warning,
llvm::formatv("clang-tidy check '{0}' was not found", Str).str(),
Arg.Range);
return;
}
CurSpec += ',';
if (!IsPositive)
CurSpec += '-';
Expand Down
23 changes: 23 additions & 0 deletions clang-tools-extra/clangd/TidyProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
//===----------------------------------------------------------------------===//

#include "TidyProvider.h"
#include "../clang-tidy/ClangTidyModuleRegistry.h"
#include "Config.h"
#include "support/FileCache.h"
#include "support/Logger.h"
#include "support/ThreadsafeFS.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/VirtualFileSystem.h"
Expand Down Expand Up @@ -266,5 +269,25 @@ tidy::ClangTidyOptions getTidyOptionsForFile(TidyProviderRef Provider,
Provider(Opts, Filename);
return Opts;
}

bool isRegisteredTidyCheck(llvm::StringRef Check) {
assert(!Check.empty());
assert(!Check.contains('*') && !Check.contains(',') &&
"isRegisteredCheck doesn't support globs");
assert(Check.ltrim().front() != '-');

static const llvm::StringSet<llvm::BumpPtrAllocator> AllChecks = [] {
llvm::StringSet<llvm::BumpPtrAllocator> Result;
tidy::ClangTidyCheckFactories Factories;
for (tidy::ClangTidyModuleRegistry::entry E :
tidy::ClangTidyModuleRegistry::entries())
E.instantiate()->addCheckFactories(Factories);
for (const auto &Factory : Factories)
Result.insert(Factory.getKey());
return Result;
}();

return AllChecks.contains(Check);
}
} // namespace clangd
} // namespace clang
5 changes: 5 additions & 0 deletions clang-tools-extra/clangd/TidyProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "support/ThreadsafeFS.h"
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"

namespace clang {
namespace clangd {
Expand Down Expand Up @@ -56,6 +57,10 @@ TidyProviderRef provideClangdConfig();
tidy::ClangTidyOptions getTidyOptionsForFile(TidyProviderRef Provider,
llvm::StringRef Filename);

/// Returns if \p Check is a registered clang-tidy check
/// \pre \p must not be empty, must not contain '*' or ',' or start with '-'.
bool isRegisteredTidyCheck(llvm::StringRef Check);

} // namespace clangd
} // namespace clang

Expand Down
18 changes: 18 additions & 0 deletions clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,24 @@ TEST_F(ConfigCompileTests, Tidy) {
EXPECT_EQ(Conf.ClangTidy.CheckOptions.lookup("StrictMode"), "true");
EXPECT_EQ(Conf.ClangTidy.CheckOptions.lookup("example-check.ExampleOption"),
"0");
EXPECT_THAT(Diags.Diagnostics, IsEmpty());
}

TEST_F(ConfigCompileTests, TidyBadChecks) {
Frag.ClangTidy.Add.emplace_back("unknown-check");
Frag.ClangTidy.Remove.emplace_back("*");
Frag.ClangTidy.Remove.emplace_back("llvm-includeorder");
EXPECT_TRUE(compileAndApply());
// Ensure bad checks are stripped from the glob.
EXPECT_EQ(Conf.ClangTidy.Checks, "-*");
EXPECT_THAT(
Diags.Diagnostics,
ElementsAre(
AllOf(DiagMessage("clang-tidy check 'unknown-check' was not found"),
DiagKind(llvm::SourceMgr::DK_Warning)),
AllOf(
DiagMessage("clang-tidy check 'llvm-includeorder' was not found"),
DiagKind(llvm::SourceMgr::DK_Warning))));
}

TEST_F(ConfigCompileTests, ExternalBlockWarnOnMultipleSource) {
Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Improvements to clang-tidy
<clang-tidy/checks/cppcoreguidelines-init-variables>` and
:doc:`modernize-make-unique <clang-tidy/checks/modernize-make-unique>`.

- CheckOptions that take boolean values now support all spellings supported in
the `YAML format <https://yaml.org/type/bool.html>`_.

New modules
^^^^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ TEST(CheckOptionsValidation, ValidIntOptions) {
CheckOptions["test.BoolIFalseValue"] = "0";
CheckOptions["test.BoolTrueValue"] = "true";
CheckOptions["test.BoolFalseValue"] = "false";
CheckOptions["test.BoolTrueShort"] = "Y";
CheckOptions["test.BoolFalseShort"] = "N";
CheckOptions["test.BoolUnparseable"] = "Nothing";
CheckOptions["test.BoolCaseMismatch"] = "True";

ClangTidyContext Context(std::make_unique<DefaultOptionsProvider>(
ClangTidyGlobalOptions(), Options));
Expand Down Expand Up @@ -227,12 +228,11 @@ TEST(CheckOptionsValidation, ValidIntOptions) {
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolIFalseValue"), false);
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolTrueValue"), true);
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolFalseValue"), false);
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolTrueShort"), true);
CHECK_VAL(TestCheck.getIntLocal<bool>("BoolFalseShort"), false);
CHECK_ERROR_INT(TestCheck.getIntLocal<bool>("BoolUnparseable"),
"invalid configuration value 'Nothing' for option "
"'test.BoolUnparseable'; expected a bool");
CHECK_ERROR_INT(TestCheck.getIntLocal<bool>("BoolCaseMismatch"),
"invalid configuration value 'True' for option "
"'test.BoolCaseMismatch'; expected a bool");

#undef CHECK_ERROR_INT
}
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
#define SVE_TYPE(Name, Id, SingletonId) \
CanQualType SingletonId;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
CanQualType Id##Ty;
#include "clang/Basic/PPCTypes.def"

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,7 @@ class BuiltinType : public Type {
#define SVE_TYPE(Name, Id, SingletonId) Id,
#include "clang/Basic/AArch64SVEACLETypes.def"
// PPC MMA Types
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) Id,
#define PPC_VECTOR_TYPE(Name, Id, Size) Id,
#include "clang/Basic/PPCTypes.def"
// All other builtin types
#define BUILTIN_TYPE(Id, SingletonId) Id,
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/TypeProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ let Class = BuiltinType in {
case BuiltinType::ID: return ctx.SINGLETON_ID;
#include "clang/Basic/AArch64SVEACLETypes.def"

#define PPC_MMA_VECTOR_TYPE(NAME, ID, SIZE) \
#define PPC_VECTOR_TYPE(NAME, ID, SIZE) \
case BuiltinType::ID: return ctx.ID##Ty;
#include "clang/Basic/PPCTypes.def"

Expand Down
28 changes: 23 additions & 5 deletions clang/include/clang/Basic/PPCTypes.def
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,32 @@
//===----------------------------------------------------------------------===//
//
// This file defines PPC types.
// Custom code should define this macro:
// Custom code should define one of these macros:
//
// PPC_MMA_VECTOR_TYPE(Name, Id, Size) - A MMA vector type of a given size
// PPC_VECTOR_TYPE(Name, Id, Size) - A PPC vector type of a given size
// (in bits).
//
// PPC_VECTOR_MMA_TYPE(Name, Id, Size) - A PPC MMA vector type of a given
// size (in bits).
//
// PPC_VECTOR_VSX_TYPE(Name, Id, Size) - A PPC VSX vector type of a given
// size (in bits).
//
//===----------------------------------------------------------------------===//

PPC_MMA_VECTOR_TYPE(__vector_quad, VectorQuad, 512)
PPC_MMA_VECTOR_TYPE(__vector_pair, VectorPair, 256)
#if defined(PPC_VECTOR_TYPE)
#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) PPC_VECTOR_TYPE(Name, Id, Size)
#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) PPC_VECTOR_TYPE(Name, Id, Size)
#elif defined(PPC_VECTOR_MMA_TYPE)
#define PPC_VECTOR_VSX_TYPE(Name, Id, Size)
#elif defined(PPC_VECTOR_VSX_TYPE)
#define PPC_VECTOR_MMA_TYPE(Name, Id, Size)
#endif


PPC_VECTOR_MMA_TYPE(__vector_quad, VectorQuad, 512)
PPC_VECTOR_VSX_TYPE(__vector_pair, VectorPair, 256)

#undef PPC_MMA_VECTOR_TYPE
#undef PPC_VECTOR_MMA_TYPE
#undef PPC_VECTOR_VSX_TYPE
#undef PPC_VECTOR_TYPE
2 changes: 1 addition & 1 deletion clang/include/clang/Serialization/ASTBitCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ class TypeIdx {
#define SVE_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID,
#include "clang/Basic/AArch64SVEACLETypes.def"
// \brief PowerPC MMA types with auto numeration
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) PREDEF_TYPE_##Id##_ID,
#define PPC_VECTOR_TYPE(Name, Id, Size) PREDEF_TYPE_##Id##_ID,
#include "clang/Basic/PPCTypes.def"
};

Expand Down
6 changes: 4 additions & 2 deletions clang/lib/AST/APValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,10 @@ void APValue::setLValue(LValueBase B, const CharUnits &O,
bool IsNullPtr) {
MutableArrayRef<APValue::LValuePathEntry> InternalPath =
setLValueUninit(B, O, Path.size(), IsOnePastTheEnd, IsNullPtr);
memcpy(InternalPath.data(), Path.data(),
Path.size() * sizeof(LValuePathEntry));
if (Path.size()) {
memcpy(InternalPath.data(), Path.data(),
Path.size() * sizeof(LValuePathEntry));
}
}

void APValue::setUnion(const FieldDecl *Field, const APValue &Value) {
Expand Down
20 changes: 13 additions & 7 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,8 +1423,14 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
#include "clang/Basic/AArch64SVEACLETypes.def"
}

if (Target.getTriple().isPPC64() && Target.hasFeature("mma")) {
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
if (Target.getTriple().isPPC64() &&
Target.hasFeature("paired-vector-memops")) {
if (Target.hasFeature("mma")) {
#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
InitBuiltinType(Id##Ty, BuiltinType::Id);
#include "clang/Basic/PPCTypes.def"
}
#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
InitBuiltinType(Id##Ty, BuiltinType::Id);
#include "clang/Basic/PPCTypes.def"
}
Expand Down Expand Up @@ -2154,11 +2160,11 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
Align = 16; \
break;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
Width = Size; \
Align = Size; \
break;
Width = Size; \
Align = Size; \
break;
#include "clang/Basic/PPCTypes.def"
}
break;
Expand Down Expand Up @@ -7232,7 +7238,7 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C,
case BuiltinType::OCLReserveID:
case BuiltinType::OCLSampler:
case BuiltinType::Dependent:
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
#define BUILTIN_TYPE(KIND, ID)
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ ExpectedType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) {
case BuiltinType::Id: \
return Importer.getToContext().SingletonId;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
return Importer.getToContext().Id##Ty;
#include "clang/Basic/PPCTypes.def"
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10968,7 +10968,7 @@ EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts) {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
return GCCTypeClass::None;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2858,7 +2858,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
<< type_name; \
break;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
type_name = #Name; \
Out << 'u' << type_name.size() << type_name; \
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2395,7 +2395,7 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers,
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::ShortAccum:
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/NSAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::BoundMember:
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/PrintfFormatString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt,
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
#define SIGNED_TYPE(Id, SingletonId)
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3084,7 +3084,7 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
case Id: \
return Name;
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case Id: \
return #Name;
#include "clang/Basic/PPCTypes.def"
Expand Down Expand Up @@ -4107,7 +4107,7 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::BuiltinFn:
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/TypeLoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::BuiltinFn:
Expand Down
Loading

0 comments on commit 07ae5c5

Please sign in to comment.