This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro
ClosedPublic

Authored by kwk on May 25 2020, 12:30 PM.

Details

Summary

This check finds macro expansions of DISALLOW_COPY_AND_ASSIGN(Type) and
replaces them with a deleted copy constructor and a deleted assignment operator.

Before the delete keyword was introduced in C++11 it was common practice to
declare a copy constructor and an assignment operator as a private members. This
effectively makes them unusable to the public API of a class.

With the advent of the delete keyword in C++11 we can abandon the
private access of the copy constructor and the assignment operator and
delete the methods entirely.

Migration example:

class Foo {
  private:
  -  DISALLOW_COPY_AND_ASSIGN(Foo);
  +  Foo(const Foo &) = delete;
  +  const Foo &operator=(const Foo &) = delete;
  };

Diff Detail

Event Timeline

kwk created this revision.May 25 2020, 12:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2020, 12:30 PM
Eugene.Zelenko added inline comments.
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
47

I think check should work in C++11 or newer.

clang-tools-extra/docs/clang-tidy/checks/list.rst
192

I think this and some other changes are unrelated.

clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
7

Just Finds.

32

modernize-use-equals-delete takes care about this.

34

Please move this to comments into code.

37

Please use single back-ticks for options.

45

Please use single back-ticks for option values.

49

Please use single back-ticks for option values.

Eugene.Zelenko added a project: Restricted Project.
kwk updated this revision to Diff 266100.May 25 2020, 9:59 PM
kwk marked 8 inline comments as done.
  • Make ReplaceDisallowCopyAndAssignMacroCheck only work in C++11 and above
  • Remove unrelated changes from clang-tools-extra/docs/clang-tidy/checks/list.rst
  • documentation simplification
  • Move comment into code
  • use single ticks
kwk added a comment.May 25 2020, 9:59 PM

@Eugene.Zelenko thank you for the review. I've fixed all places that you've mentioned. And have a question about one thing in particular. See inline.

Do you by any chance know why llvm-lit keeps complaining when I use [[@LINE-1]] in my tests as so many other tests do?

clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
32

Yes modernize-use-equals-delete does, this but it only notifies about it. Do you want me to notify with "deleted member function should be public" as well? Shouldn't I maybe just recommend to run the modernize-use-equals-delete after running my check?

kwk updated this revision to Diff 266101.May 25 2020, 10:02 PM
  • Move comment about FinalizeWithSemicolon into code
In D80531#2053969, @kwk wrote:

@Eugene.Zelenko thank you for the review. I've fixed all places that you've mentioned. And have a question about one thing in particular. See inline.

Do you by any chance know why llvm-lit keeps complaining when I use [[@LINE-1]] in my tests as so many other tests do?

It's complaining because your check lines are 2 lines after the diagnostic so you should use [[@LINE-2]]

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
29

clang-tidy fail on the variables, please rename them to use CamelCase format.

52

nit:

std::string Replacement = llvm::formatv(
    R"cpp({0}(const {0} &) = delete;
const {0} &operator=(const {0} &) = delete{1})cpp",
    classIdent->getNameStart(), FinalizeWithSemicolon ? ";" : "");
67

nit: Shouldn't this be a reference to a ReplaceDisallowCopyAndAssignMacroCheck? Doing so will allow you to use a getter in the Check for the MacroName option to save storing a copy of that as well inside the callback.

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
53–54

These can both be marked const

clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
42

This option should be removed and instead infer the value dynamically by checking the token directly after the macro use to see if its a semi-colon.

Something like this in the PPCallback should get you there

bool shouldAppendSemi(SourceRange MacroLoc) {
  llvm::Optional<Token> Next =
      Lexer::findNextToken(MacroLoc.getEnd(), SM, PP.getLangOpts());
  return !(Next && Next->is(tok::semi));
}
kwk planned changes to this revision.May 26 2020, 2:30 AM

Thank you @njames93 for the review. I'm implementing what you wrote.

kwk updated this revision to Diff 266148.May 26 2020, 3:09 AM
kwk marked 4 inline comments as done.
  • Wrap RUN lines
  • Use CamelCase variable name
  • Simplify access to options
  • Make check options const
  • Use two-line placeholder
  • Automate placement of semicolon at the end
kwk marked 2 inline comments as done.May 26 2020, 3:11 AM

@njames93 I've implemented everything you've mentioned. This simplified a lot.

clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
42

Thank you so much for this!

njames93 added inline comments.May 26 2020, 4:33 AM
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
33
if (Info->getName() != Check.MacroName)

Avoid constructing the string if you don't have to.

37

s/classNameTok/ClassNameTok

42

s/classIndent/ClassIndent

50

if you wanted to, you could format this quite easily to avoid the need of specifying a formatter in the checks

{2}const {0} &operator=(const {0} &) = delete{1})cpp",...
Lexer::getIndentationForLine(Range.getBegin(), SM))
clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
53

I'd prefer this to be private with a getter function

clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
37–39

These really aren't important to test for, so long as the diagnostic and fix it are checked, that's all you need to worry about. Like how you have it for TestClass2

Eugene.Zelenko added inline comments.May 26 2020, 6:22 AM
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
24

I think two code snippets would be more readable.

30

Please insert empty line below.

32

Please refer to modernize-use-equals-delete instead of second statement.

kwk updated this revision to Diff 266251.May 26 2020, 9:44 AM
kwk marked 11 inline comments as done.
  • Avoid constructing string
  • CamelCase for vars
  • more readable snippets for documentation
  • Added empty line after header in documentation
  • Remove sentence from doc
  • Remove unimportant tests
kwk added a comment.May 26 2020, 9:44 AM

Thanks @njames93 and @Eugene.Zelenko for your review. Most of it, I addressed but for some I have comments. See inline.

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
37

Ah, forgot about the CamelCase. Sorry.

50

Well, that does fix the indentation but for east/west-side alignment of & this doesn't solve the problem, does it?

clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
32

modernize-use-equals-delete doesn't help because it also does not remove the private access. Why refer to it?

clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp
37–39

Sure, I get that. I think I left them in because I wasn't that familiar with how %check_clang_tidy calls FileCheck two times. Thanks for catching this. Removed.

Eugene.Zelenko added inline comments.May 26 2020, 9:46 AM
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
32

It complaines about deleted stuff in private section.

kwk updated this revision to Diff 266257.May 26 2020, 9:57 AM
kwk marked 2 inline comments as done.
  • Refer to modernize-use-equals-delete for warning about deleted functions in private sections
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
32

Agreed, that makes sense. Sorry for not getting that right away. Afterall I did write about that above :)

Yes modernize-use-equals-delete does, this but it only notifies about it.

clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
42

See Release Notes on how to create links on documentation.

kwk marked an inline comment as done.May 26 2020, 10:32 AM
kwk added inline comments.
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
42
kwk updated this revision to Diff 266268.May 26 2020, 10:35 AM
  • Adjust link to documentation
kwk marked 2 inline comments as done.May 26 2020, 10:36 AM
kwk added inline comments.
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
42
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
42

clang-tidy/checks/ is not needed. All checks documentation is in same directory.

kwk updated this revision to Diff 266438.May 27 2020, 12:12 AM
kwk marked an inline comment as done.
  • fix link in doc
kwk added a comment.May 27 2020, 12:12 AM

@Eugene.Zelenko thank you for your patience with me. I fixed the link.

kwk added a comment.May 28 2020, 5:12 AM

@njames93 and @Eugene.Zelenko do you guys think this patch is ready to be approved and land?

Few changes and nits then LGTM

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
26

nit: You don't need to store a reference to the SourceManager as the Preprocessor holds a reference to it.

33

Use Info->getName() here, the Length is stored internally so its not expensive to get and makes the code look more readable.

46–47

This FIXME can probably be removed as expanding the macro isn't a good idea. The macro should expand to just defining the function rather than deleting it like we want.

51

ditto: use ClassIdent->getName() as well.

53

nit: Not a fan of the warning message, would prefer something like
prefer deleting copy constructor and assignment operator over using macro '%0' to explain what we are trying to do. Though if someone can think of something shorter that gets the same point I'm open to that.

60

Use \p before MacroLoc instead of \a as its a parameter.

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
53

Make this private with a get function and I'll be happy.

kwk updated this revision to Diff 267021.May 28 2020, 1:30 PM
kwk marked 9 inline comments as done.
  • Don't store SourceManager but get it from Preprocessor
  • Use getName instead of getNameStart
  • Remove FIXME
  • change warning message
  • doxygen: \a -> \p
  • Make MacroName private and add getter
kwk added a comment.May 28 2020, 1:31 PM

@njames93 I've addressed all your comments and hope the patch is good to land now :)

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
26

@njames93 thank you for letting me know. I passed it along because the ´ClangTidyCheck::registerPPCallbacks` that I override actually accepts both, SourceManager and the PP:

virtual void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
                                   Preprocessor *ModuleExpanderPP) {}

Other checks like MakeSmartPtrCheck, PassByValueCheck also do this similar to mine.

Anyway, I've changed the code to your liking.

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
53

Done. But since the variable is const having it public shouldn't allow a caller do anything but read the macro name. But I understand that convention is king ;)

kwk marked 4 inline comments as done.Jun 2 2020, 9:17 AM

Marked more comments as "done" after going through the code again.

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp
50

Well, yes but it will only work for the indentation not for anything else, like east/west alignment of & for example.

njames93 accepted this revision.Jun 2 2020, 12:36 PM

LGTM with 2 small nits, but I'd still give a few days see if anyone else wants to weight in.

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
53

Return by reference here.

clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
18

Put a colon on the end of this line.

27

Ditto here.

This revision is now accepted and ready to land.Jun 2 2020, 12:36 PM
kwk updated this revision to Diff 267960.Jun 2 2020, 1:02 PM
kwk marked 4 inline comments as done.
  • Return macro name by reference
  • Add colon to paragraph showing code
kwk added a comment.Jun 2 2020, 1:02 PM

Done.

clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h
53

Yeah, that makes sense. Stupid me.

kwk added a comment.Jun 2 2020, 2:05 PM

LGTM with 2 small nits, but I'd still give a few days see if anyone else wants to weight in.

I'm okay with this but I'd like to understand when it's time to wait for others? Only when a patch is approved or from the beginning of patch's life? I mean who looks at patches that are approved unless you filter for the amount of approvers? How many approvers must there be?

This revision was automatically updated to reflect the committed changes.
In D80531#2069637, @kwk wrote:

LGTM with 2 small nits, but I'd still give a few days see if anyone else wants to weight in.

I'm okay with this but I'd like to understand when it's time to wait for others? Only when a patch is approved or from the beginning of patch's life? I mean who looks at patches that are approved unless you filter for the amount of approvers? How many approvers must there be?

FWIW, I tend to - I have a queue of things to review, which doesn't have /much/ to do with whether they've already been reviewed. Sometimes, sometimes not - usually if I've decided it's worth looking at I'll still at least glance over it (enough to see if someone's asking for further consensus, etc).

While this is rather belated feedback, I've been seeing failures of this test consistently since it was committed, I think. Maybe there's something corrupted in my local client, but figured I'd mention/ask about it, in case it's useful. (+ @sammccall too):

FAIL: Clang Tools :: clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp (18811 of 74169)
******************** TEST 'Clang Tools :: clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp' FAILED ********************
Script:
--
: 'RUN: at line 1';   /usr/bin/python3.8 /usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py -format-style=LLVM -check-suffix=DEFAULT /usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp    modernize-replace-disallow-copy-and-assign-macro /usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp
: 'RUN: at line 4';   /usr/bin/python3.8 /usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py -format-style=LLVM -check-suffix=DIFFERENT-NAME /usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp   modernize-replace-disallow-copy-and-assign-macro /usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp   -config="{CheckOptions: [    {key: modernize-replace-disallow-copy-and-assign-macro.MacroName,     value: MY_MACRO_NAME}]}"
: 'RUN: at line 10';   /usr/bin/python3.8 /usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py -format-style=LLVM -check-suffix=FINALIZE /usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp   modernize-replace-disallow-copy-and-assign-macro /usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp   -config="{CheckOptions: [    {key: modernize-replace-disallow-copy-and-assign-macro.MacroName,     value: DISALLOW_COPY_AND_ASSIGN_FINALIZE}]}"
: 'RUN: at line 16';   clang-tidy /usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp -checks="-*,modernize-replace-disallow-copy-and-assign-macro"    -config="{CheckOptions: [     {key: modernize-replace-disallow-copy-and-assign-macro.MacroName,      value: DISALLOW_COPY_AND_ASSIGN_MORE_AGUMENTS}]}" | count 0
: 'RUN: at line 21';   clang-tidy /usr/local/google/home/blaikie/dev/llvm/src/clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp -checks="-*,modernize-replace-disallow-copy-and-assign-macro"    -config="{CheckOptions: [     {key: modernize-replace-disallow-copy-and-assign-macro.MacroName,      value: DISALLOW_COPY_AND_ASSIGN_NEEDS_PREEXPANSION}]}" | count 0
--
Exit Code: 1

Command Output (stdout):
--
Running ['clang-tidy', '/usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp.cpp', '-fix', '--checks=-*,modernize-replace-disallow-copy-and-assign-macro', '-format-style=LLVM', '--', '-std=c++11', '-nostdinc++']...
------------------------ clang-tidy output -----------------------
1 warning generated.
/usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp.cpp:33:3: warning: prefer deleting copy constructor and assignment operator over using macro 'DISALLOW_COPY_AND_ASSIGN' [modernize-replace-disallow-copy-and-assign-macro]
  DISALLOW_COPY_AND_ASSIGN(TestClass1);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp.cpp:33:3: note: FIX-IT applied suggested code changes
clang-tidy applied 1 of 1 suggested fixes.

------------------------------------------------------------------
------------------------------ Fixes -----------------------------
--- /usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp.cpp.orig     2020-09-09 16:32:20.416366536 -0700
+++ /usr/local/google/home/blaikie/dev/llvm/build/default/tools/clang/tools/extra/test/clang-tidy/checkers/Output/modernize-replace-disallow-copy-and-assign-macro.cpp.tmp.cpp  2020-09-09 16:32:20.476366112 -0700
@@ -30,7 +30,8 @@

 class TestClass1 {
 private:
-  DISALLOW_COPY_AND_ASSIGN(TestClass1);
+  TestClass1(const TestClass1 &) = delete;
+  const TestClass1 &operator=(const TestClass1 &) = delete;
 };
 //
 //

<lots more similar failures>

@dblaikie sorry for not getting to it for so long. I'm taking a look at the problem you've described now.

Hi @dblaikie . I did run ninja check-all and /bin/llvm-lit -av ../clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp on this very new revision (abd70fb3983f342bc1c90f9c70a7b59790ad5206) manually but I don't see this error coming up. Can you please try to test if you see the error on a fresh build?

Hi @dblaikie . I did run ninja check-all and /bin/llvm-lit -av ../clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp on this very new revision (abd70fb3983f342bc1c90f9c70a7b59790ad5206) manually but I don't see this error coming up. Can you please try to test if you see the error on a fresh build?

Hey - thanks for gettiing back to me.

I've tried a /bunch/ of variants of my usual build lately, and this seems to be what I've hit a fairly reliable repro/no-repro:

$ CC=clang CXX=clang++ cmake -G Ninja -DLLVM_ENABLE_WERROR=true  -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra' path/to/llvm/src
$ ninja check-all

If I turn of LLVM_ENABLE_WERROR (either by deleting the whole build tree and starting again, omitting the -DLLVM_ENABLE_WERROR=true part, or by manually editing the existing CMakeCache.txt file) the failure on this test case goes away. If I turn on Werror again, the failure turns up again.

It's possible (I guess likely, or this would be failing on a bunch of buildbots, I imagine) that this has somtehing to do with my specific local build of clang that I'm using to build - but even then, it seems problematic that the LLVM_ENABLE_WERROR is affecting this test execution in any way.

Also, just in general - I wonder if this test and test infrastructure (check_clang_tidy) could be made more legible in some way (at least the failure message/reporting) - perhaps it's just my lack of familiarity and anyone working on the tool would be able to read what was going wrong here, but I can't make heads or tails of the failure, couldn't figure out how to extract a file showing the good/bad behavior so I Could compare it, etc.

@dblaikie sorry for the late feedback. The LLVM_ENABLE_WERROR:BOOL will "Stop and fail the build, if a compiler warning is triggered. Defaults to OFF." I wonder if any other test fails from clang tidy because. My test explicitly checks that a warning is issued (e.g. // CHECK-MESSAGES-DEFAULT: :[[@LINE-2]]:3: warning: prefer deleting) and when the LLVM_ENABLE_WERROR propagates to this piece, it will indeed fail the build. But I wonder why this doesn't happen to the other clang-tidy checks. @njames93 @Eugene.Zelenko any ideas?

@dblaikie sorry for the late feedback. The LLVM_ENABLE_WERROR:BOOL will "Stop and fail the build, if a compiler warning is triggered. Defaults to OFF." I wonder if any other test fails from clang tidy because. My test explicitly checks that a warning is issued (e.g. // CHECK-MESSAGES-DEFAULT: :[[@LINE-2]]:3: warning: prefer deleting) and when the LLVM_ENABLE_WERROR propagates to this piece, it will indeed fail the build. But I wonder why this doesn't happen to the other clang-tidy checks. @njames93 @Eugene.Zelenko any ideas?

The reason WERROR causes this to fail is the tests are generating a warning Wextra-semi for the ; that appear after each macro usage in the class. clang-tidy would ignore this diagnostic as its set-up to ignore all warnings from clang.
However when Werror is set, that warning is promoted to an error, and clang-tidy will emit all errors, regardless of their origin.
This causes there to be extra diagnostics in the tests, though only in the tests where you invoke clang-tidy directly. Not sure why that obeys LLVM_ENABLE_WERROR likewise not sure why check_clang_tidy doesn't obey it.
Anyway the simple fix is to just remove the ; after the macro usages in the class

@njames93 I could do that but the original Macros had were defined without a semicolon at the end and one had to add it manually. See this revision in which I replaced some occurrences of DISALLOW_COPY_AND_ASSIGN: eaebcbc67926a18befaa297f1778edde63baec9b. What do you suggest? Keep the semicolon to more closely match the original macros or remove it to make the test happy?

@njames93 I could do that but the original Macros had were defined without a semicolon at the end and one had to add it manually. See this revision in which I replaced some occurrences of DISALLOW_COPY_AND_ASSIGN: eaebcbc67926a18befaa297f1778edde63baec9b. What do you suggest? Keep the semicolon to more closely match the original macros or remove it to make the test happy?

Or add -Wno-extra-semi in the tests where you invoke clang-tidy directly, That'll silence the warnings and leave the rest of the test as-is.

@dblaikie sorry for the late feedback. The LLVM_ENABLE_WERROR:BOOL will "Stop and fail the build, if a compiler warning is triggered. Defaults to OFF." I wonder if any other test fails from clang tidy because. My test explicitly checks that a warning is issued (e.g. // CHECK-MESSAGES-DEFAULT: :[[@LINE-2]]:3: warning: prefer deleting) and when the LLVM_ENABLE_WERROR propagates to this piece, it will indeed fail the build. But I wonder why this doesn't happen to the other clang-tidy checks. @njames93 @Eugene.Zelenko any ideas?

The reason WERROR causes this to fail is the tests are generating a warning Wextra-semi for the ; that appear after each macro usage in the class. clang-tidy would ignore this diagnostic as its set-up to ignore all warnings from clang.
However when Werror is set, that warning is promoted to an error, and clang-tidy will emit all errors, regardless of their origin.
This causes there to be extra diagnostics in the tests, though only in the tests where you invoke clang-tidy directly. Not sure why that obeys LLVM_ENABLE_WERROR likewise not sure why check_clang_tidy doesn't obey it.
Anyway the simple fix is to just remove the ; after the macro usages in the class

Oh, neat - thanks for identifying that! Probably be good for someone to figure out how to make the tests independent of the LLVM build flags like LLVM_ENABLE_WERROR in general.

@njames93 I could do that but the original Macros had were defined without a semicolon at the end and one had to add it manually. See this revision in which I replaced some occurrences of DISALLOW_COPY_AND_ASSIGN: eaebcbc67926a18befaa297f1778edde63baec9b. What do you suggest? Keep the semicolon to more closely match the original macros or remove it to make the test happy?

Alternatively, the DISALLOW_COPY_AND_ASSIGN macros could have a trivial implementation that makes the trailing semicolon not "extra", like the real macro? (I guess it could be any function declaration "void stub()" for instance)