forked from OSchip/llvm-project
[clang] initialize type qualifiers for FunctionNoProtoType
When initializing FunctionNoProtoType types, zero out the type qualifiers. This will ensure the ODR hash remains stable as it hashes the values for these qualifiers for all function types. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D133586
This commit is contained in:
parent
ce82530cd0
commit
1f451a8bd6
|
@ -3892,7 +3892,10 @@ protected:
|
|||
}
|
||||
|
||||
Qualifiers getFastTypeQuals() const {
|
||||
return Qualifiers::fromFastMask(FunctionTypeBits.FastTypeQuals);
|
||||
if (isFunctionProtoType())
|
||||
return Qualifiers::fromFastMask(FunctionTypeBits.FastTypeQuals);
|
||||
|
||||
return Qualifiers();
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -354,3 +354,25 @@ TEST(Decl, FriendFunctionWithinClassInHeaderUnit) {
|
|||
|
||||
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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue