Custom Clang and Xcode

I’m using a (slightly) modified version of Clang to be used within Xcode. I integrate it using the “CC” flag in Xcode. All my modifications are turned off by default, but may be switched on by a set of custom flags.

If I don’t set any of these, everything is fine. However, if I enable one of my custom warnings, these warnings show up when building the project/target, but Xcode’s autocompletion stops working. Could it be that Xcode is confused because it works with different versions of Clang?

Not all of my custom flags break the autocomplete function. E.g., I have this option in Options.td:

def export_stats : Flag<["-"], “export-stats”>,
Flags<[CC1Option]>,
HelpText<"…">;

Setting it doesn’t break anything, but the following does:

[Options.td]

def Wunsafe_api_usage : Flag<["-"], “Wunsafe-api-usage”>,
Group<W_Group>,
Flags<[CC1Option]>,
HelpText<"…">;

[DiagnosticSemaKinds.td]

def warn_unsafe_api_usage : Warning<
“WarningText”>,
InGroup<DiagGroup<“unsafe-api-usage”>>, DefaultIgnore;

Did I get something wrong, or do I just have to live with it because Xcode is not prepared for this type of modification?

Cheers
Hagi

I’ll start off by saying of course this is not supported. :wink:

I have two guesses, though:

  • Warnings are automatically added to the -W group; you should not put a new flag into Options.td for a new warning.
  • Warnings are probably also used when uniquing PCHs, so it’s possible (but not likely) that Xcode is trying to use an incompatible PCH during indexing. I doubt this is it, but if it is, turning off PCH support in the build settings might make completion come back.

Jordan

Hi Sebastian,

You will need to replace both clang and libclang.dylib in the XcodeDefault toolchain. Overriding CC simply isn’t going to work.

Ted

Took me a while to get the libclang build right and test it, but thanks, this indeed works.

I also followed Jordan’s guesses, but they didn’t solve the problem. I’ve removed the Option.td entries for warnings anyway.

Thanks a lot for your help!