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

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 19 15:13:29 PST 2019


Author: jdevlieghere
Date: Tue Feb 19 15:13:29 2019
New Revision: 354400

URL: http://llvm.org/viewvc/llvm-project?rev=354400&view=rev
Log:
[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.

Modified:
    lldb/trunk/lit/tools/lldb-instr/TestInstrumentationRegister.test
    lldb/trunk/tools/lldb-instr/Instrument.cpp

Modified: lldb/trunk/lit/tools/lldb-instr/TestInstrumentationRegister.test
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/tools/lldb-instr/TestInstrumentationRegister.test?rev=354400&r1=354399&r2=354400&view=diff
==============================================================================
--- lldb/trunk/lit/tools/lldb-instr/TestInstrumentationRegister.test (original)
+++ lldb/trunk/lit/tools/lldb-instr/TestInstrumentationRegister.test Tue Feb 19 15:13:29 2019
@@ -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, ());

Modified: lldb/trunk/tools/lldb-instr/Instrument.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-instr/Instrument.cpp?rev=354400&r1=354399&r2=354400&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-instr/Instrument.cpp (original)
+++ lldb/trunk/tools/lldb-instr/Instrument.cpp Tue Feb 19 15:13:29 2019
@@ -158,6 +158,15 @@ public:
     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 @@ public:
           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




More information about the lldb-commits mailing list