Skip to content

Commit

Permalink
Overwritten with: a77b6e9 Merged master:1454018dc1d9 into amd-gfx:3fd…
Browse files Browse the repository at this point in the history
…59da059f0

Based on upstream llvm : 1454018 Revert "[libc++] Use CMake interface targets to setup benchmark flags"

Local changes since ea979e9:
a77b6e9 Merged master:1454018dc1d9 into amd-gfx:3fd59da059f0
3fd59da Merged master:03127f795b82 into amd-gfx:2052ff69de01
2052ff6 Merged master:98e01f56b0a1 into amd-gfx:0faf255c57f9
0faf255 Merged master:a275acc4a9c8 into amd-gfx:a8f0f462af04
a8f0f46 Merged master:75966ee241a2 into amd-gfx:ef48fb9dfd56
ef48fb9 Merged master:9c4825ce282d into amd-gfx:676863267727
6768632 Merged master:c135a68d426f into amd-gfx:35fe0c30d0db
35fe0c3 Merged master:24c74f5e8c2c into amd-gfx:6083d1110df4
6083d11 Merged master:24fc3177c176 into amd-gfx:ff3a17708b84
ff3a177 Merged master:aa61e4304049 into amd-gfx:e6039cd90733
e6039cd Merged master:fcd2969da9e0 into amd-gfx:3e378fbf48e8
3e378fb Merged master:e10e7829bf6f into amd-gfx:0db76176e796
0db7617 Merged master:9860e68450cd into amd-gfx:c5a502ac4725
c5a502a Merged master:0ec1f0f332c7 into amd-gfx:350123aa4ac0
350123a Merged master:5272d29e2cb7 into amd-gfx:cba62a96b2ab
cba62a9 Merged master:fef260712407 into amd-gfx:041f8033781a
041f803 Merged master:f25d47b7ed3e into amd-gfx:2448a89cc6df
2448a89 Merged master:3ffb751f3dbf into amd-gfx:b0ff4a9889a7
b0ff4a9 Merged master:47552a614a8c into amd-gfx:028045aab0b9
028045a Merged master:402b063c8067 into amd-gfx:5a833493398a
5a83349 Merged master:12b4df991950 into amd-gfx:ecc5f403d29c
ecc5f40 Merged master:1bc298aa125c into amd-gfx:5ffe73cf47b5
5ffe73c Merged master:d0b312955f12 into amd-gfx:4c4f72e10e54
4c4f72e Merged master:22cbe40fa997 into amd-gfx:b419d0d534fb
b419d0d Merged master:93c761f5e5b0 into amd-gfx:584255ba88cf
584255b Merged master:160c133be5e1 into amd-gfx:aeb433f6a474
aeb433f Merged master:b7448a348bb8 into amd-gfx:4569d334fbce
4569d33 Merged master:85d381eb02a2 into amd-gfx:a871b73bce74
a871b73 Merged master:3aecf4bdf3f8 into amd-gfx:55d5ba92c162
55d5ba9 Merged master:25ee851746df into amd-gfx:a35835192b4e
a358351 Merged master:3e7403a1346f into amd-gfx:5f789c6d8d10
5f789c6 Merged master:1621c004da7b into amd-gfx:573483bc2f35
573483b Merged master:43a38dc25173 into amd-gfx:bd3fdd8bf9e9
bd3fdd8 Merged master:05e3ab41e418 into amd-gfx:a06305b415c2
a06305b Merged master:6dbf0cfcf789 into amd-gfx:873eb5d3a8f7
873eb5d Merged master:fc4fd898522a into amd-gfx:12ae09d839a9
12ae09d Merged master:40a142fa57d6 into amd-gfx:745aa2c38fb6
745aa2c Merged master:ce439cb1c962 into amd-gfx:d2658fcb2edb
d2658fc Revert "AMDGPU: Fix verifier error on spilling partially defined SGPRs"
da0f63f Merged master:4c30d4b4e5f2 into amd-gfx:a078d802dea9
a078d80 Merged master:397b3cc9e5aa into amd-gfx:ecc0462b1bbe
ecc0462 Merged master:909a851dbffe into amd-gfx:845a4b68fe55
845a4b6 Merged master:48cd5b72b13c into amd-gfx:fff0414d537a
fff0414 Merged master:800f0eda5b15 into amd-gfx:3bb5d8efedce
3bb5d8e Merged master:b182ccfc2d6a into amd-gfx:5f4901f0c4e9
5f4901f Merged master:21810b0e1428 into amd-gfx:99aa69d1fa46
99aa69d Merged master:612b4dda7667 into amd-gfx:6a82f7b231e2
6a82f7b Merged master:98cf77e33786 into amd-gfx:470e37ff54c5
470e37f Merged master:2916dd5669e7 into amd-gfx:785ec1b704c7
785ec1b Merged master:a31d20e67e2b into amd-gfx:4fd18a5db4d2
4fd18a5 Merged master:3b0878a37005 into amd-gfx:68fe5b911a09
68fe5b9 [AMDGPU][GlobalISel] Select waterfall intrinsics with TableGen patterns
80700d1 Merged master:0e70a127a942 into amd-gfx:d22791a719e9
d22791a Merged master:3651658bdd11 into amd-gfx:9fb40d163aad
9fb40d1 Merged master:fccf4c6115a8 into amd-gfx:a67c54661cb9
a67c546 Merged master:511d5aaca37a into amd-gfx:3291c93460cb
3291c93 Merged master:88bbd3073656 into amd-gfx:f0de6323b87e
f0de632 Merged master:31e5f7120bdd into amd-gfx:81f4fd729542
81f4fd7 Merged master:b0b95dab1ce2 into amd-gfx:b49b4e72112a
b49b4e7 Merged master:c6f51377e12b into amd-gfx:4a16eb27d030
4a16eb2 Merged master:06d100a69a08 into amd-gfx:9bd98790e775
9bd9879 Merged master:254e0abf5be2 into amd-gfx:ad883734e3bc
ad88373 Merged master:cf715717aa8c into amd-gfx:b935d4513c07
b935d45 Merged master:034b95e2839e into amd-gfx:712b9ec4fc09
712b9ec Merged master:031738a56118 into amd-gfx:2a691f810b57
2a691f8 Merged master:d6f710fd46dc into amd-gfx:1bfeb137fb97
1bfeb13 Merged master:c6d2078a35d5 into amd-gfx:274ff371947a
274ff37 Merged master:a22301ef9899 into amd-gfx:3d0e37098161
3d0e370 Merged master:02af25df2be7 into amd-gfx:db6f372dc7aa
db6f372 Merged master:49fb1c2e9018 into amd-gfx:1e18df557928
1e18df5 Merged master:fb04d7b4a698 into amd-gfx:0f98b7a0bd24
0f98b7a Merged master:aae349e2760e into amd-gfx:b2a0e7264b38
b2a0e72 Merged master:7bc03f55539f into amd-gfx:c5a8d66d784a
c5a8d66 Merged master:6fe6b29c294e into amd-gfx:49849cf359eb
49849cf Merged master:e2d61ae57333 into amd-gfx:46e8e3c2c623
46e8e3c Merged master:891ddfc64380 into amd-gfx:862f3dac7a1b

