File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -672,8 +672,8 @@ class alignas(1 << DeclAlignInBits) Decl {
672
672
SourceLoc StartLoc;
673
673
SourceLoc EndLoc;
674
674
};
675
- mutable CachedExternalSourceLocs *CachedLocs = nullptr ;
676
- CachedExternalSourceLocs *calculateSerializedLocs () const ;
675
+ mutable CachedExternalSourceLocs const *CachedLocs = nullptr ;
676
+ const CachedExternalSourceLocs *calculateSerializedLocs () const ;
677
677
protected:
678
678
679
679
Decl (DeclKind kind, llvm::PointerUnion<DeclContext *, ASTContext *> context)
Original file line number Diff line number Diff line change @@ -486,14 +486,14 @@ case DeclKind::ID: return cast<ID##Decl>(this)->getLocFromSource();
486
486
llvm_unreachable (" Unknown decl kind" );
487
487
}
488
488
489
- Decl::CachedExternalSourceLocs*
490
- Decl::calculateSerializedLocs () const {
491
- auto *Result = getASTContext ().Allocate <Decl::CachedExternalSourceLocs>();
489
+ const Decl::CachedExternalSourceLocs *Decl::calculateSerializedLocs () const {
492
490
auto *File = cast<FileUnit>(getDeclContext ()->getModuleScopeContext ());
493
491
auto Locs = File->getBasicLocsForDecl (this );
494
492
if (!Locs.hasValue ()) {
495
- return Result;
493
+ static const Decl::CachedExternalSourceLocs NullLocs;
494
+ return &NullLocs;
496
495
}
496
+ auto *Result = getASTContext ().Allocate <Decl::CachedExternalSourceLocs>();
497
497
auto &SM = getASTContext ().SourceMgr ;
498
498
#define CASE (X ) \
499
499
Result->X = SM.getLocFromExternalSource (Locs->SourceFilePath , Locs->X .Line , \
You can’t perform that action at this time.
0 commit comments