Skip to content

Commit

Permalink
[pp-trace] Print HashLoc in InclusionDirective callback
Browse files Browse the repository at this point in the history
The HashLoc in InclusionDirective callback is an unused parameter.
Since pp-trace is also used as a test of Clang’s PPCallbacks interface,
add it to the output of pp-trace could avoid some unintended change on
it.

This shuold resolves PR52673

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D125373
  • Loading branch information
oToToT committed Jun 3, 2022
1 parent e8e4b74 commit 8df2b1a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang-tools-extra/docs/ReleaseNotes.rst
Expand Up @@ -239,7 +239,7 @@ The improvements are...
Improvements to pp-trace
------------------------

The improvements are...
- Added `HashLoc` information to `InclusionDirective` callback output.

Clang-tidy Visual Studio plugin
-------------------------------
1 change: 1 addition & 0 deletions clang-tools-extra/docs/pp-trace.rst
Expand Up @@ -223,6 +223,7 @@ Imported ((module name)|(null)) const Modu
Example:::

- Callback: InclusionDirective
HashLoc: "D:/Clang/llvmnewmod/clang-tools-extra/test/pp-trace/pp-trace-include.cpp:4:1"
IncludeTok: include
FileName: "Input/Level1B.h"
IsAngled: false
Expand Down
1 change: 1 addition & 0 deletions clang-tools-extra/pp-trace/PPCallbacksTracker.cpp
Expand Up @@ -137,6 +137,7 @@ void PPCallbacksTracker::InclusionDirective(
llvm::StringRef SearchPath, llvm::StringRef RelativePath,
const Module *Imported, SrcMgr::CharacteristicKind FileType) {
beginCallback("InclusionDirective");
appendArgument("HashLoc", HashLoc);
appendArgument("IncludeTok", IncludeTok);
appendFilePathArgument("FileName", FileName);
appendArgument("IsAngled", IsAngled);
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/test/pp-trace/pp-trace-include.cpp
Expand Up @@ -51,6 +51,7 @@
// CHECK-NEXT: FileType: C_User
// CHECK-NEXT: PrevFID: (getFileEntryForID failed)
// CHECK-NEXT: - Callback: InclusionDirective
// CHECK-NEXT: HashLoc: "{{.*}}{{[/\\]}}pp-trace-include.cpp:3:1"
// CHECK-NEXT: IncludeTok: include
// CHECK-NEXT: FileName: "Inputs/Level1A.h"
// CHECK-NEXT: IsAngled: false
Expand All @@ -65,6 +66,7 @@
// CHECK-NEXT: FileType: C_User
// CHECK-NEXT: PrevFID: (invalid)
// CHECK-NEXT: - Callback: InclusionDirective
// CHECK-NEXT: HashLoc: "{{.*}}{{[/\\]}}Inputs/Level1A.h:1:1"
// CHECK-NEXT: IncludeTok: include
// CHECK-NEXT: FileName: "Level2A.h"
// CHECK-NEXT: IsAngled: false
Expand Down Expand Up @@ -95,6 +97,7 @@
// CHECK-NEXT: FileType: C_User
// CHECK-NEXT: PrevFID: "{{.*}}{{[/\\]}}Inputs/Level1A.h"
// CHECK-NEXT: - Callback: InclusionDirective
// CHECK-NEXT: HashLoc: "{{.*}}{{[/\\]}}pp-trace-include.cpp:4:1"
// CHECK-NEXT: IncludeTok: include
// CHECK-NEXT: FileName: "Inputs/Level1B.h"
// CHECK-NEXT: IsAngled: false
Expand All @@ -109,6 +112,7 @@
// CHECK-NEXT: FileType: C_User
// CHECK-NEXT: PrevFID: (invalid)
// CHECK-NEXT: - Callback: InclusionDirective
// CHECK-NEXT: HashLoc: "{{.*}}{{[/\\]}}Inputs/Level1B.h:1:1"
// CHECK-NEXT: IncludeTok: include
// CHECK-NEXT: FileName: "Level2B.h"
// CHECK-NEXT: IsAngled: false
Expand Down

0 comments on commit 8df2b1a

Please sign in to comment.