This revision was automatically updated to reflect the committed changes. sammccall marked an inline comment as done. Closed by commit rGfc7a9f36a923: [clangd] Ignore cvr-qualifiers in selection. (authored by sammccall).
Changed prior to commit: https://reviews.llvm.org/D117185?vs=399551&id=399651#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D117185/new/ https://reviews.llvm.org/D117185 Files: clang-tools-extra/clangd/Selection.cpp clang-tools-extra/clangd/unittests/SelectionTests.cpp Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SelectionTests.cpp +++ clang-tools-extra/clangd/unittests/SelectionTests.cpp @@ -331,9 +331,17 @@ {"int (*getFunc([[do^uble]]))(int);", "BuiltinTypeLoc"}, + // Member pointers and pack expansion use declarator syntax, but are + // restricted so they don't need special casing. + {"class X{}; [[int X::^*]]y[10];", "MemberPointerTypeLoc"}, + {"template<typename ...T> void foo([[T*^...]]x);", + "PackExpansionTypeLoc"}, + {"template<typename ...T> void foo([[^T]]*...x);", + "TemplateTypeParmTypeLoc"}, + // FIXME: the AST has no location info for qualifiers. {"const [[a^uto]] x = 42;", "AutoTypeLoc"}, - {"[[co^nst auto x = 42]];", "VarDecl"}, + {"co^nst auto x = 42;", nullptr}, {"^", nullptr}, {"void foo() { [[foo^^]] (); }", "DeclRefExpr"}, Index: clang-tools-extra/clangd/Selection.cpp =================================================================== --- clang-tools-extra/clangd/Selection.cpp +++ clang-tools-extra/clangd/Selection.cpp @@ -188,7 +188,19 @@ // As well as comments, don't count semicolons as real tokens. // They're not properly claimed as expr-statement is missing from the AST. bool shouldIgnore(const syntax::Token &Tok) { - return Tok.kind() == tok::comment || Tok.kind() == tok::semi; + switch (Tok.kind()) { + // Even "attached" comments are not considered part of a node's range. + case tok::comment: + // The AST doesn't directly store locations for terminating semicolons. + case tok::semi: + // We don't have locations for cvr-qualifiers: see QualifiedTypeLoc. + case tok::kw_const: + case tok::kw_volatile: + case tok::kw_restrict: + return true; + default: + return false; + } } // Determine whether 'Target' is the first expansion of the macro
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SelectionTests.cpp +++ clang-tools-extra/clangd/unittests/SelectionTests.cpp @@ -331,9 +331,17 @@ {"int (*getFunc([[do^uble]]))(int);", "BuiltinTypeLoc"}, + // Member pointers and pack expansion use declarator syntax, but are + // restricted so they don't need special casing. + {"class X{}; [[int X::^*]]y[10];", "MemberPointerTypeLoc"}, + {"template<typename ...T> void foo([[T*^...]]x);", + "PackExpansionTypeLoc"}, + {"template<typename ...T> void foo([[^T]]*...x);", + "TemplateTypeParmTypeLoc"}, + // FIXME: the AST has no location info for qualifiers. {"const [[a^uto]] x = 42;", "AutoTypeLoc"}, - {"[[co^nst auto x = 42]];", "VarDecl"}, + {"co^nst auto x = 42;", nullptr}, {"^", nullptr}, {"void foo() { [[foo^^]] (); }", "DeclRefExpr"}, Index: clang-tools-extra/clangd/Selection.cpp =================================================================== --- clang-tools-extra/clangd/Selection.cpp +++ clang-tools-extra/clangd/Selection.cpp @@ -188,7 +188,19 @@ // As well as comments, don't count semicolons as real tokens. // They're not properly claimed as expr-statement is missing from the AST. bool shouldIgnore(const syntax::Token &Tok) { - return Tok.kind() == tok::comment || Tok.kind() == tok::semi; + switch (Tok.kind()) { + // Even "attached" comments are not considered part of a node's range. + case tok::comment: + // The AST doesn't directly store locations for terminating semicolons. + case tok::semi: + // We don't have locations for cvr-qualifiers: see QualifiedTypeLoc. + case tok::kw_const: + case tok::kw_volatile: + case tok::kw_restrict: + return true; + default: + return false; + } } // Determine whether 'Target' is the first expansion of the macro
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits