diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-07 03:40:27 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-07 03:40:27 +0000 |
commit | c8f7e213b9f04664cc85f0deb66a4c9fe94ba03c (patch) | |
tree | cb41d468e377e569dd5f4af79aa88e1137d0c173 /clang/lib/Basic/SourceManager.cpp | |
parent | 2cc62093fcb335d0b6a737aac2a0e3c701e1d376 (diff) | |
download | bcm5719-llvm-c8f7e213b9f04664cc85f0deb66a4c9fe94ba03c.tar.gz bcm5719-llvm-c8f7e213b9f04664cc85f0deb66a4c9fe94ba03c.zip |
Fix bug in SourceManager::getDecomposedInstantiationLocSlowCase.
It would add up relative (decomposed) offsets like in getDecomposedSpellingLocSlowCase, but while
it makes sense to preserve the offset among lexed spelling locations, it doesn't make
sense to add anything to the offset of the instantiation location. The instantiation
location will be the same regardless of the relative offset in the tokens that were
instantiated.
This bug didn't actually affect anything because, currently, in practice we never create macro
locations with relative offset greater than 0.
llvm-svn: 134586
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 9b8d1b4bb03..d6c4c16cec7 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -749,18 +749,19 @@ SourceLocation SourceManager::getSpellingLocSlowCase(SourceLocation Loc) const { std::pair<FileID, unsigned> -SourceManager::getDecomposedInstantiationLocSlowCase(const SrcMgr::SLocEntry *E, - unsigned Offset) const { +SourceManager::getDecomposedInstantiationLocSlowCase( + const SrcMgr::SLocEntry *E) const { // If this is an instantiation record, walk through all the instantiation // points. FileID FID; SourceLocation Loc; + unsigned Offset; do { Loc = E->getInstantiation().getInstantiationLocStart(); FID = getFileID(Loc); E = &getSLocEntry(FID); - Offset += Loc.getOffset()-E->getOffset(); + Offset = Loc.getOffset()-E->getOffset(); } while (!Loc.isFileID()); return std::make_pair(FID, Offset); |