[clang] [clang] remove unused NestedNameSpecifier 'Invalid' constructor (PR #221128)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 3 20:58:24 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Matheus Izvekov (mizvekov)
<details>
<summary>Changes</summary>
These invalid NNS were used as thombstone keys for DenseMap, but the DenseMap implementation changed and that's not needed anymore.
---
Full diff: https://github.com/llvm/llvm-project/pull/221128.diff
3 Files Affected:
- (modified) clang/include/clang/AST/NestedNameSpecifier.h (-2)
- (modified) clang/include/clang/AST/NestedNameSpecifierBase.h (+2-6)
- (modified) clang/lib/AST/ASTImporter.cpp (+22-16)
``````````diff
diff --git a/clang/include/clang/AST/NestedNameSpecifier.h b/clang/include/clang/AST/NestedNameSpecifier.h
index b7d24d5397077..f13351f0d5d3e 100644
--- a/clang/include/clang/AST/NestedNameSpecifier.h
+++ b/clang/include/clang/AST/NestedNameSpecifier.h
@@ -28,8 +28,6 @@ auto NestedNameSpecifier::getKind() const -> Kind {
return Kind::Null;
case FlagKind::Global:
return Kind::Global;
- case FlagKind::Invalid:
- llvm_unreachable("use of invalid NestedNameSpecifier");
}
llvm_unreachable("unhandled FlagKind");
}
diff --git a/clang/include/clang/AST/NestedNameSpecifierBase.h b/clang/include/clang/AST/NestedNameSpecifierBase.h
index 3330fed58ba79..5d883246252a1 100644
--- a/clang/include/clang/AST/NestedNameSpecifierBase.h
+++ b/clang/include/clang/AST/NestedNameSpecifierBase.h
@@ -49,7 +49,7 @@ struct alignas(8) NamespaceAndPrefixStorage;
/// the global specifier ('::'). The last two specifiers can only appear at the
/// start of a nested-namespace-specifier.
class NestedNameSpecifier {
- enum class FlagKind { Null, Global, Invalid };
+ enum class FlagKind { Null, Global };
enum class StoredKind {
Type,
NamespaceOrSuper,
@@ -100,15 +100,11 @@ class NestedNameSpecifier {
NestedNameSpecifier Prefix);
public:
- static constexpr NestedNameSpecifier getInvalid() {
- return NestedNameSpecifier(FlagKind::Invalid);
- }
-
static constexpr NestedNameSpecifier getGlobal() {
return NestedNameSpecifier(FlagKind::Global);
}
- NestedNameSpecifier() : NestedNameSpecifier(FlagKind::Invalid) {}
+ NestedNameSpecifier() = delete;
/// The kind of specifier that completes this nested name
/// specifier.
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 5778b0996c36a..22c3af47f451f 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1638,16 +1638,18 @@ ASTNodeImporter::VisitFunctionProtoType(const FunctionProtoType *T) {
ExpectedType ASTNodeImporter::VisitUnresolvedUsingType(
const UnresolvedUsingType *T) {
- Error Err = Error::success();
- auto ToQualifier = importChecked(Err, T->getQualifier());
- auto *ToD = importChecked(Err, T->getDecl());
- if (Err)
- return std::move(Err);
+ auto ToQualifierOrErr = import(T->getQualifier());
+ if (!ToQualifierOrErr)
+ return ToQualifierOrErr.takeError();
+ auto ToDeclOrErr = import(T->getDecl());
+ if (!ToDeclOrErr)
+ return ToDeclOrErr.takeError();
if (T->isCanonicalUnqualified())
- return Importer.getToContext().getCanonicalUnresolvedUsingType(ToD);
- return Importer.getToContext().getUnresolvedUsingType(T->getKeyword(),
- ToQualifier, ToD);
+ return Importer.getToContext().getCanonicalUnresolvedUsingType(
+ *ToDeclOrErr);
+ return Importer.getToContext().getUnresolvedUsingType(
+ T->getKeyword(), *ToQualifierOrErr, *ToDeclOrErr);
}
ExpectedType ASTNodeImporter::VisitParenType(const ParenType *T) {
@@ -1704,14 +1706,18 @@ ExpectedType ASTNodeImporter::VisitTypeOfType(const TypeOfType *T) {
}
ExpectedType ASTNodeImporter::VisitUsingType(const UsingType *T) {
- Error Err = Error::success();
- auto ToQualifier = importChecked(Err, T->getQualifier());
- auto *ToD = importChecked(Err, T->getDecl());
- QualType ToT = importChecked(Err, T->desugar());
- if (Err)
- return std::move(Err);
- return Importer.getToContext().getUsingType(T->getKeyword(), ToQualifier, ToD,
- ToT);
+ auto ToQualifierOrErr = import(T->getQualifier());
+ if (!ToQualifierOrErr)
+ return ToQualifierOrErr.takeError();
+ auto ToDeclOrErr = import(T->getDecl());
+ if (!ToDeclOrErr)
+ return ToDeclOrErr.takeError();
+
+ ExpectedType ToTypeOrErr = import(T->desugar());
+ if (!ToTypeOrErr)
+ return ToTypeOrErr.takeError();
+ return Importer.getToContext().getUsingType(
+ T->getKeyword(), *ToQualifierOrErr, *ToDeclOrErr, *ToTypeOrErr);
}
ExpectedType ASTNodeImporter::VisitDecltypeType(const DecltypeType *T) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/221128
More information about the cfe-commits
mailing list