[PATCH] [clang-tidy] Handle c-style casts from/to enums.
Alexander Kornienko
alexfh at google.com
Wed Oct 1 05:57:26 PDT 2014
================
Comment at: clang-tidy/google/AvoidCStyleCastsCheck.cpp:85-89
@@ -84,3 +84,7 @@
- std::string DestTypeString = CastExpr->getTypeAsWritten().getAsString();
+ StringRef DestTypeString = Lexer::getSourceText(
+ CharSourceRange::getTokenRange(
+ CastExpr->getLParenLoc().getLocWithOffset(1),
+ CastExpr->getRParenLoc().getLocWithOffset(-1)),
+ *Result.SourceManager, Result.Context->getLangOpts());
----------------
klimek wrote:
> Why does getTypeAsWritten not work any more? Perhaps add a comment explaining that...
getTypeAsWritten().getAsString() normalizes spelling of types in certain ways, e.g. "char*" -> "char *", "SomeEnum" -> "enum SomeEnum", which we don't want to do.
http://reviews.llvm.org/D5558
More information about the cfe-commits
mailing list