forked from OSchip/llvm-project
[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:
parent
b626f45329
commit
24a816c7d3
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue