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;
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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits