[lldb-instr] Don't print REGISTER macro when RECORD is already present

Currently we'd always print the LLDB_REGISTER macro, even if the
LLDB_RECORD macro was already present. This patches changes that to make
it easier to incrementally update the macros.

Note that it's still possible for the RECORD and REGISTER macros to get
out of sync.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@354400 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lit/tools/lldb-instr/TestInstrumentationRegister.test b/lit/tools/lldb-instr/TestInstrumentationRegister.test
index baf737b..4767221 100644
--- a/lit/tools/lldb-instr/TestInstrumentationRegister.test
+++ b/lit/tools/lldb-instr/TestInstrumentationRegister.test
@@ -11,3 +11,4 @@
 # CHECK: LLDB_REGISTER_STATIC_METHOD(void, Foo, E, ());
 # CHECK: LLDB_REGISTER_STATIC_METHOD(int, Foo, F, (int));
 # CHECK-NOT: LLDB_REGISTER_STATIC_METHOD(void, Foo, G
+# CHECK-NOT: LLDB_REGISTER_METHOD_CONST(void, Foo, I, ());
diff --git a/tools/lldb-instr/Instrument.cpp b/tools/lldb-instr/Instrument.cpp
index 06a34ce..3a5df4b 100644
--- a/tools/lldb-instr/Instrument.cpp
+++ b/tools/lldb-instr/Instrument.cpp
@@ -158,6 +158,15 @@
     if (ShouldSkip(Decl))
       return false;
 
+    // Skip CXXMethodDecls that already starts with a macro. This should make
+    // it easier to rerun the tool to find missing macros.
+    Stmt *Body = Decl->getBody();
+    for (auto &C : Body->children()) {
+      if (C->getBeginLoc().isMacroID())
+        return false;
+      break;
+    }
+
     // Print 'bool' instead of '_Bool'.
     PrintingPolicy Policy(Context.getLangOpts());
     Policy.Bool = true;
@@ -209,14 +218,6 @@
           Decl->isStatic(), Decl->isConst());
     }
 
-    // If this CXXMethodDecl already starts with a macro we're done.
-    Stmt *Body = Decl->getBody();
-    for (auto &C : Body->children()) {
-      if (C->getBeginLoc().isMacroID())
-        return false;
-      break;
-    }
-
     // Insert the macro at the beginning of the function. We don't attempt to
     // fix the formatting and instead rely on clang-format to fix it after the
     // tool has run. This is also the reason that the macros end with two