summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReader.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-22 21:17:02 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-09-22 21:17:02 +0000
commite523e389b2a2a91fde6c5e317ca0fcd4eef3cccd (patch)
treef7d8370ae31da706cbefe4de2df3308ae29b0e89 /clang/lib/Serialization/ASTReader.cpp
parent8c4b716352b4f8b848b426ce3068b58590e9ce55 (diff)
downloadbcm5719-llvm-e523e389b2a2a91fde6c5e317ca0fcd4eef3cccd.tar.gz
bcm5719-llvm-e523e389b2a2a91fde6c5e317ca0fcd4eef3cccd.zip
Do manual binary search for preprocessing entities because their end locations
may be unordered and MSVC's debug-mode doesn't like it. llvm-svn: 140337
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index 5f489d40678..f83f709ebef 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2947,9 +2947,28 @@ ASTReader::findBeginPreprocessedEntity(SourceLocation BLoc) const {
typedef const PPEntityOffset *pp_iterator;
pp_iterator pp_begin = M.PreprocessedEntityOffsets;
pp_iterator pp_end = pp_begin + M.NumPreprocessedEntities;
- pp_iterator PPI =
- std::lower_bound(pp_begin, pp_end, BLoc,
- PPEntityComp<&PPEntityOffset::End>(*this, M));
+
+ size_t Count = M.NumPreprocessedEntities;
+ size_t Half;
+ pp_iterator First = pp_begin;
+ pp_iterator PPI;
+
+ // Do a binary search manually instead of using std::lower_bound because
+ // The end locations of entities may be unordered (when a macro expansion
+ // is inside another macro argument), but for this case it is not important
+ // whether we get the first macro expansion or its containing macro.
+ while (Count > 0) {
+ Half = Count/2;
+ PPI = First;
+ std::advance(PPI, Half);
+ if (SourceMgr.isBeforeInTranslationUnit(ReadSourceLocation(M, PPI->End),
+ BLoc)){
+ First = PPI;
+ ++First;
+ Count = Count - Half - 1;
+ } else
+ Count = Half;
+ }
if (PPI == pp_end)
return findNextPreprocessedEntity(SLocMapI);
OpenPOWER on IntegriCloud