<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hi,</p>
<p><br>
</p>
<p>I was wondering if it was possible to create a Dummy Type by subclassing LLVM Type.</p>
<p>I do not want to create a new type or even do much with this dummy type , all I need </p>
<p>is a placeholder type until I generate IR.</p>
<p><br>
</p>
<p>I want to use this approach as most of my AST is already configured to <br>
accept a Type*  and not a DummyType* ( which is my own class )</p>
<p><br>
</p>
<p>I explored this a bit and did manage to create one.</p>
<p><br>
==========  DummyType class =========</p>
<p><br>
</p>
<p></p>
<div>class DummyType : public llvm::Type</div>
<div>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>private:</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>std::string typeIdentifier;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>public:</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>DummyType(const std::string& typeIdentifier,TypeID tyId):typeIdentifier(typeIdentifier),Type(TheContext,tyId)</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{<span class="Apple-tab-span" style="font-size: 12pt; white-space: pre;">
</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>std::string getTypeIdentifierString() const</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>{</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>return this->typeIdentifier ;</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>}<span class="Apple-tab-span" style="white-space:pre">
</span></div>
<div><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div>};</div>
<p><br>
</p>
<p>============================================</p>
<p> Now , </p>
<p><br>
</p>
<p><b>Type* ty = new DummyType()  works.</b></p>
<p><b><br>
</b></p>
<b>However , I wish to use "dynamic_cast<>" at runtime but I'm unable to do so.</b><br>
example - DummyType* dum_type = dynamic_cast<DummyType>(ty) ; // where ty is a Type*
<p></p>
<p><br>
I get the following error - <br>
</p>
<div><b>error: 'llvm::Type' is not polymorphic</b></div>
<div><b><br>
</b></div>
<div>Is there some way around this ( without suggesting a change to my entire AST ) ?<br>
 Any help will be appreciated.<br>
<br>
Thanks,</div>
<div>Malhar</div>
<div><br>
</div>
<div><br>
</div>
<br>
<p></p>
</div>
</body>
</html>