diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-11-14 18:59:01 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-11-14 18:59:01 +0000 |
commit | cc55754a7917b6ec3058079c8eae965eb1641a04 (patch) | |
tree | cb6684efa5c6bc5371f055186f2b63fe7d6b6902 /clang/lib/Tooling/Refactoring/ASTSelection.cpp | |
parent | d56725a042871238ed0a4ad4576497b55db2c960 (diff) | |
download | bcm5719-llvm-cc55754a7917b6ec3058079c8eae965eb1641a04.tar.gz bcm5719-llvm-cc55754a7917b6ec3058079c8eae965eb1641a04.zip |
[refactor][extract] avoid extracting expressions from types in functions
llvm-svn: 318169
Diffstat (limited to 'clang/lib/Tooling/Refactoring/ASTSelection.cpp')
-rw-r--r-- | clang/lib/Tooling/Refactoring/ASTSelection.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Tooling/Refactoring/ASTSelection.cpp b/clang/lib/Tooling/Refactoring/ASTSelection.cpp index ab2be155121..4f1168becf8 100644 --- a/clang/lib/Tooling/Refactoring/ASTSelection.cpp +++ b/clang/lib/Tooling/Refactoring/ASTSelection.cpp @@ -383,10 +383,12 @@ bool CodeRangeASTSelection::isInFunctionLikeBodyOfCode() const { if (const auto *D = Node.get<Decl>()) { if (isFunctionLikeDeclaration(D)) return IsPrevCompound; - // FIXME (Alex L): We should return false on top-level decls in functions - // e.g. we don't want to extract: + // Stop the search at any type declaration to avoid returning true for + // expressions in type declarations in functions, like: // function foo() { struct X { // int m = /*selection:*/ 1 + 2 /*selection end*/; }; }; + if (isa<TypeDecl>(D)) + return false; } IsPrevCompound = Node.get<CompoundStmt>() != nullptr; } |