Reverted the original patch too, in r318667 since I assume that was breaking Ilya's build.
Hopefully this is easy to fix and they can be re-landed together. On Mon, Nov 20, 2017 at 9:39 AM, Hans Wennborg <h...@chromium.org> wrote: > I've reverted in r318665 to get the buildbots green until this is figured out. > > > > On Sat, Nov 18, 2017 at 11:55 AM, Hans Wennborg <h...@chromium.org> wrote: >> We're still seeing some in macro-related code. From Chromium: >> >> ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5): error: if >> statement has empty body [-Werror,-Wempty-body] >> ff_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); >> ^ >> ../../third_party/ffmpeg\libavutil/internal.h(276,80): note: expanded >> from macro 'ff_dlog' >> # define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG, >> __VA_ARGS__); } while (0) >> >> ^ >> ../../third_party/ffmpeg/libavcodec/bitstream.c(169,5): note: put the >> semicolon on a separate line to silence this warning >> >> (See https://build.chromium.org/p/chromium.clang/builders/ToTWin/builds/420) >> >> On Fri, Nov 17, 2017 at 1:33 PM, Reid Kleckner via cfe-commits >> <cfe-commits@lists.llvm.org> wrote: >>> Author: rnk >>> Date: Fri Nov 17 13:33:28 2017 >>> New Revision: 318556 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=318556&view=rev >>> Log: >>> Loosen -Wempty-body warning >>> >>> Do not show it when `if` or `else` come from macros. >>> E.g., >>> >>> #define USED(A) if (A); else >>> #define SOME_IF(A) if (A) >>> >>> void test() { >>> // No warnings are shown in those cases now. >>> USED(0); >>> SOME_IF(0); >>> } >>> >>> Patch by Ilya Biryukov! >>> >>> Differential Revision: https://reviews.llvm.org/D40185 >>> >>> Modified: >>> cfe/trunk/include/clang/Sema/Sema.h >>> cfe/trunk/lib/Parse/ParseStmt.cpp >>> cfe/trunk/lib/Sema/SemaChecking.cpp >>> cfe/trunk/lib/Sema/SemaStmt.cpp >>> cfe/trunk/test/SemaCXX/warn-empty-body.cpp >>> >>> Modified: cfe/trunk/include/clang/Sema/Sema.h >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=318556&r1=318555&r2=318556&view=diff >>> ============================================================================== >>> --- cfe/trunk/include/clang/Sema/Sema.h (original) >>> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Nov 17 13:33:28 2017 >>> @@ -9690,6 +9690,7 @@ public: >>> class ConditionResult { >>> Decl *ConditionVar; >>> FullExprArg Condition; >>> + SourceLocation RParenLoc; >>> bool Invalid; >>> bool HasKnownValue; >>> bool KnownValue; >>> @@ -9713,6 +9714,9 @@ public: >>> return std::make_pair(cast_or_null<VarDecl>(ConditionVar), >>> Condition.get()); >>> } >>> + >>> + void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } >>> + >>> llvm::Optional<bool> getKnownValue() const { >>> if (!HasKnownValue) >>> return None; >>> >>> Modified: cfe/trunk/lib/Parse/ParseStmt.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=318556&r1=318555&r2=318556&view=diff >>> ============================================================================== >>> --- cfe/trunk/lib/Parse/ParseStmt.cpp (original) >>> +++ cfe/trunk/lib/Parse/ParseStmt.cpp Fri Nov 17 13:33:28 2017 >>> @@ -1101,6 +1101,7 @@ bool Parser::ParseParenExprOrCondition(S >>> >>> // Otherwise the condition is valid or the rparen is present. >>> T.consumeClose(); >>> + Cond.setRParenLoc(T.getCloseLocation()); >>> >>> // Check for extraneous ')'s to catch things like "if (foo())) {". We >>> know >>> // that all callers are looking for a statement after the condition, so >>> ")" >>> >>> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=318556&r1=318555&r2=318556&view=diff >>> ============================================================================== >>> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) >>> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Nov 17 13:33:28 2017 >>> @@ -11821,7 +11821,7 @@ static bool ShouldDiagnoseEmptyStmtBody( >>> >>> // Get line numbers of statement and body. >>> bool StmtLineInvalid; >>> - unsigned StmtLine = SourceMgr.getPresumedLineNumber(StmtLoc, >>> + unsigned StmtLine = SourceMgr.getSpellingLineNumber(StmtLoc, >>> &StmtLineInvalid); >>> if (StmtLineInvalid) >>> return false; >>> >>> Modified: cfe/trunk/lib/Sema/SemaStmt.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=318556&r1=318555&r2=318556&view=diff >>> ============================================================================== >>> --- cfe/trunk/lib/Sema/SemaStmt.cpp (original) >>> +++ cfe/trunk/lib/Sema/SemaStmt.cpp Fri Nov 17 13:33:28 2017 >>> @@ -530,8 +530,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, >>> if (elseStmt) >>> DiagnoseEmptyStmtBody(ElseLoc, elseStmt, diag::warn_empty_else_body); >>> else >>> - DiagnoseEmptyStmtBody(CondExpr->getLocEnd(), thenStmt, >>> - diag::warn_empty_if_body); >>> + DiagnoseEmptyStmtBody(Cond.RParenLoc, thenStmt, >>> diag::warn_empty_if_body); >>> >>> return BuildIfStmt(IfLoc, IsConstexpr, InitStmt, Cond, thenStmt, ElseLoc, >>> elseStmt); >>> >>> Modified: cfe/trunk/test/SemaCXX/warn-empty-body.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-empty-body.cpp?rev=318556&r1=318555&r2=318556&view=diff >>> ============================================================================== >>> --- cfe/trunk/test/SemaCXX/warn-empty-body.cpp (original) >>> +++ cfe/trunk/test/SemaCXX/warn-empty-body.cpp Fri Nov 17 13:33:28 2017 >>> @@ -301,3 +301,14 @@ void test7(int x, int y) { >>> if (x) IDENTITY(); // no-warning >>> } >>> >>> +#define SOME_IF(A) if (A) >>> +#define IF_ELSE(A) if (A); else >>> + >>> + >>> +void test_macros() { >>> + SOME_IF(0); >>> + IF_ELSE(0); >>> + >>> + IDENTITY(if (0);) // expected-warning{{if statement has empty body}} >>> expected-note{{separate line}} >>> + IDENTITY(if (0); else;) // expected-warning{{else clause has empty >>> body}} expected-note{{separate line}}} >>> +} >>> >>> >>> _______________________________________________ >>> cfe-commits mailing list >>> cfe-commits@lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits