diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2011-09-27 23:46:37 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2011-09-27 23:46:37 +0000 |
| commit | 9ab36372dbac59491c589ab3092b54c469079f8f (patch) | |
| tree | 0b37cd91c77478ecad32b073380e5d69f62994fe /clang/lib/Sema | |
| parent | ab2dcc8de6c1973751dd326fe1401e674fe91207 (diff) | |
| download | bcm5719-llvm-9ab36372dbac59491c589ab3092b54c469079f8f.tar.gz bcm5719-llvm-9ab36372dbac59491c589ab3092b54c469079f8f.zip | |
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
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 25f1342aeb0..2b67b4dc486 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -252,10 +252,13 @@ void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, NullValue = "NULL"; else NullValue = "(void*) 0"; - - Diag(MissingNilLoc, diag::warn_missing_sentinel) - << calleeType - << FixItHint::CreateInsertion(MissingNilLoc, ", " + NullValue); + + if (MissingNilLoc.isInvalid()) + Diag(Loc, diag::warn_missing_sentinel) << calleeType; + else + Diag(MissingNilLoc, diag::warn_missing_sentinel) + << calleeType + << FixItHint::CreateInsertion(MissingNilLoc, ", " + NullValue); Diag(D->getLocation(), diag::note_sentinel_here) << calleeType; } |

