diff options
author | Matt Beaumont-Gay <matthewbg@google.com> | 2012-01-06 22:43:58 +0000 |
---|---|---|
committer | Matt Beaumont-Gay <matthewbg@google.com> | 2012-01-06 22:43:58 +0000 |
commit | d87a0cd2b3e1c9e9f01212875f4cbe5b7bb7ab57 (patch) | |
tree | 6919ce0acbee739edf215e680d38e224d0c18c86 /lib/Sema/SemaChecking.cpp | |
parent | cd93b96bc51c255d104095bc6a6d8eac74a84b1e (diff) |
Suppress -Wunused-value within macros from system headers.
Along the way, move a helper function from SemaChecking.cpp to a more
accessible home in SourceManager.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147692 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 21 |
1 files changed, 8 insertions, 13 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, |