[cfe-dev] Fixing semantic diagnostics that embed english words

Douglas Gregor dgregor at apple.com
Sun Dec 13 12:37:31 PST 2009

On Dec 12, 2009, at 11:38 AM, Nicola Gigante wrote:

> Hello,
> I'm sending a patch that fixes some diagnostic messages that used to embed english words as arguments.
> Previously, those string were flying around the various Sema*.cpp files as a const char *Flavor argument passed
> to the DiagnoseAssignmentResult() method and a couple of others.
> I've replaced those strings with values from an AssignmentAction enumeration declared in Sema.h around line 830. Is it ok to do things like that? The constants' name of the enumeration are very similar to the strings that they represents.

Yes, this is very helpful! We generally prefix enumerator names with something resembling the enumeration name, so that we're less likely to have conflicts. For example, in the names here:

+  enum AssignmentAction {
+    Assigning,
+    Copying,
+    Passing,
+    Returning,
+    Converting,
+    Initializing,
+    Sending,
+    Casting
+  };

we would prefer to use the names AA_Assigning, AA_Copying, AA_Passing, etc.

> In the meantime, I've found that a similar Flavor argument was passed to BuildCXXDerivedToBaseExpr() method but that it wasn't used anywhere so I've removed it, is it ok?

Yes, thanks!

Thank you for fixing this; if you could perform the rename mentioned above, I'd be happy to commit your patch.

	- Doug

More information about the cfe-dev mailing list