[PATCH] [clang-tidy] Handle c-style casts from/to enums.
Manuel Klimek
klimek at google.com
Wed Oct 1 05:58:41 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());
----------------
alexfh wrote:
> 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.
The char* -> char * we don't really care about. The enum seems important, thus putting that into a comment would be nice.
http://reviews.llvm.org/D5558
More information about the cfe-commits
mailing list