summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-10-09 16:48:48 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-10-09 17:25:28 +0200
commit4d3c6a04995a19209c3a66b92fddbb50c92418b7 (patch)
treec620dbe630c79b350e22a4ad54ca1561f55022ba /compilerplugins
parent7cd19a8f10881028bfaf4217e586955f1d435c31 (diff)
ignore macro expansion completely for now
Change-Id: Ie37b83fef1279a0a953de27941e3b342437c81d1
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/bodynotinblock.cxx14
1 files changed, 7 insertions, 7 deletions
diff --git a/compilerplugins/clang/bodynotinblock.cxx b/compilerplugins/clang/bodynotinblock.cxx
index 9e59896f892f..9c047c501fca 100644
--- a/compilerplugins/clang/bodynotinblock.cxx
+++ b/compilerplugins/clang/bodynotinblock.cxx
@@ -74,6 +74,13 @@ void BodyNotInBlock::checkBody( const Stmt* body, const StmtParents& parents, in
{
if( body == NULL || parents.size() < 2 )
return;
+ // TODO: If the if/while/for comes from a macro expansion, ignore it completely for
+ // now. The code below could assume everything is in the same place (and thus also column)
+ // and give a false warning. Moreover some macros are rather lousily written and would
+ // result in poor formatting. To be evaluated later, maybe this could be handled
+ // including macro expansion.
+ if( parents.back()->getLocStart().isMacroID())
+ return;
if( dyn_cast< CompoundStmt >( body ))
return; // if body is a compound statement, then it is in {}
// Find the next statement (in source position) after 'body'.
@@ -93,13 +100,6 @@ void BodyNotInBlock::checkBody( const Stmt* body, const StmtParents& parents, in
++it; // skip empty ones (missing 'else' bodies for example)
if( it != parents[ parent_pos ]->child_end())
{
- // TODO: If both statements come from macro expansions, they may be
- // below evaluated to be in the same place (because they may be
- // the result of expansion of the same macro). Analysing this including
- // macro expansions would be probably more complicated, so just
- // ignore that in order to avoid false positives.
- if( body->getLocStart().isMacroID() && (*it)->getLocStart().isMacroID())
- return;
bool invalid1, invalid2;
unsigned bodyColumn = context.getSourceManager()
.getPresumedColumnNumber( body->getLocStart(), &invalid1 );