[PATCH] D133586: [clang] initialize type qualifiers for FunctionNoProtoType
Richard Howell via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 20 13:52:51 PDT 2022
rmaz updated this revision to Diff 461689.
rmaz edited the summary of this revision.
rmaz added a comment.
Add unit test for type qualifiers
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133586/new/
https://reviews.llvm.org/D133586
Files:
clang/include/clang/AST/Type.h
clang/unittests/AST/DeclTest.cpp
Index: clang/unittests/AST/DeclTest.cpp
===================================================================
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -311,3 +311,21 @@
EXPECT_TRUE(bar->isInlined());
}
+TEST(Decl, NoProtoFunctionDeclAttributes) {
+ llvm::Annotations Code(R"(
+ void f();
+ )");
+
+ auto AST = tooling::buildASTFromCodeWithArgs(Code.code(), /*Args=*/{});
+ ASTContext &Ctx = AST->getASTContext();
+
+ auto *f = selectFirst<FunctionDecl>(
+ "f", match(functionDecl(hasName("f")).bind("f"), Ctx));
+
+ const auto *FPT = f->getType()->getAs<FunctionNoProtoType>();
+
+ // Functions without prototypes always have 0 initialized qualifiers
+ EXPECT_FALSE(FPT->isConst());
+ EXPECT_FALSE(FPT->isVolatile());
+ EXPECT_FALSE(FPT->isRestrict());
+}
Index: clang/include/clang/AST/Type.h
===================================================================
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1647,6 +1647,7 @@
/// Only common bits are stored here. Additional uncommon bits are stored
/// in a trailing object after FunctionProtoType.
class FunctionTypeBitfields {
+ friend class FunctionNoProtoType;
friend class FunctionProtoType;
friend class FunctionType;
@@ -3926,7 +3927,9 @@
Result->getDependence() &
~(TypeDependence::DependentInstantiation |
TypeDependence::UnexpandedPack),
- Info) {}
+ Info) {
+ FunctionTypeBits.FastTypeQuals = 0;
+ }
public:
// No additional state past what FunctionType provides.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133586.461689.patch
Type: text/x-patch
Size: 1664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220920/e1f165a1/attachment.bin>
More information about the cfe-commits
mailing list