Source code

Revision control

Other Tools

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at */
#ifndef MemMoveAnnotation_h__
#define MemMoveAnnotation_h__
#include "CustomMatchers.h"
#include "CustomTypeAnnotation.h"
#include "Utils.h"
#include <unordered_set>
class MemMoveAnnotation final : public CustomTypeAnnotation {
: CustomTypeAnnotation(moz_non_memmovable, "non-memmove()able") {}
virtual ~MemMoveAnnotation() {}
std::string getImplicitReason(const TagDecl *D) const override {
// Annotate everything in ::std, with a few exceptions; see bug
// 1201314 for discussion.
if (getDeclarationNamespace(D) == "std") {
// 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 (isNameExcepted( {
return "";
return "it is an stl-provided type not guaranteed to be memmove-able";
return "";
bool isNameExcepted(const char *Name) const {
static std::unordered_set<std::string> NamesSet = {
// libstdc++ specific names
// MSVCRT specific names
// MSVCRT 2019
return NamesSet.find(Name) != NamesSet.end();
extern MemMoveAnnotation NonMemMovable;