summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/modernize-use-override.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2017-03-01 10:16:36 +0000
committerAlexander Kornienko <alexfh@google.com>2017-03-01 10:16:36 +0000
commiteedf7ec07f40ab17fb8d77ed15ae27a65473856a (patch)
tree910fb1cd4bc7ea18188365c8743853fc913ef06b /clang-tools-extra/test/clang-tidy/modernize-use-override.cpp
parentc84ca256d30272cf958d2f94357b58d872b983bf (diff)
downloadbcm5719-llvm-eedf7ec07f40ab17fb8d77ed15ae27a65473856a.tar.gz
bcm5719-llvm-eedf7ec07f40ab17fb8d77ed15ae27a65473856a.zip
[clang-tidy] Fix handling of methods with try-statement as a body in modernize-use-override
Summary: Fix generated by modernize-use-override caused syntax error when method used try-statement as a body. `override` keyword was inserted after last declaration token which happened to be a `try` keyword. This fixes PR27119. Reviewers: ehsan, djasper, alexfh Reviewed By: alexfh Subscribers: JDevlieghere, cfe-commits Tags: #clang-tools-extra Patch by Paweł Żukowski! Differential Revision: https://reviews.llvm.org/D30002 llvm-svn: 296598
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/modernize-use-override.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/modernize-use-override.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/modernize-use-override.cpp b/clang-tools-extra/test/clang-tidy/modernize-use-override.cpp
index 1e39e37d210..d406cbe741d 100644
--- a/clang-tools-extra/test/clang-tidy/modernize-use-override.cpp
+++ b/clang-tools-extra/test/clang-tidy/modernize-use-override.cpp
@@ -288,3 +288,17 @@ struct MembersOfSpecializations : public Base2 {
};
template <> void MembersOfSpecializations<3>::a() {}
void ff() { MembersOfSpecializations<3>().a(); };
+
+// In case try statement is used as a method body,
+// make sure that override fix is placed before try keyword.
+struct TryStmtAsBody : public Base {
+ void a() try
+ // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
+ // CHECK-FIXES: {{^}} void a() override try
+ { b(); } catch(...) { c(); }
+
+ virtual void d() try
+ // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
+ // CHECK-FIXES: {{^}} void d() override try
+ { e(); } catch(...) { f(); }
+};
OpenPOWER on IntegriCloud