-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[yaml2obj] Add a
-E
flag to preprocess only.
If you're having trouble getting a yaml2obj macro expansion to do what you want, it's useful to be able to print the output of the preprocessing to see what your macros expanded to //before// going into the YAML processing phase. yaml2obj has its own preprocessing system which isn't the same as any other well-known thing like cpp. So there's no way to do this macro expansion via another tool: yaml2obj will have to do it itself. In this commit I add an `-E` flag to yaml2obj to do that. Differential Revision: https://reviews.llvm.org/D130981
- Loading branch information
1 parent
bb28324
commit 07e6eb6
Showing
2 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# RUN: yaml2obj -E -Dfoo=wibble %s | FileCheck %s | ||
|
||
This is a test of yaml2obj's pure preprocessing mode, so it doesn't | ||
have to contain valid YAML, or any YAML at all. But we do have to be | ||
careful with the FileCheck CHECK directives, because they'll be | ||
emitted into the preprocessed output, and risk matching themselves! | ||
For that reason, each one matches only at the start of a line. | ||
|
||
Expand a macro: | ||
[[foo]] # CHECK: {{^wibble}} | ||
|
||
Expand an undefined macro: | ||
[[bar]] # CHECK: {{^\[\[bar\]\]}} | ||
|
||
Expand an undefined macro where we provided a default value: | ||
[[baz=123]] # CHECK: {{^123}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters