summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2019-12-03 13:04:45 -0500
committerAaron Ballman <aaron@aaronballman.com>2019-12-03 13:05:59 -0500
commitfa6c157ebeef55fd1e00266d1d1ad6aaa6161ef2 (patch)
treee993d3ddb2c7556b6eaa3c3da16c6fd9fdebf8ac /clang/lib
parent6ed9cef25f915d4533f261c401cee29d8d8012d5 (diff)
downloadbcm5719-llvm-fa6c157ebeef55fd1e00266d1d1ad6aaa6161ef2.tar.gz
bcm5719-llvm-fa6c157ebeef55fd1e00266d1d1ad6aaa6161ef2.zip
Differentiate between the presumed and actual file when dumping the AST to JSON
Currently, when dumping the AST to JSON, the presumed file is what is included when dumping a source location. This patch changes the behavior to instead dump the actual file, and only dump a presumed file name when it differs from the actual file. This also corrects an issue with the test script generator that would prevent it from working on Windows due to file permissions issues.
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/JSONNodeDumper.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index 274cc25b8bb..40c6c8375a6 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -202,14 +202,20 @@ void JSONNodeDumper::writeBareSourceLocation(SourceLocation Loc,
PresumedLoc Presumed = SM.getPresumedLoc(Loc);
unsigned ActualLine = IsSpelling ? SM.getSpellingLineNumber(Loc)
: SM.getExpansionLineNumber(Loc);
+ StringRef ActualFile = SM.getBufferName(Loc);
+
if (Presumed.isValid()) {
JOS.attribute("offset", SM.getDecomposedLoc(Loc).second);
- if (LastLocFilename != Presumed.getFilename()) {
- JOS.attribute("file", Presumed.getFilename());
+ if (LastLocFilename != ActualFile) {
+ JOS.attribute("file", ActualFile);
JOS.attribute("line", ActualLine);
} else if (LastLocLine != ActualLine)
JOS.attribute("line", ActualLine);
+ StringRef PresumedFile = Presumed.getFilename();
+ if (PresumedFile != ActualFile && LastLocPresumedFilename != PresumedFile)
+ JOS.attribute("presumedFile", PresumedFile);
+
unsigned PresumedLine = Presumed.getLine();
if (ActualLine != PresumedLine && LastLocPresumedLine != PresumedLine)
JOS.attribute("presumedLine", PresumedLine);
@@ -217,7 +223,8 @@ void JSONNodeDumper::writeBareSourceLocation(SourceLocation Loc,
JOS.attribute("col", Presumed.getColumn());
JOS.attribute("tokLen",
Lexer::MeasureTokenLength(Loc, SM, Ctx.getLangOpts()));
- LastLocFilename = Presumed.getFilename();
+ LastLocFilename = ActualFile;
+ LastLocPresumedFilename = PresumedFile;
LastLocPresumedLine = PresumedLine;
LastLocLine = ActualLine;
OpenPOWER on IntegriCloud