Addressing Doug's suggestions:
-Added comment for FunctionDecl::EndRangeLoc
-Removed a redundant check from FunctionDecl::setBody
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73886 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 77b7bf6..cfb8f94 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -647,6 +647,13 @@
// Move to DeclGroup when it is implemented.
SourceLocation TypeSpecStartLoc;
+ /// \brief End part of this FunctionDecl's source range.
+ ///
+ /// We could compute the full range in getSourceRange(). However, when we're
+ /// dealing with a function definition deserialized from a PCH/AST file,
+ /// we can only compute the full range once the function body has been
+ /// de-serialized, so it's far better to have the (sometimes-redundant)
+ /// EndRangeLoc.
SourceLocation EndRangeLoc;
/// \brief The template or declaration that this declaration
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index bf63932..1b1b4fe 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -379,7 +379,7 @@
void FunctionDecl::setBody(Stmt *B) {
Body = B;
- if (B && EndRangeLoc < B->getLocEnd())
+ if (B)
EndRangeLoc = B->getLocEnd();
}