summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorMatt Davis <Matthew.Davis@sony.com>2018-03-28 16:05:05 +0000
committerMatt Davis <Matthew.Davis@sony.com>2018-03-28 16:05:05 +0000
commit9cc6bba52c38c134bb1c11fd5fb20f8a028323d4 (patch)
tree0de6c8e69b0854266b5826fbbcef9d7bc11529c8 /clang/lib
parentda5c6acfe9cc4eb18ac3d2090b966ed94f9d5c3b (diff)
downloadbcm5719-llvm-9cc6bba52c38c134bb1c11fd5fb20f8a028323d4.tar.gz
bcm5719-llvm-9cc6bba52c38c134bb1c11fd5fb20f8a028323d4.zip
[Diag] Avoid emitting a redefinition note if no location is available.
Summary: The "previous definition is here" note is not helpful if there is no location information. The note will reference nothing in such a case. This patch first checks to see if there is location data, and if so the note diagnostic is emitted. This fixes PR15409. The issue in the first comment seems to already be resolved. This patch addresses the second example. Reviewers: bruno, rsmith Reviewed By: bruno Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44901 llvm-svn: 328712
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index bc3e42739d3..6cfc5012f67 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4057,7 +4057,8 @@ void Sema::notePreviousDefinition(const NamedDecl *Old, SourceLocation New) {
}
// Redefinition coming from different files or couldn't do better above.
- Diag(Old->getLocation(), diag::note_previous_definition);
+ if (Old->getLocation().isValid())
+ Diag(Old->getLocation(), diag::note_previous_definition);
}
/// We've just determined that \p Old and \p New both appear to be definitions
OpenPOWER on IntegriCloud