forked from OSchip/llvm-project
PR11002: Make sure we emit sentinel warnings with a valid source location. (Ideally, we want to use the location returned by getLocForEndOfToken, but that is not always successful.)
llvm-svn: 140658
This commit is contained in:
parent
ab2dcc8de6
commit
9ab36372db
|
@ -253,6 +253,9 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
|
||||||
else
|
else
|
||||||
NullValue = "(void*) 0";
|
NullValue = "(void*) 0";
|
||||||
|
|
||||||
|
if (MissingNilLoc.isInvalid())
|
||||||
|
Diag(Loc, diag::warn_missing_sentinel) << calleeType;
|
||||||
|
else
|
||||||
Diag(MissingNilLoc, diag::warn_missing_sentinel)
|
Diag(MissingNilLoc, diag::warn_missing_sentinel)
|
||||||
<< calleeType
|
<< calleeType
|
||||||
<< FixItHint::CreateInsertion(MissingNilLoc, ", " + NullValue);
|
<< FixItHint::CreateInsertion(MissingNilLoc, ", " + NullValue);
|
||||||
|
|
|
@ -4,13 +4,15 @@
|
||||||
|
|
||||||
#define ATTR __attribute__ ((__sentinel__))
|
#define ATTR __attribute__ ((__sentinel__))
|
||||||
|
|
||||||
void foo1 (int x, ...) ATTR; // expected-note 2 {{function has been explicitly marked sentinel here}}
|
void foo1 (int x, ...) ATTR; // expected-note 3 {{function has been explicitly marked sentinel here}}
|
||||||
void foo5 (int x, ...) __attribute__ ((__sentinel__(1))); // expected-note {{function has been explicitly marked sentinel here}}
|
void foo5 (int x, ...) __attribute__ ((__sentinel__(1))); // expected-note {{function has been explicitly marked sentinel here}}
|
||||||
void foo6 (int x, ...) __attribute__ ((__sentinel__(5))); // expected-note {{function has been explicitly marked sentinel here}}
|
void foo6 (int x, ...) __attribute__ ((__sentinel__(5))); // expected-note {{function has been explicitly marked sentinel here}}
|
||||||
void foo7 (int x, ...) __attribute__ ((__sentinel__(0))); // expected-note {{function has been explicitly marked sentinel here}}
|
void foo7 (int x, ...) __attribute__ ((__sentinel__(0))); // expected-note {{function has been explicitly marked sentinel here}}
|
||||||
void foo10 (int x, ...) __attribute__ ((__sentinel__(1,1)));
|
void foo10 (int x, ...) __attribute__ ((__sentinel__(1,1)));
|
||||||
void foo12 (int x, ... ) ATTR; // expected-note {{function has been explicitly marked sentinel here}}
|
void foo12 (int x, ... ) ATTR; // expected-note {{function has been explicitly marked sentinel here}}
|
||||||
|
|
||||||
|
#define FOOMACRO(...) foo1(__VA_ARGS__)
|
||||||
|
|
||||||
void test1() {
|
void test1() {
|
||||||
foo1(1, NULL); // OK
|
foo1(1, NULL); // OK
|
||||||
foo1(1, 0) ; // expected-warning {{missing sentinel in function call}}
|
foo1(1, 0) ; // expected-warning {{missing sentinel in function call}}
|
||||||
|
@ -30,6 +32,9 @@ void test1() {
|
||||||
struct A a, b, c;
|
struct A a, b, c;
|
||||||
foo1(3, &a, &b, &c); // expected-warning {{missing sentinel in function call}}
|
foo1(3, &a, &b, &c); // expected-warning {{missing sentinel in function call}}
|
||||||
foo1(3, &a, &b, &c, (struct A*) 0);
|
foo1(3, &a, &b, &c, (struct A*) 0);
|
||||||
|
|
||||||
|
// PR11002
|
||||||
|
FOOMACRO(1, 2); // expected-warning {{missing sentinel in function call}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue