diff options
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r-- | compilerplugins/clang/rangedforcopy.cxx | 10 | ||||
-rw-r--r-- | compilerplugins/clang/test/rangedforcopy.cxx | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/compilerplugins/clang/rangedforcopy.cxx b/compilerplugins/clang/rangedforcopy.cxx index b0ab6bf35027..2de4766dab04 100644 --- a/compilerplugins/clang/rangedforcopy.cxx +++ b/compilerplugins/clang/rangedforcopy.cxx @@ -12,6 +12,7 @@ #include <string> #include <iostream> +#include "check.hxx" #include "plugin.hxx" #include "clang/AST/CXXInheritance.h" @@ -54,6 +55,15 @@ bool RangedForCopy::VisitCXXForRangeStmt( const CXXForRangeStmt* stmt ) const QualType type = varDecl->getType(); if (type->isRecordType() && !type->isReferenceType() && !type->isPointerType()) { + if (loplugin::TypeCheck(type).Class("__bit_const_reference").StdNamespace()) + { + // With libc++ without _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL, + // iterating over a const std::vector<bool> non-compliantly uses a variable of some + // internal __bit_const_reference class type, rather than of type bool (see + // <https://reviews.llvm.org/D123851> "[libc++] Change + // vector<bool>::const_iterator::reference to bool in ABIv2"): + return true; + } std::string name = type.getAsString(); report( DiagnosticsEngine::Warning, diff --git a/compilerplugins/clang/test/rangedforcopy.cxx b/compilerplugins/clang/test/rangedforcopy.cxx index f4346b18111d..e9a836e2489c 100644 --- a/compilerplugins/clang/test/rangedforcopy.cxx +++ b/compilerplugins/clang/test/rangedforcopy.cxx @@ -7,6 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <vector> + struct S { int i1; @@ -27,4 +29,12 @@ void f(S const (&a)[2]) } } +void f(std::vector<bool> const& v) +{ + for (auto b : v) + { + (void)b; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |