Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/release_36'
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Moskalchuk <dm@crystax.net>
  • Loading branch information
dmsck committed Jul 24, 2015
2 parents db10203 + c2e93b9 commit 916dd84
Show file tree
Hide file tree
Showing 35 changed files with 644 additions and 115 deletions.
10 changes: 10 additions & 0 deletions include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -5467,6 +5467,12 @@ def err_conditional_ambiguous : Error<
def err_conditional_ambiguous_ovl : Error<
"conditional expression is ambiguous; %diff{$ and $|types}0,1 "
"can be converted to several common types">;
def err_conditional_vector_size : Error<
"vector condition type %0 and result type %1 do not have the same number "
"of elements">;
def err_conditional_vector_element_size : Error<
"vector condition type %0 and result type %1 do not have elements of the "
"same size">;

def err_throw_incomplete : Error<
"cannot throw object of incomplete type %0">;
Expand Down Expand Up @@ -6049,8 +6055,12 @@ def err_typecheck_call_invalid_ordered_compare : Error<
def err_typecheck_call_invalid_unary_fp : Error<
"floating point classification requires argument of floating point type "
"(passed in %0)">;
def err_typecheck_cond_expect_int_float : Error<
"used type %0 where integer or floating point type is required">;
def err_typecheck_cond_expect_scalar : Error<
"used type %0 where arithmetic or pointer type is required">;
def err_typecheck_cond_expect_nonfloat : Error<
"used type %0 where floating point type is not allowed">;
def ext_typecheck_cond_one_void : Extension<
"C99 forbids conditional expressions with only one void side">;
def err_typecheck_cond_expect_scalar_or_vector : Error<
Expand Down
10 changes: 10 additions & 0 deletions include/clang/Basic/TargetCXXABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ class TargetCXXABI {
/// - guard variables are smaller.
GenericAArch64,

/// The generic Mips ABI is a modified version of the Itanium ABI.
///
/// At the moment, only change from the generic ABI in this case is:
/// - representation of member function pointers adjusted as in ARM.
GenericMIPS,

/// The Microsoft ABI is the ABI used by Microsoft Visual Studio (and
/// compatible compilers).
///
Expand Down Expand Up @@ -114,6 +120,7 @@ class TargetCXXABI {
case GenericARM:
case iOS:
case iOS64:
case GenericMIPS:
return true;

case Microsoft:
Expand All @@ -130,6 +137,7 @@ class TargetCXXABI {
case GenericARM:
case iOS:
case iOS64:
case GenericMIPS:
return false;

case Microsoft:
Expand Down Expand Up @@ -212,6 +220,7 @@ class TargetCXXABI {
case GenericItanium:
case iOS: // old iOS compilers did not follow this rule
case Microsoft:
case GenericMIPS:
return true;
}
llvm_unreachable("bad ABI kind");
Expand Down Expand Up @@ -257,6 +266,7 @@ class TargetCXXABI {
case GenericAArch64:
case GenericARM:
case iOS:
case GenericMIPS:
return UseTailPaddingUnlessPOD03;

// iOS on ARM64 uses the C++11 POD rules. It does not honor the
Expand Down
7 changes: 7 additions & 0 deletions include/clang/Sema/Template.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ namespace clang {
/// outermost scope.
LocalInstantiationScope *cloneScopes(LocalInstantiationScope *Outermost) {
if (this == Outermost) return this;

// Save the current scope from SemaRef since the LocalInstantiationScope
// will overwrite it on construction
LocalInstantiationScope *oldScope = SemaRef.CurrentInstantiationScope;

LocalInstantiationScope *newScope =
new LocalInstantiationScope(SemaRef, CombineWithOuterScope);

Expand All @@ -299,6 +304,8 @@ namespace clang {
newScope->ArgumentPacks.push_back(NewPack);
}
}
// Restore the saved scope to SemaRef
SemaRef.CurrentInstantiationScope = oldScope;
return newScope;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ CXXABI *ASTContext::createCXXABI(const TargetInfo &T) {
case TargetCXXABI::iOS:
case TargetCXXABI::iOS64:
case TargetCXXABI::GenericAArch64:
case TargetCXXABI::GenericMIPS:
case TargetCXXABI::GenericItanium:
return CreateItaniumCXXABI(*this);
case TargetCXXABI::Microsoft:
Expand Down Expand Up @@ -7972,7 +7973,7 @@ static GVALinkage basicGVALinkageForFunction(const ASTContext &Context,
// Functions specified with extern and inline in -fms-compatibility mode
// forcibly get emitted. While the body of the function cannot be later
// replaced, the function definition cannot be discarded.
if (FD->getMostRecentDecl()->isMSExternInline())
if (FD->isMSExternInline())
return GVA_StrongODR;

return GVA_DiscardableODR;
Expand Down Expand Up @@ -8163,6 +8164,7 @@ MangleContext *ASTContext::createMangleContext() {
case TargetCXXABI::GenericAArch64:
case TargetCXXABI::GenericItanium:
case TargetCXXABI::GenericARM:
case TargetCXXABI::GenericMIPS:
case TargetCXXABI::iOS:
case TargetCXXABI::iOS64:
return ItaniumMangleContext::create(*this, getDiagnostics());
Expand Down
53 changes: 27 additions & 26 deletions lib/AST/ASTDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,29 +998,27 @@ class TemplateDiff {
(!HasFromValueDecl && !HasToValueDecl)) &&
"Template argument cannot be both integer and declaration");

unsigned ParamWidth = 128; // Safe default
if (FromDefaultNonTypeDecl->getType()->isIntegralOrEnumerationType())
ParamWidth = Context.getIntWidth(FromDefaultNonTypeDecl->getType());

if (!HasFromInt && !HasToInt && !HasFromValueDecl && !HasToValueDecl) {
Tree.SetNode(FromExpr, ToExpr);
Tree.SetDefault(FromIter.isEnd() && FromExpr, ToIter.isEnd() && ToExpr);
if (FromDefaultNonTypeDecl->getType()->isIntegralOrEnumerationType()) {
if (FromExpr)
HasFromInt = GetInt(Context, FromIter, FromExpr, FromInt);
HasFromInt = GetInt(Context, FromIter, FromExpr, FromInt,
FromDefaultNonTypeDecl->getType());
if (ToExpr)
HasToInt = GetInt(Context, ToIter, ToExpr, ToInt);
HasToInt = GetInt(Context, ToIter, ToExpr, ToInt,
ToDefaultNonTypeDecl->getType());
}
if (HasFromInt && HasToInt) {
Tree.SetNode(FromInt, ToInt, HasFromInt, HasToInt);
Tree.SetSame(IsSameConvertedInt(ParamWidth, FromInt, ToInt));
Tree.SetSame(FromInt == ToInt);
Tree.SetKind(DiffTree::Integer);
} else if (HasFromInt || HasToInt) {
Tree.SetNode(FromInt, ToInt, HasFromInt, HasToInt);
Tree.SetSame(false);
Tree.SetKind(DiffTree::Integer);
} else {
Tree.SetSame(IsEqualExpr(Context, ParamWidth, FromExpr, ToExpr) ||
Tree.SetSame(IsEqualExpr(Context, FromExpr, ToExpr) ||
(FromNullPtr && ToNullPtr));
Tree.SetNullPtr(FromNullPtr, ToNullPtr);
Tree.SetKind(DiffTree::Expression);
Expand All @@ -1030,11 +1028,17 @@ class TemplateDiff {

if (HasFromInt || HasToInt) {
if (!HasFromInt && FromExpr)
HasFromInt = GetInt(Context, FromIter, FromExpr, FromInt);
HasFromInt = GetInt(Context, FromIter, FromExpr, FromInt,
FromDefaultNonTypeDecl->getType());
if (!HasToInt && ToExpr)
HasToInt = GetInt(Context, ToIter, ToExpr, ToInt);
HasToInt = GetInt(Context, ToIter, ToExpr, ToInt,
ToDefaultNonTypeDecl->getType());
Tree.SetNode(FromInt, ToInt, HasFromInt, HasToInt);
Tree.SetSame(IsSameConvertedInt(ParamWidth, FromInt, ToInt));
if (HasFromInt && HasToInt) {
Tree.SetSame(FromInt == ToInt);
} else {
Tree.SetSame(false);
}
Tree.SetDefault(FromIter.isEnd() && HasFromInt,
ToIter.isEnd() && HasToInt);
Tree.SetKind(DiffTree::Integer);
Expand Down Expand Up @@ -1210,9 +1214,11 @@ class TemplateDiff {
}

/// GetInt - Retrieves the template integer argument, including evaluating
/// default arguments.
/// default arguments. If the value comes from an expression, extend the
/// APSInt to size of IntegerType to match the behavior in
/// Sema::CheckTemplateArgument
static bool GetInt(ASTContext &Context, const TSTiterator &Iter,
Expr *ArgExpr, llvm::APInt &Int) {
Expr *ArgExpr, llvm::APSInt &Int, QualType IntegerType) {
// Default, value-depenedent expressions require fetching
// from the desugared TemplateArgument, otherwise expression needs to
// be evaluatable.
Expand All @@ -1224,12 +1230,14 @@ class TemplateDiff {
case TemplateArgument::Expression:
ArgExpr = Iter.getDesugar().getAsExpr();
Int = ArgExpr->EvaluateKnownConstInt(Context);
Int = Int.extOrTrunc(Context.getTypeSize(IntegerType));
return true;
default:
llvm_unreachable("Unexpected template argument kind");
}
} else if (ArgExpr->isEvaluatable(Context)) {
Int = ArgExpr->EvaluateKnownConstInt(Context);
Int = Int.extOrTrunc(Context.getTypeSize(IntegerType));
return true;
}

Expand Down Expand Up @@ -1302,18 +1310,8 @@ class TemplateDiff {
return nullptr;
}

/// IsSameConvertedInt - Returns true if both integers are equal when
/// converted to an integer type with the given width.
static bool IsSameConvertedInt(unsigned Width, const llvm::APSInt &X,
const llvm::APSInt &Y) {
llvm::APInt ConvertedX = X.extOrTrunc(Width);
llvm::APInt ConvertedY = Y.extOrTrunc(Width);
return ConvertedX == ConvertedY;
}

/// IsEqualExpr - Returns true if the expressions evaluate to the same value.
static bool IsEqualExpr(ASTContext &Context, unsigned ParamWidth,
Expr *FromExpr, Expr *ToExpr) {
static bool IsEqualExpr(ASTContext &Context, Expr *FromExpr, Expr *ToExpr) {
if (FromExpr == ToExpr)
return true;

Expand Down Expand Up @@ -1345,7 +1343,7 @@ class TemplateDiff {

switch (FromVal.getKind()) {
case APValue::Int:
return IsSameConvertedInt(ParamWidth, FromVal.getInt(), ToVal.getInt());
return FromVal.getInt() == ToVal.getInt();
case APValue::LValue: {
APValue::LValueBase FromBase = FromVal.getLValueBase();
APValue::LValueBase ToBase = ToVal.getLValueBase();
Expand Down Expand Up @@ -1655,11 +1653,14 @@ class TemplateDiff {
}
Unbold();
}

/// HasExtraInfo - Returns true if E is not an integer literal or the
/// negation of an integer literal
bool HasExtraInfo(Expr *E) {
if (!E) return false;

E = E->IgnoreImpCasts();

if (isa<IntegerLiteral>(E)) return false;

if (UnaryOperator *UO = dyn_cast<UnaryOperator>(E))
Expand Down
3 changes: 2 additions & 1 deletion lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2674,7 +2674,8 @@ bool FunctionDecl::isMSExternInline() const {
if (!Context.getLangOpts().MSVCCompat && !hasAttr<DLLExportAttr>())
return false;

for (const FunctionDecl *FD = this; FD; FD = FD->getPreviousDecl())
for (const FunctionDecl *FD = getMostRecentDecl(); FD;
FD = FD->getPreviousDecl())
if (FD->getStorageClass() == SC_Extern)
return true;

Expand Down
4 changes: 2 additions & 2 deletions lib/Analysis/ThreadSafety.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2108,8 +2108,8 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {

// Create a dummy expression,
VarDecl *VD = const_cast<VarDecl*>(AD.getVarDecl());
DeclRefExpr DRE(VD, false, VD->getType(), VK_LValue,
AD.getTriggerStmt()->getLocEnd());
DeclRefExpr DRE(VD, false, VD->getType().getNonReferenceType(),
VK_LValue, AD.getTriggerStmt()->getLocEnd());
LocksetBuilder.handleCall(&DRE, DD);
break;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Basic/TargetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ bool TargetCXXABI::tryParse(llvm::StringRef name) {
.Case("ios", iOS)
.Case("itanium", GenericItanium)
.Case("microsoft", Microsoft)
.Case("mips", GenericMIPS)
.Default(unknown);
if (kind == unknown) return false;

Expand Down
12 changes: 10 additions & 2 deletions lib/Basic/Targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ class NetBSDTargetInfo : public OSTargetInfo<Target> {
public:
NetBSDTargetInfo(const llvm::Triple &Triple) : OSTargetInfo<Target>(Triple) {
this->UserLabelPrefix = "";
this->MCountName = "_mcount";
}
};

Expand Down Expand Up @@ -3435,7 +3436,10 @@ class WindowsX86_32TargetInfo : public WindowsTargetInfo<X86_32TargetInfo> {
: WindowsTargetInfo<X86_32TargetInfo>(Triple) {
WCharType = UnsignedShort;
DoubleAlign = LongLongAlign = 64;
DescriptionString = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32";
bool IsWinCOFF =
getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
DescriptionString = IsWinCOFF ? "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
: "e-m:e-p:32:32-i64:64-f80:32-n8:16:32-S32";
}
void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
Expand Down Expand Up @@ -5714,7 +5718,9 @@ class MipsTargetInfoBase : public TargetInfo {
const std::string &CPUStr)
: TargetInfo(Triple), CPU(CPUStr), IsMips16(false), IsMicromips(false),
IsNan2008(false), IsSingleFloat(false), FloatABI(HardFloat),
DspRev(NoDSP), HasMSA(false), HasFP64(false), ABI(ABIStr) {}
DspRev(NoDSP), HasMSA(false), HasFP64(false), ABI(ABIStr) {
TheCXXABI.set(TargetCXXABI::GenericMIPS);
}

bool isNaN2008Default() const {
return CPU == "mips32r6" || CPU == "mips64r6";
Expand Down Expand Up @@ -6846,6 +6852,8 @@ static TargetInfo *AllocateTarget(const llvm::Triple &Triple) {
switch (os) {
case llvm::Triple::Linux:
return new LinuxTargetInfo<PPC64TargetInfo>(Triple);
case llvm::Triple::NetBSD:
return new NetBSDTargetInfo<PPC64TargetInfo>(Triple);
default:
return new PPC64TargetInfo(Triple);
}
Expand Down
1 change: 1 addition & 0 deletions lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static CGCXXABI *createCXXABI(CodeGenModule &CGM) {
case TargetCXXABI::GenericARM:
case TargetCXXABI::iOS:
case TargetCXXABI::iOS64:
case TargetCXXABI::GenericMIPS:
case TargetCXXABI::GenericItanium:
return CreateItaniumCXXABI(CGM);
case TargetCXXABI::Microsoft:
Expand Down
3 changes: 3 additions & 0 deletions lib/CodeGen/ItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ CodeGen::CGCXXABI *CodeGen::CreateItaniumCXXABI(CodeGenModule &CGM) {
return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true,
/* UseARMGuardVarABI = */ true);

case TargetCXXABI::GenericMIPS:
return new ItaniumCXXABI(CGM, /* UseARMMethodPtrABI = */ true);

case TargetCXXABI::GenericItanium:
if (CGM.getContext().getTargetInfo().getTriple().getArch()
== llvm::Triple::le32) {
Expand Down
2 changes: 2 additions & 0 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,7 @@ static bool findMIPSMultilibs(const llvm::Triple &TargetTriple, StringRef Path,

MultilibSet AndroidMipsMultilibs = MultilibSet()
.Maybe(Multilib("/mips-r2").flag("+march=mips32r2"))
.Maybe(Multilib("/mips-r6").flag("+march=mips32r6"))
.FilterOut(NonExistent);

MultilibSet DebianMipsMultilibs;
Expand Down Expand Up @@ -1928,6 +1929,7 @@ static bool findMIPSMultilibs(const llvm::Triple &TargetTriple, StringRef Path,
addMultilibFlag(isMips16(Args), "mips16", Flags);
addMultilibFlag(CPUName == "mips32", "march=mips32", Flags);
addMultilibFlag(CPUName == "mips32r2", "march=mips32r2", Flags);
addMultilibFlag(CPUName == "mips32r6", "march=mips32r6", Flags);
addMultilibFlag(CPUName == "mips64", "march=mips64", Flags);
addMultilibFlag(CPUName == "mips64r2" || CPUName == "octeon",
"march=mips64r2", Flags);
Expand Down
7 changes: 1 addition & 6 deletions lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
TI.getTypeWidth(TI.getWCharType()), TI, Builder);
DefineTypeSizeof("__SIZEOF_WINT_T__",
TI.getTypeWidth(TI.getWIntType()), TI, Builder);
// This is a temporary workaround while MIPS64 has not yet fully supported
// 128-bit integers. But declaration of int128 type is necessary even though
// __SIZEOF_INT128__ is undefined because c++ standard header files like
// limits throw error message if __int128 is not available.
if (TI.hasInt128Type() && !(TI.getTriple().getArch() == llvm::Triple::mips64el
|| TI.getTriple().getArch() == llvm::Triple::mips64))
if (TI.hasInt128Type())
DefineTypeSizeof("__SIZEOF_INT128__", 128, TI, Builder);

DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Builder);
Expand Down
5 changes: 3 additions & 2 deletions lib/Sema/DeclSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ bool Declarator::isDeclarationOfFunction() const {
bool Declarator::isStaticMember() {
assert(getContext() == MemberContext);
return getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static ||
CXXMethodDecl::isStaticOverloadedOperator(
getName().OperatorFunctionId.Operator);
(getName().Kind == UnqualifiedId::IK_OperatorFunctionId &&
CXXMethodDecl::isStaticOverloadedOperator(
getName().OperatorFunctionId.Operator));
}

bool DeclSpec::hasTagDefinition() const {
Expand Down
Loading

0 comments on commit 916dd84

Please sign in to comment.