[LLVMdev] questions

Chris Lattner sabre at nondot.org
Tue Sep 17 11:47:00 PDT 2002


> I used the "dyn_cast<>" method to dynamically check whether something is
> of a given type. dyn_cast<> helpfully returns 0 if it's not of that type.
> So, you can do something like:
>
>   if (const PointerType *PT = dyn_cast<PointerType>(Inst.getType()))
>     if (const StructType *ST = dyn_cast<StructType>(PT->getType()))
>       // Work with ST...

Yup, one typeo though, this should be:

  if (const PointerType *PT = dyn_cast<PointerType>(Inst.getType()))
    if (const StructType *ST = dyn_cast<StructType>(PT->getElementType()))
      // Work with ST...

> } When we process the function 'fun1', should we change fun1 to
> } something like
> } fun1( int *a, float *b )
> } then change fun1(&mystru) in main to something like
> } fun1( &mystru.a, &mystru.b)?
> }
> I assume that, since "mystru" isn't being used as specified in rules
> U1-U3, that we shouldn't have to handle it...
> But I could be wrong...
> *crosses fingers, hoping he's not wrong*

You're right.  It isn't one of the cases you have to handle, so you ignore
it.

-Chris

http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list