Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: tools/clang/rewrite_to_chrome_style/tests/macros-expected.cc

Issue 1645263002: rewrite_to_chrome_style: tweak macro ignoring logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Betterer commetns Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Identifiers in macros should never be rewritten, as the risk of things
6 // breaking is extremely high.
7
8 namespace blink {
9
10 #define DEFINE_TYPE_CASTS(thisType, argumentType, argumentName, predicate) \
11 inline thisType* to##thisType(argumentType* argumentName) { \
12 if (!predicate) \
13 asm("int 3"); \
14 return static_cast<thisType*>(argumentName); \
15 }
16
17 #define LIKELY(x) x
18
19 struct Base {};
20 struct Derived : public Base {};
21
22 DEFINE_TYPE_CASTS(Derived, Base, object, true);
23
24 void F() {
25 Base* base_ptr = new Derived;
26 // 'toDerived' should not be renamed, since the definition lives inside
27 // a macro invocation.
28 Derived* derived_ptr = toDerived(base_ptr);
29 // 'derivedPtr' should be renamed: it's a reference to a declaration defined
30 // outside a macro invocation.
31 if (LIKELY(derived_ptr)) {
32 delete derived_ptr;
33 }
34 }
35
36 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698