Skip to content

Commit bc15a42

Browse files
committed
Also handle qualifiers like const
1 parent 69426f2 commit bc15a42

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

clang/lib/AST/QualTypeNames.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "clang/AST/DeclTemplate.h"
1111
#include "clang/AST/DeclarationName.h"
1212
#include "clang/AST/Mangle.h"
13+
#include "clang/AST/Type.h"
1314

1415
namespace clang {
1516

@@ -423,7 +424,10 @@ QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx,
423424
getFullyQualifiedType(AT->getModifiedType(), Ctx, WithGlobalNsPrefix);
424425
QualType NewEquivalent =
425426
getFullyQualifiedType(AT->getEquivalentType(), Ctx, WithGlobalNsPrefix);
426-
return Ctx.getAttributedType(AT->getAttrKind(), NewModified, NewEquivalent);
427+
Qualifiers Qualifiers = QT.getLocalQualifiers();
428+
return Ctx.getQualifiedType(
429+
Ctx.getAttributedType(AT->getAttrKind(), NewModified, NewEquivalent),
430+
Qualifiers);
427431
}
428432

429433
// Remove the part of the type related to the type being a template

clang/unittests/Tooling/QualTypeNamesTest.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,23 @@ TEST(QualTypeNameTest, NullableAttributesWithGlobalNs) {
305305
Visitor.ExpectedQualTypeNames["param2"] = "::std::unique_ptr<int> _Nonnull";
306306
Visitor.ExpectedQualTypeNames["param3"] =
307307
"::std::unique_ptr< ::std::unique_ptr<int> _Nullable> _Nonnull";
308+
Visitor.ExpectedQualTypeNames["param4"] =
309+
"::std::unique_ptr<int> _Nullable const *";
310+
Visitor.ExpectedQualTypeNames["param5"] =
311+
"::std::unique_ptr<int> _Nullable const *";
312+
Visitor.ExpectedQualTypeNames["param6"] =
313+
"::std::unique_ptr<int> _Nullable const *";
308314
Visitor.runOver(R"(namespace std {
309315
template<class T> class unique_ptr {};
310316
}
311317
void foo(
312318
std::unique_ptr<int> _Nullable param1,
313319
_Nonnull std::unique_ptr<int> param2,
314-
std::unique_ptr<std::unique_ptr<int> _Nullable> _Nonnull param3);
320+
std::unique_ptr<std::unique_ptr<int> _Nullable> _Nonnull param3,
321+
const std::unique_ptr<int> _Nullable *param4,
322+
_Nullable std::unique_ptr<int> const *param5,
323+
std::unique_ptr<int> _Nullable const *param6
324+
);
315325
)");
316326
}
317327
} // end anonymous namespace

0 commit comments

Comments
 (0)