Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TODOs for generic structs #644

Open
abeln opened this issue Jul 29, 2019 · 6 comments
Open

Fix TODOs for generic structs #644

abeln opened this issue Jul 29, 2019 · 6 comments
Labels
feature This labels new features and enhancements.

Comments

@abeln
Copy link

abeln commented Jul 29, 2019

This issue tracks the TODOs left during the initial implementation of generic structs (see comments below).

@abeln abeln changed the title Better diagnostics for expanding cycles TODOs for generic structs Aug 7, 2019
@abeln
Copy link
Author

abeln commented Aug 7, 2019

Better error messages for expanding cycles

Once #638 is merged, we'll raise an error when we detect an expanding cycle in a generic struct.

e.g.

struct F _For_any(T) {
  struct F<T> *f1; // allowed
  struct F<struct F<T> > *f2; // error: expanding cycle
};

The error as displayed in #638 is very basic: it only mentions that there's a cycle, but doesn't mention which structs (nodes) are involved in it.
We'd like a better error that mentions the involved structs and fields.

e.g.

struct G _For_any(U);

struct F _For_any(T) {
  struct G<struct F<T> > *g;
};

struct G _For_any(T) {
  struct F<t> *f; // error: expanding cycle: G (field f), F(field g)
};

@abeln abeln changed the title TODOs for generic structs Fix TODOs for generic structs Aug 7, 2019
@abeln
Copy link
Author

abeln commented Aug 7, 2019

Improve the efficiency of ASTContext::getTypeAppsWithBase.

  /// Return all type applications that have the given generic decl as base.
  /// This is currently slow since it iterates over all cached type applications.
  /// TODO: improve its efficiency.
  std::vector<const RecordDecl *> getTypeAppsWithBase(const RecordDecl *Base);

@abeln
Copy link
Author

abeln commented Aug 7, 2019

Handle case where a struct has both a _For_any() and _Itype_for_any() specifiers (ParseDeclCXX.cpp:1650).

  // Checked C - handle generic structs.
  if (Tok.is(tok::kw__For_any)) {
    // TODO: add error handling here.
    unsigned DiagID;
    const char *PrevSpec;
    DS.setSpecForany(Tok.getLocation(), PrevSpec, DiagID);
    ParseForanySpecifier(DS);
  }

@mgrang
Copy link

mgrang commented Sep 5, 2019

@abeln Has this been fixed? If yes, please go ahead and close this bug.

@mgrang mgrang added the feature This labels new features and enhancements. label Sep 5, 2019
@abeln
Copy link
Author

abeln commented Sep 5, 2019

Nope, these are still open.

@abeln
Copy link
Author

abeln commented Sep 18, 2019

Another TODO: handle serialization and deserialization of generic structs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This labels new features and enhancements.
Projects
None yet
Development

No branches or pull requests

2 participants