| 1 |
/* |
| 2 |
SPDX-FileCopyrightText: 2015 Klarälvdalens Datakonsult AB a KDAB Group company [email protected] |
| 3 |
SPDX-FileContributor: Sérgio Martins <[email protected]> |
| 4 |
|
| 5 |
SPDX-FileCopyrightText: 2015 Sergio Martins <[email protected]> |
| 6 |
|
| 7 |
SPDX-License-Identifier: LGPL-2.0-or-later |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef DETACHING_TEMPORARIES_H |
| 11 |
#define DETACHING_TEMPORARIES_H |
| 12 |
|
| 13 |
#include "checks/detachingbase.h" |
| 14 |
|
| 15 |
#include <llvm/ADT/StringRef.h> |
| 16 |
|
| 17 |
#include <map> |
| 18 |
#include <string> |
| 19 |
#include <vector> |
| 20 |
|
| 21 |
/** |
| 22 |
* Finds places where you're calling non-const member functions on temporaries. |
| 23 |
* |
| 24 |
* For example getList().first(), which would detach if the container is shared. |
| 25 |
* See README-deatching-temporary for more information |
| 26 |
*/ |
| 27 |
class DetachingTemporary : public DetachingBase |
| 28 |
{ |
| 29 |
public: |
| 30 |
DetachingTemporary(const std::string &name, Options options); |
| 31 |
void VisitStmt(clang::Stmt *stm) override; |
| 32 |
|
| 33 |
private: |
| 34 |
bool isDetachingMethod(clang::CXXMethodDecl *method) const; |
| 35 |
std::map<llvm::StringRef, std::vector<llvm::StringRef>> m_writeMethodsByType; |
| 36 |
}; |
| 37 |
|
| 38 |
#endif |