[cfe-commits] [PATCH] Disassociate pragmas from IdentifierInfos

Argyrios Kyrtzidis kyrtzidis at apple.com
Tue Jul 13 02:14:02 PDT 2010

On 13 Jul 2010, at 09:55, Douglas Gregor wrote:

> On Jul 13, 2010, at 12:57 AM, Argyrios Kyrtzidis wrote:
>> The attached patch modifies the pragma handlers to accept and use StringRefs instead of IdentifierInfos.
>> When loading the PCH, IdentifierInfos that are associated with pragmas cause declarations that use these identifiers to be deserialized (e.g. the "clang" pragma causes the "clang" namespace to be loaded).
>> We can avoid this if we just use StringRefs for the pragmas.
>> As a bonus, since we don't have to create and pass IdentifierInfos, the pragma interfaces get a bit more simplified.
> Good stuff. My only concern is that it's generally dangerous to hold on to StringRefs like this:
> @@ -33,12 +35,13 @@ namespace clang {
> /// we treat "#pragma STDC" and "#pragma GCC" as namespaces that contain other
> /// pragmas.
> class PragmaHandler {
> -  const IdentifierInfo *Name;
> +  llvm::StringRef Name;
> It works when the StrinRef refers to a string literal or some storage that lives longer than the pragma handler, but the latter is a trap waiting for someone. It would be better to either store a std::string in PragmaHandler or to eliminate the Name field altogether.

Good catch! I changed it to std::string and committed at r108237.

Thanks for reviewing!


More information about the cfe-commits mailing list