[clang] remove unused NestedNameSpecifier 'Invalid' constructor - #221128
Open
mizvekov wants to merge 1 commit into
Open
[clang] remove unused NestedNameSpecifier 'Invalid' constructor#221128mizvekov wants to merge 1 commit into
mizvekov wants to merge 1 commit into
Conversation
These invalid NNS were used as thombstone keys for DenseMap, but the DenseMap implementation changed and that's not needed anymore.
|
@llvm/pr-subscribers-clang Author: Matheus Izvekov (mizvekov) ChangesThese 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:
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) {
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These invalid NNS were used as thombstone keys for DenseMap, but the DenseMap implementation changed and that's not needed anymore.