diff options
author | Anna Zaks <ganna@apple.com> | 2012-02-03 01:27:37 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-02-03 01:27:37 +0000 |
commit | afdb041308bca3e875b23e7a22d879e9039bff03 (patch) | |
tree | ea0d709fe40494682ec48662d645782b8e1e6d74 /lib/Sema/SemaChecking.cpp | |
parent | 4cc9b10523b61ed260767aeb62cc36fd7734a942 (diff) |
Do not show macro expansion in strncat warnings, which can be defined as
a builtin.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149657 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 9dbee1b2b3..10cf173216 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -2742,12 +2742,22 @@ void Sema::CheckStrncatArguments(const CallExpr *CE, if (PatternType == 0) return; + // Generate the diagnostic. + SourceLocation SL = LenArg->getLocStart(); + SourceRange SR = LenArg->getSourceRange(); + SourceManager &SM = PP.getSourceManager(); + + // If the function is defined as a builtin macro, do not show macro expansion. + if (SM.isMacroArgExpansion(SL)) { + SL = SM.getSpellingLoc(SL); + SR = SourceRange(SM.getSpellingLoc(SR.getBegin()), + SM.getSpellingLoc(SR.getEnd())); + } + if (PatternType == 1) - Diag(DstArg->getLocStart(), diag::warn_strncat_large_size) - << LenArg->getSourceRange(); + Diag(SL, diag::warn_strncat_large_size) << SR; else - Diag(DstArg->getLocStart(), diag::warn_strncat_src_size) - << LenArg->getSourceRange(); + Diag(SL, diag::warn_strncat_src_size) << SR; // Output a FIXIT hint if the destination is an array (rather than a // pointer to an array). This could be enhanced to handle some @@ -2773,9 +2783,8 @@ void Sema::CheckStrncatArguments(const CallExpr *CE, DstArg->printPretty(OS, Context, 0, getPrintingPolicy()); OS << ") - 1"; - Diag(LenArg->getLocStart(), diag::note_strncat_wrong_size) - << FixItHint::CreateReplacement(LenArg->getSourceRange(), - OS.str()); + Diag(SL, diag::note_strncat_wrong_size) + << FixItHint::CreateReplacement(SR, OS.str()); } //===--- CHECK: Return Address of Stack Variable --------------------------===// |