diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-12-05 18:44:44 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-12-05 18:44:44 +0000 |
commit | ea0fdfe146ac42e90a83a88a796f24ef8e37a2d6 (patch) | |
tree | fcc7eda7d441d3929b56364622e4a70646670106 | |
parent | 598ec0992d5090004628aade64ee6ba60393b203 (diff) | |
download | bcm5719-llvm-ea0fdfe146ac42e90a83a88a796f24ef8e37a2d6.tar.gz bcm5719-llvm-ea0fdfe146ac42e90a83a88a796f24ef8e37a2d6.zip |
Format strings: add more expression types that don't need parens to cast.
No functionality change (the test change is a comment only, and the new
functionality can't be tested using the current test).
llvm-svn: 169399
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 12 | ||||
-rw-r--r-- | clang/test/FixIt/format-darwin.m | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index ce44eafa045..d91f03416b6 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -2690,12 +2690,24 @@ static bool requiresParensToAddCast(const Expr *E) { switch (Inside->getStmtClass()) { case Stmt::ArraySubscriptExprClass: case Stmt::CallExprClass: + case Stmt::CharacterLiteralClass: + case Stmt::CXXBoolLiteralExprClass: case Stmt::DeclRefExprClass: + case Stmt::FloatingLiteralClass: + case Stmt::IntegerLiteralClass: case Stmt::MemberExprClass: + case Stmt::ObjCArrayLiteralClass: + case Stmt::ObjCBoolLiteralExprClass: + case Stmt::ObjCBoxedExprClass: + case Stmt::ObjCDictionaryLiteralClass: + case Stmt::ObjCEncodeExprClass: case Stmt::ObjCIvarRefExprClass: case Stmt::ObjCMessageExprClass: case Stmt::ObjCPropertyRefExprClass: + case Stmt::ObjCStringLiteralClass: + case Stmt::ObjCSubscriptRefExprClass: case Stmt::ParenExprClass: + case Stmt::StringLiteralClass: case Stmt::UnaryOperatorClass: return false; default: diff --git a/clang/test/FixIt/format-darwin.m b/clang/test/FixIt/format-darwin.m index 1bfe27292e1..06ec393552c 100644 --- a/clang/test/FixIt/format-darwin.m +++ b/clang/test/FixIt/format-darwin.m @@ -65,7 +65,7 @@ void testParens(Foo *obj, struct Bar *record) { NSInteger arr[4] = {0}; NSInteger i = 0; - // These cases match the cases in CheckPrintfHandler::checkFormatExpr. + // These cases match the relevant cases in CheckPrintfHandler::checkFormatExpr. printf("%s", arr[0]); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}} printf("%s", getNSInteger()); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}} printf("%s", i); // expected-warning{{values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead}} |