Page MenuHomePhabricator

[TypeSystem] Handle Clang AttributedTypes

Authored by spyffe on Jun 1 2017, 5:15 PM.



When parsing types originating in modules, it is possible to encounter AttributedTypes (such as the type generated for NSString *_Nonnull). Some of LLDB's ClangASTContext methods deal with them; others do not. In particular, one function that did not was GetTypeInfo, causing TestObjCNewSyntax to fail.

This fixes that, treating AttributedType as essentially transparent and getting the information for the modified type.

In addition, however, TestObjCNewSyntax is a monolithic test that verifies a bunch of different things, all of which can break independently of one another. I broke it apart into smaller tests so that we get more precise failures when something (like this) breaks.

Diff Detail


Event Timeline

spyffe created this revision.Jun 1 2017, 5:15 PM
jingham accepted this revision.Jun 1 2017, 5:51 PM

That seems correct since we aren't recording the attributes in the type flags.

The only question I have is that you're assuming something that has a TypeClass of Attributed will always convert to an AttributedType successfully, and that attributed types can always fetch the type they are an attribute-modified type of. Those both seem reasonable assumptions, do you know they are true?

This revision is now accepted and ready to land.Jun 1 2017, 5:51 PM
spyffe added a comment.Jun 1 2017, 6:10 PM

ModifiedType gets assigned during construction and getModifiedType() is just an accessor, so if that is nullptr something very bad is happening. We should not expect that except in case of a parser bug of some sort.

AttributedType checks that a Type* is an AttributedType in the following way (Type.h):

static bool classof(const Type *T) {
  return T->getTypeClass() == Attributed;

So our use of the type class is canonical.

Okay. If the attributed types were hand-built types from DWARF, I would still worry a bit about the getModifiedType() call. But these only come from modules, and those are built by orthodox methods so they should be self-consistent.

This revision was automatically updated to reflect the committed changes.