本文整理汇总了C++中SourceLocation::isSet方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceLocation::isSet方法的具体用法?C++ SourceLocation::isSet怎么用?C++ SourceLocation::isSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceLocation
的用法示例。
在下文中一共展示了SourceLocation::isSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool
SourceManager::sameSourceId(const SourceLocation &a, const SourceLocation &b)
{
if (!a.isSet() && !b.isSet())
return true;
size_t loc_a, loc_b;
if (!findLocation(a, &loc_a) || !findLocation(b, &loc_b))
return false;
return loc_a == loc_b;
}
示例2: normalize
bool
SourceManager::areLocationsInsertedOnSameLine(const SourceLocation &aLocA,
const SourceLocation &aLocB)
{
SourceLocation a = normalize(aLocA);
SourceLocation b = normalize(aLocB);
// This can occur with builtin tokens.
if (!a.isSet() && !b.isSet())
return true;
size_t loc_a, loc_b;
if (!findLocation(a, &loc_a) || !findLocation(b, &loc_b))
return false;
if (loc_a != loc_b)
return false;
unsigned line_a = getLine(locations_[loc_a], a);
unsigned line_b = getLine(locations_[loc_b], b);
return line_a && line_b && line_a == line_b;
}
示例3: while
void
SourceManager::getTokenHistory(const SourceLocation &aLoc, TokenHistory *history)
{
SourceLocation loc = aLoc;
while (loc.isSet()) {
size_t loc_index;
if (!findLocation(loc, &loc_index))
return;
const LREntry &range = locations_[loc_index];
if (loc.isInMacro()) {
history->macros.append(FullMacroRef(range.getMacro(), loc.offset() - range.id));
} else {
history->files.append(fullSourceRef(range, loc));
}
loc = range.getParent();
}
}
示例4: assert
bool
SourceManager::findLocation(const SourceLocation &loc, size_t *aIndex)
{
if (!loc.isSet())
return false;
if (last_lookup_ < locations_.length() && locations_[last_lookup_].owns(loc)) {
*aIndex = last_lookup_;
return true;
}
// We should not allocate ids >= the next id.
assert(loc.offset() < next_source_id_);
// Binary search.
size_t lower = 0;
size_t upper = locations_.length();
while (lower < upper) {
size_t index = (lower + upper) / 2;
LREntry &range = locations_[index];
if (loc.offset() < range.id) {
upper = index;
} else if (loc.offset() > range.id + range.length() + 1) {
// Note +1 for the terminal offset.
lower = index + 1;
} else {
assert(range.owns(loc));
// Update cache.
last_lookup_ = index;
*aIndex = index;
return true;
}
}
// What happened?
assert(false);
return false;
}