diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 21 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 3 |
2 files changed, 10 insertions, 14 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 248998ed0b..73ff49a338 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -3755,11 +3755,6 @@ std::string PrettyPrintInRange(const llvm::APSInt &Value, IntRange Range) { return ValueInRange.toString(10); } -static bool isFromSystemMacro(Sema &S, SourceLocation loc) { - SourceManager &smgr = S.Context.getSourceManager(); - return loc.isMacroID() && smgr.isInSystemHeader(smgr.getSpellingLoc(loc)); -} - void CheckImplicitConversion(Sema &S, Expr *E, QualType T, SourceLocation CC, bool *ICContext = 0) { if (E->isTypeDependent() || E->isValueDependent()) return; @@ -3821,7 +3816,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, // Strip vector types. if (isa<VectorType>(Source)) { if (!isa<VectorType>(Target)) { - if (isFromSystemMacro(S, CC)) + if (S.SourceMgr.isInSystemMacro(CC)) return; return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_vector_scalar); } @@ -3838,7 +3833,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, // Strip complex types. if (isa<ComplexType>(Source)) { if (!isa<ComplexType>(Target)) { - if (isFromSystemMacro(S, CC)) + if (S.SourceMgr.isInSystemMacro(CC)) return; return DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_complex_scalar); @@ -3870,7 +3865,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, return; } - if (isFromSystemMacro(S, CC)) + if (S.SourceMgr.isInSystemMacro(CC)) return; DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_float_precision); @@ -3880,7 +3875,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, // If the target is integral, always warn. if ((TargetBT && TargetBT->isInteger())) { - if (isFromSystemMacro(S, CC)) + if (S.SourceMgr.isInSystemMacro(CC)) return; Expr *InnerE = E->IgnoreParenImpCasts(); @@ -3917,7 +3912,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, // TODO: this should happen for bitfield stores, too. llvm::APSInt Value(32); if (E->isIntegerConstantExpr(Value, S.Context)) { - if (isFromSystemMacro(S, CC)) + if (S.SourceMgr.isInSystemMacro(CC)) return; std::string PrettySourceValue = Value.toString(10); @@ -3932,7 +3927,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, } // People want to build with -Wshorten-64-to-32 and not -Wconversion. - if (isFromSystemMacro(S, CC)) + if (S.SourceMgr.isInSystemMacro(CC)) return; if (SourceRange.Width == 64 && TargetRange.Width == 32) @@ -3944,7 +3939,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, (!TargetRange.NonNegative && SourceRange.NonNegative && SourceRange.Width == TargetRange.Width)) { - if (isFromSystemMacro(S, CC)) + if (S.SourceMgr.isInSystemMacro(CC)) return; unsigned DiagID = diag::warn_impcast_integer_sign; @@ -3982,7 +3977,7 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, (TargetEnum->getDecl()->getIdentifier() || TargetEnum->getDecl()->getTypedefNameForAnonDecl()) && SourceEnum != TargetEnum) { - if (isFromSystemMacro(S, CC)) + if (S.SourceMgr.isInSystemMacro(CC)) return; return DiagnoseImpCast(S, E, SourceType, T, CC, diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index d7489d418e..78a58964db 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -152,7 +152,8 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S) { SourceLocation Loc; SourceRange R1, R2; - if (!E->isUnusedResultAWarning(Loc, R1, R2, Context)) + if (SourceMgr.isInSystemMacro(E->getExprLoc()) || + !E->isUnusedResultAWarning(Loc, R1, R2, Context)) return; // Okay, we have an unused result. Depending on what the base expression is, |