Skip to content

Commit

Permalink
Merge from 'master' to 'sycl-web' (intel#128)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  CONFLICT (content): Merge conflict in clang/test/Driver/clang-offload-bundler.c
  • Loading branch information
bader committed Jan 31, 2020
2 parents 70e4c84 + 6e82d0d commit cc6e3f4
Show file tree
Hide file tree
Showing 359 changed files with 14,551 additions and 5,536 deletions.
4 changes: 4 additions & 0 deletions clang-tools-extra/CODE_OWNERS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ D: clang-tidy
N: Julie Hockett
E: [email protected]
D: clang-doc

N: Sam McCall
E: [email protected]
D: clangd
10 changes: 5 additions & 5 deletions clang-tools-extra/clang-doc/HTMLGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ genStylesheetsHTML(StringRef InfoPath, const ClangDocContext &CDCtx) {
llvm::sys::path::filename(FilePath));
// Paths in HTML must be in posix-style
llvm::sys::path::native(StylesheetPath, llvm::sys::path::Style::posix);
LinkNode->Attributes.emplace_back("href", StylesheetPath.str());
LinkNode->Attributes.emplace_back("href", std::string(StylesheetPath.str()));
Out.emplace_back(std::move(LinkNode));
}
return Out;
Expand All @@ -293,7 +293,7 @@ genJsScriptsHTML(StringRef InfoPath, const ClangDocContext &CDCtx) {
llvm::sys::path::append(ScriptPath, llvm::sys::path::filename(FilePath));
// Paths in HTML must be in posix-style
llvm::sys::path::native(ScriptPath, llvm::sys::path::Style::posix);
ScriptNode->Attributes.emplace_back("src", ScriptPath.str());
ScriptNode->Attributes.emplace_back("src", std::string(ScriptPath.str()));
Out.emplace_back(std::move(ScriptNode));
}
return Out;
Expand Down Expand Up @@ -422,7 +422,7 @@ genReferencesBlock(const std::vector<Reference> &References,

std::vector<std::unique_ptr<TagNode>> Out;
Out.emplace_back(std::make_unique<TagNode>(HTMLTag::TAG_H2, Title));
Out.back()->Attributes.emplace_back("id", Title);
Out.back()->Attributes.emplace_back("id", std::string(Title));
Out.emplace_back(std::make_unique<TagNode>(HTMLTag::TAG_UL));
auto &ULBody = Out.back();
for (const auto &R : References) {
Expand Down Expand Up @@ -454,7 +454,7 @@ writeFileDefinition(const Location &L,
Node->Children.emplace_back(std::make_unique<TextNode>(" of file "));
auto LocFileNode = std::make_unique<TagNode>(
HTMLTag::TAG_A, llvm::sys::path::filename(FileURL));
LocFileNode->Attributes.emplace_back("href", FileURL.str());
LocFileNode->Attributes.emplace_back("href", std::string(FileURL.str()));
Node->Children.emplace_back(std::move(LocFileNode));
return Node;
}
Expand Down Expand Up @@ -502,7 +502,7 @@ static std::unique_ptr<TagNode> genInfoFileMainNode(

auto LeftSidebarNode = std::make_unique<TagNode>(HTMLTag::TAG_DIV);
LeftSidebarNode->Attributes.emplace_back("id", "sidebar-left");
LeftSidebarNode->Attributes.emplace_back("path", InfoPath);
LeftSidebarNode->Attributes.emplace_back("path", std::string(InfoPath));
LeftSidebarNode->Attributes.emplace_back(
"class", "col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas-left");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ using llvm::SmallSetVector;
static const RecordDecl *findDefinition(StringRef RecordName,
ASTContext &Context) {
auto Results =
match(recordDecl(hasName(std::string(RecordName)), isDefinition())
.bind("recordDecl"),
match(recordDecl(hasName(RecordName), isDefinition()).bind("recordDecl"),
Context);
if (Results.empty()) {
llvm::errs() << "Definition of " << RecordName << " not found\n";
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/ClangTidy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext &Context,

if (CheckName.startswith("core") ||
Context.isCheckEnabled(ClangTidyCheckName)) {
List.emplace_back(CheckName, true);
List.emplace_back(std::string(CheckName), true);
}
}
return List;
Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class ClangTidyContext {
return DiagLevelAndFormatString(
static_cast<DiagnosticIDs::Level>(
DiagEngine->getDiagnosticLevel(DiagnosticID, Loc)),
DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID));
std::string(
DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID)));
}

private:
Expand Down
3 changes: 1 addition & 2 deletions clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ rewriteInverseTimeCall(const MatchFinder::MatchResult &Result,
DurationScale Scale, const Expr &Node) {
llvm::StringRef InverseFunction = getTimeInverseForScale(Scale);
if (const auto *MaybeCallArg = selectFirst<const Expr>(
"e", match(callExpr(callee(functionDecl(
hasName(std::string(InverseFunction)))),
"e", match(callExpr(callee(functionDecl(hasName(InverseFunction))),
hasArgument(0, expr().bind("e"))),
Node, *Result.Context))) {
return tooling::fixit::getText(*MaybeCallArg, *Result.Context).str();
Expand Down
14 changes: 7 additions & 7 deletions clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
// a 'Duration'. If we know the result is a 'Duration', we can then infer
// that the second operand must be a 'Time'.
auto CallMatcher =
callExpr(callee(functionDecl(
hasName(std::string(getDurationFactoryForScale(*Scale))))),
hasArgument(0, binaryOperator(hasOperatorName("-"),
hasLHS(TimeInverseMatcher))
.bind("binop")))
callExpr(
callee(functionDecl(hasName(getDurationFactoryForScale(*Scale)))),
hasArgument(0, binaryOperator(hasOperatorName("-"),
hasLHS(TimeInverseMatcher))
.bind("binop")))
.bind("outer_call");
Finder->addMatcher(CallMatcher, this);

Expand Down Expand Up @@ -160,8 +160,8 @@ void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
// latter case (addressed first), we also need to worry about parenthesis.
const auto *MaybeCallArg = selectFirst<const CallExpr>(
"arg", match(expr(hasAncestor(
callExpr(callee(functionDecl(hasName(std::string(
getDurationFactoryForScale(*Scale))))))
callExpr(callee(functionDecl(hasName(
getDurationFactoryForScale(*Scale)))))
.bind("arg"))),
*BinOp, *Result.Context));
if (MaybeCallArg && MaybeCallArg->getArg(0)->IgnoreImpCasts() == BinOp &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void SpecialMemberFunctionsCheck::check(
if (!MatchedDecl)
return;

ClassDefId ID(MatchedDecl->getLocation(), MatchedDecl->getName());
ClassDefId ID(MatchedDecl->getLocation(), std::string(MatchedDecl->getName()));

auto StoreMember = [this, &ID](SpecialMemberFunctionKind Kind) {
llvm::SmallVectorImpl<SpecialMemberFunctionKind> &Members =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ static bool
derivedTypeHasReplacementMethod(const MatchFinder::MatchResult &Result,
llvm::StringRef ReplacementMethod) {
const auto *Class = Result.Nodes.getNodeAs<CXXRecordDecl>("class");
return !match(cxxRecordDecl(unless(isExpansionInFileMatching(
"gtest/gtest(-typed-test)?\\.h$")),
hasMethod(cxxMethodDecl(
hasName(std::string(ReplacementMethod))))),
return !match(cxxRecordDecl(
unless(isExpansionInFileMatching(
"gtest/gtest(-typed-test)?\\.h$")),
hasMethod(cxxMethodDecl(hasName(ReplacementMethod)))),
*Class, *Result.Context)
.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ classifyToken(const FunctionDecl &F, Preprocessor &PP, Token Tok) {
bool ContainsSomethingElse = false;

Token End;
End.startToken();
End.setKind(tok::eof);
SmallVector<Token, 2> Stream{Tok, End};

Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ void RenamerClangTidyCheck::checkMacro(SourceManager &SourceMgr,
return;
FailureInfo &Info = *MaybeFailure;
StringRef Name = MacroNameTok.getIdentifierInfo()->getName();
NamingCheckId ID(MI->getDefinitionLoc(), Name);
NamingCheckId ID(MI->getDefinitionLoc(), std::string(Name));
NamingCheckFailure &Failure = NamingCheckFailures[ID];
SourceRange Range(MacroNameTok.getLocation(), MacroNameTok.getEndLoc());

Expand All @@ -351,7 +351,7 @@ void RenamerClangTidyCheck::checkMacro(SourceManager &SourceMgr,
void RenamerClangTidyCheck::expandMacro(const Token &MacroNameTok,
const MacroInfo *MI) {
StringRef Name = MacroNameTok.getIdentifierInfo()->getName();
NamingCheckId ID(MI->getDefinitionLoc(), Name);
NamingCheckId ID(MI->getDefinitionLoc(), std::string(Name));

auto Failure = NamingCheckFailures.find(ID);
if (Failure == NamingCheckFailures.end())
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Optional<FixItHint> UsingInserter::createUsingDeclaration(
return None;
}
// Find conflicting declarations and references.
auto ConflictingDecl = namedDecl(hasName(std::string(UnqualifiedName)));
auto ConflictingDecl = namedDecl(hasName(UnqualifiedName));
bool HasConflictingDeclaration =
!match(findAll(ConflictingDecl), *Function, Context).empty();
bool HasConflictingDeclRef =
Expand Down
21 changes: 13 additions & 8 deletions clang-tools-extra/clangd/ClangdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,21 @@ void ClangdServer::prepareRename(PathRef File, Position Pos,
return CB(InpAST.takeError());
auto &AST = InpAST->AST;
const auto &SM = AST.getSourceManager();
SourceLocation Loc =
SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
Pos, AST.getSourceManager(), AST.getLangOpts()));
auto Range = getTokenRange(SM, AST.getLangOpts(), Loc);
if (!Range)
return CB(llvm::None); // "rename" is not valid at the position.
auto Loc = sourceLocationInMainFile(SM, Pos);
if (!Loc)
return CB(Loc.takeError());
const auto *TouchingIdentifier =
spelledIdentifierTouching(*Loc, AST.getTokens());
if (!TouchingIdentifier)
return CB(llvm::None); // no rename on non-identifiers.

auto Range = halfOpenToRange(
SM, CharSourceRange::getCharRange(TouchingIdentifier->location(),
TouchingIdentifier->endLocation()));

if (CrossFileRename)
// FIXME: we now assume cross-file rename always succeeds, revisit this.
return CB(*Range);
return CB(Range);

// Performing the local rename isn't substantially more expensive than
// doing an AST-based check, so we just rename and throw away the results.
Expand All @@ -338,7 +343,7 @@ void ClangdServer::prepareRename(PathRef File, Position Pos,
// the message to users (VSCode does).
return CB(Changes.takeError());
}
return CB(*Range);
return CB(Range);
};
WorkScheduler.runWithAST("PrepareRename", File, std::move(Action));
}
Expand Down
9 changes: 0 additions & 9 deletions clang-tools-extra/clangd/ClangdServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,6 @@ class ClangdServer {
const FileSystemProvider &FSProvider, const Options &Opts,
Callbacks *Callbacks = nullptr);

// FIXME: remove this compatibility alias.
ClangdServer(const GlobalCompilationDatabase &CDB,
const FileSystemProvider &FSProvider, Callbacks &Callbacks,
const Options &Opts)
: ClangdServer(CDB, FSProvider, Opts, &Callbacks) {}

/// Add a \p File to the list of tracked C++ files or update the contents if
/// \p File is already tracked. Also schedules parsing of the AST for it on a
/// separate thread. When the parsing is complete, DiagConsumer passed in
Expand Down Expand Up @@ -359,9 +353,6 @@ class ClangdServer {
TUScheduler WorkScheduler;
};

// FIXME: Remove this compatibility alias.
using DiagnosticsConsumer = ClangdServer::Callbacks;

} // namespace clangd
} // namespace clang

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/FindTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct TargetFinder {
}

void add(const Decl *Dcl, RelSet Flags) {
const NamedDecl *D = llvm::dyn_cast<NamedDecl>(Dcl);
const NamedDecl *D = llvm::dyn_cast_or_null<NamedDecl>(Dcl);
if (!D)
return;
debug(*D, Flags);
Expand Down
52 changes: 35 additions & 17 deletions clang-tools-extra/clangd/XRefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "index/Relation.h"
#include "index/SymbolLocation.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
Expand Down Expand Up @@ -249,31 +250,17 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
return Result;
}

// Emit all symbol locations (declaration or definition) from AST.
DeclRelationSet Relations =
DeclRelation::TemplatePattern | DeclRelation::Alias;
for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
auto AddResultDecl = [&](const NamedDecl *D) {
const NamedDecl *Def = getDefinition(D);
const NamedDecl *Preferred = Def ? Def : D;

// If we're at the point of declaration of a template specialization,
// it's more useful to navigate to the template declaration.
if (SM.getMacroArgExpandedLocation(Preferred->getLocation()) ==
IdentStartLoc) {
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Preferred)) {
D = CTSD->getSpecializedTemplate();
Def = getDefinition(D);
Preferred = Def ? Def : D;
}
}

auto Loc = makeLocation(AST.getASTContext(), nameLocation(*Preferred, SM),
*MainFilePath);
if (!Loc)
continue;
return;

Result.emplace_back();
Result.back().Name = printName(AST.getASTContext(), *D);
Result.back().Name = printName(AST.getASTContext(), *Preferred);
Result.back().PreferredDeclaration = *Loc;
// Preferred is always a definition if possible, so this check works.
if (Def == Preferred)
Expand All @@ -282,6 +269,37 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
// Record SymbolID for index lookup later.
if (auto ID = getSymbolID(Preferred))
ResultIndex[*ID] = Result.size() - 1;
};

// Emit all symbol locations (declaration or definition) from AST.
DeclRelationSet Relations =
DeclRelation::TemplatePattern | DeclRelation::Alias;
for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
// Special case: void foo() ^override: jump to the overridden method.
if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D)) {
const auto *Attr = D->getAttr<OverrideAttr>();
const syntax::Token *Tok =
spelledIdentifierTouching(SourceLoc, AST.getTokens());
if (Attr && Tok &&
SM.getSpellingLoc(Attr->getLocation()) == Tok->location()) {
// We may be overridding multiple methods - offer them all.
for (const NamedDecl *ND : CMD->overridden_methods())
AddResultDecl(ND);
continue;
}
}

// Special case: the point of declaration of a template specialization,
// it's more useful to navigate to the template declaration.
if (SM.getMacroArgExpandedLocation(D->getLocation()) == IdentStartLoc) {
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
AddResultDecl(CTSD->getSpecializedTemplate());
continue;
}
}

// Otherwise the target declaration is the right one.
AddResultDecl(D);
}

// Now query the index for all Symbol IDs we found in the AST.
Expand Down
8 changes: 4 additions & 4 deletions clang-tools-extra/clangd/clients/clangd-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"publisher": "llvm-vs-code-extensions",
"homepage": "https://clang.llvm.org/extra/clangd.html",
"engines": {
"vscode": "^1.36.0"
"vscode": "^1.41.0"
},
"categories": [
"Programming Languages",
Expand Down Expand Up @@ -40,9 +40,9 @@
},
"dependencies": {
"jsonc-parser": "^2.1.0",
"vscode-languageclient": "^6.0.0-next.1",
"vscode-languageserver": "^6.0.0-next.1",
"vscode-languageserver-types": "^3.15.0-next.5"
"vscode-languageclient": "^6.1.0",
"vscode-languageserver": "^6.1.0",
"vscode-languageserver-types": "^3.15.1"
},
"devDependencies": {
"@types/mocha": "^2.2.32",
Expand Down
Loading

0 comments on commit cc6e3f4

Please sign in to comment.