[PATCH] D144074: [clangd] Hide inlay hints when using a macro as a calling argument that with a param comment
Younan Zhang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 26 03:06:58 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb2d04d41e47: [clangd] Hide inlay hints when using a macro as a calling argument that with a… (authored by zyounan).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144074/new/
https://reviews.llvm.org/D144074
Files:
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp
Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1050,9 +1050,15 @@
void bar() {
foo(/*param*/42);
foo( /* param = */ 42);
+#define X 42
+#define Y X
+#define Z(...) Y
+ foo(/*param=*/Z(a));
+ foo($macro[[Z(a)]]);
foo(/* the answer */$param[[42]]);
}
)cpp",
+ ExpectedHint{"param: ", "macro"},
ExpectedHint{"param: ", "param"});
}
Index: clang-tools-extra/clangd/InlayHints.cpp
===================================================================
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -516,8 +516,8 @@
// at the end.
bool isPrecededByParamNameComment(const Expr *E, StringRef ParamName) {
auto &SM = AST.getSourceManager();
- auto ExprStartLoc = SM.getTopMacroCallerLoc(E->getBeginLoc());
- auto Decomposed = SM.getDecomposedLoc(ExprStartLoc);
+ auto FileLoc = SM.getFileLoc(E->getBeginLoc());
+ auto Decomposed = SM.getDecomposedLoc(FileLoc);
if (Decomposed.first != MainFileID)
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144074.500536.patch
Type: text/x-patch
Size: 1276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230226/50cfa012/attachment-0001.bin>
More information about the cfe-commits
mailing list