Changeset View
Changeset View
Standalone View
Standalone View
clang/unittests/AST/DeclTest.cpp
Show First 20 Lines • Show All 348 Lines • ▼ Show 20 Lines | TEST(Decl, FriendFunctionWithinClassInHeaderUnit) { | ||||
ASTContext &Ctx = AST->getASTContext(); | ASTContext &Ctx = AST->getASTContext(); | ||||
auto *getFooValue = selectFirst<FunctionDecl>( | auto *getFooValue = selectFirst<FunctionDecl>( | ||||
"getFooValue", | "getFooValue", | ||||
match(functionDecl(hasName("getFooValue")).bind("getFooValue"), Ctx)); | match(functionDecl(hasName("getFooValue")).bind("getFooValue"), Ctx)); | ||||
EXPECT_TRUE(getFooValue->isInlined()); | 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", | |||||
aaron.ballman: You should also pass `-std=c89` explicitly so that the test continues to work when we switch… | |||||
"-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()); | |||||
} |
You should also pass -std=c89 explicitly so that the test continues to work when we switch the default language mode to C23 someday in the future.