summaryrefslogtreecommitdiffstats
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index bf63932..71e88a9 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -379,7 +379,7 @@ Stmt *FunctionDecl::getBodyIfAvailable() const {
void FunctionDecl::setBody(Stmt *B) {
Body = B;
- if (B && EndRangeLoc < B->getLocEnd())
+ if (B)
EndRangeLoc = B->getLocEnd();
}
@@ -494,8 +494,9 @@ void FunctionDecl::setParams(ASTContext& C, ParmVarDecl **NewParamInfo,
ParamInfo = new (Mem) ParmVarDecl*[NumParams];
memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
- // Update source range.
- if (EndRangeLoc < NewParamInfo[NumParams-1]->getLocEnd())
+ // Update source range. The check below allows us to set EndRangeLoc before
+ // setting the parameters.
+ if (EndRangeLoc.isInvalid() || EndRangeLoc == getLocation())
EndRangeLoc = NewParamInfo[NumParams-1]->getLocEnd();
}
}
OpenPOWER on IntegriCloud