Christian Convey
2015-Jun-24 16:20 UTC
[LLVMdev] Out-of-source subclassses vs. LLVM's RTTI system
Hi all, Is there a good way to add out-of-LLVM-source subclasses, without modifying the corresponding in-source "Kind" enumeration? As I play around with writing an AA pass, I'd like a good way to issue warnings for cases where my AA pass can't handle a particular IR construct. I was thinking to report those warnings via *llvm::LLVMContext::diagnose( const DiagnosticInfo & DI )*. None of the existing subclasses of *DiangosticInfo* seems quite appropriate for my needs, so I wanted to create my own subclass, outside of the LLVM source. So I'm stuck between (a) wanting all of my code to reside outside of the LLVM source, and (b) being obligated (I think) to modify the *DiagnosticKind* enum. Thanks, Christian -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150624/25dbf1ec/attachment.html>
Tobias Grosser
2015-Jun-24 16:43 UTC
[LLVMdev] Out-of-source subclassses vs. LLVM's RTTI system
On 06/24/2015 06:20 PM, Christian Convey wrote:> Hi all, > > Is there a good way to add out-of-LLVM-source subclasses, without > modifying the corresponding in-source "Kind" enumeration? > > As I play around with writing an AA pass, I'd like a good way to issue > warnings for cases where my AA pass can't handle a particular IR > construct. I was thinking to report those warnings via > /llvm::LLVMContext::diagnose( const DiagnosticInfo & DI )/. None of the > existing subclasses of /DiangosticInfo/ seems quite appropriate for my > needs, so I wanted to create my own subclass, outside of the LLVM source. > > So I'm stuck between (a) wanting all of my code to reside outside of the > LLVM source, and (b) being obligated (I think) to modify the > /DiagnosticKind/ enum.Maybe have a look at Polly's lib/Analysis/ScopDetectionDiagnostic.cpp and lib/Analysis/ScopDetection.cpp. We use LLVM's diagnostics in a loadable module without modifying LLVM's DiagnosticKind enum. Best, Tobias
Christian Convey
2015-Jun-24 17:00 UTC
[LLVMdev] Out-of-source subclassses vs. LLVM's RTTI system
Hi Tobias On Wed, Jun 24, 2015 at 12:43 PM, Tobias Grosser <tobias at grosser.es> wrote:> Maybe have a look at Polly's lib/Analysis/ScopDetectionDiagnostic.cpp and > lib/Analysis/ScopDetection.cpp. We use LLVM's diagnostics in a loadable > module without modifying LLVM's DiagnosticKind enum. >Thanks very much for the suggestion. It looks like Polly's approach is the same as my initial approach: just call the most-appropriate-seeming llvm::emit...Remark...(...) method. I can use that as a fallback approach, if needed. But I was hoping implement a function for emitting diagnostic info, where one of the parameters was the severity level (llvm::DiagnosticSeverity). I'm particularly interested in drawing a distinction between "remarks" (which should be optionally filtered) and "warnings" (which should always be sent to errs()) The DiagnosticInfoOptimizationBase supports the exact set of details I care about. Unfortunately it's an abstract class, which is why I'm in my current situation. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150624/b5795748/attachment.html>