Added AMD modification notices and removed some GPL files.

Change-Id: I0c334c8956295f18bf8ef465dcf7bf09be8d400e
  • Loading branch information
trenouf committed Aug 20, 2020
2 parents ea979e9 + a77b6e9 commit ccbc834
Show file tree
Hide file tree
Showing 1,941 changed files with 95,552 additions and 27,915 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ struct EqualClangTidyError {
std::vector<ClangTidyError> ClangTidyDiagnosticConsumer::take() {
finalizeLastError();

llvm::sort(Errors, LessClangTidyError());
llvm::stable_sort(Errors, LessClangTidyError());
Errors.erase(std::unique(Errors.begin(), Errors.end(), EqualClangTidyError()),
Errors.end());
if (RemoveIncompatibleErrors)
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ AST_POLYMORPHIC_MATCHER(
static const char *AbseilLibraries[] = {
"algorithm", "base", "container", "debugging", "flags",
"hash", "iterator", "memory", "meta", "numeric",
"random", "strings", "synchronization", "time", "types",
"utility"};
"random", "strings", "synchronization", "status", "time",
"types", "utility"};
return std::any_of(
std::begin(AbseilLibraries), std::end(AbseilLibraries),
[&](const char *Library) { return Path.startswith(Library); });
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/add_new_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def write_implementation(module_path, module, namespace, check_name_camel):
void %(check_name)s::check(const MatchFinder::MatchResult &Result) {
// FIXME: Add callback implementation.
const auto *MatchedDecl = Result.Nodes.getNodeAs<FunctionDecl>("x");
if (MatchedDecl->getName().startswith("awesome_"))
if (!MatchedDecl->getIdentifier() || MatchedDecl->getName().startswith("awesome_"))
return;
diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome")
<< MatchedDecl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,10 +805,12 @@ void NotNullTerminatedResultCheck::check(
// PP->getMacroInfo() returns nullptr if macro has no definition.
if (MI) {
const auto &T = MI->tokens().back();
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
llvm::APInt IntValue;
ValueStr.getAsInteger(10, IntValue);
AreSafeFunctionsWanted = IntValue.getZExtValue();
if (T.isLiteral() && T.getLiteralData()) {
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
llvm::APInt IntValue;
ValueStr.getAsInteger(10, IntValue);
AreSafeFunctionsWanted = IntValue.getZExtValue();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ static bool hasAnyNestedLocalQualifiers(QualType Type) {
}

SourceRange UseTrailingReturnTypeCheck::findReturnTypeAndCVSourceRange(
const FunctionDecl &F, const ASTContext &Ctx, const SourceManager &SM,
const LangOptions &LangOpts) {
const FunctionDecl &F, const TypeLoc &ReturnLoc, const ASTContext &Ctx,
const SourceManager &SM, const LangOptions &LangOpts) {

// We start with the range of the return type and expand to neighboring
// qualifiers (const, volatile and restrict).
Expand All @@ -274,6 +274,35 @@ SourceRange UseTrailingReturnTypeCheck::findReturnTypeAndCVSourceRange(
return {};
}

// If the return type is a constrained 'auto' or 'decltype(auto)', we need to
// include the tokens after the concept. Unfortunately, the source range of an
// AutoTypeLoc, if it is constrained, does not include the 'auto' or
// 'decltype(auto)'. If the return type is a plain 'decltype(...)', the
// source range only contains the first 'decltype' token.
auto ATL = ReturnLoc.getAs<AutoTypeLoc>();
if ((ATL && (ATL.isConstrained() ||
ATL.getAutoKeyword() == AutoTypeKeyword::DecltypeAuto)) ||
ReturnLoc.getAs<DecltypeTypeLoc>()) {
SourceLocation End =
expandIfMacroId(ReturnLoc.getSourceRange().getEnd(), SM);
SourceLocation BeginNameF = expandIfMacroId(F.getLocation(), SM);

// Extend the ReturnTypeRange until the last token before the function
// name.
std::pair<FileID, unsigned> Loc = SM.getDecomposedLoc(End);
StringRef File = SM.getBufferData(Loc.first);
const char *TokenBegin = File.data() + Loc.second;
Lexer Lexer(SM.getLocForStartOfFile(Loc.first), LangOpts, File.begin(),
TokenBegin, File.end());
Token T;
SourceLocation LastTLoc = End;
while (!Lexer.LexFromRawLexer(T) &&
SM.isBeforeInTranslationUnit(T.getLocation(), BeginNameF)) {
LastTLoc = T.getLocation();
}
ReturnTypeRange.setEnd(LastTLoc);
}

// If the return type has no local qualifiers, it's source range is accurate.
if (!hasAnyNestedLocalQualifiers(F.getReturnType()))
return ReturnTypeRange;
Expand Down Expand Up @@ -317,7 +346,7 @@ SourceRange UseTrailingReturnTypeCheck::findReturnTypeAndCVSourceRange(
return ReturnTypeRange;
}

bool UseTrailingReturnTypeCheck::keepSpecifiers(
void UseTrailingReturnTypeCheck::keepSpecifiers(
std::string &ReturnType, std::string &Auto, SourceRange ReturnTypeCVRange,
const FunctionDecl &F, const FriendDecl *Fr, const ASTContext &Ctx,
const SourceManager &SM, const LangOptions &LangOpts) {
Expand All @@ -327,14 +356,14 @@ bool UseTrailingReturnTypeCheck::keepSpecifiers(
if (!F.isConstexpr() && !F.isInlineSpecified() &&
F.getStorageClass() != SC_Extern && F.getStorageClass() != SC_Static &&
!Fr && !(M && M->isVirtualAsWritten()))
return true;
return;

// Tokenize return type. If it contains macros which contain a mix of
// qualifiers, specifiers and types, give up.
llvm::Optional<SmallVector<ClassifiedToken, 8>> MaybeTokens =
classifyTokensBeforeFunctionName(F, Ctx, SM, LangOpts);
if (!MaybeTokens)
return false;
return;

// Find specifiers, remove them from the return type, add them to 'auto'.
unsigned int ReturnTypeBeginOffset =
Expand Down Expand Up @@ -367,14 +396,12 @@ bool UseTrailingReturnTypeCheck::keepSpecifiers(
ReturnType.erase(TOffsetInRT, TLengthWithWS);
DeletedChars += TLengthWithWS;
}

return true;
}

void UseTrailingReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
auto F = functionDecl(unless(anyOf(hasTrailingReturn(), returns(voidType()),
returns(autoType()), cxxConversionDecl(),
cxxMethodDecl(isImplicit()))))
auto F = functionDecl(
unless(anyOf(hasTrailingReturn(), returns(voidType()),
cxxConversionDecl(), cxxMethodDecl(isImplicit()))))
.bind("Func");

Finder->addMatcher(F, this);
Expand All @@ -397,11 +424,17 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
if (F->getLocation().isInvalid())
return;

// Skip functions which return just 'auto'.
const auto *AT = F->getDeclaredReturnType()->getAs<AutoType>();
if (AT != nullptr && !AT->isConstrained() &&
AT->getKeyword() == AutoTypeKeyword::Auto &&
!hasAnyNestedLocalQualifiers(F->getDeclaredReturnType()))
return;

// TODO: implement those
if (F->getDeclaredReturnType()->isFunctionPointerType() ||
F->getDeclaredReturnType()->isMemberFunctionPointerType() ||
F->getDeclaredReturnType()->isMemberPointerType() ||
F->getDeclaredReturnType()->getAs<DecltypeType>() != nullptr) {
F->getDeclaredReturnType()->isMemberPointerType()) {
diag(F->getLocation(), Message);
return;
}
Expand Down Expand Up @@ -435,7 +468,7 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
// discards user formatting and order of const, volatile, type, whitespace,
// space before & ... .
SourceRange ReturnTypeCVRange =
findReturnTypeAndCVSourceRange(*F, Ctx, SM, LangOpts);
findReturnTypeAndCVSourceRange(*F, FTL.getReturnLoc(), Ctx, SM, LangOpts);
if (ReturnTypeCVRange.isInvalid())
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ class UseTrailingReturnTypeCheck : public ClangTidyCheck {
const SourceManager &SM,
const LangOptions &LangOpts);
SourceRange findReturnTypeAndCVSourceRange(const FunctionDecl &F,
const TypeLoc &ReturnLoc,
const ASTContext &Ctx,
const SourceManager &SM,
const LangOptions &LangOpts);
bool keepSpecifiers(std::string &ReturnType, std::string &Auto,
void keepSpecifiers(std::string &ReturnType, std::string &Auto,
SourceRange ReturnTypeCVRange, const FunctionDecl &F,
const FriendDecl *Fr, const ASTContext &Ctx,
const SourceManager &SM, const LangOptions &LangOpts);
Expand Down
27 changes: 14 additions & 13 deletions clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ TransformerClangTidyCheck::TransformerClangTidyCheck(RewriteRule R,

void TransformerClangTidyCheck::registerPPCallbacks(
const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
// Only register the IncludeInsert when some `Case` will add
// includes.
if (Rule && llvm::any_of(Rule->Cases, [](const RewriteRule::Case &C) {
return !C.AddedIncludes.empty();
}))
Inserter.registerPreprocessor(PP);
Inserter.registerPreprocessor(PP);
}

void TransformerClangTidyCheck::registerMatchers(
Expand Down Expand Up @@ -96,13 +91,19 @@ void TransformerClangTidyCheck::check(
// Associate the diagnostic with the location of the first change.
DiagnosticBuilder Diag = diag((*Edits)[0].Range.getBegin(), *Explanation);
for (const auto &T : *Edits)
Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);

for (const auto &I : Case.AddedIncludes) {
Diag << Inserter.createMainFileIncludeInsertion(
I.first,
/*IsAngled=*/I.second == transformer::IncludeFormat::Angled);
}
switch (T.Kind) {
case transformer::EditKind::Range:
Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);
break;
case transformer::EditKind::AddInclude: {
StringRef FileName = T.Replacement;
bool IsAngled = FileName.startswith("<") && FileName.endswith(">");
Diag << Inserter.createMainFileIncludeInsertion(
IsAngled ? FileName.substr(1, FileName.size() - 2) : FileName,
IsAngled);
break;
}
}
}

void TransformerClangTidyCheck::storeOptions(
Expand Down
89 changes: 62 additions & 27 deletions clang-tools-extra/clangd/ClangdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
Expand All @@ -52,6 +53,7 @@
#include <future>
#include <memory>
#include <mutex>
#include <string>
#include <type_traits>

namespace clang {
Expand Down Expand Up @@ -109,6 +111,41 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
ClangdServer::Callbacks *ServerCallbacks;
bool TheiaSemanticHighlighting;
};

// Set of clang-tidy checks that don't work well in clangd, either due to
// crashes or false positives.
// Returns a clang-tidy filter string: -check1,-check2.
llvm::StringRef getUnusableTidyChecks() {
static const std::string FalsePositives =
llvm::join_items(", ",
// Check relies on seeing ifndef/define/endif directives,
// clangd doesn't replay those when using a preamble.
"-llvm-header-guard");
static const std::string CrashingChecks =
llvm::join_items(", ",
// Check can choke on invalid (intermediate) c++ code,
// which is often the case when clangd tries to build an
// AST.
"-bugprone-use-after-move");
static const std::string UnusableTidyChecks =
llvm::join_items(", ", FalsePositives, CrashingChecks);
return UnusableTidyChecks;
}

// Returns a clang-tidy options string: check1,check2.
llvm::StringRef getDefaultTidyChecks() {
// These default checks are chosen for:
// - low false-positive rate
// - providing a lot of value
// - being reasonably efficient
static const std::string DefaultChecks = llvm::join_items(
",", "readability-misleading-indentation", "readability-deleted-default",
"bugprone-integer-division", "bugprone-sizeof-expression",
"bugprone-suspicious-missing-comma", "bugprone-unused-raii",
"bugprone-unused-return-value", "misc-unused-using-decls",
"misc-unused-alias-decls", "misc-definitions-in-headers");
return DefaultChecks;
}
} // namespace

ClangdServer::Options ClangdServer::optsForTest() {
Expand Down Expand Up @@ -171,16 +208,20 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
if (Opts.StaticIndex)
AddIndex(Opts.StaticIndex);
if (Opts.BackgroundIndex) {
BackgroundIndex::Options BGOpts;
BGOpts.ThreadPoolSize = std::max(Opts.AsyncThreadsCount, 1u);
BGOpts.OnProgress = [Callbacks](BackgroundQueue::Stats S) {
if (Callbacks)
Callbacks->onBackgroundIndexProgress(S);
};
BGOpts.ContextProvider = [this](PathRef P) {
return createProcessingContext(P);
};
BackgroundIdx = std::make_unique<BackgroundIndex>(
Context::current().clone(), TFS, CDB,
TFS, CDB,
BackgroundIndexStorage::createDiskBackedStorageFactory(
[&CDB](llvm::StringRef File) { return CDB.getProjectInfo(File); }),
std::max(Opts.AsyncThreadsCount, 1u),
[Callbacks](BackgroundQueue::Stats S) {
if (Callbacks)
Callbacks->onBackgroundIndexProgress(S);
},
[this](PathRef P) { return createProcessingContext(P); });
std::move(BGOpts));
AddIndex(BackgroundIdx.get());
}
if (DynamicIdx)
Expand All @@ -196,6 +237,15 @@ void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
if (GetClangTidyOptions)
Opts.ClangTidyOpts =
GetClangTidyOptions(*TFS.view(/*CWD=*/llvm::None), File);
if (Opts.ClangTidyOpts.Checks.hasValue()) {
// If the set of checks was configured, make sure clangd incompatible ones
// are disabled.
Opts.ClangTidyOpts.Checks = llvm::join_items(
", ", *Opts.ClangTidyOpts.Checks, getUnusableTidyChecks());
} else {
// Otherwise provide a nice set of defaults.
Opts.ClangTidyOpts.Checks = getDefaultTidyChecks().str();
}
Opts.SuggestMissingIncludes = SuggestMissingIncludes;

// Compile command is set asynchronously during update, as it can be slow.
Expand Down Expand Up @@ -525,26 +575,6 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
WorkScheduler.runWithAST("ApplyTweak", File, std::move(Action));
}

void ClangdServer::dumpAST(PathRef File,
llvm::unique_function<void(std::string)> Callback) {
auto Action = [Callback = std::move(Callback)](
llvm::Expected<InputsAndAST> InpAST) mutable {
if (!InpAST) {
llvm::consumeError(InpAST.takeError());
return Callback("<no-ast>");
}
std::string Result;

llvm::raw_string_ostream ResultOS(Result);
clangd::dumpAST(InpAST->AST, ResultOS);
ResultOS.flush();

Callback(Result);
};

WorkScheduler.runWithAST("DumpAST", File, std::move(Action));
}

void ClangdServer::locateSymbolAt(PathRef File, Position Pos,
Callback<std::vector<LocatedSymbol>> CB) {
auto Action = [Pos, CB = std::move(CB),
Expand Down Expand Up @@ -754,6 +784,11 @@ void ClangdServer::semanticHighlights(
TUScheduler::InvalidateOnUpdate);
}

void ClangdServer::customAction(PathRef File, llvm::StringRef Name,
Callback<InputsAndAST> Action) {
WorkScheduler.runWithAST(Name, File, std::move(Action));
}

llvm::StringMap<TUScheduler::FileStats> ClangdServer::fileStats() const {
return WorkScheduler.fileStats();
}
Expand Down
11 changes: 7 additions & 4 deletions clang-tools-extra/clangd/ClangdServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ class ClangdServer {
void applyTweak(PathRef File, Range Sel, StringRef ID,
Callback<Tweak::Effect> CB);

/// Only for testing purposes.
/// Waits until all requests to worker thread are finished and dumps AST for
/// \p File. \p File must be in the list of added documents.
void dumpAST(PathRef File, llvm::unique_function<void(std::string)> Callback);
/// Called when an event occurs for a watched file in the workspace.
void onFileEvent(const DidChangeWatchedFilesParams &Params);

Expand All @@ -317,6 +313,13 @@ class ClangdServer {
void semanticHighlights(PathRef File,
Callback<std::vector<HighlightingToken>>);

/// Runs an arbitrary action that has access to the AST of the specified file.
/// The action will execute on one of ClangdServer's internal threads.
/// The AST is only valid for the duration of the callback.
/// As with other actions, the file must have been opened.
void customAction(PathRef File, llvm::StringRef Name,
Callback<InputsAndAST> Action);

/// Returns estimated memory usage and other statistics for each of the
/// currently open files.
/// Overall memory usage of clangd may be significantly more than reported
Expand Down
6 changes: 4 additions & 2 deletions clang-tools-extra/clangd/CodeComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1617,8 +1617,10 @@ class CodeCompleteFlow {

llvm::Optional<float> fuzzyScore(const CompletionCandidate &C) {
// Macros can be very spammy, so we only support prefix completion.
// We won't end up with underfull index results, as macros are sema-only.
if (C.SemaResult && C.SemaResult->Kind == CodeCompletionResult::RK_Macro &&
if (((C.SemaResult &&
C.SemaResult->Kind == CodeCompletionResult::RK_Macro) ||
(C.IndexResult &&
C.IndexResult->SymInfo.Kind == index::SymbolKind::Macro)) &&
!C.Name.startswith_lower(Filter->pattern()))
return None;
return Filter->match(C.Name);
Expand Down
Loading

0 comments on commit ccbc834

Please sign in to comment.