diff options
author | Fred Tingaud <95592999+frederic-tingaud-sonarsource@users.noreply.github.com> | 2024-02-15 14:55:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-15 14:55:25 +0100 |
commit | c609211d912dfa9849c5ca873d40d10e32e0a975 (patch) | |
tree | da3a1e9d255ed9b68bb0912ad936d71041d7715c /clang/lib/AST/DeclBase.cpp | |
parent | 513e4dc1af5e0a57dab5cd8df6fb1fc9e82b1e33 (diff) | |
download | llvm-c609211d912dfa9849c5ca873d40d10e32e0a975.zip llvm-c609211d912dfa9849c5ca873d40d10e32e0a975.tar.gz llvm-c609211d912dfa9849c5ca873d40d10e32e0a975.tar.bz2 |
[clang] Fix isInStdNamespace for Decl flagged extern c++ (#81776)
The MSVC STL implementation declares multiple classes using:
```cpp
namespace std {
extern "C++" class locale {
...
};
}
```
`isInStdNamespace` uses the first DeclContext to check whether a Decl is
inside the `std` namespace. Here, the first DeclContext of the `locale`
Decl is a LinkageSpecDecl so the method will return false.
We need to skip this LinkageSpecDecl to find the first DeclContext of
type Namespace and actually check whether we're in the `std` namespace.
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 8163f9b..10fe8bb 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -402,7 +402,7 @@ bool Decl::isInAnonymousNamespace() const { bool Decl::isInStdNamespace() const { const DeclContext *DC = getDeclContext(); - return DC && DC->isStdNamespace(); + return DC && DC->getNonTransparentContext()->isStdNamespace(); } bool Decl::isFileContextDecl() const { |