Skip to content

Commit

Permalink
Merge master:fce1a6f5848 into amd-gfx:9e2b7a4f3b3
Browse files Browse the repository at this point in the history
Local branch amd-gfx 9e2b7a4 Revert "Revert "AMDGPU: Change boolean content type to 0 or 1""
Remote branch master fce1a6f Revert "AMDGPU: Try to commute sub of boolean ext"

Change-Id: I1e08eda16557e6ee5db2d1433df7f3e9f78781a5
  • Loading branch information
piotrAMD committed Dec 13, 2019
2 parents 9e2b7a4 + fce1a6f commit 131b828
Show file tree
Hide file tree
Showing 1,204 changed files with 25,142 additions and 7,459 deletions.
40 changes: 20 additions & 20 deletions clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static bool LineIsMarkedWithNOLINTinMacro(const SourceManager &SM,
namespace clang {
namespace tidy {

bool ShouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
bool shouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
const Diagnostic &Info, ClangTidyContext &Context,
bool CheckMacroExpansion) {
return Info.getLocation().isValid() &&
Expand All @@ -375,7 +375,7 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
if (LastErrorWasIgnored && DiagLevel == DiagnosticsEngine::Note)
return;

if (ShouldSuppressDiagnostic(DiagLevel, Info, Context)) {
if (shouldSuppressDiagnostic(DiagLevel, Info, Context)) {
++Context.Stats.ErrorsIgnoredNOLINT;
// Ignored a warning, should ignore related notes as well
LastErrorWasIgnored = true;
Expand Down Expand Up @@ -471,55 +471,55 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
DiagLevelAndFormatString.first, DiagLevelAndFormatString.second);

// Forward the details.
auto builder = ExternalDiagEngine->Report(Info.getLocation(), ExternalID);
auto Builder = ExternalDiagEngine->Report(Info.getLocation(), ExternalID);
for (auto Hint : Info.getFixItHints())
builder << Hint;
Builder << Hint;
for (auto Range : Info.getRanges())
builder << Range;
Builder << Range;
for (unsigned Index = 0; Index < Info.getNumArgs(); ++Index) {
DiagnosticsEngine::ArgumentKind kind = Info.getArgKind(Index);
switch (kind) {
DiagnosticsEngine::ArgumentKind Kind = Info.getArgKind(Index);
switch (Kind) {
case clang::DiagnosticsEngine::ak_std_string:
builder << Info.getArgStdStr(Index);
Builder << Info.getArgStdStr(Index);
break;
case clang::DiagnosticsEngine::ak_c_string:
builder << Info.getArgCStr(Index);
Builder << Info.getArgCStr(Index);
break;
case clang::DiagnosticsEngine::ak_sint:
builder << Info.getArgSInt(Index);
Builder << Info.getArgSInt(Index);
break;
case clang::DiagnosticsEngine::ak_uint:
builder << Info.getArgUInt(Index);
Builder << Info.getArgUInt(Index);
break;
case clang::DiagnosticsEngine::ak_tokenkind:
builder << static_cast<tok::TokenKind>(Info.getRawArg(Index));
Builder << static_cast<tok::TokenKind>(Info.getRawArg(Index));
break;
case clang::DiagnosticsEngine::ak_identifierinfo:
builder << Info.getArgIdentifier(Index);
Builder << Info.getArgIdentifier(Index);
break;
case clang::DiagnosticsEngine::ak_qual:
builder << Qualifiers::fromOpaqueValue(Info.getRawArg(Index));
Builder << Qualifiers::fromOpaqueValue(Info.getRawArg(Index));
break;
case clang::DiagnosticsEngine::ak_qualtype:
builder << QualType::getFromOpaquePtr((void *)Info.getRawArg(Index));
Builder << QualType::getFromOpaquePtr((void *)Info.getRawArg(Index));
break;
case clang::DiagnosticsEngine::ak_declarationname:
builder << DeclarationName::getFromOpaqueInteger(Info.getRawArg(Index));
Builder << DeclarationName::getFromOpaqueInteger(Info.getRawArg(Index));
break;
case clang::DiagnosticsEngine::ak_nameddecl:
builder << reinterpret_cast<const NamedDecl *>(Info.getRawArg(Index));
Builder << reinterpret_cast<const NamedDecl *>(Info.getRawArg(Index));
break;
case clang::DiagnosticsEngine::ak_nestednamespec:
builder << reinterpret_cast<NestedNameSpecifier *>(Info.getRawArg(Index));
Builder << reinterpret_cast<NestedNameSpecifier *>(Info.getRawArg(Index));
break;
case clang::DiagnosticsEngine::ak_declcontext:
builder << reinterpret_cast<DeclContext *>(Info.getRawArg(Index));
Builder << reinterpret_cast<DeclContext *>(Info.getRawArg(Index));
break;
case clang::DiagnosticsEngine::ak_qualtype_pair:
assert(false); // This one is not passed around.
break;
case clang::DiagnosticsEngine::ak_attr:
builder << reinterpret_cast<Attr *>(Info.getRawArg(Index));
Builder << reinterpret_cast<Attr *>(Info.getRawArg(Index));
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class ClangTidyContext {
/// examining source files other than the one in which the diagnostic is
/// located, and in some use cases we cannot rely on such other files being
/// mapped in the SourceMapper.
bool ShouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
bool shouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel,
const Diagnostic &Info, ClangTidyContext &Context,
bool CheckMacroExpansion = true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,26 +262,25 @@ static bool matchesStyle(StringRef Name,
llvm::Regex("^[a-z]([a-z0-9]*(_[A-Z])?)*"),
};

bool Matches = true;
if (Name.startswith(Style.Prefix))
Name = Name.drop_front(Style.Prefix.size());
else
Matches = false;
return false;

if (Name.endswith(Style.Suffix))
Name = Name.drop_back(Style.Suffix.size());
else
Matches = false;
return false;

// Ensure the name doesn't have any extra underscores beyond those specified
// in the prefix and suffix.
if (Name.startswith("_") || Name.endswith("_"))
Matches = false;
return false;

if (Style.Case && !Matchers[static_cast<size_t>(*Style.Case)].match(Name))
Matches = false;
return false;

return Matches;
return true;
}

static std::string fixupWithCase(StringRef Name,
Expand Down
28 changes: 26 additions & 2 deletions clang-tools-extra/clangd/ClangdLSPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
{"declarationProvider", true},
{"definitionProvider", true},
{"documentHighlightProvider", true},
{"documentLinkProvider",
llvm::json::Object{
{"resolveProvider", false},
}},
{"hoverProvider", true},
{"renameProvider", std::move(RenameProvider)},
{"selectionRangeProvider", true},
Expand Down Expand Up @@ -1091,10 +1095,10 @@ void ClangdLSPServer::onHover(const TextDocumentPositionParams &Params,
R.range = (*H)->SymRange;
switch (HoverContentFormat) {
case MarkupKind::PlainText:
R.contents.value = (*H)->present().renderAsPlainText();
R.contents.value = (*H)->present().asPlainText();
return Reply(std::move(R));
case MarkupKind::Markdown:
R.contents.value = (*H)->present().renderAsMarkdown();
R.contents.value = (*H)->present().asMarkdown();
return Reply(std::move(R));
};
llvm_unreachable("unhandled MarkupKind");
Expand Down Expand Up @@ -1200,6 +1204,25 @@ void ClangdLSPServer::onSelectionRange(
});
}

void ClangdLSPServer::onDocumentLink(
const DocumentLinkParams &Params,
Callback<std::vector<DocumentLink>> Reply) {

// TODO(forster): This currently resolves all targets eagerly. This is slow,
// because it blocks on the preamble/AST being built. We could respond to the
// request faster by using string matching or the lexer to find the includes
// and resolving the targets lazily.
Server->documentLinks(
Params.textDocument.uri.file(),
[Reply = std::move(Reply)](
llvm::Expected<std::vector<DocumentLink>> Links) mutable {
if (!Links) {
return Reply(Links.takeError());
}
return Reply(std::move(Links));
});
}

ClangdLSPServer::ClangdLSPServer(
class Transport &Transp, const FileSystemProvider &FSProvider,
const clangd::CodeCompleteOptions &CCOpts,
Expand Down Expand Up @@ -1243,6 +1266,7 @@ ClangdLSPServer::ClangdLSPServer(
MsgHandler->bind("textDocument/typeHierarchy", &ClangdLSPServer::onTypeHierarchy);
MsgHandler->bind("typeHierarchy/resolve", &ClangdLSPServer::onResolveTypeHierarchy);
MsgHandler->bind("textDocument/selectionRange", &ClangdLSPServer::onSelectionRange);
MsgHandler->bind("textDocument/documentLink", &ClangdLSPServer::onDocumentLink);
// clang-format on
}

Expand Down
2 changes: 2 additions & 0 deletions clang-tools-extra/clangd/ClangdLSPServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class ClangdLSPServer : private DiagnosticsConsumer {
Callback<std::vector<SymbolDetails>>);
void onSelectionRange(const SelectionRangeParams &,
Callback<std::vector<SelectionRange>>);
void onDocumentLink(const DocumentLinkParams &,
Callback<std::vector<DocumentLink>>);

std::vector<Fix> getFixes(StringRef File, const clangd::Diagnostic &D);

Expand Down
11 changes: 11 additions & 0 deletions clang-tools-extra/clangd/ClangdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,17 @@ void ClangdServer::semanticRanges(PathRef File, Position Pos,
WorkScheduler.runWithAST("SemanticRanges", File, std::move(Action));
}

void ClangdServer::documentLinks(PathRef File,
Callback<std::vector<DocumentLink>> CB) {
auto Action =
[CB = std::move(CB)](llvm::Expected<InputsAndAST> InpAST) mutable {
if (!InpAST)
return CB(InpAST.takeError());
CB(clangd::getDocumentLinks(InpAST->AST));
};
WorkScheduler.runWithAST("DocumentLinks", File, std::move(Action));
}

std::vector<std::pair<Path, std::size_t>>
ClangdServer::getUsedBytesPerFile() const {
return WorkScheduler.getUsedBytesPerFile();
Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clangd/ClangdServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ class ClangdServer {
void semanticRanges(PathRef File, Position Pos,
Callback<std::vector<Range>> CB);

/// Get all document links in a file.
void documentLinks(PathRef File, Callback<std::vector<DocumentLink>> CB);

/// Returns estimated memory usage for each of the currently open files.
/// The order of results is unspecified.
/// Overall memory usage of clangd may be significantly more than reported
Expand Down
64 changes: 62 additions & 2 deletions clang-tools-extra/clangd/FindTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,40 @@ nodeToString(const ast_type_traits::DynTypedNode &N) {
return S;
}

// Given a dependent type and a member name, heuristically resolve the
// name to one or more declarations.
// The current heuristic is simply to look up the name in the primary
// template. This is a heuristic because the template could potentially
// have specializations that declare different members.
// Multiple declarations could be returned if the name is overloaded
// (e.g. an overloaded method in the primary template).
// This heuristic will give the desired answer in many cases, e.g.
// for a call to vector<T>::size().
std::vector<const NamedDecl *>
getMembersReferencedViaDependentName(const Type *T, const DeclarationName &Name,
bool IsNonstaticMember) {
if (!T)
return {};
if (auto *ICNT = T->getAs<InjectedClassNameType>()) {
T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
}
auto *TST = T->getAs<TemplateSpecializationType>();
if (!TST)
return {};
const ClassTemplateDecl *TD = dyn_cast_or_null<ClassTemplateDecl>(
TST->getTemplateName().getAsTemplateDecl());
if (!TD)
return {};
CXXRecordDecl *RD = TD->getTemplatedDecl();
if (!RD->hasDefinition())
return {};
RD = RD->getDefinition();
return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
return IsNonstaticMember ? D->isCXXInstanceMember()
: !D->isCXXInstanceMember();
});
}

// TargetFinder locates the entities that an AST node refers to.
//
// Typically this is (possibly) one declaration and (possibly) one type, but
Expand Down Expand Up @@ -79,9 +113,9 @@ nodeToString(const ast_type_traits::DynTypedNode &N) {
// formally size() is unresolved, but the primary template is a good guess.
// This affects:
// - DependentTemplateSpecializationType,
// - DependentScopeMemberExpr
// - DependentScopeDeclRefExpr
// - DependentNameType
// - UnresolvedUsingValueDecl
// - UnresolvedUsingTypenameDecl
struct TargetFinder {
using RelSet = DeclRelationSet;
using Rel = DeclRelation;
Expand Down Expand Up @@ -212,6 +246,32 @@ struct TargetFinder {
break;
}
}
void
VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
const Type *BaseType = E->getBaseType().getTypePtrOrNull();
if (E->isArrow()) {
// FIXME: Handle smart pointer types by looking up operator->
// in the primary template.
if (!BaseType || !BaseType->isPointerType()) {
return;
}
BaseType = BaseType->getAs<PointerType>()
->getPointeeType()
.getTypePtrOrNull();
}
for (const NamedDecl *D :
getMembersReferencedViaDependentName(BaseType, E->getMember(),
/*IsNonstaticMember=*/true)) {
Outer.add(D, Flags);
}
}
void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E) {
for (const NamedDecl *D : getMembersReferencedViaDependentName(
E->getQualifier()->getAsType(), E->getDeclName(),
/*IsNonstaticMember=*/false)) {
Outer.add(D, Flags);
}
}
void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *OIRE) {
Outer.add(OIRE->getDecl(), Flags);
}
Expand Down
Loading

0 comments on commit 131b828

Please sign in to comment.