ART: Fix SCOPED_TRACE macro
Correctly evaluate __LINE__ through a preprocessor indirection.
Avoid duplicate-variable errors for multiple SCOPED_TRACE uses.
Test: mmma art
Change-Id: Ib1960b5e2c6ddcbaf766b7d1cb2927ccf5925593
diff --git a/libartbase/base/systrace.h b/libartbase/base/systrace.h
index 2ff33e8..d995dce 100644
--- a/libartbase/base/systrace.h
+++ b/libartbase/base/systrace.h
@@ -24,6 +24,7 @@
#include <string>
#include "android-base/stringprintf.h"
+#include "macros.h"
namespace art {
@@ -75,7 +76,7 @@
};
#define SCOPED_TRACE \
- ::art::ScopedTraceNoStart trace ## __LINE__; \
+ ::art::ScopedTraceNoStart APPEND_TOKENS_AFTER_EVAL(trace, __LINE__) ; \
(ATRACE_ENABLED()) && ::art::ScopedTraceNoStart::ScopedTraceMessageHelper().stream()
} // namespace art