[clangd] Disable ExtractFunction for C

This tweak uses constructs like auto and refs, which are not available
in C.

Differential Revision: https://reviews.llvm.org/D85727
This commit is contained in:
Kadir Cetinkaya 2020-08-11 15:03:32 +02:00
parent b626f45329
commit 24a816c7d3
No known key found for this signature in database
GPG Key ID: E39E36B8D2057ED6
2 changed files with 5 additions and 0 deletions

View File

@ -673,6 +673,8 @@ bool ExtractFunction::prepare(const Selection &Inputs) {
const Node *CommonAnc = Inputs.ASTSelection.commonAncestor();
const SourceManager &SM = Inputs.AST->getSourceManager();
const LangOptions &LangOpts = Inputs.AST->getLangOpts();
if (!LangOpts.CPlusPlus)
return false;
if (auto MaybeExtZone = findExtractionZone(CommonAnc, SM, LangOpts)) {
ExtZone = std::move(*MaybeExtZone);
return true;

View File

@ -605,6 +605,9 @@ TEST_F(ExtractFunctionTest, FunctionTest) {
EXPECT_THAT(apply(" if(true) [[{ return; }]] "), HasSubstr("extracted"));
// Don't extract uncertain return
EXPECT_THAT(apply(" if(true) [[if (false) return;]] "), StartsWith("fail"));
FileName = "a.c";
EXPECT_THAT(apply(" for([[int i = 0;]];);"), HasSubstr("unavailable"));
}
TEST_F(ExtractFunctionTest, FileTest) {