summaryrefslogtreecommitdiffstats
path: root/clang/include/clang/Lex/Token.h
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-03-19 00:10:23 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-03-19 00:10:23 +0000
commita8f2f1da999b7ef1e5e16ec539164106018cb431 (patch)
tree3fb09db2219818be070e2ac0f27abc37acfbec3d /clang/include/clang/Lex/Token.h
parentcfb53e49b6962f314d7a153d7d940d9aff291274 (diff)
downloadbcm5719-llvm-a8f2f1da999b7ef1e5e16ec539164106018cb431.tar.gz
bcm5719-llvm-a8f2f1da999b7ef1e5e16ec539164106018cb431.zip
Parse: Don't assume tokens have a length
Don't crash if the last token in a bad inline method body is an annotation token. llvm-svn: 232694
Diffstat (limited to 'clang/include/clang/Lex/Token.h')
-rw-r--r--clang/include/clang/Lex/Token.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/include/clang/Lex/Token.h b/clang/include/clang/Lex/Token.h
index 8617c67b321..e0878093402 100644
--- a/clang/include/clang/Lex/Token.h
+++ b/clang/include/clang/Lex/Token.h
@@ -130,7 +130,7 @@ public:
SourceLocation getAnnotationEndLoc() const {
assert(isAnnotation() && "Used AnnotEndLocID on non-annotation token");
- return SourceLocation::getFromRawEncoding(UintData);
+ return SourceLocation::getFromRawEncoding(UintData ? UintData : Loc);
}
void setAnnotationEndLoc(SourceLocation L) {
assert(isAnnotation() && "Used AnnotEndLocID on non-annotation token");
@@ -141,6 +141,11 @@ public:
return isAnnotation() ? getAnnotationEndLoc() : getLocation();
}
+ SourceLocation getEndLoc() const {
+ return isAnnotation() ? getAnnotationEndLoc()
+ : getLocation().getLocWithOffset(getLength());
+ }
+
/// \brief SourceRange of the group of tokens that this annotation token
/// represents.
SourceRange getAnnotationRange() const {
OpenPOWER on IntegriCloud