ilya-biryukov added a comment.

In https://reviews.llvm.org/D53866#1301086, @nik wrote:

> I still don't have feedback for a real world case except "unintentional 
> #include". Unfortunately, in real world cases the cyclic include might be not 
> obvious at all.
>  @ilya: As far as I understand you prefer to make the preamble generation 
> rather fail as long as we don't have more information. How do you suggest to 
> implement this? I see that Clang->getPreprocessor().addPPCallbacks() is 
> called in PrecompiledPreamble::Build(). Adding a custom PPCallbacks there 
> that overrides "void InclusionDirective()" might be enough to detect the 
> cyclic #include and to set a flag that is checked before 
> PrecompiledPreamble::Build() returns - BuildPreambleError could get a new 
> enumerator. Is there a better way to do this? For example, it would be 
> desirable to not only observe this case, but then to also stop/abort/skip all 
> the further parsing that is done for the preamble only as it's pointless then.


Maybe produce a **fatal** error in the preprocessor? That seems to be the 
simplest option: the preprocessor is aware it's building the preamble and 
there's definitely some logic to produce fatal errors in other cases (include 
not found).
A fatal error currently aborts other stages of the compilation pipeline and 
producing one would make the run of the compiler that tries to produce the 
preamble fail, giving the empty preamble as a result.


Repository:
  rC Clang

https://reviews.llvm.org/D53866



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to