salman-javed-nz updated this revision to Diff 431213. salman-javed-nz edited the summary of this revision. salman-javed-nz added a comment.
Renamed test case to better explain what it is that it's testing. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126138/new/ https://reviews.llvm.org/D126138 Files: clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp Index: clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp +++ clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp @@ -96,6 +96,16 @@ #define MACRO_NOLINT class G { G(int i); }; // NOLINT MACRO_NOLINT +// Check that we can suppress diagnostics about macro arguments (as opposed to +// diagnostics about the macro contents itself). +#define MACRO_SUPPRESS_DIAG_FOR_ARG(X) \ + class X { \ + X(int i); /* NOLINT */ \ + }; + +MACRO_SUPPRESS_DIAG_FOR_ARG(G1) +MACRO_SUPPRESS_DIAG_FOR_ARG(G2) + #define DOUBLE_MACRO MACRO(H) // NOLINT DOUBLE_MACRO @@ -116,4 +126,4 @@ int array3[10]; // NOLINT(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays) int array4[10]; // NOLINT(*-avoid-c-arrays) -// CHECK-MESSAGES: Suppressed 34 warnings (34 NOLINT) +// CHECK-MESSAGES: Suppressed 36 warnings (36 NOLINT) Index: clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp =================================================================== --- clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp +++ clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp @@ -266,7 +266,7 @@ return true; if (!DiagLoc.isMacroID()) return false; - DiagLoc = SrcMgr.getImmediateMacroCallerLoc(DiagLoc); + DiagLoc = SrcMgr.getImmediateExpansionRange(DiagLoc).getBegin(); } return false; }
Index: clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp +++ clang-tools-extra/test/clang-tidy/infrastructure/nolint.cpp @@ -96,6 +96,16 @@ #define MACRO_NOLINT class G { G(int i); }; // NOLINT MACRO_NOLINT +// Check that we can suppress diagnostics about macro arguments (as opposed to +// diagnostics about the macro contents itself). +#define MACRO_SUPPRESS_DIAG_FOR_ARG(X) \ + class X { \ + X(int i); /* NOLINT */ \ + }; + +MACRO_SUPPRESS_DIAG_FOR_ARG(G1) +MACRO_SUPPRESS_DIAG_FOR_ARG(G2) + #define DOUBLE_MACRO MACRO(H) // NOLINT DOUBLE_MACRO @@ -116,4 +126,4 @@ int array3[10]; // NOLINT(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays) int array4[10]; // NOLINT(*-avoid-c-arrays) -// CHECK-MESSAGES: Suppressed 34 warnings (34 NOLINT) +// CHECK-MESSAGES: Suppressed 36 warnings (36 NOLINT) Index: clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp =================================================================== --- clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp +++ clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp @@ -266,7 +266,7 @@ return true; if (!DiagLoc.isMacroID()) return false; - DiagLoc = SrcMgr.getImmediateMacroCallerLoc(DiagLoc); + DiagLoc = SrcMgr.getImmediateExpansionRange(DiagLoc).getBegin(); } return false; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits