[PATCH] D49466: Initial implementation of -fmacro-prefix-mapand -ffile-prefix-map
Erich Keane via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 19 08:56:15 PDT 2018
erichkeane added inline comments.
================
Comment at: include/clang/Lex/PreprocessorOptions.h:171
+ /// A prefix map for __FILE__ and __BASEFILE__
+ std::map<std::string, std::string> MacroPrefixMap;
+
----------------
dankm wrote:
> erichkeane wrote:
> > erichkeane wrote:
> > > It seems this can be StringRefs as well.
> > Did you miss this one? Or is there a good reason these cannot be stringrefs?
> I didn't miss it. StringRefs here don't survive. The function that adds them to the map creates temporary strings, that go away once that function ends causing StringRefs to dangle. std::string keeps copies.
Oh! I hadn't realized that getAllArgValues gives a vector<string>. That is actually pretty odd for our codebase. Looking into it, there is no reason that function cannot return a vector of StringRef...
Alright, at one point someone should likely fix that, but that person should change this type.
Repository:
rC Clang
https://reviews.llvm.org/D49466
More information about the cfe-commits
mailing list