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