mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Improve cyclic reference diagnostics for macro resolution and expansion
We are likely to debugging more cyclic references involving macros in the future, so improve the diagnostics to specify what operation we're performing (e.g., macro resolution vs. expansion of a particular kind of macro) and the macro name, when possible, so failures are easier to diagnose. No functionality change for well-formed code.
This commit is contained in:
@@ -7054,6 +7054,28 @@ ERROR(invalid_macro_role_for_macro_syntax,none,
|
||||
ERROR(macro_cannot_introduce_names,none,
|
||||
"'%0' macros are not allowed to introduce names", (StringRef))
|
||||
|
||||
ERROR(macro_resolve_circular_reference, none,
|
||||
"circular reference resolving %select{freestanding|attached}0 macro %1",
|
||||
(bool, DeclName))
|
||||
NOTE(macro_resolve_circular_reference_through, none,
|
||||
"while resolving %select{freestanding|attached}0 macro %1",
|
||||
(bool, DeclName))
|
||||
|
||||
ERROR(macro_expand_circular_reference, none,
|
||||
"circular reference expanding %0 macro %1", (StringRef, DeclName))
|
||||
NOTE(macro_expand_circular_reference_through, none,
|
||||
"circular reference expanding %0 macro %1", (StringRef, DeclName))
|
||||
|
||||
ERROR(macro_expand_circular_reference_entity, none,
|
||||
"circular reference expanding %0 macros on %1", (StringRef, DeclName))
|
||||
NOTE(macro_expand_circular_reference_entity_through, none,
|
||||
"circular reference expanding %0 macros on %1", (StringRef, DeclName))
|
||||
|
||||
ERROR(macro_expand_circular_reference_unnamed, none,
|
||||
"circular reference expanding %0 macros", (StringRef))
|
||||
NOTE(macro_expand_circular_reference_unnamed_through, none,
|
||||
"circular reference expanding %0 macros", (StringRef))
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: Move Only Errors
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -3243,6 +3243,12 @@ public:
|
||||
friend llvm::hash_code hash_value(const UnresolvedMacroReference &ref) {
|
||||
return reinterpret_cast<ptrdiff_t>(ref.pointer.getOpaqueValue());
|
||||
}
|
||||
|
||||
friend SourceLoc extractNearestSourceLoc(
|
||||
const UnresolvedMacroReference &ref
|
||||
) {
|
||||
return ref.getSigilLoc();
|
||||
}
|
||||
};
|
||||
|
||||
void simple_display(llvm::raw_ostream &out,
|
||||
@@ -3266,6 +3272,9 @@ private:
|
||||
|
||||
public:
|
||||
bool isCached() const { return true; }
|
||||
|
||||
void diagnoseCycle(DiagnosticEngine &diags) const;
|
||||
void noteCycleStep(DiagnosticEngine &diags) const;
|
||||
};
|
||||
|
||||
class ResolveTypeEraserTypeRequest
|
||||
@@ -3917,6 +3926,8 @@ private:
|
||||
|
||||
public:
|
||||
bool isCached() const { return true; }
|
||||
void diagnoseCycle(DiagnosticEngine &diags) const;
|
||||
void noteCycleStep(DiagnosticEngine &diags) const;
|
||||
};
|
||||
|
||||
/// Expand all accessor macros attached to the given declaration.
|
||||
@@ -3937,6 +3948,8 @@ private:
|
||||
|
||||
public:
|
||||
bool isCached() const { return true; }
|
||||
void diagnoseCycle(DiagnosticEngine &diags) const;
|
||||
void noteCycleStep(DiagnosticEngine &diags) const;
|
||||
};
|
||||
|
||||
/// Expand all conformance macros attached to the given declaration.
|
||||
@@ -3957,6 +3970,8 @@ private:
|
||||
|
||||
public:
|
||||
bool isCached() const { return true; }
|
||||
void diagnoseCycle(DiagnosticEngine &diags) const;
|
||||
void noteCycleStep(DiagnosticEngine &diags) const;
|
||||
};
|
||||
|
||||
/// Expand all member attribute macros attached to the given
|
||||
@@ -3977,6 +3992,8 @@ private:
|
||||
|
||||
public:
|
||||
bool isCached() const { return true; }
|
||||
void diagnoseCycle(DiagnosticEngine &diags) const;
|
||||
void noteCycleStep(DiagnosticEngine &diags) const;
|
||||
};
|
||||
|
||||
/// Expand synthesized member macros attached to the given declaration.
|
||||
@@ -3996,6 +4013,8 @@ private:
|
||||
|
||||
public:
|
||||
bool isCached() const { return true; }
|
||||
void diagnoseCycle(DiagnosticEngine &diags) const;
|
||||
void noteCycleStep(DiagnosticEngine &diags) const;
|
||||
};
|
||||
|
||||
/// Represent a loaded plugin either an in-process library or an executable.
|
||||
@@ -4050,6 +4069,8 @@ private:
|
||||
|
||||
public:
|
||||
bool isCached() const { return true; }
|
||||
void diagnoseCycle(DiagnosticEngine &diags) const;
|
||||
void noteCycleStep(DiagnosticEngine &diags) const;
|
||||
};
|
||||
|
||||
/// Resolve an external macro given its module and type name.
|
||||
|
||||
Reference in New Issue
Block a user