Skip to content

Commit

Permalink
[DPWBS-1493] Merge upstream branch 'master' into htc/master
Browse files Browse the repository at this point in the history
The following files needed to be touched for merge-conflict resolution:

compiler-rt/cmake/builtin-config-idx.cmake  dedaf3a
llvm/include/llvm/module.modulemap          8cec5c3

The following files needed to be touched due to changes upstream:

TriCoreMCTargetDesc.cpp  7e49dc6
TriCoreFrameLowering.cpp 7e49dc6
                         0840d72
TriCoreLegalizerInfo.cpp 8bc03d2

The following XFAIL tests were promoted to normal tests:

xfail-legalize-extract-s96.mir 052c962
xfail-legalize-freeze.mir      052c962
xfail-legalize-insert.mir      052c962

The following test, while still invalid, can now be legalized due to better combines available from upstream and is promoted to a normal test:

legalize-unmerge-values-invalid.mir 052c962

The following tests needed their checks updated due to upstream changes:

legalize-load-store.mir     052c962
legalize-unmerge-values.mir 052c962
legalize-vaarg.mir          8bc03d2

The following test was added with the given commit and was changed to reflect the naming in our downstream project:

file-header-machine-types.test 5921782

Related to the test above, an inconsistency in the spelling on TriCore was fixed in ELFDumper.cpp
  • Loading branch information
