On 10/28/2014 01:35 PM, Richard Smith wrote: > How does this compare to Sema's existing SFINAETrap mechanism?
It is more general than SFINAETrap. I originally tried that but it is insufficient. Inside any template instantiation Sema::InstantiatingTemplate::Initialize always sets InNonInstantiationSFINAEContext to false so Sema::isSFINAEContext returns None and SFINAETrap does not suppress the error. Also I want to suppress all errors, not just those tolerated by SFINAE. > What happens if you trigger an error in a non-immediate context > with one of these objects active? Like PerformPendingInstantiations? My tool handles that itself using DiagnosticSuppressionScope as a primitive. Basically I call PerformPendingInstantiations first to resolve any real errors in the original translation unit. Then inside an instance of the proposed DiagnosticSuppressionScope I add one possible construct at a time and repeat PerformPendingInstantiations. My goal is to detect which implicit class member definitions can be safely called/compiled. The tool works as follows: 1. Use CI.getPreprocessor().enableIncrementalProcessing() to keep the parser alive and prevent ActOnEndOfTranslationUnit. 2. In HandleTranslationUnit, call PerformPendingInstantiations first. Then use DiagnosticSuppressionScope and DiagnosticErrorTrap to call methods like DefineImplicitDefaultConstructor one at a time. Each time we call PerformPendingInstantiations inside the protected scope and then check the trap to decide whether to mark the implicit decl invalid with setInvalidDecl. 3. In HandleTranslationUnit, after looping over all implicit members of all classes as above, call ActOnEndOfTranslationUnit. Then perform visitation an ASTConsumer normally does. With this approach my ASTConsumer can visit all valid APIs that a program could call without error even if the translation unit does not spell out calls to all allowed implicit members. Thanks, -Brad _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
