Kaydet (Commit) 07ca074e authored tarafından Noel Grandin's avatar Noel Grandin

cstylecast plugin: ignore templates, improve message

Change-Id: I8347010d5607dc2cbb113b33f1cb2cc78ec106d2
üst 6129aea3
...@@ -58,6 +58,10 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) { ...@@ -58,6 +58,10 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) {
if( expr->getCastKind() == CK_BitCast ) { if( expr->getCastKind() == CK_BitCast ) {
return true; return true;
} }
// ignore stuff from inside templates for now
if( expr->getCastKind() == CK_Dependent ) {
return true;
}
SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc( SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(
expr->getLocStart()); expr->getLocStart());
StringRef filename = compiler.getSourceManager().getFilename(spellingLocation); StringRef filename = compiler.getSourceManager().getFilename(spellingLocation);
...@@ -66,16 +70,18 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) { ...@@ -66,16 +70,18 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) {
return true; return true;
} }
if ( compat::isInMainFile(compiler.getSourceManager(), spellingLocation) if ( compat::isInMainFile(compiler.getSourceManager(), spellingLocation)
? (filename.startswith(SRCDIR "/sal")) // sal has tons of weird stuff going on that I don't understand enough to fix ? (filename.startswith(SRCDIR "/sal") // sal has tons of weird stuff going on that I don't understand enough to fix
|| filename.startswith(SRCDIR "/bridges")) // I'm not messing with this code - far too dangerous
: (filename.startswith(SRCDIR "/include/tools/solar.h")) ) { : (filename.startswith(SRCDIR "/include/tools/solar.h")) ) {
return true; return true;
} }
report( report(
DiagnosticsEngine::Warning, DiagnosticsEngine::Warning,
"c-style cast, type=%0, from=%1, recommendedFix=%2", "c-style cast, type=%0, from=%1, to=%2, recommendedFix=%3",
expr->getSourceRange().getBegin()) expr->getSourceRange().getBegin())
<< expr->getCastKind() << expr->getCastKind()
<< expr->getSubExprAsWritten()->getType() << expr->getSubExprAsWritten()->getType()
<< expr->getType()
<< recommendedFix(expr->getCastKind()) << recommendedFix(expr->getCastKind())
<< expr->getSourceRange(); << expr->getSourceRange();
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment