On Sep 3, 2010, at 10:33 AM, Fariborz Jahanian wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=112977&view=rev
> Log:
> Use getSpelling to get original text of the
> c++ operator token. (radar 8328250).
Thanks Fariborz, one gotcha here:
> switch (Tok.getKind()) {
> default:
> return 0;
> + case tok::ampamp:
> + case tok::ampequal:
> + case tok::amp:
> + case tok::pipe:
> + case tok::tilde:
> + case tok::exclaim:
> + case tok::exclaimequal:
> + case tok::pipepipe:
> + case tok::pipeequal:
> + case tok::caret:
> + case tok::caretequal: {
> + llvm::StringRef ThisTok = PP.getSpelling(Tok);
PP.getSpelling(Tok) returns an std::string, which will be destroyed at the end
of the statement. This causes the StringRef (which is basically a pointer +
length) to dangle. There are a couple of different ways to fix this, but the
simplest is to declare ThisTok as an std::string.
-Chris
> + if (isalpha(ThisTok[0])) {
> + IdentifierInfo *II = &PP.getIdentifierTable().get(ThisTok.data());
> + Tok.setKind(tok::identifier);
> + SelectorLoc = ConsumeToken();
> + return II;
> + }
> + return 0;
> + }
> +
> case tok::identifier:
> case tok::kw_asm:
> case tok::kw_auto:
>
>
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits