本文整理汇总了C++中NamedDecl::getLinkage方法的典型用法代码示例。如果您正苦于以下问题:C++ NamedDecl::getLinkage方法的具体用法?C++ NamedDecl::getLinkage怎么用?C++ NamedDecl::getLinkage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamedDecl
的用法示例。
在下文中一共展示了NamedDecl::getLinkage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkUndefinedInternals
/// checkUndefinedInternals - Check for undefined objects with internal linkage.
static void checkUndefinedInternals(Sema &S) {
if (S.UndefinedInternals.empty()) return;
// Collect all the still-undefined entities with internal linkage.
SmallVector<UndefinedInternal, 16> undefined;
for (llvm::MapVector<NamedDecl*,SourceLocation>::iterator
i = S.UndefinedInternals.begin(), e = S.UndefinedInternals.end();
i != e; ++i) {
NamedDecl *decl = i->first;
// Ignore attributes that have become invalid.
if (decl->isInvalidDecl()) continue;
// If we found out that the decl is external, don't warn.
if (decl->getLinkage() == ExternalLinkage) continue;
// __attribute__((weakref)) is basically a definition.
if (decl->hasAttr<WeakRefAttr>()) continue;
if (FunctionDecl *fn = dyn_cast<FunctionDecl>(decl)) {
if (fn->isPure() || fn->hasBody())
continue;
} else {
if (cast<VarDecl>(decl)->hasDefinition() != VarDecl::DeclarationOnly)
continue;
}
S.Diag(decl->getLocation(), diag::warn_undefined_internal)
<< isa<VarDecl>(decl) << decl;
S.Diag(i->second, diag::note_used_here);
}
}
示例2: checkUndefinedButUsed
/// checkUndefinedButUsed - Check for undefined objects with internal linkage
/// or that are inline.
static void checkUndefinedButUsed(Sema &S) {
if (S.UndefinedButUsed.empty()) return;
// Collect all the still-undefined entities with internal linkage.
SmallVector<std::pair<NamedDecl *, SourceLocation>, 16> Undefined;
S.getUndefinedButUsed(Undefined);
if (Undefined.empty()) return;
for (SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> >::iterator
I = Undefined.begin(), E = Undefined.end(); I != E; ++I) {
NamedDecl *ND = I->first;
if (ND->getLinkage() != ExternalLinkage) {
S.Diag(ND->getLocation(), diag::warn_undefined_internal)
<< isa<VarDecl>(ND) << ND;
} else {
assert(cast<FunctionDecl>(ND)->getMostRecentDecl()->isInlined() &&
"used object requires definition but isn't inline or internal?");
S.Diag(ND->getLocation(), diag::warn_undefined_inline) << ND;
}
if (I->second.isValid())
S.Diag(I->second, diag::note_used_here);
}
}