summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/DocumentXML.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-12 07:15:47 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-12 07:15:47 +0000
commit453b012513e67aa99b3d4c5f7712231012efeca3 (patch)
treef50a2385ab797dfb12f0745b98f0fe697332b5c2 /clang/lib/Frontend/DocumentXML.cpp
parentea18d8ec2d4c153511d38f85e65c78c3e637d3c6 (diff)
downloadbcm5719-llvm-453b012513e67aa99b3d4c5f7712231012efeca3.tar.gz
bcm5719-llvm-453b012513e67aa99b3d4c5f7712231012efeca3.zip
Make sure to always check the result of
SourceManager::getPresumedLoc(), so that we don't try to make use of an invalid presumed location. Doing so can cause crashes. llvm-svn: 118885
Diffstat (limited to 'clang/lib/Frontend/DocumentXML.cpp')
-rw-r--r--clang/lib/Frontend/DocumentXML.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Frontend/DocumentXML.cpp b/clang/lib/Frontend/DocumentXML.cpp
index 2f7e995b208..b24ece5119d 100644
--- a/clang/lib/Frontend/DocumentXML.cpp
+++ b/clang/lib/Frontend/DocumentXML.cpp
@@ -327,9 +327,11 @@ PresumedLoc DocumentXML::addLocation(const SourceLocation& Loc)
if (!SpellingLoc.isInvalid())
{
PLoc = SM.getPresumedLoc(SpellingLoc);
- addSourceFileAttribute(PLoc.getFilename());
- addAttribute("line", PLoc.getLine());
- addAttribute("col", PLoc.getColumn());
+ if (PLoc.isValid()) {
+ addSourceFileAttribute(PLoc.getFilename());
+ addAttribute("line", PLoc.getLine());
+ addAttribute("col", PLoc.getColumn());
+ }
}
// else there is no error in some cases (eg. CXXThisExpr)
return PLoc;
@@ -346,8 +348,9 @@ void DocumentXML::addLocationRange(const SourceRange& R)
if (!SpellingLoc.isInvalid())
{
PresumedLoc PLoc = SM.getPresumedLoc(SpellingLoc);
- if (PStartLoc.isInvalid() ||
- strcmp(PLoc.getFilename(), PStartLoc.getFilename()) != 0) {
+ if (PLoc.isInvalid()) {
+ } else if (PStartLoc.isInvalid() ||
+ strcmp(PLoc.getFilename(), PStartLoc.getFilename()) != 0) {
addToMap(SourceFiles, PLoc.getFilename(), ID_FILE);
addAttribute("endfile", PLoc.getFilename());
addAttribute("endline", PLoc.getLine());
OpenPOWER on IntegriCloud