Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions clang/include/clang/Parse/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -2117,10 +2117,9 @@ class Parser : public CodeCompletionHandler {

ExprResult ParseUnevaluatedStringInAttribute(const IdentifierInfo &AttrName);

bool
ParseAttributeArgumentList(const clang::IdentifierInfo &AttrName,
SmallVectorImpl<Expr *> &Exprs,
ParsedAttributeArgumentsProperties ArgsProperties);
bool parseAttributeArgumentList(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other nearby attribute functions are generally going with an initial capital letter; probably should stick with the nearby formatting instead of changing it for just one API.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going this route, I think we should document the arguments. It's not going to be clear what the Arg parameter is for.

const IdentifierInfo &AttrName, SmallVectorImpl<Expr *> &Exprs,
ParsedAttributeArgumentsProperties ArgsProperties, unsigned Arg);

/// Parses syntax-generic attribute arguments for attributes which are
/// known to the implementation, and adds them to the given ParsedAttributes
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,10 @@ Parser::ParseUnevaluatedStringInAttribute(const IdentifierInfo &AttrName) {
return ParseUnevaluatedStringLiteralExpression();
}

bool Parser::ParseAttributeArgumentList(
bool Parser::parseAttributeArgumentList(
const IdentifierInfo &AttrName, SmallVectorImpl<Expr *> &Exprs,
ParsedAttributeArgumentsProperties ArgsProperties) {
ParsedAttributeArgumentsProperties ArgsProperties, unsigned Arg) {
bool SawError = false;
unsigned Arg = 0;
while (true) {
ExprResult Expr;
if (ArgsProperties.isStringLiteralArg(Arg)) {
Expand Down Expand Up @@ -580,7 +579,8 @@ unsigned Parser::ParseAttributeArgsCommon(
ParsedAttributeArgumentsProperties ArgProperties =
attributeStringLiteralListArg(getTargetInfo().getTriple(), *AttrName,
Form.getSyntax(), ScopeName);
if (ParseAttributeArgumentList(*AttrName, ParsedExprs, ArgProperties)) {
if (parseAttributeArgumentList(*AttrName, ParsedExprs, ArgProperties,
ArgExprs.size())) {
SkipUntil(tok::r_paren, StopAtSemi);
return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Sema/attr-modular-format.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
int printf(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"))); // no-error
int myprintf(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"))); // expected-error {{'modular_format' attribute requires 'format' attribute}}

int lprintf(const char *fmt, ...) __attribute__((modular_format(__modular_printf, L"__printf", L"float"), format(printf, 1, 2)));
// expected-warning@-1 2{{encoding prefix 'L' on an unevaluated string literal has no effect}}

int dupe(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float", "int", "float"), format(printf, 1, 2))); // expected-error {{duplicate aspect 'float' in 'modular_format' attribute}}
int multi_dupe(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float", "int", "float", "int"), format(printf, 1, 2))); // expected-error {{duplicate aspect 'float' in 'modular_format' attribute}} \
// expected-error {{duplicate aspect 'int' in 'modular_format' attribute}}
Expand Down
Loading