diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-03-28 19:09:40 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-03-28 19:09:40 +0000 |
commit | 04a94d14422a83bd6883c8a4a6837b04108b0742 (patch) | |
tree | 3fd0eb0812012bcb123ba5d9afb5e1e3e50f09d7 /clang/lib/Sema/SemaCast.cpp | |
parent | 6fffec6fd463453bb27ecc93339fd999cc9dca74 (diff) | |
download | bcm5719-llvm-04a94d14422a83bd6883c8a4a6837b04108b0742.tar.gz bcm5719-llvm-04a94d14422a83bd6883c8a4a6837b04108b0742.zip |
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!
llvm-svn: 178274
Diffstat (limited to 'clang/lib/Sema/SemaCast.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCast.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index 0e19adfd28c..e2a40847663 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/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 |