| Index: tools/clang/rewrite_to_chrome_style/tests/macros-original.cc
|
| diff --git a/tools/clang/rewrite_to_chrome_style/tests/macros-original.cc b/tools/clang/rewrite_to_chrome_style/tests/macros-original.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6ff5613bb4ddf5355e07cbe3400ed7f1553c54d8
|
| --- /dev/null
|
| +++ b/tools/clang/rewrite_to_chrome_style/tests/macros-original.cc
|
| @@ -0,0 +1,36 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// Identifiers in macros should never be rewritten, as the risk of things
|
| +// breaking is extremely high.
|
| +
|
| +namespace blink {
|
| +
|
| +#define DEFINE_TYPE_CASTS(thisType, argumentType, argumentName, predicate) \
|
| + inline thisType* to##thisType(argumentType* argumentName) { \
|
| + if (!predicate) \
|
| + asm("int 3"); \
|
| + return static_cast<thisType*>(argumentName); \
|
| + }
|
| +
|
| +#define LIKELY(x) x
|
| +
|
| +struct Base {};
|
| +struct Derived : public Base {};
|
| +
|
| +DEFINE_TYPE_CASTS(Derived, Base, object, true);
|
| +
|
| +void F() {
|
| + Base* basePtr = new Derived;
|
| + // 'toDerived' should not be renamed, since the definition lives inside
|
| + // a macro invocation.
|
| + Derived* derivedPtr = toDerived(basePtr);
|
| + // 'derivedPtr' should be renamed: it's a reference to a declaration defined
|
| + // outside a macro invocation.
|
| + if (LIKELY(derivedPtr)) {
|
| + delete derivedPtr;
|
| + }
|
| +}
|
| +
|
| +} // namespace blink
|
|
|