aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCast.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-03-28 19:09:40 +0000
committerJordan Rose <jordan_rose@apple.com>2013-03-28 19:09:40 +0000
commit5fd1fac0104e22533bc0284fdd0f42f843c975f5 (patch)
tree2e61a74e5238a459d13bd6b84557098f4641fc9f /lib/Sema/SemaCast.cpp
parent25ffbef84450f0c666957a2d00cdf928c61b44d7 (diff)
Provide a fixit to static_cast for reinterpret_casts within a class hierarchy.
The suggestion was already in the text of the note; this just adds the actual fixit and the appropriate test cases. Patch by Alexander Zinenko! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178274 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCast.cpp')
-rw-r--r--lib/Sema/SemaCast.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp
index 0e19adfd28..e2a4084766 100644
--- a/lib/Sema/SemaCast.cpp
+++ b/lib/Sema/SemaCast.cpp
@@ -766,12 +766,13 @@ static void DiagnoseReinterpretUpDownCast(Sema &Self, const Expr *SrcExpr,
QualType DerivedType =
ReinterpretKind == ReinterpretUpcast? SrcType : DestType;
- Self.Diag(OpRange.getBegin(), diag::warn_reinterpret_different_from_static)
- << DerivedType << BaseType << !VirtualBase << ReinterpretKind;
- Self.Diag(OpRange.getBegin(), diag::note_reinterpret_updowncast_use_static)
- << ReinterpretKind;
-
- // TODO: emit fixits. This requires passing operator SourceRange from Parser.
+ SourceLocation BeginLoc = OpRange.getBegin();
+ Self.Diag(BeginLoc, diag::warn_reinterpret_different_from_static)
+ << DerivedType << BaseType << !VirtualBase << ReinterpretKind
+ << OpRange;
+ Self.Diag(BeginLoc, diag::note_reinterpret_updowncast_use_static)
+ << ReinterpretKind
+ << FixItHint::CreateReplacement(BeginLoc, "static_cast");
}
/// CheckReinterpretCast - Check that a reinterpret_cast\<DestType\>(SrcExpr) is