gargaroff committed Jun 2, 2020
2 parents 636fb20 + 052c962 commit 6fbe470
Show file tree
Hide file tree
Showing 3,456 changed files with 125,961 additions and 52,248 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
14 changes: 0 additions & 14 deletions clang-tools-extra/clang-doc/Generators.cpp
Expand Up @@ -27,20 +27,6 @@ findGeneratorByName(llvm::StringRef Format) {

// Enum conversion

std::string getAccess(AccessSpecifier AS) {
switch (AS) {
case AccessSpecifier::AS_public:
return "public";
case AccessSpecifier::AS_protected:
return "protected";
case AccessSpecifier::AS_private:
return "private";
case AccessSpecifier::AS_none:
return {};
}
llvm_unreachable("Unknown AccessSpecifier");
}

std::string getTagType(TagTypeKind AS) {
switch (AS) {
case TagTypeKind::TTK_Class:
Expand Down
2 changes: 0 additions & 2 deletions clang-tools-extra/clang-doc/Generators.h
Expand Up @@ -42,8 +42,6 @@ typedef llvm::Registry<Generator> GeneratorRegistry;
llvm::Expected<std::unique_ptr<Generator>>
findGeneratorByName(llvm::StringRef Format);

std::string getAccess(AccessSpecifier AS);

std::string getTagType(TagTypeKind AS);

} // namespace doc
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-doc/HTMLGenerator.cpp
Expand Up @@ -402,7 +402,7 @@ genRecordMembersBlock(const llvm::SmallVector<MemberTypeInfo, 4> &Members,
Out.emplace_back(std::make_unique<TagNode>(HTMLTag::TAG_UL));
auto &ULBody = Out.back();
for (const auto &M : Members) {
std::string Access = getAccess(M.Access);
std::string Access = getAccessSpelling(M.Access).str();
if (Access != "")
Access = Access + " ";
auto LIBody = std::make_unique<TagNode>(HTMLTag::TAG_LI);
Expand Down Expand Up @@ -679,7 +679,7 @@ genHTML(const FunctionInfo &I, const ClangDocContext &CDCtx,
Out.emplace_back(std::make_unique<TagNode>(HTMLTag::TAG_P));
auto &FunctionHeader = Out.back();

std::string Access = getAccess(I.Access);
std::string Access = getAccessSpelling(I.Access).str();
if (Access != "")
FunctionHeader->Children.emplace_back(
std::make_unique<TextNode>(Access + " "));
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-doc/MDGenerator.cpp
Expand Up @@ -157,7 +157,7 @@ static void genMarkdown(const ClangDocContext &CDCtx, const FunctionInfo &I,
First = false;
}
writeHeader(I.Name, 3, OS);
std::string Access = getAccess(I.Access);
std::string Access = getAccessSpelling(I.Access).str();
if (Access != "")
writeLine(genItalic(Access + " " + I.ReturnType.Type.Name + " " + I.Name +
"(" + Stream.str() + ")"),
Expand Down Expand Up @@ -250,7 +250,7 @@ static void genMarkdown(const ClangDocContext &CDCtx, const RecordInfo &I,
if (!I.Members.empty()) {
writeHeader("Members", 2, OS);
for (const auto &Member : I.Members) {
std::string Access = getAccess(Member.Access);
std::string Access = getAccessSpelling(Member.Access).str();
if (Access != "")
writeLine(Access + " " + Member.Type.Name + " " + Member.Name, OS);
else
Expand Down
12 changes: 12 additions & 0 deletions clang-tools-extra/clang-query/Query.cpp
Expand Up @@ -43,6 +43,15 @@ bool HelpQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
"Set whether to bind the root matcher to \"root\".\n"
" set print-matcher (true|false) "
"Set whether to print the current matcher,\n"
" set traversal <kind> "
"Set traversal kind of clang-query session. Available kinds are:\n"
" AsIs "
"Print and match the AST as clang sees it.\n"
" IgnoreImplicitCastsAndParentheses "
"Omit implicit casts and parens in matching and dumping.\n"
" IgnoreUnlessSpelledInSource "
"Omit AST nodes unless spelled in the source. This mode is the "
"default.\n"
" set output <feature> "
"Set whether to output only <feature> content.\n"
" enable output <feature> "
Expand Down Expand Up @@ -98,6 +107,8 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
OS << "Not a valid top-level matcher.\n";
return false;
}

AST->getASTContext().getParentMapContext().setTraversalKind(QS.TK);
Finder.matchAST(AST->getASTContext());

if (QS.PrintMatcher) {
Expand Down Expand Up @@ -148,6 +159,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
const SourceManager &SM = Ctx.getSourceManager();
ASTDumper Dumper(OS, &Ctx.getCommentCommandTraits(), &SM,
SM.getDiagnostics().getShowColors(), Ctx.getPrintingPolicy());
Dumper.SetTraversalKind(QS.TK);
Dumper.Visit(BI->second);
OS << "\n";
}
Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/clang-query/Query.h
Expand Up @@ -28,6 +28,7 @@ enum QueryKind {
QK_Match,
QK_SetBool,
QK_SetOutputKind,
QK_SetTraversalKind,
QK_EnableOutputKind,
QK_DisableOutputKind,
QK_Quit
Expand Down Expand Up @@ -119,6 +120,10 @@ template <> struct SetQueryKind<OutputKind> {
static const QueryKind value = QK_SetOutputKind;
};

template <> struct SetQueryKind<ast_type_traits::TraversalKind> {
static const QueryKind value = QK_SetTraversalKind;
};

/// Query for "set VAR VALUE".
template <typename T> struct SetQuery : Query {
SetQuery(T QuerySession::*Var, T Value)
Expand Down
25 changes: 24 additions & 1 deletion clang-tools-extra/clang-query/QueryParser.cpp
Expand Up @@ -128,6 +128,24 @@ template <typename QueryType> QueryRef QueryParser::parseSetOutputKind() {
llvm_unreachable("Invalid output kind");
}

QueryRef QueryParser::parseSetTraversalKind(
ast_type_traits::TraversalKind QuerySession::*Var) {
StringRef ValStr;
unsigned Value =
LexOrCompleteWord<unsigned>(this, ValStr)
.Case("AsIs", ast_type_traits::TK_AsIs)
.Case("IgnoreImplicitCastsAndParentheses",
ast_type_traits::TK_IgnoreImplicitCastsAndParentheses)
.Case("IgnoreUnlessSpelledInSource",
ast_type_traits::TK_IgnoreUnlessSpelledInSource)
.Default(~0u);
if (Value == ~0u) {
return new InvalidQuery("expected traversal kind, got '" + ValStr + "'");
}
return new SetQuery<ast_type_traits::TraversalKind>(
Var, static_cast<ast_type_traits::TraversalKind>(Value));
}

QueryRef QueryParser::endQuery(QueryRef Q) {
StringRef Extra = Line;
StringRef ExtraTrimmed = Extra.drop_while(
Expand Down Expand Up @@ -171,7 +189,8 @@ enum ParsedQueryVariable {
PQV_Invalid,
PQV_Output,
PQV_BindRoot,
PQV_PrintMatcher
PQV_PrintMatcher,
PQV_Traversal
};

QueryRef makeInvalidQueryFromDiagnostics(const Diagnostics &Diag) {
Expand Down Expand Up @@ -272,6 +291,7 @@ QueryRef QueryParser::doParse() {
.Case("output", PQV_Output)
.Case("bind-root", PQV_BindRoot)
.Case("print-matcher", PQV_PrintMatcher)
.Case("traversal", PQV_Traversal)
.Default(PQV_Invalid);
if (VarStr.empty())
return new InvalidQuery("expected variable name");
Expand All @@ -289,6 +309,9 @@ QueryRef QueryParser::doParse() {
case PQV_PrintMatcher:
Q = parseSetBool(&QuerySession::PrintMatcher);
break;
case PQV_Traversal:
Q = parseSetTraversalKind(&QuerySession::TK);
break;
case PQV_Invalid:
llvm_unreachable("Invalid query kind");
}
Expand Down
2 changes: 2 additions & 0 deletions clang-tools-extra/clang-query/QueryParser.h
Expand Up @@ -43,6 +43,8 @@ class QueryParser {
template <typename T> struct LexOrCompleteWord;

QueryRef parseSetBool(bool QuerySession::*Var);
QueryRef
parseSetTraversalKind(ast_type_traits::TraversalKind QuerySession::*Var);
template <typename QueryType> QueryRef parseSetOutputKind();
QueryRef completeMatcherExpression();

Expand Down
5 changes: 4 additions & 1 deletion clang-tools-extra/clang-query/QuerySession.h
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H

#include "clang/AST/ASTTypeTraits.h"
#include "clang/ASTMatchers/Dynamic/VariantValue.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringMap.h"
Expand All @@ -25,7 +26,7 @@ class QuerySession {
QuerySession(llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs)
: ASTs(ASTs), PrintOutput(false), DiagOutput(true),
DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
Terminate(false) {}
Terminate(false), TK(ast_type_traits::TK_IgnoreUnlessSpelledInSource) {}

llvm::ArrayRef<std::unique_ptr<ASTUnit>> ASTs;

Expand All @@ -36,6 +37,8 @@ class QuerySession {
bool BindRoot;
bool PrintMatcher;
bool Terminate;

ast_type_traits::TraversalKind TK;
llvm::StringMap<ast_matchers::dynamic::VariantValue> NamedValues;
};

Expand Down
14 changes: 11 additions & 3 deletions clang-tools-extra/clang-query/tool/ClangQuery.cpp
Expand Up @@ -35,6 +35,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/WithColor.h"
#include <fstream>
#include <string>

Expand Down Expand Up @@ -86,7 +87,14 @@ bool runCommandsInFile(const char *ExeName, std::string const &FileName,
int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);

CommonOptionsParser OptionsParser(argc, argv, ClangQueryCategory);
llvm::Expected<CommonOptionsParser> OptionsParser =
CommonOptionsParser::create(argc, argv, ClangQueryCategory,
llvm::cl::OneOrMore);

if (!OptionsParser) {
llvm::WithColor::error() << llvm::toString(OptionsParser.takeError());
return 1;
}

if (!Commands.empty() && !CommandFiles.empty()) {
llvm::errs() << argv[0] << ": cannot specify both -c and -f\n";
Expand All @@ -99,8 +107,8 @@ int main(int argc, const char **argv) {
return 1;
}

ClangTool Tool(OptionsParser.getCompilations(),
OptionsParser.getSourcePathList());
ClangTool Tool(OptionsParser->getCompilations(),
OptionsParser->getSourcePathList());
std::vector<std::unique_ptr<ASTUnit>> ASTs;
int Status = Tool.buildASTs(ASTs);
int ASTStatus = 0;
Expand Down
Expand Up @@ -104,9 +104,11 @@ findMembersUsedInInitExpr(const CXXCtorInitializer *Initializer,
// for those accesses Sema::PerformObjectMemberConversion always inserts an
// UncheckedDerivedToBase ImplicitCastExpr between the this expr and the
// object expression
auto FoundExprs =
match(findAll(memberExpr(hasObjectExpression(cxxThisExpr())).bind("ME")),
*Initializer->getInit(), Context);
auto FoundExprs = match(
traverse(
TK_AsIs,
findAll(memberExpr(hasObjectExpression(cxxThisExpr())).bind("ME"))),
*Initializer->getInit(), Context);
for (BoundNodes &BN : FoundExprs)
if (auto *MemExpr = BN.getNodeAs<MemberExpr>("ME"))
if (auto *FD = dyn_cast<FieldDecl>(MemExpr->getMemberDecl()))
Expand Down
5 changes: 4 additions & 1 deletion clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
Expand Up @@ -21,8 +21,9 @@
#include "NoInternalDependenciesCheck.h"
#include "NoNamespaceCheck.h"
#include "RedundantStrcatCallsCheck.h"
#include "StringFindStartswithCheck.h"
#include "StrCatAppendCheck.h"
#include "StringFindStartswithCheck.h"
#include "StringFindStrContainsCheck.h"
#include "TimeComparisonCheck.h"
#include "TimeSubtractionCheck.h"
#include "UpgradeDurationConversionsCheck.h"
Expand Down Expand Up @@ -61,6 +62,8 @@ class AbseilModule : public ClangTidyModule {
"abseil-str-cat-append");
CheckFactories.registerCheck<StringFindStartswithCheck>(
"abseil-string-find-startswith");
CheckFactories.registerCheck<StringFindStrContainsCheck>(
"abseil-string-find-str-contains");
CheckFactories.registerCheck<TimeComparisonCheck>(
"abseil-time-comparison");
CheckFactories.registerCheck<TimeSubtractionCheck>(
Expand Down
2 changes: 2 additions & 0 deletions clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
Expand Up @@ -20,6 +20,7 @@ add_clang_library(clangTidyAbseilModule
RedundantStrcatCallsCheck.cpp
StrCatAppendCheck.cpp
StringFindStartswithCheck.cpp
StringFindStrContainsCheck.cpp
TimeComparisonCheck.cpp
TimeSubtractionCheck.cpp
UpgradeDurationConversionsCheck.cpp
Expand All @@ -32,4 +33,5 @@ add_clang_library(clangTidyAbseilModule
clangTidy
clangTidyUtils
clangTooling
clangTransformer
)
21 changes: 11 additions & 10 deletions clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.cpp
Expand Up @@ -20,16 +20,17 @@ void DurationDivisionCheck::registerMatchers(MatchFinder *finder) {
const auto DurationExpr =
expr(hasType(cxxRecordDecl(hasName("::absl::Duration"))));
finder->addMatcher(
implicitCastExpr(
hasSourceExpression(ignoringParenCasts(
cxxOperatorCallExpr(hasOverloadedOperatorName("/"),
hasArgument(0, DurationExpr),
hasArgument(1, DurationExpr))
.bind("OpCall"))),
hasImplicitDestinationType(qualType(unless(isInteger()))),
unless(hasParent(cxxStaticCastExpr())),
unless(hasParent(cStyleCastExpr())),
unless(isInTemplateInstantiation())),
traverse(ast_type_traits::TK_AsIs,
implicitCastExpr(
hasSourceExpression(ignoringParenCasts(
cxxOperatorCallExpr(hasOverloadedOperatorName("/"),
hasArgument(0, DurationExpr),
hasArgument(1, DurationExpr))
.bind("OpCall"))),
hasImplicitDestinationType(qualType(unless(isInteger()))),
unless(hasParent(cxxStaticCastExpr())),
unless(hasParent(cStyleCastExpr())),
unless(isInTemplateInstantiation()))),
this);
}

Expand Down
Expand Up @@ -78,20 +78,23 @@ void FasterStrsplitDelimiterCheck::registerMatchers(MatchFinder *Finder) {

// Find uses of absl::StrSplit(..., "x") and absl::StrSplit(...,
// absl::ByAnyChar("x")) to transform them into absl::StrSplit(..., 'x').
Finder->addMatcher(callExpr(callee(functionDecl(hasName("::absl::StrSplit"))),
hasArgument(1, anyOf(ByAnyCharArg, SingleChar)),
unless(isInTemplateInstantiation()))
.bind("StrSplit"),
this);
Finder->addMatcher(
traverse(ast_type_traits::TK_AsIs,
callExpr(callee(functionDecl(hasName("::absl::StrSplit"))),
hasArgument(1, anyOf(ByAnyCharArg, SingleChar)),
unless(isInTemplateInstantiation()))
.bind("StrSplit")),
this);

// Find uses of absl::MaxSplits("x", N) and
// absl::MaxSplits(absl::ByAnyChar("x"), N) to transform them into
// absl::MaxSplits('x', N).
Finder->addMatcher(
callExpr(
callee(functionDecl(hasName("::absl::MaxSplits"))),
hasArgument(0, anyOf(ByAnyCharArg, ignoringParenCasts(SingleChar))),
unless(isInTemplateInstantiation())),
traverse(ast_type_traits::TK_AsIs,
callExpr(callee(functionDecl(hasName("::absl::MaxSplits"))),
hasArgument(0, anyOf(ByAnyCharArg,
ignoringParenCasts(SingleChar))),
unless(isInTemplateInstantiation()))),
this);
}

Expand Down
Expand Up @@ -64,11 +64,12 @@ const clang::CallExpr* ProcessArgument(const Expr* Arg,
static const auto* const Strcat = new auto(hasName("::absl::StrCat"));
const auto IsStrcat = cxxBindTemporaryExpr(
has(callExpr(callee(functionDecl(*Strcat))).bind("StrCat")));
if (const auto* SubStrcatCall = selectFirst<const CallExpr>(
if (const auto *SubStrcatCall = selectFirst<const CallExpr>(
"StrCat",
match(stmt(anyOf(
cxxConstructExpr(IsAlphanum, hasArgument(0, IsStrcat)),
IsStrcat)),
match(stmt(traverse(ast_type_traits::TK_AsIs,
anyOf(cxxConstructExpr(IsAlphanum,
hasArgument(0, IsStrcat)),
IsStrcat))),
*Arg->IgnoreParenImpCasts(), *Result.Context))) {
RemoveCallLeaveArgs(SubStrcatCall, CheckResult);
return SubStrcatCall;
Expand Down
19 changes: 11 additions & 8 deletions clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
Expand Up @@ -58,14 +58,17 @@ void StrCatAppendCheck::registerMatchers(MatchFinder *Finder) {
// StrCat on the RHS. The first argument of the StrCat call should be the same
// as the LHS. Ignore calls from template instantiations.
Finder->addMatcher(
cxxOperatorCallExpr(
unless(isInTemplateInstantiation()), hasOverloadedOperatorName("="),
hasArgument(0, declRefExpr(to(decl().bind("LHS")))),
hasArgument(1, IgnoringTemporaries(
callExpr(callee(StrCat), hasArgument(0, AlphaNum),
unless(HasAnotherReferenceToLhs))
.bind("Call"))))
.bind("Op"),
traverse(ast_type_traits::TK_AsIs,
cxxOperatorCallExpr(
unless(isInTemplateInstantiation()),
hasOverloadedOperatorName("="),
hasArgument(0, declRefExpr(to(decl().bind("LHS")))),
hasArgument(
1, IgnoringTemporaries(
callExpr(callee(StrCat), hasArgument(0, AlphaNum),
unless(HasAnotherReferenceToLhs))
.bind("Call"))))
.bind("Op")),
this);
}

Expand Down

0 comments on commit 6fbe470

Please sign in to comment.