Bug 1325694 - Mark the MSVC specific std::atomic base classes as memmovable for static analysis; r=froydnj

This commit is contained in:
Ehsan Akhgari 2016-12-23 16:11:35 -05:00
Родитель dc8eed03da
Коммит 18f30a60a6
3 изменённых файлов: 55 добавлений и 1 удалений

Просмотреть файл

@ -526,7 +526,30 @@ protected:
// This doesn't check that it's really ::std::pair and not
// ::std::something_else::pair, but should be good enough.
StringRef Name = getNameChecked(D);
if (Name == "pair" || Name == "atomic" || Name == "__atomic_base") {
if (Name == "pair" ||
Name == "atomic" ||
// libstdc++ specific names
Name == "__atomic_base" ||
Name == "atomic_bool" ||
// MSVCRT specific names
Name == "_Atomic_impl" ||
Name == "_Atomic_base" ||
Name == "_Atomic_bool" ||
Name == "_Atomic_char" ||
Name == "_Atomic_schar" ||
Name == "_Atomic_uchar" ||
Name == "_Atomic_char16_t" ||
Name == "_Atomic_char32_t" ||
Name == "_Atomic_wchar_t" ||
Name == "_Atomic_short" ||
Name == "_Atomic_ushort" ||
Name == "_Atomic_int" ||
Name == "_Atomic_uint" ||
Name == "_Atomic_long" ||
Name == "_Atomic_ulong" ||
Name == "_Atomic_llong" ||
Name == "_Atomic_ullong" ||
Name == "_Atomic_address") {
return false;
}
return true;

Просмотреть файл

@ -0,0 +1,30 @@
// expected-no-diagnostics
#define MOZ_NEEDS_MEMMOVABLE_TYPE __attribute__((annotate("moz_needs_memmovable_type")))
template<class T>
class MOZ_NEEDS_MEMMOVABLE_TYPE Mover { T mForceInst; };
#include <atomic>
#include <cstdint>
struct CustomType{};
static struct {
Mover<std::atomic<CustomType>> m1;
Mover<std::atomic<bool>> m2;
Mover<std::atomic<char>> m3;
Mover<std::atomic<signed char>> m4;
Mover<std::atomic<unsigned char>> m5;
Mover<std::atomic<char16_t>> m6;
Mover<std::atomic<char32_t>> m7;
Mover<std::atomic<wchar_t>> m8;
Mover<std::atomic<short>> m9;
Mover<std::atomic<unsigned short>> m10;
Mover<std::atomic<int>> m11;
Mover<std::atomic<unsigned int>> m12;
Mover<std::atomic<long>> m13;
Mover<std::atomic<unsigned long>> m14;
Mover<std::atomic<long long>> m15;
Mover<std::atomic<unsigned long long>> m16;
Mover<std::atomic<void*>> m17;
Mover<std::atomic<CustomType*>> m18;
} good;

Просмотреть файл

@ -30,6 +30,7 @@ SOURCES += [
'TestNonHeapClass.cpp',
'TestNonMemMovable.cpp',
'TestNonMemMovableStd.cpp',
'TestNonMemMovableStdAtomic.cpp',
'TestNonParameterChecker.cpp',
'TestNonTemporaryClass.cpp',
'TestNoRefcountedInsideLambdas.cpp',