[clang] [llvm] Add source file name for template instantiations in -ftime-trace (PR #98320)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 01:09:34 PDT 2024
================
@@ -38,14 +42,24 @@ std::string teardownProfiler() {
// Returns true if code compiles successfully.
// We only parse AST here. This is enough for constexpr evaluation.
-bool compileFromString(StringRef Code, StringRef Standard, StringRef FileName) {
+bool compileFromString(StringRef Code, StringRef Standard, StringRef File,
+ llvm::StringMap<StringRef> Headers = {}) {
----------------
ilya-biryukov wrote:
NIT: `StringMap<StringRef>` is a bit of a trap because it's way too easy to write something like `map.insert("foo.h", std::string("#include <vector>\n") + std::string("#include <map>"))` and get into a state where the string is incorrect.
And we don't really need to avoid copies in tests for efficiency purposes, so I'd recommend just using `StringMap<string>` instead to minimize the chance of getting potential use-after-free surprises in the future.
https://github.com/llvm/llvm-project/pull/98320
More information about the cfe-commits
mailing list