diff --git a/clang-tools-extra/clangd/InlayHints.cpp b/clang-tools-extra/clangd/InlayHints.cpp --- a/clang-tools-extra/clangd/InlayHints.cpp +++ b/clang-tools-extra/clangd/InlayHints.cpp @@ -517,7 +517,7 @@ bool isPrecededByParamNameComment(const Expr *E, StringRef ParamName) { auto &SM = AST.getSourceManager(); auto ExprStartLoc = SM.getTopMacroCallerLoc(E->getBeginLoc()); - auto Decomposed = SM.getDecomposedLoc(ExprStartLoc); + auto Decomposed = SM.getDecomposedExpansionLoc(ExprStartLoc); if (Decomposed.first != MainFileID) return false; diff --git a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp --- a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp +++ b/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"}); }