diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-04-28 18:26:32 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-04-28 18:26:32 +0000 |
commit | 41e6629100664281aaf77dc20579a6d3e983149b (patch) | |
tree | 8c50affb47c0549fba98376da556880c7236878a /clang/lib/Basic/SourceManager.cpp | |
parent | 551ccac7e4d59bf0f6236b3d993d401b410e3fd9 (diff) | |
download | llvm-41e6629100664281aaf77dc20579a6d3e983149b.zip llvm-41e6629100664281aaf77dc20579a6d3e983149b.tar.gz llvm-41e6629100664281aaf77dc20579a6d3e983149b.tar.bz2 |
Fix use of uninitialized value exposed by r267802. Accessors of an invalid
PresumedLoc should not be called.
llvm-svn: 267914
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 92f473a..c2d9e58 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -1160,7 +1160,8 @@ unsigned SourceManager::getColumnNumber(FileID FID, unsigned FilePos, // isInvalid - Return the result of calling loc.isInvalid(), and // if Invalid is not null, set its value to same. -static bool isInvalid(SourceLocation Loc, bool *Invalid) { +template<typename LocType> +static bool isInvalid(LocType Loc, bool *Invalid) { bool MyInvalid = Loc.isInvalid(); if (Invalid) *Invalid = MyInvalid; @@ -1183,8 +1184,9 @@ unsigned SourceManager::getExpansionColumnNumber(SourceLocation Loc, unsigned SourceManager::getPresumedColumnNumber(SourceLocation Loc, bool *Invalid) const { - if (isInvalid(Loc, Invalid)) return 0; - return getPresumedLoc(Loc).getColumn(); + PresumedLoc PLoc = getPresumedLoc(Loc); + if (isInvalid(PLoc, Invalid)) return 0; + return PLoc.getColumn(); } #ifdef __SSE2__ |