summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-03 13:29:08 +0000
committered <ed@FreeBSD.org>2009-06-03 13:29:08 +0000
commit48ecc7affef226b2bac1e08bdfdc059306a1734c (patch)
tree4075b1f9165f6c8d2b9a7e98b89a1348669f78fe /lib
parentf27e5a09a0d815b8a4814152954ff87dadfdefc0 (diff)
downloadFreeBSD-src-48ecc7affef226b2bac1e08bdfdc059306a1734c.zip
FreeBSD-src-48ecc7affef226b2bac1e08bdfdc059306a1734c.tar.gz
Import Clang, at r72770.
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp44
-rw-r--r--lib/AST/Type.cpp2
-rw-r--r--lib/Frontend/Backend.cpp21
-rw-r--r--lib/Frontend/PCHWriter.cpp1
-rw-r--r--lib/Sema/Sema.cpp2
-rw-r--r--lib/Sema/SemaType.cpp4
6 files changed, 58 insertions, 16 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 29bca29..3b40526 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -2785,7 +2785,7 @@ QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const {
}
// Non-pointers have none gc'able attribute regardless of the attribute
// set on them.
- else if (!isObjCObjectPointerType(Ty) && !Ty->isPointerType())
+ else if (!Ty->isPointerType() && !isObjCObjectPointerType(Ty))
return QualType::GCNone;
}
return GCAttrs;
@@ -3033,26 +3033,52 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
if (RHSClass == Type::ExtQual) {
QualType::GCAttrTypes GCAttr = RHSCan.getObjCGCAttr();
if (GCAttr != QualType::GCNone) {
+ QualType::GCAttrTypes GCLHSAttr = LHSCan.getObjCGCAttr();
+ // __weak attribute must appear on both declarations.
+ // __strong attribue is redundant if other decl is an objective-c
+ // object pointer (or decorated with __strong attribute); otherwise
+ // issue error.
+ if ((GCAttr == QualType::Weak && GCLHSAttr != GCAttr) ||
+ (GCAttr == QualType::Strong && GCLHSAttr != GCAttr &&
+ LHSCan->isPointerType() && !isObjCObjectPointerType(LHSCan) &&
+ !isObjCIdStructType(LHSCan->getAsPointerType()->getPointeeType())))
+ return QualType();
+
RHS = QualType(cast<ExtQualType>(RHS.getDesugaredType())->getBaseType(),
RHS.getCVRQualifiers());
QualType Result = mergeTypes(LHS, RHS);
- if (Result.getObjCGCAttr() == QualType::GCNone)
- Result = getObjCGCQualType(Result, GCAttr);
- else if (Result.getObjCGCAttr() != GCAttr)
- Result = QualType();
+ if (!Result.isNull()) {
+ if (Result.getObjCGCAttr() == QualType::GCNone)
+ Result = getObjCGCQualType(Result, GCAttr);
+ else if (Result.getObjCGCAttr() != GCAttr)
+ Result = QualType();
+ }
return Result;
}
}
if (LHSClass == Type::ExtQual) {
QualType::GCAttrTypes GCAttr = LHSCan.getObjCGCAttr();
if (GCAttr != QualType::GCNone) {
+ QualType::GCAttrTypes GCRHSAttr = RHSCan.getObjCGCAttr();
+ // __weak attribute must appear on both declarations. __strong
+ // __strong attribue is redundant if other decl is an objective-c
+ // object pointer (or decorated with __strong attribute); otherwise
+ // issue error.
+ if ((GCAttr == QualType::Weak && GCRHSAttr != GCAttr) ||
+ (GCAttr == QualType::Strong && GCRHSAttr != GCAttr &&
+ RHSCan->isPointerType() && !isObjCObjectPointerType(RHSCan) &&
+ !isObjCIdStructType(RHSCan->getAsPointerType()->getPointeeType())))
+ return QualType();
+
LHS = QualType(cast<ExtQualType>(LHS.getDesugaredType())->getBaseType(),
LHS.getCVRQualifiers());
QualType Result = mergeTypes(LHS, RHS);
- if (Result.getObjCGCAttr() == QualType::GCNone)
- Result = getObjCGCQualType(Result, GCAttr);
- else if (Result.getObjCGCAttr() != GCAttr)
- Result = QualType();
+ if (!Result.isNull()) {
+ if (Result.getObjCGCAttr() == QualType::GCNone)
+ Result = getObjCGCQualType(Result, GCAttr);
+ else if (Result.getObjCGCAttr() != GCAttr)
+ Result = QualType();
+ }
return Result;
}
}
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index b2ee58f..f573744 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -1410,7 +1410,7 @@ void FunctionProtoType::getAsStringInternal(std::string &S, const PrintingPolicy
if (getNumArgs())
S += ", ";
S += "...";
- } else if (getNumArgs() == 0) {
+ } else if (getNumArgs() == 0 && !Policy.CPlusPlus) {
// Do not emit int() if we have a proto, emit 'int(void)'.
S += "void";
}
diff --git a/lib/Frontend/Backend.cpp b/lib/Frontend/Backend.cpp
index 44aa3a8..697ba94 100644
--- a/lib/Frontend/Backend.cpp
+++ b/lib/Frontend/Backend.cpp
@@ -294,10 +294,16 @@ void BackendConsumer::CreatePasses() {
PM->add(createPruneEHPass()); // Remove dead EH info
PM->add(createFunctionAttrsPass()); // Set readonly/readnone attrs
}
- if (CompileOpts.InlineFunctions)
+ switch (CompileOpts.Inlining) {
+ case CompileOptions::NoInlining:
+ break;
+ case CompileOptions::NormalInlining:
PM->add(createFunctionInliningPass()); // Inline small functions
- else
+ break;
+ case CompileOptions::OnlyAlwaysInlining:
PM->add(createAlwaysInlinerPass()); // Respect always_inline
+ break;
+ }
if (CompileOpts.OptimizationLevel > 2)
PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args
if (CompileOpts.SimplifyLibCalls)
@@ -341,7 +347,16 @@ void BackendConsumer::CreatePasses() {
if (CompileOpts.OptimizationLevel > 1 && CompileOpts.UnitAtATime)
PM->add(createConstantMergePass()); // Merge dup global constants
} else {
- PM->add(createAlwaysInlinerPass());
+ switch (CompileOpts.Inlining) {
+ case CompileOptions::NoInlining:
+ break;
+ case CompileOptions::NormalInlining:
+ PM->add(createFunctionInliningPass()); // Inline small functions
+ break;
+ case CompileOptions::OnlyAlwaysInlining:
+ PM->add(createAlwaysInlinerPass()); // Respect always_inline
+ break;
+ }
}
}
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 9f9b3b4..80e863b 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -347,6 +347,7 @@ void PCHWriter::WriteBlockInfoBlock() {
// PCH Top-Level Block.
BLOCK(PCH_BLOCK);
+ RECORD(ORIGINAL_FILE_NAME);
RECORD(TYPE_OFFSET);
RECORD(DECL_OFFSET);
RECORD(LANGUAGE_OPTIONS);
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 1212d07..e3cea5b 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -60,7 +60,7 @@ static void ConvertArgToStringFn(Diagnostic::ArgumentKind Kind, intptr_t Val,
// Not va_list.
Ty.getUnqualifiedType() != Context.getBuiltinVaListType()) {
S = "'"+S+"' (aka '";
- S += DesugaredTy.getAsString();
+ S += DesugaredTy.getAsString(Context.PrintingPolicy);
S += "')";
Output.append(S.begin(), S.end());
return;
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 81ac211..cd19d97 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -107,7 +107,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
if (DS.isEmpty()) {
if (DeclLoc.isInvalid())
DeclLoc = DS.getSourceRange().getBegin();
- Diag(DeclLoc, diag::warn_missing_declspec)
+ Diag(DeclLoc, diag::ext_missing_declspec)
<< DS.getSourceRange()
<< CodeModificationHint::CreateInsertion(DS.getSourceRange().getBegin(),
"int");
@@ -125,7 +125,7 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS,
Diag(DeclLoc, diag::err_missing_type_specifier)
<< DS.getSourceRange();
else
- Diag(DeclLoc, diag::warn_missing_type_specifier)
+ Diag(DeclLoc, diag::ext_missing_type_specifier)
<< DS.getSourceRange();
// FIXME: If we could guarantee that the result would be well-formed, it
OpenPOWER on IntegriCloud