[clang] clang: __builtin_VARIABLE_NAME (PR #86756)

2024-03-27 Thread Jon Roelofs via cfe-commits
@@ -2305,6 +2308,36 @@ APValue SourceLocExpr::EvaluateInContext(const ASTContext , }; switch (getIdentKind()) { + case SourceLocIdentKind::VariableName: { +// __builtin_VARIABLE_NAME() is a Clang-specific extension that expands to +// the name of the variable

[clang] clang: __builtin_VARIABLE_NAME (PR #86756)

2024-03-26 Thread Jon Roelofs via cfe-commits
jroelofs wrote: Here's an example of the awkward lengths Halide has to go through to do this without compiler support: https://github.com/halide/Halide/blob/a132246ced07adc59c7b3631009464e5a14e0abb/src/Introspection.h#L19-L23 https://github.com/llvm/llvm-project/pull/86756

[clang] clang: __builtin_VARIABLE_NAME (PR #86756)

2024-03-26 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 1949f7d6c9bd59172c01c7933e1c558797c47eac dc4a313b793b4215c8a68bea0b4b8e70f8a7806b --

[clang] clang: __builtin_VARIABLE_NAME (PR #86756)

2024-03-26 Thread Jon Roelofs via cfe-commits
@@ -2305,6 +2308,36 @@ APValue SourceLocExpr::EvaluateInContext(const ASTContext , }; switch (getIdentKind()) { + case SourceLocIdentKind::VariableName: { +// __builtin_VARIABLE_NAME() is a Clang-specific extension that expands to +// the name of the variable

[clang] clang: __builtin_VARIABLE_NAME (PR #86756)

2024-03-26 Thread Jon Roelofs via cfe-commits
https://github.com/jroelofs created https://github.com/llvm/llvm-project/pull/86756 Some C++ Embedded DSLs make use of `std::source_location` as a form of crude reflection. Until now, they didn't have a great way to reflect variable names into their IRs. With `__buitlin_SOURCE_LOCATION()`,