@@ -1795,3 +1795,156 @@ bool swift::operator==(MacroRoles lhs, MacroRoles rhs) {
1795
1795
llvm::hash_code swift::hash_value (MacroRoles roles) {
1796
1796
return roles.toRaw ();
1797
1797
}
1798
+
1799
+ static bool isAttachedSyntax (const UnresolvedMacroReference &ref) {
1800
+ return ref.getAttr () != nullptr ;
1801
+ }
1802
+
1803
+ void ResolveMacroRequest::diagnoseCycle (DiagnosticEngine &diags) const {
1804
+ const auto &storage = getStorage ();
1805
+ auto macroRef = std::get<0 >(storage);
1806
+ diags.diagnose (macroRef.getSigilLoc (), diag::macro_resolve_circular_reference,
1807
+ isAttachedSyntax (macroRef),
1808
+ macroRef.getMacroName ().getFullName ());
1809
+ }
1810
+
1811
+ void ResolveMacroRequest::noteCycleStep (DiagnosticEngine &diags) const {
1812
+ const auto &storage = getStorage ();
1813
+ auto macroRef = std::get<0 >(storage);
1814
+ diags.diagnose (macroRef.getSigilLoc (),
1815
+ diag::macro_resolve_circular_reference_through,
1816
+ isAttachedSyntax (macroRef),
1817
+ macroRef.getMacroName ().getFullName ());
1818
+ }
1819
+
1820
+ void ExpandMacroExpansionDeclRequest::diagnoseCycle (DiagnosticEngine &diags) const {
1821
+ auto decl = std::get<0 >(getStorage ());
1822
+ diags.diagnose (decl->getPoundLoc (),
1823
+ diag::macro_expand_circular_reference,
1824
+ " freestanding" ,
1825
+ decl->getMacroName ().getFullName ());
1826
+ }
1827
+
1828
+ void ExpandMacroExpansionDeclRequest::noteCycleStep (DiagnosticEngine &diags) const {
1829
+ auto decl = std::get<0 >(getStorage ());
1830
+ diags.diagnose (decl->getPoundLoc (),
1831
+ diag::macro_expand_circular_reference_through,
1832
+ " freestanding" ,
1833
+ decl->getMacroName ().getFullName ());
1834
+ }
1835
+
1836
+ void ExpandAccessorMacros::diagnoseCycle (DiagnosticEngine &diags) const {
1837
+ auto decl = std::get<0 >(getStorage ());
1838
+ diags.diagnose (decl->getLoc (),
1839
+ diag::macro_expand_circular_reference_entity,
1840
+ " accessor" ,
1841
+ decl->getName ());
1842
+ }
1843
+
1844
+ void ExpandAccessorMacros::noteCycleStep (DiagnosticEngine &diags) const {
1845
+ auto decl = std::get<0 >(getStorage ());
1846
+ diags.diagnose (decl->getLoc (),
1847
+ diag::macro_expand_circular_reference_entity_through,
1848
+ " accessor" ,
1849
+ decl->getName ());
1850
+ }
1851
+
1852
+ void ExpandConformanceMacros::diagnoseCycle (DiagnosticEngine &diags) const {
1853
+ auto decl = std::get<0 >(getStorage ());
1854
+ diags.diagnose (decl->getLoc (),
1855
+ diag::macro_expand_circular_reference_entity,
1856
+ " conformance" ,
1857
+ decl->getName ());
1858
+ }
1859
+
1860
+ void ExpandConformanceMacros::noteCycleStep (DiagnosticEngine &diags) const {
1861
+ auto decl = std::get<0 >(getStorage ());
1862
+ diags.diagnose (decl->getLoc (),
1863
+ diag::macro_expand_circular_reference_entity_through,
1864
+ " conformance" ,
1865
+ decl->getName ());
1866
+ }
1867
+
1868
+ void ExpandMemberAttributeMacros::diagnoseCycle (DiagnosticEngine &diags) const {
1869
+ auto decl = std::get<0 >(getStorage ());
1870
+ if (auto value = dyn_cast<ValueDecl>(decl)) {
1871
+ diags.diagnose (decl->getLoc (),
1872
+ diag::macro_expand_circular_reference_entity,
1873
+ " member attribute" ,
1874
+ value->getName ());
1875
+ } else {
1876
+ diags.diagnose (decl->getLoc (),
1877
+ diag::macro_expand_circular_reference_unnamed,
1878
+ " member attribute" );
1879
+ }
1880
+ }
1881
+
1882
+ void ExpandMemberAttributeMacros::noteCycleStep (DiagnosticEngine &diags) const {
1883
+ auto decl = std::get<0 >(getStorage ());
1884
+ if (auto value = dyn_cast<ValueDecl>(decl)) {
1885
+ diags.diagnose (decl->getLoc (),
1886
+ diag::macro_expand_circular_reference_entity_through,
1887
+ " member attribute" ,
1888
+ value->getName ());
1889
+ } else {
1890
+ diags.diagnose (decl->getLoc (),
1891
+ diag::macro_expand_circular_reference_unnamed_through,
1892
+ " member attribute" );
1893
+ }
1894
+ }
1895
+
1896
+ void ExpandSynthesizedMemberMacroRequest::diagnoseCycle (DiagnosticEngine &diags) const {
1897
+ auto decl = std::get<0 >(getStorage ());
1898
+ if (auto value = dyn_cast<ValueDecl>(decl)) {
1899
+ diags.diagnose (decl->getLoc (),
1900
+ diag::macro_expand_circular_reference_entity,
1901
+ " member" ,
1902
+ value->getName ());
1903
+ } else {
1904
+ diags.diagnose (decl->getLoc (),
1905
+ diag::macro_expand_circular_reference_unnamed,
1906
+ " member" );
1907
+ }
1908
+ }
1909
+
1910
+ void ExpandSynthesizedMemberMacroRequest::noteCycleStep (DiagnosticEngine &diags) const {
1911
+ auto decl = std::get<0 >(getStorage ());
1912
+ if (auto value = dyn_cast<ValueDecl>(decl)) {
1913
+ diags.diagnose (decl->getLoc (),
1914
+ diag::macro_expand_circular_reference_entity_through,
1915
+ " member" ,
1916
+ value->getName ());
1917
+ } else {
1918
+ diags.diagnose (decl->getLoc (),
1919
+ diag::macro_expand_circular_reference_unnamed_through,
1920
+ " member" );
1921
+ }
1922
+ }
1923
+
1924
+ void ExpandPeerMacroRequest::diagnoseCycle (DiagnosticEngine &diags) const {
1925
+ auto decl = std::get<0 >(getStorage ());
1926
+ if (auto value = dyn_cast<ValueDecl>(decl)) {
1927
+ diags.diagnose (decl->getLoc (),
1928
+ diag::macro_expand_circular_reference_entity,
1929
+ " peer" ,
1930
+ value->getName ());
1931
+ } else {
1932
+ diags.diagnose (decl->getLoc (),
1933
+ diag::macro_expand_circular_reference_unnamed,
1934
+ " peer" );
1935
+ }
1936
+ }
1937
+
1938
+ void ExpandPeerMacroRequest::noteCycleStep (DiagnosticEngine &diags) const {
1939
+ auto decl = std::get<0 >(getStorage ());
1940
+ if (auto value = dyn_cast<ValueDecl>(decl)) {
1941
+ diags.diagnose (decl->getLoc (),
1942
+ diag::macro_expand_circular_reference_entity_through,
1943
+ " peer" ,
1944
+ value->getName ());
1945
+ } else {
1946
+ diags.diagnose (decl->getLoc (),
1947
+ diag::macro_expand_circular_reference_unnamed_through,
1948
+ " peer" );
1949
+ }
1950
+ }
0 commit comments