[PATCH] D105951: [clang] P2266 implicit moves STL workaround
Matheus Izvekov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 14 12:11:42 PDT 2021
mizvekov added inline comments.
================
Comment at: clang/lib/Sema/SemaStmt.cpp:3314
+ return false;
+ const Decl *D = E.getReferencedDeclOfCallee();
+ if (!S.SourceMgr.isInSystemHeader(D->getLocation()))
----------------
aaron.ballman wrote:
> This can return `nullptr`, so we should probably return `false` in that case; WDYT?
Yes I missed that, you are absolutely right!
================
Comment at: clang/lib/Sema/SemaStmt.cpp:3317-3321
+ for (const DeclContext *DC = D->getDeclContext(); DC; DC = DC->getParent()) {
+ if (const auto *NS = dyn_cast<NamespaceDecl>(DC))
+ if (NS->isStdNamespace())
+ return true;
+ }
----------------
aaron.ballman wrote:
> Can you use `D->isInStdNamespace()` instead?
It doesn't look like `isInStdNamespace` is equivalent here, even though the name suggests otherwise.
This is a small helper, all it does is:
```
bool Decl::isInStdNamespace() const {
const DeclContext *DC = getDeclContext();
return DC && DC->isStdNamespace();
}
```
It helps you check `isStdNamespace` from a Decl, without having to through a DeclContext yourself.
Now if we really need this workaround to apply 'recursively' like this, that is a different question which I am not sure.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D105951/new/
https://reviews.llvm.org/D105951
More information about the cfe-commits
mailing list