forked from OSchip/llvm-project
When 'bool' is not a built-in type but is defined as a macro, print
'bool' rather than '_Bool' within types, to make things a bit more readable. Fixes <rdar://problem/10063263>. llvm-svn: 140650
This commit is contained in:
parent
ac8dbf0fc7
commit
c0b07286cf
|
@ -342,6 +342,8 @@ class ASTContext : public llvm::RefCountedBase<ASTContext> {
|
|||
friend class ASTWriter;
|
||||
|
||||
const TargetInfo *Target;
|
||||
mutable clang::PrintingPolicy PrintingPolicy;
|
||||
|
||||
public:
|
||||
IdentifierTable &Idents;
|
||||
SelectorTable &Selectors;
|
||||
|
@ -349,8 +351,9 @@ public:
|
|||
mutable DeclarationNameTable DeclarationNames;
|
||||
llvm::OwningPtr<ExternalASTSource> ExternalSource;
|
||||
ASTMutationListener *Listener;
|
||||
clang::PrintingPolicy PrintingPolicy;
|
||||
|
||||
clang::PrintingPolicy getPrintingPolicy() const;
|
||||
|
||||
SourceManager& getSourceManager() { return SourceMgr; }
|
||||
const SourceManager& getSourceManager() const { return SourceMgr; }
|
||||
void *Allocate(unsigned Size, unsigned Align = 8) const {
|
||||
|
|
|
@ -38,7 +38,8 @@ struct PrintingPolicy {
|
|||
SuppressTagKeyword(false), SuppressTag(false), SuppressScope(false),
|
||||
SuppressInitializers(false),
|
||||
Dump(false), ConstantArraySizeAsWritten(false),
|
||||
AnonymousTagLocations(true), SuppressStrongLifetime(false) { }
|
||||
AnonymousTagLocations(true), SuppressStrongLifetime(false),
|
||||
Bool(LO.Bool) { }
|
||||
|
||||
/// \brief The number of spaces to use to indent each line.
|
||||
unsigned Indentation : 8;
|
||||
|
@ -130,6 +131,10 @@ struct PrintingPolicy {
|
|||
/// \brief When true, suppress printing of the __strong lifetime qualifier in
|
||||
/// ARC.
|
||||
unsigned SuppressStrongLifetime : 1;
|
||||
|
||||
/// \brief Whether we can use 'bool' rather than '_Bool', even if the language
|
||||
/// doesn't actually have 'bool' (because, e.g., it is defined as a macro).
|
||||
unsigned Bool : 1;
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
|
|
|
@ -1759,7 +1759,7 @@ public:
|
|||
}
|
||||
|
||||
Kind getKind() const { return static_cast<Kind>(BuiltinTypeBits.Kind); }
|
||||
const char *getName(const LangOptions &LO) const;
|
||||
const char *getName(const PrintingPolicy &Policy) const;
|
||||
|
||||
bool isSugared() const { return false; }
|
||||
QualType desugar() const { return QualType(this, 0); }
|
||||
|
|
|
@ -182,7 +182,7 @@ private:
|
|||
llvm::SmallString<128> newCast;
|
||||
newCast += '(';
|
||||
newCast += bridge;
|
||||
newCast += E->getType().getAsString(Pass.Ctx.PrintingPolicy);
|
||||
newCast += E->getType().getAsString(Pass.Ctx.getPrintingPolicy());
|
||||
newCast += ')';
|
||||
|
||||
if (isa<ParenExpr>(E->getSubExpr())) {
|
||||
|
@ -215,7 +215,7 @@ private:
|
|||
|
||||
if (family == OMF_autorelease || family == OMF_release) {
|
||||
std::string err = "it is not safe to cast to '";
|
||||
err += E->getType().getAsString(Pass.Ctx.PrintingPolicy);
|
||||
err += E->getType().getAsString(Pass.Ctx.getPrintingPolicy());
|
||||
err += "' the result of '";
|
||||
err += family == OMF_autorelease ? "autorelease" : "release";
|
||||
err += "' message; a __bridge cast may result in a pointer to a "
|
||||
|
@ -230,7 +230,7 @@ private:
|
|||
if (ReturnStmt *retS = dyn_cast_or_null<ReturnStmt>(parent)) {
|
||||
std::string note = "remove the cast and change return type of function "
|
||||
"to '";
|
||||
note += E->getSubExpr()->getType().getAsString(Pass.Ctx.PrintingPolicy);
|
||||
note += E->getSubExpr()->getType().getAsString(Pass.Ctx.getPrintingPolicy());
|
||||
note += "' to have the object automatically autoreleased";
|
||||
Pass.TA.reportNote(note, retS->getLocStart());
|
||||
}
|
||||
|
|
|
@ -231,11 +231,11 @@ ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM,
|
|||
BlockDescriptorExtendedType(0), cudaConfigureCallDecl(0),
|
||||
NullTypeSourceInfo(QualType()),
|
||||
SourceMgr(SM), LangOpts(LOpts),
|
||||
AddrSpaceMap(0), Target(t),
|
||||
AddrSpaceMap(0), Target(t), PrintingPolicy(LOpts),
|
||||
Idents(idents), Selectors(sels),
|
||||
BuiltinInfo(builtins),
|
||||
DeclarationNames(*this),
|
||||
ExternalSource(0), Listener(0), PrintingPolicy(LOpts),
|
||||
ExternalSource(0), Listener(0),
|
||||
LastSDM(0, 0),
|
||||
UniqueBlockByRefTypeID(0)
|
||||
{
|
||||
|
@ -4385,7 +4385,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
|
|||
= TemplateSpecializationType::PrintTemplateArgumentList(
|
||||
TemplateArgs.data(),
|
||||
TemplateArgs.size(),
|
||||
(*this).PrintingPolicy);
|
||||
(*this).getPrintingPolicy());
|
||||
|
||||
S += TemplateArgsStr;
|
||||
}
|
||||
|
@ -6475,6 +6475,12 @@ MangleContext *ASTContext::createMangleContext() {
|
|||
|
||||
CXXABI::~CXXABI() {}
|
||||
|
||||
PrintingPolicy ASTContext::getPrintingPolicy() const {
|
||||
PrintingPolicy.Bool
|
||||
= LangOpts.Bool || Idents.get("bool").hasMacroDefinition();
|
||||
return PrintingPolicy;
|
||||
}
|
||||
|
||||
size_t ASTContext::getSideTableAllocatedMemory() const {
|
||||
return ASTRecordLayouts.getMemorySize()
|
||||
+ llvm::capacity_in_bytes(ObjCLayouts)
|
||||
|
|
|
@ -158,8 +158,8 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty,
|
|||
// FIXME: Playing with std::string is really slow.
|
||||
bool ForceAKA = false;
|
||||
QualType CanTy = Ty.getCanonicalType();
|
||||
std::string S = Ty.getAsString(Context.PrintingPolicy);
|
||||
std::string CanS = CanTy.getAsString(Context.PrintingPolicy);
|
||||
std::string S = Ty.getAsString(Context.getPrintingPolicy());
|
||||
std::string CanS = CanTy.getAsString(Context.getPrintingPolicy());
|
||||
|
||||
for (SmallVectorImpl<intptr_t>::iterator I = QualTypeVals.begin(),
|
||||
E = QualTypeVals.end(); I != E; ++I) {
|
||||
|
@ -170,10 +170,10 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty,
|
|||
QualType CompareCanTy = CompareTy.getCanonicalType();
|
||||
if (CompareCanTy == CanTy)
|
||||
continue; // Same canonical types
|
||||
std::string CompareS = CompareTy.getAsString(Context.PrintingPolicy);
|
||||
std::string CompareS = CompareTy.getAsString(Context.getPrintingPolicy());
|
||||
if (CompareS != S)
|
||||
continue; // Original strings are different
|
||||
std::string CompareCanS = CompareCanTy.getAsString(Context.PrintingPolicy);
|
||||
std::string CompareCanS = CompareCanTy.getAsString(Context.getPrintingPolicy());
|
||||
if (CompareCanS == CanS)
|
||||
continue; // No new info from canonical type
|
||||
|
||||
|
@ -205,7 +205,7 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty,
|
|||
if (DesugaredTy == Ty) {
|
||||
DesugaredTy = Ty.getCanonicalType();
|
||||
}
|
||||
std::string akaStr = DesugaredTy.getAsString(Context.PrintingPolicy);
|
||||
std::string akaStr = DesugaredTy.getAsString(Context.getPrintingPolicy());
|
||||
if (akaStr != S) {
|
||||
S = "'" + S + "' (aka '" + akaStr + "')";
|
||||
return S;
|
||||
|
@ -270,13 +270,13 @@ void clang::FormatASTNodeDiagnosticArgument(
|
|||
Qualified = false;
|
||||
}
|
||||
const NamedDecl *ND = reinterpret_cast<const NamedDecl*>(Val);
|
||||
ND->getNameForDiagnostic(S, Context.PrintingPolicy, Qualified);
|
||||
ND->getNameForDiagnostic(S, Context.getPrintingPolicy(), Qualified);
|
||||
break;
|
||||
}
|
||||
case DiagnosticsEngine::ak_nestednamespec: {
|
||||
llvm::raw_string_ostream OS(S);
|
||||
reinterpret_cast<NestedNameSpecifier*>(Val)->print(OS,
|
||||
Context.PrintingPolicy);
|
||||
Context.getPrintingPolicy());
|
||||
NeedQuotes = false;
|
||||
break;
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ void clang::FormatASTNodeDiagnosticArgument(
|
|||
S += "function ";
|
||||
|
||||
S += "'";
|
||||
ND->getNameForDiagnostic(S, Context.PrintingPolicy, true);
|
||||
ND->getNameForDiagnostic(S, Context.getPrintingPolicy(), true);
|
||||
S += "'";
|
||||
}
|
||||
NeedQuotes = false;
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace {
|
|||
|
||||
void Decl::print(raw_ostream &Out, unsigned Indentation,
|
||||
bool PrintInstantiation) const {
|
||||
print(Out, getASTContext().PrintingPolicy, Indentation, PrintInstantiation);
|
||||
print(Out, getASTContext().getPrintingPolicy(), Indentation, PrintInstantiation);
|
||||
}
|
||||
|
||||
void Decl::print(raw_ostream &Out, const PrintingPolicy &Policy,
|
||||
|
@ -168,7 +168,7 @@ void DeclContext::dumpDeclContext() const {
|
|||
DC = DC->getParent();
|
||||
|
||||
ASTContext &Ctx = cast<TranslationUnitDecl>(DC)->getASTContext();
|
||||
DeclPrinter Printer(llvm::errs(), Ctx, Ctx.PrintingPolicy, 0);
|
||||
DeclPrinter Printer(llvm::errs(), Ctx, Ctx.getPrintingPolicy(), 0);
|
||||
Printer.VisitDeclContext(const_cast<DeclContext *>(this), /*Indent=*/false);
|
||||
}
|
||||
|
||||
|
|
|
@ -1467,10 +1467,10 @@ const char *Type::getTypeClassName() const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char *BuiltinType::getName(const LangOptions &LO) const {
|
||||
const char *BuiltinType::getName(const PrintingPolicy &Policy) const {
|
||||
switch (getKind()) {
|
||||
case Void: return "void";
|
||||
case Bool: return LO.Bool ? "bool" : "_Bool";
|
||||
case Bool: return Policy.Bool ? "bool" : "_Bool";
|
||||
case Char_S: return "char";
|
||||
case Char_U: return "char";
|
||||
case SChar: return "signed char";
|
||||
|
|
|
@ -205,11 +205,11 @@ void TypePrinter::print(const Type *T, Qualifiers Quals, std::string &buffer) {
|
|||
|
||||
void TypePrinter::printBuiltin(const BuiltinType *T, std::string &S) {
|
||||
if (S.empty()) {
|
||||
S = T->getName(Policy.LangOpts);
|
||||
S = T->getName(Policy);
|
||||
} else {
|
||||
// Prefix the basic type, e.g. 'int X'.
|
||||
S = ' ' + S;
|
||||
S = T->getName(Policy.LangOpts) + S;
|
||||
S = T->getName(Policy) + S;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace {
|
|||
: Out(o? *o : llvm::outs()), Dump(Dump) { }
|
||||
|
||||
virtual void HandleTranslationUnit(ASTContext &Context) {
|
||||
PrintingPolicy Policy = Context.PrintingPolicy;
|
||||
PrintingPolicy Policy = Context.getPrintingPolicy();
|
||||
Policy.Dump = Dump;
|
||||
Context.getTranslationUnitDecl()->print(Out, Policy, /*Indentation=*/0,
|
||||
/*PrintInstantiation=*/true);
|
||||
|
|
|
@ -854,7 +854,7 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
|||
for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) {
|
||||
if (i) Getr += ", ";
|
||||
std::string ParamStr = FT->getArgType(i).getAsString(
|
||||
Context->PrintingPolicy);
|
||||
Context->getPrintingPolicy());
|
||||
Getr += ParamStr;
|
||||
}
|
||||
if (FT->isVariadic()) {
|
||||
|
@ -1088,11 +1088,11 @@ void RewriteObjC::RewriteTypeIntoString(QualType T, std::string &ResultStr,
|
|||
PointeeTy = BPT->getPointeeType();
|
||||
if ((FPRetType = PointeeTy->getAs<FunctionType>())) {
|
||||
ResultStr += FPRetType->getResultType().getAsString(
|
||||
Context->PrintingPolicy);
|
||||
Context->getPrintingPolicy());
|
||||
ResultStr += "(*";
|
||||
}
|
||||
} else
|
||||
ResultStr += T.getAsString(Context->PrintingPolicy);
|
||||
ResultStr += T.getAsString(Context->getPrintingPolicy());
|
||||
}
|
||||
|
||||
void RewriteObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl,
|
||||
|
@ -1150,10 +1150,10 @@ void RewriteObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl,
|
|||
}
|
||||
else
|
||||
ResultStr += Context->getObjCClassType().getAsString(
|
||||
Context->PrintingPolicy);
|
||||
Context->getPrintingPolicy());
|
||||
|
||||
ResultStr += " self, ";
|
||||
ResultStr += Context->getObjCSelType().getAsString(Context->PrintingPolicy);
|
||||
ResultStr += Context->getObjCSelType().getAsString(Context->getPrintingPolicy());
|
||||
ResultStr += " _cmd";
|
||||
|
||||
// Method arguments.
|
||||
|
@ -1169,9 +1169,9 @@ void RewriteObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl,
|
|||
QualType QT = PDecl->getType();
|
||||
// Make sure we convert "t (^)(...)" to "t (*)(...)".
|
||||
if (convertBlockPointerToFunctionPointer(QT))
|
||||
QT.getAsStringInternal(Name, Context->PrintingPolicy);
|
||||
QT.getAsStringInternal(Name, Context->getPrintingPolicy());
|
||||
else
|
||||
PDecl->getType().getAsStringInternal(Name, Context->PrintingPolicy);
|
||||
PDecl->getType().getAsStringInternal(Name, Context->getPrintingPolicy());
|
||||
ResultStr += Name;
|
||||
}
|
||||
}
|
||||
|
@ -1188,7 +1188,7 @@ void RewriteObjC::RewriteObjCMethodDecl(const ObjCInterfaceDecl *IDecl,
|
|||
for (unsigned i = 0, e = FT->getNumArgs(); i != e; ++i) {
|
||||
if (i) ResultStr += ", ";
|
||||
std::string ParamStr = FT->getArgType(i).getAsString(
|
||||
Context->PrintingPolicy);
|
||||
Context->getPrintingPolicy());
|
||||
ResultStr += ParamStr;
|
||||
}
|
||||
if (FT->isVariadic()) {
|
||||
|
@ -1675,7 +1675,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
|
|||
// Simply use 'id' for all qualified types.
|
||||
elementTypeAsString = "id";
|
||||
else
|
||||
elementTypeAsString = ElementType.getAsString(Context->PrintingPolicy);
|
||||
elementTypeAsString = ElementType.getAsString(Context->getPrintingPolicy());
|
||||
buf += elementTypeAsString;
|
||||
buf += " ";
|
||||
elementName = D->getName();
|
||||
|
@ -1691,7 +1691,7 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
|
|||
// Simply use 'id' for all qualified types.
|
||||
elementTypeAsString = "id";
|
||||
else
|
||||
elementTypeAsString = VD->getType().getAsString(Context->PrintingPolicy);
|
||||
elementTypeAsString = VD->getType().getAsString(Context->getPrintingPolicy());
|
||||
}
|
||||
|
||||
// struct __objcFastEnumerationState enumState = { 0 };
|
||||
|
@ -2387,7 +2387,7 @@ void RewriteObjC::RewriteTypeOfDecl(VarDecl *ND) {
|
|||
}
|
||||
// FIXME. This will not work for multiple declarators; as in:
|
||||
// __typeof__(a) b,c,d;
|
||||
std::string TypeAsString(QT.getAsString(Context->PrintingPolicy));
|
||||
std::string TypeAsString(QT.getAsString(Context->getPrintingPolicy()));
|
||||
SourceLocation DeclLoc = ND->getTypeSpecStartLoc();
|
||||
const char *startBuf = SM->getCharacterData(DeclLoc);
|
||||
if (ND->getInit()) {
|
||||
|
@ -2437,7 +2437,7 @@ void RewriteObjC::RewriteFunctionDecl(FunctionDecl *FD) {
|
|||
}
|
||||
|
||||
void RewriteObjC::RewriteBlockPointerType(std::string& Str, QualType Type) {
|
||||
std::string TypeString(Type.getAsString(Context->PrintingPolicy));
|
||||
std::string TypeString(Type.getAsString(Context->getPrintingPolicy()));
|
||||
const char *argPtr = TypeString.c_str();
|
||||
if (!strchr(argPtr, '^')) {
|
||||
Str += TypeString;
|
||||
|
@ -2453,7 +2453,7 @@ void RewriteObjC::RewriteBlockPointerType(std::string& Str, QualType Type) {
|
|||
void RewriteObjC::RewriteBlockPointerTypeVariable(std::string& Str,
|
||||
ValueDecl *VD) {
|
||||
QualType Type = VD->getType();
|
||||
std::string TypeString(Type.getAsString(Context->PrintingPolicy));
|
||||
std::string TypeString(Type.getAsString(Context->getPrintingPolicy()));
|
||||
const char *argPtr = TypeString.c_str();
|
||||
int paren = 0;
|
||||
while (*argPtr) {
|
||||
|
@ -2487,7 +2487,7 @@ void RewriteObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) {
|
|||
if (!proto)
|
||||
return;
|
||||
QualType Type = proto->getResultType();
|
||||
std::string FdStr = Type.getAsString(Context->PrintingPolicy);
|
||||
std::string FdStr = Type.getAsString(Context->getPrintingPolicy());
|
||||
FdStr += " ";
|
||||
FdStr += FD->getName();
|
||||
FdStr += "(";
|
||||
|
@ -4235,7 +4235,7 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
|
|||
const FunctionType *AFT = CE->getFunctionType();
|
||||
QualType RT = AFT->getResultType();
|
||||
std::string StructRef = "struct " + Tag;
|
||||
std::string S = "static " + RT.getAsString(Context->PrintingPolicy) + " __" +
|
||||
std::string S = "static " + RT.getAsString(Context->getPrintingPolicy()) + " __" +
|
||||
funcName.str() + "_" + "block_func_" + utostr(i);
|
||||
|
||||
BlockDecl *BD = CE->getBlockDecl();
|
||||
|
@ -4259,9 +4259,9 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
|
|||
ParamStr = (*AI)->getNameAsString();
|
||||
QualType QT = (*AI)->getType();
|
||||
if (convertBlockPointerToFunctionPointer(QT))
|
||||
QT.getAsStringInternal(ParamStr, Context->PrintingPolicy);
|
||||
QT.getAsStringInternal(ParamStr, Context->getPrintingPolicy());
|
||||
else
|
||||
QT.getAsStringInternal(ParamStr, Context->PrintingPolicy);
|
||||
QT.getAsStringInternal(ParamStr, Context->getPrintingPolicy());
|
||||
S += ParamStr;
|
||||
}
|
||||
if (FT->isVariadic()) {
|
||||
|
@ -4310,7 +4310,7 @@ std::string RewriteObjC::SynthesizeBlockFunc(BlockExpr *CE, int i,
|
|||
QualType QT = (*I)->getType();
|
||||
if (HasLocalVariableExternalStorage(*I))
|
||||
QT = Context->getPointerType(QT);
|
||||
QT.getAsStringInternal(Name, Context->PrintingPolicy);
|
||||
QT.getAsStringInternal(Name, Context->getPrintingPolicy());
|
||||
S += Name + " = __cself->" +
|
||||
(*I)->getNameAsString() + "; // bound by copy\n";
|
||||
}
|
||||
|
@ -4408,8 +4408,8 @@ std::string RewriteObjC::SynthesizeBlockImpl(BlockExpr *CE, std::string Tag,
|
|||
QualType QT = (*I)->getType();
|
||||
if (HasLocalVariableExternalStorage(*I))
|
||||
QT = Context->getPointerType(QT);
|
||||
QT.getAsStringInternal(FieldName, Context->PrintingPolicy);
|
||||
QT.getAsStringInternal(ArgName, Context->PrintingPolicy);
|
||||
QT.getAsStringInternal(FieldName, Context->getPrintingPolicy());
|
||||
QT.getAsStringInternal(ArgName, Context->getPrintingPolicy());
|
||||
Constructor += ", " + ArgName;
|
||||
}
|
||||
S += FieldName + ";\n";
|
||||
|
@ -5222,7 +5222,7 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) {
|
|||
|
||||
QualType T = Ty;
|
||||
(void)convertBlockPointerToFunctionPointer(T);
|
||||
T.getAsStringInternal(Name, Context->PrintingPolicy);
|
||||
T.getAsStringInternal(Name, Context->getPrintingPolicy());
|
||||
|
||||
ByrefType += " " + Name + ";\n";
|
||||
ByrefType += "};\n";
|
||||
|
|
|
@ -2140,7 +2140,7 @@ void Sema::CheckStrlcpycatArguments(const CallExpr *Call,
|
|||
llvm::SmallString<128> sizeString;
|
||||
llvm::raw_svector_ostream OS(sizeString);
|
||||
OS << "sizeof(";
|
||||
DstArg->printPretty(OS, Context, 0, Context.PrintingPolicy);
|
||||
DstArg->printPretty(OS, Context, 0, Context.getPrintingPolicy());
|
||||
OS << ")";
|
||||
|
||||
Diag(OriginalSizeArg->getLocStart(), diag::note_strlcpycat_wrong_size)
|
||||
|
|
|
@ -1840,6 +1840,14 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC,
|
|||
Results.AddResult(Result("operator"));
|
||||
}
|
||||
|
||||
/// \brief Retrieve a printing policy suitable for code completion.
|
||||
static PrintingPolicy getCompletionPrintingPolicy(ASTContext &Context) {
|
||||
PrintingPolicy Policy(Context.getPrintingPolicy());
|
||||
Policy.AnonymousTagLocations = false;
|
||||
Policy.SuppressStrongLifetime = true;
|
||||
return Policy;
|
||||
}
|
||||
|
||||
/// \brief Retrieve the string representation of the given type as a string
|
||||
/// that has the appropriate lifetime for code completion.
|
||||
///
|
||||
|
@ -1848,14 +1856,12 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC,
|
|||
static const char *GetCompletionTypeString(QualType T,
|
||||
ASTContext &Context,
|
||||
CodeCompletionAllocator &Allocator) {
|
||||
PrintingPolicy Policy(Context.PrintingPolicy);
|
||||
Policy.AnonymousTagLocations = false;
|
||||
Policy.SuppressStrongLifetime = true;
|
||||
PrintingPolicy Policy = getCompletionPrintingPolicy(Context);
|
||||
|
||||
if (!T.getLocalQualifiers()) {
|
||||
// Built-in type names are constant strings.
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(T))
|
||||
return BT->getName(Context.getLangOptions());
|
||||
return BT->getName(Policy);
|
||||
|
||||
// Anonymous tag types are constant strings.
|
||||
if (const TagType *TagT = dyn_cast<TagType>(T))
|
||||
|
@ -1952,10 +1958,7 @@ static std::string formatObjCParamQualifiers(unsigned ObjCQuals) {
|
|||
static std::string FormatFunctionParameter(ASTContext &Context,
|
||||
ParmVarDecl *Param,
|
||||
bool SuppressName = false) {
|
||||
PrintingPolicy Policy(Context.PrintingPolicy);
|
||||
Policy.AnonymousTagLocations = false;
|
||||
Policy.SuppressStrongLifetime = true;
|
||||
|
||||
PrintingPolicy Policy = getCompletionPrintingPolicy(Context);
|
||||
bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->getDeclContext());
|
||||
if (Param->getType()->isDependentType() ||
|
||||
!Param->getType()->isBlockPointerType()) {
|
||||
|
@ -2118,8 +2121,7 @@ static void AddTemplateParameterChunks(ASTContext &Context,
|
|||
unsigned MaxParameters = 0,
|
||||
unsigned Start = 0,
|
||||
bool InDefaultArg = false) {
|
||||
PrintingPolicy Policy(Context.PrintingPolicy);
|
||||
Policy.AnonymousTagLocations = false;
|
||||
PrintingPolicy Policy = getCompletionPrintingPolicy(Context);
|
||||
|
||||
typedef CodeCompletionString::Chunk Chunk;
|
||||
bool FirstParameter = true;
|
||||
|
@ -2203,7 +2205,7 @@ AddQualifierToCompletionString(CodeCompletionBuilder &Result,
|
|||
std::string PrintedNNS;
|
||||
{
|
||||
llvm::raw_string_ostream OS(PrintedNNS);
|
||||
Qualifier->print(OS, Context.PrintingPolicy);
|
||||
Qualifier->print(OS, getCompletionPrintingPolicy(Context));
|
||||
}
|
||||
if (QualifierIsInformative)
|
||||
Result.AddInformativeChunk(Result.getAllocator().CopyString(PrintedNNS));
|
||||
|
@ -2335,10 +2337,7 @@ CodeCompletionResult::CreateCodeCompletionString(Sema &S,
|
|||
typedef CodeCompletionString::Chunk Chunk;
|
||||
CodeCompletionBuilder Result(Allocator, Priority, Availability);
|
||||
|
||||
PrintingPolicy Policy(S.Context.PrintingPolicy);
|
||||
Policy.AnonymousTagLocations = false;
|
||||
Policy.SuppressStrongLifetime = true;
|
||||
|
||||
PrintingPolicy Policy = getCompletionPrintingPolicy(S.Context);
|
||||
if (Kind == RK_Pattern) {
|
||||
Pattern->Priority = Priority;
|
||||
Pattern->Availability = Availability;
|
||||
|
@ -2590,9 +2589,7 @@ CodeCompleteConsumer::OverloadCandidate::CreateSignatureString(
|
|||
Sema &S,
|
||||
CodeCompletionAllocator &Allocator) const {
|
||||
typedef CodeCompletionString::Chunk Chunk;
|
||||
PrintingPolicy Policy(S.Context.PrintingPolicy);
|
||||
Policy.AnonymousTagLocations = false;
|
||||
Policy.SuppressStrongLifetime = true;
|
||||
PrintingPolicy Policy = getCompletionPrintingPolicy(S.Context);
|
||||
|
||||
// FIXME: Set priority, availability appropriately.
|
||||
CodeCompletionBuilder Result(Allocator, 1, CXAvailability_Available);
|
||||
|
@ -2900,7 +2897,7 @@ static void MaybeAddOverrideCalls(Sema &S, DeclContext *InContext,
|
|||
if (NNS) {
|
||||
std::string Str;
|
||||
llvm::raw_string_ostream OS(Str);
|
||||
NNS->print(OS, S.Context.PrintingPolicy);
|
||||
NNS->print(OS, getCompletionPrintingPolicy(S.Context));
|
||||
Builder.AddTextChunk(Results.getAllocator().CopyString(OS.str()));
|
||||
}
|
||||
} else if (!InContext->Equals(Overridden->getDeclContext()))
|
||||
|
@ -3937,10 +3934,7 @@ void Sema::CodeCompleteOperatorName(Scope *S) {
|
|||
void Sema::CodeCompleteConstructorInitializer(Decl *ConstructorD,
|
||||
CXXCtorInitializer** Initializers,
|
||||
unsigned NumInitializers) {
|
||||
PrintingPolicy Policy(Context.PrintingPolicy);
|
||||
Policy.AnonymousTagLocations = false;
|
||||
Policy.SuppressStrongLifetime = true;
|
||||
|
||||
PrintingPolicy Policy = getCompletionPrintingPolicy(Context);
|
||||
CXXConstructorDecl *Constructor
|
||||
= static_cast<CXXConstructorDecl *>(ConstructorD);
|
||||
if (!Constructor)
|
||||
|
@ -6448,9 +6442,7 @@ void Sema::CodeCompleteObjCMethodDecl(Scope *S,
|
|||
ResultBuilder Results(*this, CodeCompleter->getAllocator(),
|
||||
CodeCompletionContext::CCC_Other);
|
||||
Results.EnterNewScope();
|
||||
PrintingPolicy Policy(Context.PrintingPolicy);
|
||||
Policy.AnonymousTagLocations = false;
|
||||
Policy.SuppressStrongLifetime = true;
|
||||
PrintingPolicy Policy = getCompletionPrintingPolicy(Context);
|
||||
for (KnownMethodsMap::iterator M = KnownMethods.begin(),
|
||||
MEnd = KnownMethods.end();
|
||||
M != MEnd; ++M) {
|
||||
|
|
|
@ -205,7 +205,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
|
|||
else
|
||||
OS << ", ";
|
||||
|
||||
OS << E->getAsString(Context.PrintingPolicy);
|
||||
OS << E->getAsString(Context.getPrintingPolicy());
|
||||
}
|
||||
OS << ")";
|
||||
break;
|
||||
|
@ -218,7 +218,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
|
|||
case EST_ComputedNoexcept:
|
||||
OS << "noexcept(";
|
||||
OldProto->getNoexceptExpr()->printPretty(OS, Context, 0,
|
||||
Context.PrintingPolicy);
|
||||
Context.getPrintingPolicy());
|
||||
OS << ")";
|
||||
break;
|
||||
|
||||
|
|
|
@ -4049,7 +4049,7 @@ Sema::ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *From,
|
|||
QualType ConvTy
|
||||
= Conversion->getConversionType().getNonReferenceType();
|
||||
std::string TypeStr;
|
||||
ConvTy.getAsStringInternal(TypeStr, Context.PrintingPolicy);
|
||||
ConvTy.getAsStringInternal(TypeStr, Context.getPrintingPolicy());
|
||||
|
||||
Diag(Loc, ExplicitConvDiag)
|
||||
<< T << ConvTy
|
||||
|
|
|
@ -6729,7 +6729,7 @@ Sema::getTemplateArgumentBindingsText(const TemplateParameterList *Params,
|
|||
}
|
||||
|
||||
Out << " = ";
|
||||
Args[I].print(Context.PrintingPolicy, Out);
|
||||
Args[I].print(Context.getPrintingPolicy(), Out);
|
||||
}
|
||||
|
||||
Out << ']';
|
||||
|
|
|
@ -484,7 +484,7 @@ void Sema::PrintInstantiationStack() {
|
|||
= TemplateSpecializationType::PrintTemplateArgumentList(
|
||||
Active->TemplateArgs,
|
||||
Active->NumTemplateArgs,
|
||||
Context.PrintingPolicy);
|
||||
Context.getPrintingPolicy());
|
||||
Diags.Report(Active->PointOfInstantiation,
|
||||
diag::note_default_arg_instantiation_here)
|
||||
<< (Template->getNameAsString() + TemplateArgsStr)
|
||||
|
@ -538,7 +538,7 @@ void Sema::PrintInstantiationStack() {
|
|||
= TemplateSpecializationType::PrintTemplateArgumentList(
|
||||
Active->TemplateArgs,
|
||||
Active->NumTemplateArgs,
|
||||
Context.PrintingPolicy);
|
||||
Context.getPrintingPolicy());
|
||||
Diags.Report(Active->PointOfInstantiation,
|
||||
diag::note_default_function_arg_instantiation_here)
|
||||
<< (FD->getNameAsString() + TemplateArgsStr)
|
||||
|
|
|
@ -10,7 +10,7 @@ typedef signed char BOOL;
|
|||
__strong id global;
|
||||
@implementation A
|
||||
- (int)method:(id)param1 {
|
||||
void foo(id (^block)(id x, A* y));
|
||||
void foo(bool (^block)(id x, A* y));
|
||||
for(BOOL B = YES; ; ) { }
|
||||
}
|
||||
@end
|
||||
|
@ -29,6 +29,6 @@ __strong id global;
|
|||
// CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
|
||||
// RUN: c-index-test -code-completion-at=%s:15:1 -fobjc-arc -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC3 %s
|
||||
// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:15:1 -fobjc-arc -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC3 %s
|
||||
// CHECK-CC3: FunctionDecl:{ResultType void}{TypedText foo}{LeftParen (}{Placeholder ^id(id x, A *y)block}{RightParen )} (34)
|
||||
// CHECK-CC3: FunctionDecl:{ResultType void}{TypedText foo}{LeftParen (}{Placeholder ^bool(id x, A *y)block}{RightParen )} (34)
|
||||
// CHECK-CC3: VarDecl:{ResultType id}{TypedText global} (50)
|
||||
// CHECK-CC3: ParmDecl:{ResultType id}{TypedText param1} (34)
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
|
||||
|
||||
#define bool _Bool
|
||||
@protocol NSObject;
|
||||
|
||||
void bar(id(^)(void));
|
||||
|
@ -22,8 +24,8 @@ void foo4(id (^objectCreationBlock)(int)) {
|
|||
}
|
||||
|
||||
void bar5(id(^)(void)); // expected-note{{passing argument to parameter here}}
|
||||
void foo5(id (^objectCreationBlock)(int)) {
|
||||
return bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(int)' to parameter of type 'id (^)(void)'}}
|
||||
void foo5(id (^objectCreationBlock)(bool)) {
|
||||
return bar5(objectCreationBlock); // expected-error {{incompatible block pointer types passing 'id (^)(bool)' to parameter of type 'id (^)(void)'}}
|
||||
}
|
||||
|
||||
void bar6(id(^)(int));
|
||||
|
|
|
@ -3199,7 +3199,7 @@ CXString clang_getCursorDisplayName(CXCursor C) {
|
|||
if (!D)
|
||||
return createCXString("");
|
||||
|
||||
PrintingPolicy &Policy = getCursorContext(C).PrintingPolicy;
|
||||
PrintingPolicy Policy = getCursorContext(C).getPrintingPolicy();
|
||||
if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(D))
|
||||
D = FunTmpl->getTemplatedDecl();
|
||||
|
||||
|
|
Loading…
Reference in New Issue