diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-12-18 13:57:15 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-12-18 22:43:27 +0100 |
commit | 09f5ffafc2dcc999acfe5939ce341d27122a4446 (patch) | |
tree | cb91ba26c01c82dc84af546cdf18b4845fd6bffa /compilerplugins | |
parent | c052ec5add428b9e22494ada72758bc93de902f6 (diff) |
loplugin:commaoperator: Ignore occurrence in FD_SET expansion on Windows
Change-Id: I66974c273918d6d887364e7d552e3caf63e16343
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/commaoperator.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compilerplugins/clang/commaoperator.cxx b/compilerplugins/clang/commaoperator.cxx index 21c2b430f52a..c4a61e772281 100644 --- a/compilerplugins/clang/commaoperator.cxx +++ b/compilerplugins/clang/commaoperator.cxx @@ -39,6 +39,21 @@ bool CommaOperator::VisitBinaryOperator(const BinaryOperator* binaryOp) if (ignoreLocation(binaryOp)) { return true; } + // Ignore FD_SET expanding to "...} while(0, 0)" in some Microsoft + // winsock2.h (TODO: improve heuristic of determining that the whole + // binaryOp is part of a single macro body expansion): + if (compiler.getSourceManager().isMacroBodyExpansion( + binaryOp->getLocStart()) + && compiler.getSourceManager().isMacroBodyExpansion( + binaryOp->getOperatorLoc()) + && compiler.getSourceManager().isMacroBodyExpansion( + binaryOp->getLocEnd()) + && ignoreLocation( + compiler.getSourceManager().getSpellingLoc( + binaryOp->getOperatorLoc()))) + { + return true; + } if (binaryOp->getOpcode() != BO_Comma) { return true; } |