[PATCH] D133586: [clang] initialize type qualifiers for FunctionNoProtoType
Richard Howell via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 26 07:20:08 PDT 2022
rmaz updated this revision to Diff 462898.
rmaz added a comment.
remove else case
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
@@ -354,3 +354,25 @@
EXPECT_TRUE(getFooValue->isInlined());
}
+
+TEST(Decl, NoProtoFunctionDeclAttributes) {
+ llvm::Annotations Code(R"(
+ void f();
+ )");
+
+ auto AST = tooling::buildASTFromCodeWithArgs(
+ Code.code(),
+ /*Args=*/{"-target", "i386-apple-darwin", "-x", "objective-c",
+ "-std=c89"});
+ 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
@@ -3892,7 +3892,10 @@
}
Qualifiers getFastTypeQuals() const {
- return Qualifiers::fromFastMask(FunctionTypeBits.FastTypeQuals);
+ if (isFunctionProtoType())
+ return Qualifiers::fromFastMask(FunctionTypeBits.FastTypeQuals);
+
+ return Qualifiers();
}
public:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133586.462898.patch
Type: text/x-patch
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220926/a7ea4ea5/attachment.bin>
More information about the cfe-commits
mailing list