History log of /llvm-project/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp (Results 1 – 25 of 31)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6
# 8d714db7 11-Dec-2024 Christian Kandeler <christian.kandeler@qt.io>

[clangd] Consider expression statements in ExtractVariable tweak (#112525)

For instance:
int func();
int main()
{
func(); // => auto placeholder = func();
}


Revision tags: llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3
# c9974ae4 19-Feb-2024 Christian Kandeler <christian.kandeler@qt.io>

[clangd] Do not offer extraction to variable for decl init expression (#69477)

That would turn:
int x = f() + 1;
into:
auto placeholder = f() + 1;
int x = placeholder;
which makes little

[clangd] Do not offer extraction to variable for decl init expression (#69477)

That would turn:
int x = f() + 1;
into:
auto placeholder = f() + 1;
int x = placeholder;
which makes little sense and is clearly not intended, as stated
explicitly by a comment in eligibleForExtraction(). It appears that the
declaration case was simply forgotten (the assignment case was already
implemented).

show more ...


Revision tags: llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5
# 5bd0f0d9 11-Nov-2023 Björn Pettersson <bjorn.a.pettersson@ericsson.com>

[clangd] Check for valid location in ExtractionContext::exprIsValidOutside (#71162)

If the code has a call to an implicitly declared function, an expression
could end up referencing declarations wi

[clangd] Check for valid location in ExtractionContext::exprIsValidOutside (#71162)

If the code has a call to an implicitly declared function, an expression
could end up referencing declarations without valid source locations. So
when doing the exprIsValidOutside check we could end up calling
SourceManager::isPointWithin using invalid source locations, and then a
debug build would crash with an assertion failure in
SourceManager::isBeforeInTranslationUnit.

This patch make sure that we deal with the invalid locations (by
considering a ReferencedDecl with invalid location as not being inside
the Scope).

show more ...


Revision tags: llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0
# 94b14355 11-Sep-2023 Julian Schmidt <44101708+5chmidti@users.noreply.github.com>

[clangd] allow extracting to variable for lambda expressions

Support for extracting lambda expressions, e.g. extracting a lambda from a callexpr (e.g. algorithms/ranges) to a named variable.

Review

[clangd] allow extracting to variable for lambda expressions

Support for extracting lambda expressions, e.g. extracting a lambda from a callexpr (e.g. algorithms/ranges) to a named variable.

Reviewed By: nridge

Differential Revision: https://reviews.llvm.org/D141757

show more ...


Revision tags: llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init
# 8b4a27f4 13-Jul-2023 Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>

[clangd][NFC] Remove dead code

refactor/tweaks/ExtractVariable.cpp:
Condition (!C++ && !ExprType) is never true because if ExprType was null
we would early-exit earlier.

tool/ClangdMain.cpp:
Static

[clangd][NFC] Remove dead code

refactor/tweaks/ExtractVariable.cpp:
Condition (!C++ && !ExprType) is never true because if ExprType was null
we would early-exit earlier.

tool/ClangdMain.cpp:
StaticIdx variable is not initialized before check, so checking it
doesn't make sense.

Found by static analyzer tool.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D155164

show more ...


Revision tags: llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3
# 8b1b0d1d 21-Aug-2022 Kazu Hirata <kazu@google.com>

Revert "Use std::is_same_v instead of std::is_same (NFC)"

This reverts commit c5da37e42d388947a40654b7011f2a820ec51601.

This patch seems to break builds with some versions of MSVC.


# c5da37e4 21-Aug-2022 Kazu Hirata <kazu@google.com>

Use std::is_same_v instead of std::is_same (NFC)


Revision tags: llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init
# 95a932fb 25-Jul-2022 Kazu Hirata <kazu@google.com>

Remove redundaunt override specifiers (NFC)

Identified with modernize-use-override.


Revision tags: llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3
# ae67984c 26-Apr-2022 David Goldman <davg@google.com>

[clangd] ExtractVariable support for C and Objective-C

- Use the expression's type for non-C++ as the variable type. This works
well, but might not preserve the typedefs due to type
canonicaliza

[clangd] ExtractVariable support for C and Objective-C

- Use the expression's type for non-C++ as the variable type. This works
well, but might not preserve the typedefs due to type
canonicalization.

- Improve support for Objective-C property references which are
represented using `ObjCPropertyRefExpr` and `BuiltinType::PseudoObject`.

Differential Revision: https://reviews.llvm.org/D124486

show more ...


Revision tags: llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2
# 4d006520 26-Feb-2022 Sam McCall <sam.mccall@gmail.com>

[clangd] Clean up unused includes. NFCI

Add includes where needed to fix build.
Haven't systematically added used headers, so there is still accidental
dependency on transitive includes.


Revision tags: llvmorg-14.0.0-rc1, llvmorg-15-init, llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1, llvmorg-13.0.0, llvmorg-13.0.0-rc4, llvmorg-13.0.0-rc3, llvmorg-13.0.0-rc2, llvmorg-13.0.0-rc1, llvmorg-14-init, llvmorg-12.0.1, llvmorg-12.0.1-rc4, llvmorg-12.0.1-rc3, llvmorg-12.0.1-rc2, llvmorg-12.0.1-rc1, llvmorg-12.0.0, llvmorg-12.0.0-rc5, llvmorg-12.0.0-rc4
# f71404c3 22-Mar-2021 Kadir Cetinkaya <kadircet@google.com>

[clangd] Replace usages of dummy with more descriptive words

Dummy is a word with inappropriate associations. This patch updates the
references to it in clangd code base with more precise ones.

The

[clangd] Replace usages of dummy with more descriptive words

Dummy is a word with inappropriate associations. This patch updates the
references to it in clangd code base with more precise ones.

The only user-visible change is the default variable name used when extracting a
variable. It will be named as `placeholder` from now on.

Differential Revision: https://reviews.llvm.org/D99065

show more ...


Revision tags: llvmorg-12.0.0-rc3, llvmorg-12.0.0-rc2, llvmorg-11.1.0, llvmorg-11.1.0-rc3, llvmorg-12.0.0-rc1, llvmorg-13-init, llvmorg-11.1.0-rc2, llvmorg-11.1.0-rc1
# 7af6a134 02-Jan-2021 Nathan James <n.james93@hotmail.co.uk>

[NFC] Switch up some dyn_cast calls


Revision tags: llvmorg-11.0.1, llvmorg-11.0.1-rc2
# ee02e20c 10-Dec-2020 Kirill Bobyrev <kbobyrev@google.com>

[clangd] NFC: Use SmallVector<T> where possible

SmallVector<T> with default size is now the recommended version (D92522).

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D92

[clangd] NFC: Use SmallVector<T> where possible

SmallVector<T> with default size is now the recommended version (D92522).

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D92788

show more ...


Revision tags: llvmorg-11.0.1-rc1
# 82a71822 13-Oct-2020 Kadir Cetinkaya <kadircet@google.com>

[clangd] Disable extract variable for RHS of assignments

Differential Revision: https://reviews.llvm.org/D89307


Revision tags: llvmorg-11.0.0, llvmorg-11.0.0-rc6, llvmorg-11.0.0-rc5
# 17747d2e 28-Sep-2020 Sam McCall <sam.mccall@gmail.com>

[clangd] Remove Tweak::Intent, use CodeAction kind directly. NFC

Intent was a nice idea but it ends up being a bit awkward/heavyweight
without adding much.

In particular, it makes it hard to implem

[clangd] Remove Tweak::Intent, use CodeAction kind directly. NFC

Intent was a nice idea but it ends up being a bit awkward/heavyweight
without adding much.

In particular, it makes it hard to implement `CodeActionParams.only` properly
(there's an inheritance hierarchy for kinds).

Differential Revision: https://reviews.llvm.org/D88427

show more ...


Revision tags: llvmorg-11.0.0-rc4, llvmorg-11.0.0-rc3, llvmorg-11.0.0-rc2, llvmorg-11.0.0-rc1, llvmorg-12-init, llvmorg-10.0.1, llvmorg-10.0.1-rc4, llvmorg-10.0.1-rc3, llvmorg-10.0.1-rc2
# f92011d8 19-Jun-2020 Eric Christopher <echristo@gmail.com>

As part of using inclusive language within the llvm project,
migrate away from the use of blacklist and whitelist.


Revision tags: llvmorg-10.0.1-rc1
# ad97ccf6 28-Apr-2020 Sam McCall <sam.mccall@gmail.com>

[clangd] Move non-clang base pieces into separate support/ lib. NFCI

Summary:
This enforces layering, reduces a sprawling clangd/ directory, and makes life
easier for embedders.

Reviewers: kbobyrev

[clangd] Move non-clang base pieces into separate support/ lib. NFCI

Summary:
This enforces layering, reduces a sprawling clangd/ directory, and makes life
easier for embedders.

Reviewers: kbobyrev

Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79014

show more ...


Revision tags: llvmorg-10.0.0, llvmorg-10.0.0-rc6, llvmorg-10.0.0-rc5, llvmorg-10.0.0-rc4, llvmorg-10.0.0-rc3
# 555d5ad8 24-Feb-2020 Kadir Cetinkaya <kadircet@google.com>

[clangd] Disable ExtractVariable for C

Summary:
Currently extract variable doesn't spell the type explicitly and just
uses an `auto` instead, which is not available in C.

Reviewers: usaxena95

Subs

[clangd] Disable ExtractVariable for C

Summary:
Currently extract variable doesn't spell the type explicitly and just
uses an `auto` instead, which is not available in C.

Reviewers: usaxena95

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75053

show more ...


Revision tags: llvmorg-10.0.0-rc2, llvmorg-10.0.0-rc1, llvmorg-11-init
# 7dc388bd 16-Dec-2019 Sam McCall <sam.mccall@gmail.com>

[clangd] Make Tweak::Selection movable. NFC


Revision tags: llvmorg-9.0.1, llvmorg-9.0.1-rc3, llvmorg-9.0.1-rc2, llvmorg-9.0.1-rc1, llvmorg-9.0.0, llvmorg-9.0.0-rc6, llvmorg-9.0.0-rc5, llvmorg-9.0.0-rc4
# 5b270932 09-Sep-2019 Kadir Cetinkaya <kadircet@google.com>

[clangd] Support multifile edits as output of Tweaks

Summary:
First patch for propogating multifile changes from tweak outputs to LSP
WorkspaceEdits.

Uses SM to convert tooling::Replacements to Tex

[clangd] Support multifile edits as output of Tweaks

Summary:
First patch for propogating multifile changes from tweak outputs to LSP
WorkspaceEdits.

Uses SM to convert tooling::Replacements to TextEdits.
Errors out if there are any inconsistencies between the draft version and the
version generated the edits.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66637

llvm-svn: 371392

show more ...


# 915f9785 04-Sep-2019 Sam McCall <sam.mccall@gmail.com>

[clangd] Rename ClangdUnit.h -> ParsedAST.h. NFC

This much better reflects what is (now) in this header.
Maybe a rename to ParsedTU would be an improvement, but that's a much
more invasive change an

[clangd] Rename ClangdUnit.h -> ParsedAST.h. NFC

This much better reflects what is (now) in this header.
Maybe a rename to ParsedTU would be an improvement, but that's a much
more invasive change and life is too short.

ClangdUnit is dead, long live ClangdUnitTests!

llvm-svn: 370862

show more ...


Revision tags: llvmorg-9.0.0-rc3
# 1c705d9c 14-Aug-2019 Jonas Devlieghere <jonas@devlieghere.com>

[clang-tools-extra] Migrate llvm::make_unique to std::make_unique

Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical r

[clang-tools-extra] Migrate llvm::make_unique to std::make_unique

Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

Differential revision: https://reviews.llvm.org/D66259

llvm-svn: 368944

show more ...


Revision tags: llvmorg-9.0.0-rc2
# 6a3c2c84 12-Aug-2019 Sam McCall <sam.mccall@gmail.com>

[clangd] Refactor computation of extracted expr in ExtractVariable tweak. NFC

Summary:
This takes this logic out of the Tweak class, and simplifies the signature of
the function where the main logic

[clangd] Refactor computation of extracted expr in ExtractVariable tweak. NFC

Summary:
This takes this logic out of the Tweak class, and simplifies the signature of
the function where the main logic is.

The goal is to make it easier to turn into a loop like:

for (current = N; current and current->parent are both expr; current = current->parent)
if (suitable(current))
return current;
return null;

Reviewers: SureYeaah

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65333

llvm-svn: 368590

show more ...


# 1aaef90c 09-Aug-2019 Sam McCall <sam.mccall@gmail.com>

[clangd] Disallow extraction of expression-statements.

Summary:
I split out the "extract parent instead of this" logic from the "this isn't
worth extracting" logic (now in eligibleForExtraction()),

[clangd] Disallow extraction of expression-statements.

Summary:
I split out the "extract parent instead of this" logic from the "this isn't
worth extracting" logic (now in eligibleForExtraction()), because I found it
hard to reason about.

While here, handle overloaded as well as builtin assignment operators.

Also this uncovered a bug in getCallExpr() which I fixed.

Reviewers: SureYeaah

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65337

llvm-svn: 368500

show more ...


Revision tags: llvmorg-9.0.0-rc1
# 91e8eac7 26-Jul-2019 Sam McCall <sam.mccall@gmail.com>

[clangd] Support extraction of binary "subexpressions" like a + [[b + c]].

Summary:
These aren't formally subexpressions in C++, in this case + is left-associative.
However informally +, *, etc are

[clangd] Support extraction of binary "subexpressions" like a + [[b + c]].

Summary:
These aren't formally subexpressions in C++, in this case + is left-associative.
However informally +, *, etc are usually (mathematically) associative and users
consider these subexpressions.

We detect these and in simple cases support extracting the partial expression.
As well as builtin associative operators, we assume that overloads of them
are associative and support those too.

Reviewers: SureYeaah

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D65139

llvm-svn: 367121

show more ...


12