File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1722,8 +1722,15 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
17221722
17231723 if constexpr (std::is_base_of_v<NominalTypeDecl, DeclTy>) {
17241724 // Estimate brace locations.
1725- auto begin = ClangN.getAsDecl ()->getBeginLoc ();
1726- auto end = ClangN.getAsDecl ()->getEndLoc ();
1725+ clang::SourceLocation begin;
1726+ clang::SourceLocation end;
1727+ if (auto *td = dyn_cast_or_null<clang::TagDecl>(ClangN.getAsDecl ())) {
1728+ begin = td->getBraceRange ().getBegin ();
1729+ end = td->getBraceRange ().getEnd ();
1730+ } else {
1731+ begin = ClangN.getAsDecl ()->getBeginLoc ();
1732+ end = ClangN.getAsDecl ()->getEndLoc ();
1733+ }
17271734 SourceRange range;
17281735 if (begin.isValid () && end.isValid () && D->getNameLoc ().isValid ())
17291736 range = SourceRange (importSourceLoc (begin), importSourceLoc (end));
@@ -1732,6 +1739,11 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
17321739 }
17331740 assert (range.isValid () == D->getNameLoc ().isValid ());
17341741 D->setBraces (range);
1742+ #ifndef NDEBUG
1743+ auto declRange = D->getSourceRange ();
1744+ CharSourceRange checkValidRange (SwiftContext.SourceMgr , declRange.Start ,
1745+ declRange.End );
1746+ #endif
17351747 }
17361748
17371749 // SwiftAttrs on ParamDecls are interpreted by applyParamAttributes().
You can’t perform that action at this time.
0 commit comments