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
1722
1722
1723
1723
if constexpr (std::is_base_of_v<NominalTypeDecl, DeclTy>) {
1724
1724
// 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
+ }
1727
1734
SourceRange range;
1728
1735
if (begin.isValid () && end.isValid () && D->getNameLoc ().isValid ())
1729
1736
range = SourceRange (importSourceLoc (begin), importSourceLoc (end));
@@ -1732,6 +1739,11 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
1732
1739
}
1733
1740
assert (range.isValid () == D->getNameLoc ().isValid ());
1734
1741
D->setBraces (range);
1742
+ #ifndef NDEBUG
1743
+ auto declRange = D->getSourceRange ();
1744
+ CharSourceRange checkValidRange (SwiftContext.SourceMgr , declRange.Start ,
1745
+ declRange.End );
1746
+ #endif
1735
1747
}
1736
1748
1737
1749
// SwiftAttrs on ParamDecls are interpreted by applyParamAttributes().
You can’t perform that action at this time.
0 commit comments