[clang-tools-extra] r361113 - [clangd] Respect WarningsAsErrors configuration for clang-tidy
Author: maskray Date: Sat May 18 21:19:14 2019 New Revision: 361113 URL: http://llvm.org/viewvc/llvm-project?rev=361113=rev Log: [clangd] Respect WarningsAsErrors configuration for clang-tidy This completes the fix for https://bugs.llvm.org/show_bug.cgi?id=41218. Reviewed By: sammccall Patch by Nathan Ridge! Differential Revision: https://reviews.llvm.org/D61841 Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/clangd/Diagnostics.cpp clang-tools-extra/trunk/clangd/Diagnostics.h clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp clang-tools-extra/trunk/clangd/unittests/TestTU.cpp clang-tools-extra/trunk/clangd/unittests/TestTU.h Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=361113=361112=361113=diff == --- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Sat May 18 21:19:14 2019 @@ -332,14 +332,22 @@ ParsedAST::build(std::unique_ptrsetASTContext(>getASTContext()); CTContext->setCurrentFile(MainInput.getFile()); CTFactories.createChecks(CTContext.getPointer(), CTChecks); -ASTDiags.suppressDiagnostics([]( - DiagnosticsEngine::Level DiagLevel, - const clang::Diagnostic ) { +ASTDiags.setLevelAdjuster([](DiagnosticsEngine::Level DiagLevel, + const clang::Diagnostic ) { if (CTContext) { -bool IsClangTidyDiag = !CTContext->getCheckName(Info.getID()).empty(); +std::string CheckName = CTContext->getCheckName(Info.getID()); +bool IsClangTidyDiag = !CheckName.empty(); if (IsClangTidyDiag) { - // Skip the ShouldSuppressDiagnostic check for diagnostics not in - // the main file, because we don't want that function to query the + // Check for warning-as-error. + // We deliberately let this take precedence over suppression comments + // to match clang-tidy's behaviour. + if (DiagLevel == DiagnosticsEngine::Warning && + CTContext->treatAsError(CheckName)) { +return DiagnosticsEngine::Error; + } + + // Check for suppression comment. Skip the check for diagnostics not + // in the main file, because we don't want that function to query the // source buffer for preamble files. For the same reason, we ask // ShouldSuppressDiagnostic not to follow macro expansions, since // those might take us into a preamble file as well. @@ -350,11 +358,11 @@ ParsedAST::build(std::unique_ptrgetPreprocessor(); for (const auto : CTChecks) { Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=361113=361112=361113=diff == --- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original) +++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Sat May 18 21:19:14 2019 @@ -514,9 +514,12 @@ void StoreDiags::HandleDiagnostic(Diagno // Handle the new main diagnostic. flushLastDiag(); -if (SuppressionFilter && SuppressionFilter(DiagLevel, Info)) { - LastPrimaryDiagnosticWasSuppressed = true; - return; +if (Adjuster) { + DiagLevel = Adjuster(DiagLevel, Info); + if (DiagLevel == DiagnosticsEngine::Ignored) { +LastPrimaryDiagnosticWasSuppressed = true; +return; + } } LastPrimaryDiagnosticWasSuppressed = false; Modified: clang-tools-extra/trunk/clangd/Diagnostics.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.h?rev=361113=361112=361113=diff == --- clang-tools-extra/trunk/clangd/Diagnostics.h (original) +++ clang-tools-extra/trunk/clangd/Diagnostics.h Sat May 18 21:19:14 2019 @@ -128,20 +128,20 @@ public: using DiagFixer = std::function(DiagnosticsEngine::Level, const clang::Diagnostic &)>; - using DiagFilter = - std::function; + using LevelAdjuster = std::function; /// If set, possibly adds fixes for diagnostics using \p Fixer. void contributeFixes(DiagFixer Fixer) { this->Fixer = Fixer; } - /// If set, ignore diagnostics for which \p SuppressionFilter returns true. - void suppressDiagnostics(DiagFilter SuppressionFilter) { -this->SuppressionFilter = SuppressionFilter; - } + /// If set, this allows the client of this class to adjust the level of + /// diagnostics, such as promoting warnings to errors, or ignoring + /// diagnostics. + void setLevelAdjuster(LevelAdjuster Adjuster) { this->Adjuster = Adjuster; }
[PATCH] D61841: [clangd] Respect WarningsAsErrors configuration for clang-tidy
This revision was automatically updated to reflect the committed changes. Closed by commit rL361113: [clangd] Respect WarningsAsErrors configuration for clang-tidy (authored by MaskRay, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D61841?vs=199956=200168#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61841/new/ https://reviews.llvm.org/D61841 Files: clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/clangd/Diagnostics.cpp clang-tools-extra/trunk/clangd/Diagnostics.h clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp clang-tools-extra/trunk/clangd/unittests/TestTU.cpp clang-tools-extra/trunk/clangd/unittests/TestTU.h Index: clang-tools-extra/trunk/clangd/unittests/TestTU.h === --- clang-tools-extra/trunk/clangd/unittests/TestTU.h +++ clang-tools-extra/trunk/clangd/unittests/TestTU.h @@ -57,6 +57,7 @@ std::vector ExtraArgs; llvm::Optional ClangTidyChecks; + llvm::Optional ClangTidyWarningsAsErrors; // Index to use when building AST. const SymbolIndex *ExternalIndex = nullptr; Index: clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp === --- clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp +++ clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp @@ -73,6 +73,7 @@ MATCHER_P(DiagSource, S, "") { return arg.Source == S; } MATCHER_P(DiagName, N, "") { return arg.Name == N; } +MATCHER_P(DiagSeverity, S, "") { return arg.Severity == S; } MATCHER_P(EqualToFix, Fix, "LSP fix " + llvm::to_string(Fix)) { if (arg.Message != Fix.Message) @@ -227,6 +228,44 @@ DiagSource(Diag::ClangTidy), DiagName("bugprone-integer-division"; } +TEST(DiagnosticTest, ClangTidyWarningAsError) { + Annotations Main(R"cpp( +int main() { + int i = 3; + double f = [[8]] / i; +} + )cpp"); + TestTU TU = TestTU::withCode(Main.code()); + TU.ClangTidyChecks = "bugprone-integer-division"; + TU.ClangTidyWarningsAsErrors = "bugprone-integer-division"; + EXPECT_THAT( + TU.build().getDiagnostics(), + UnorderedElementsAre(::testing::AllOf( + Diag(Main.range(), "result of integer division used in a floating " + "point context; possible loss of precision"), + DiagSource(Diag::ClangTidy), DiagName("bugprone-integer-division"), + DiagSeverity(DiagnosticsEngine::Error; +} + +TEST(DiagnosticTest, ClangTidyWarningAsErrorTrumpsSuppressionComment) { + Annotations Main(R"cpp( +int main() { + int i = 3; + double f = [[8]] / i; // NOLINT +} + )cpp"); + TestTU TU = TestTU::withCode(Main.code()); + TU.ClangTidyChecks = "bugprone-integer-division"; + TU.ClangTidyWarningsAsErrors = "bugprone-integer-division"; + EXPECT_THAT( + TU.build().getDiagnostics(), + UnorderedElementsAre(::testing::AllOf( + Diag(Main.range(), "result of integer division used in a floating " + "point context; possible loss of precision"), + DiagSource(Diag::ClangTidy), DiagName("bugprone-integer-division"), + DiagSeverity(DiagnosticsEngine::Error; +} + TEST(DiagnosticsTest, Preprocessor) { // This looks like a preamble, but there's an #else in the middle! // Check that: Index: clang-tools-extra/trunk/clangd/unittests/TestTU.cpp === --- clang-tools-extra/trunk/clangd/unittests/TestTU.cpp +++ clang-tools-extra/trunk/clangd/unittests/TestTU.cpp @@ -48,6 +48,7 @@ Inputs.FS = buildTestFS(Files); Inputs.Opts = ParseOptions(); Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks; + Inputs.Opts.ClangTidyOpts.WarningsAsErrors = ClangTidyWarningsAsErrors; Inputs.Index = ExternalIndex; if (Inputs.Index) Inputs.Opts.SuggestMissingIncludes = true; Index: clang-tools-extra/trunk/clangd/Diagnostics.h === --- clang-tools-extra/trunk/clangd/Diagnostics.h +++ clang-tools-extra/trunk/clangd/Diagnostics.h @@ -128,20 +128,20 @@ using DiagFixer = std::function(DiagnosticsEngine::Level, const clang::Diagnostic &)>; - using DiagFilter = - std::function; + using LevelAdjuster = std::function; /// If set, possibly adds fixes for diagnostics using \p Fixer. void contributeFixes(DiagFixer Fixer) { this->Fixer = Fixer; } - /// If set, ignore diagnostics for which \p SuppressionFilter returns true. - void suppressDiagnostics(DiagFilter SuppressionFilter) { -this->SuppressionFilter = SuppressionFilter; - } + /// If set, this allows the client of this class to adjust the level of + /// diagnostics, such as promoting warnings to errors, or
[PATCH] D60953: [clangd] Respect clang-tidy suppression comments
This revision was automatically updated to reflect the committed changes. Closed by commit rL361112: [clangd] Respect clang-tidy suppression comments (authored by MaskRay, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D60953?vs=199954=200167#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60953/new/ https://reviews.llvm.org/D60953 Files: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/clangd/Diagnostics.cpp clang-tools-extra/trunk/clangd/Diagnostics.h clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp Index: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h === --- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h +++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h @@ -217,6 +217,23 @@ bool AllowEnablingAnalyzerAlphaCheckers; }; +/// Check whether a given diagnostic should be suppressed due to the presence +/// of a "NOLINT" suppression comment. +/// This is exposed so that other tools that present clang-tidy diagnostics +/// (such as clangd) can respect the same suppression rules as clang-tidy. +/// This does not handle suppression of notes following a suppressed diagnostic; +/// that is left to the caller is it requires maintaining state in between calls +/// to this function. +/// The `CheckMacroExpansion` parameter determines whether the function should +/// handle the case where the diagnostic is inside a macro expansion. A degree +/// of control over this is needed because handling this case can require +/// examining source files other than the one in which the diagnostic is +/// located, and in some use cases we cannot rely on such other files being +/// mapped in the SourceMapper. +bool ShouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic , ClangTidyContext , + bool CheckMacroExpansion = true); + /// \brief A diagnostic consumer that turns each \c Diagnostic into a /// \c SourceManager-independent \c ClangTidyError. // @@ -246,7 +263,7 @@ /// \brief Updates \c LastErrorRelatesToUserCode and LastErrorPassesLineFilter /// according to the diagnostic \p Location. - void checkFilters(SourceLocation Location, const SourceManager& Sources); + void checkFilters(SourceLocation Location, const SourceManager ); bool passesLineFilter(StringRef FileName, unsigned LineNumber) const; ClangTidyContext Index: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp === --- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -166,11 +166,13 @@ bool contains(StringRef S) { switch (auto = Cache[S]) { - case Yes: return true; - case No: return false; - case None: -Result = Globs.contains(S) ? Yes : No; -return Result == Yes; +case Yes: + return true; +case No: + return false; +case None: + Result = Globs.contains(S) ? Yes : No; + return Result == Yes; } llvm_unreachable("invalid enum"); } @@ -387,16 +389,30 @@ return false; } +namespace clang { +namespace tidy { + +bool ShouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic , ClangTidyContext , + bool CheckMacroExpansion) { + return Info.getLocation().isValid() && + DiagLevel != DiagnosticsEngine::Error && + DiagLevel != DiagnosticsEngine::Fatal && + (CheckMacroExpansion ? LineIsMarkedWithNOLINTinMacro + : LineIsMarkedWithNOLINT)(Info.getSourceManager(), +Info.getLocation(), +Info.getID(), Context); +} + +} // namespace tidy +} // namespace clang + void ClangTidyDiagnosticConsumer::HandleDiagnostic( DiagnosticsEngine::Level DiagLevel, const Diagnostic ) { if (LastErrorWasIgnored && DiagLevel == DiagnosticsEngine::Note) return; - if (Info.getLocation().isValid() && DiagLevel != DiagnosticsEngine::Error && - DiagLevel != DiagnosticsEngine::Fatal && - LineIsMarkedWithNOLINTinMacro(Info.getSourceManager(), -Info.getLocation(), Info.getID(), -Context)) { + if (ShouldSuppressDiagnostic(DiagLevel, Info, Context)) { ++Context.Stats.ErrorsIgnoredNOLINT; // Ignored a warning, should ignore related notes as well LastErrorWasIgnored = true; Index:
[clang-tools-extra] r361112 - [clangd] Respect clang-tidy suppression comments
Author: maskray Date: Sat May 18 21:06:52 2019 New Revision: 361112 URL: http://llvm.org/viewvc/llvm-project?rev=361112=rev Log: [clangd] Respect clang-tidy suppression comments This partially fixes https://bugs.llvm.org/show_bug.cgi?id=41218. Reviewed By: sammccall Patch by Nathan Ridge! Differential Revision: https://reviews.llvm.org/D60953 Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h clang-tools-extra/trunk/clangd/ClangdUnit.cpp clang-tools-extra/trunk/clangd/Diagnostics.cpp clang-tools-extra/trunk/clangd/Diagnostics.h clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=361112=36=361112=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Sat May 18 21:06:52 2019 @@ -166,11 +166,13 @@ public: bool contains(StringRef S) { switch (auto = Cache[S]) { - case Yes: return true; - case No: return false; - case None: -Result = Globs.contains(S) ? Yes : No; -return Result == Yes; +case Yes: + return true; +case No: + return false; +case None: + Result = Globs.contains(S) ? Yes : No; + return Result == Yes; } llvm_unreachable("invalid enum"); } @@ -387,16 +389,30 @@ static bool LineIsMarkedWithNOLINTinMacr return false; } +namespace clang { +namespace tidy { + +bool ShouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic , ClangTidyContext , + bool CheckMacroExpansion) { + return Info.getLocation().isValid() && + DiagLevel != DiagnosticsEngine::Error && + DiagLevel != DiagnosticsEngine::Fatal && + (CheckMacroExpansion ? LineIsMarkedWithNOLINTinMacro + : LineIsMarkedWithNOLINT)(Info.getSourceManager(), +Info.getLocation(), +Info.getID(), Context); +} + +} // namespace tidy +} // namespace clang + void ClangTidyDiagnosticConsumer::HandleDiagnostic( DiagnosticsEngine::Level DiagLevel, const Diagnostic ) { if (LastErrorWasIgnored && DiagLevel == DiagnosticsEngine::Note) return; - if (Info.getLocation().isValid() && DiagLevel != DiagnosticsEngine::Error && - DiagLevel != DiagnosticsEngine::Fatal && - LineIsMarkedWithNOLINTinMacro(Info.getSourceManager(), -Info.getLocation(), Info.getID(), -Context)) { + if (ShouldSuppressDiagnostic(DiagLevel, Info, Context)) { ++Context.Stats.ErrorsIgnoredNOLINT; // Ignored a warning, should ignore related notes as well LastErrorWasIgnored = true; Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=361112=36=361112=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Sat May 18 21:06:52 2019 @@ -217,6 +217,23 @@ private: bool AllowEnablingAnalyzerAlphaCheckers; }; +/// Check whether a given diagnostic should be suppressed due to the presence +/// of a "NOLINT" suppression comment. +/// This is exposed so that other tools that present clang-tidy diagnostics +/// (such as clangd) can respect the same suppression rules as clang-tidy. +/// This does not handle suppression of notes following a suppressed diagnostic; +/// that is left to the caller is it requires maintaining state in between calls +/// to this function. +/// The `CheckMacroExpansion` parameter determines whether the function should +/// handle the case where the diagnostic is inside a macro expansion. A degree +/// of control over this is needed because handling this case can require +/// examining source files other than the one in which the diagnostic is +/// located, and in some use cases we cannot rely on such other files being +/// mapped in the SourceMapper. +bool ShouldSuppressDiagnostic(DiagnosticsEngine::Level DiagLevel, + const Diagnostic , ClangTidyContext , + bool CheckMacroExpansion = true); + /// \brief A diagnostic consumer that turns each \c Diagnostic into a /// \c SourceManager-independent \c ClangTidyError. // @@ -246,7 +263,7 @@ private: /// \brief Updates \c
r361109 - [X86] Remove semicolons at the end of intrinsics implemented as macros so they can be used as arguments to other intrinsics.
Author: ctopper Date: Sat May 18 18:01:52 2019 New Revision: 361109 URL: http://llvm.org/viewvc/llvm-project?rev=361109=rev Log: [X86] Remove semicolons at the end of intrinsics implemented as macros so they can be used as arguments to other intrinsics. Also fix one intrinsic that was using variable names without underscores. Fixes PR41932 Modified: cfe/trunk/lib/Headers/avx512fintrin.h cfe/trunk/lib/Headers/f16cintrin.h cfe/trunk/lib/Headers/xsaveintrin.h Modified: cfe/trunk/lib/Headers/avx512fintrin.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=361109=361108=361109=diff == --- cfe/trunk/lib/Headers/avx512fintrin.h (original) +++ cfe/trunk/lib/Headers/avx512fintrin.h Sat May 18 18:01:52 2019 @@ -1981,12 +1981,12 @@ _mm512_maskz_add_ps(__mmask16 __U, __m51 #define _mm512_mask_add_round_pd(W, U, A, B, R) \ (__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ (__v8df)_mm512_add_round_pd((A), (B), (R)), \ - (__v8df)(__m512d)(W)); + (__v8df)(__m512d)(W)) #define _mm512_maskz_add_round_pd(U, A, B, R) \ (__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ (__v8df)_mm512_add_round_pd((A), (B), (R)), \ - (__v8df)_mm512_setzero_pd()); + (__v8df)_mm512_setzero_pd()) #define _mm512_add_round_ps(A, B, R) \ (__m512)__builtin_ia32_addps512((__v16sf)(__m512)(A), \ @@ -1995,12 +1995,12 @@ _mm512_maskz_add_ps(__mmask16 __U, __m51 #define _mm512_mask_add_round_ps(W, U, A, B, R) \ (__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ (__v16sf)_mm512_add_round_ps((A), (B), (R)), \ - (__v16sf)(__m512)(W)); + (__v16sf)(__m512)(W)) #define _mm512_maskz_add_round_ps(U, A, B, R) \ (__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ (__v16sf)_mm512_add_round_ps((A), (B), (R)), \ - (__v16sf)_mm512_setzero_ps()); + (__v16sf)_mm512_setzero_ps()) static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_mask_sub_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) { @@ -2096,12 +2096,12 @@ _mm512_maskz_sub_ps(__mmask16 __U, __m51 #define _mm512_mask_sub_round_pd(W, U, A, B, R) \ (__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ (__v8df)_mm512_sub_round_pd((A), (B), (R)), \ - (__v8df)(__m512d)(W)); + (__v8df)(__m512d)(W)) #define _mm512_maskz_sub_round_pd(U, A, B, R) \ (__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ (__v8df)_mm512_sub_round_pd((A), (B), (R)), \ - (__v8df)_mm512_setzero_pd()); + (__v8df)_mm512_setzero_pd()) #define _mm512_sub_round_ps(A, B, R) \ (__m512)__builtin_ia32_subps512((__v16sf)(__m512)(A), \ @@ -2110,12 +2110,12 @@ _mm512_maskz_sub_ps(__mmask16 __U, __m51 #define _mm512_mask_sub_round_ps(W, U, A, B, R) \ (__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ (__v16sf)_mm512_sub_round_ps((A), (B), (R)), \ - (__v16sf)(__m512)(W)); + (__v16sf)(__m512)(W)) #define _mm512_maskz_sub_round_ps(U, A, B, R) \ (__m512)__builtin_ia32_selectps_512((__mmask16)(U), \ (__v16sf)_mm512_sub_round_ps((A), (B), (R)), \ - (__v16sf)_mm512_setzero_ps()); + (__v16sf)_mm512_setzero_ps()) static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_mask_mul_ss(__m128 __W, __mmask8 __U,__m128 __A, __m128 __B) { @@ -2211,12 +2211,12 @@ _mm512_maskz_mul_ps(__mmask16 __U, __m51 #define _mm512_mask_mul_round_pd(W, U, A, B, R) \ (__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ (__v8df)_mm512_mul_round_pd((A), (B), (R)), \ - (__v8df)(__m512d)(W)); + (__v8df)(__m512d)(W)) #define _mm512_maskz_mul_round_pd(U, A, B, R) \ (__m512d)__builtin_ia32_selectpd_512((__mmask8)(U), \ (__v8df)_mm512_mul_round_pd((A), (B), (R)), \ - (__v8df)_mm512_setzero_pd()); + (__v8df)_mm512_setzero_pd()) #define _mm512_mul_round_ps(A, B, R) \ (__m512)__builtin_ia32_mulps512((__v16sf)(__m512)(A), \ @@ -2225,12 +2225,12 @@ _mm512_maskz_mul_ps(__mmask16 __U, __m51 #define _mm512_mask_mul_round_ps(W, U, A, B, R) \
[PATCH] D61838: [Sema] Suppress additional warnings for C's zero initializer
al3xtjames updated this revision to Diff 200159. al3xtjames added a comment. Switched to using Expr::IgnoreImplicit() instead of manually checking for an ImplicitCastExpression. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61838/new/ https://reviews.llvm.org/D61838 Files: clang/lib/AST/Expr.cpp clang/test/Sema/zero-initializer.c Index: clang/test/Sema/zero-initializer.c === --- clang/test/Sema/zero-initializer.c +++ clang/test/Sema/zero-initializer.c @@ -7,6 +7,8 @@ struct B { struct A a; }; struct C { struct B b; }; struct D { struct C c; int n; }; +struct E { short e; }; +struct F { struct E e; int n; }; int main(void) { @@ -23,6 +25,9 @@ struct C p = { 0 }; // no-warning struct C q = { 9 }; // warning suppressed for struct with single element struct D r = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}} + struct F s = { 0 }; // no-warning + struct F t = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}} + f = (struct foo ) { 0 }; // no-warning g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' initializer}} h = (struct foo ) { 9, 9 }; // no-warning @@ -36,6 +41,8 @@ p = (struct C) { 0 }; // no-warning q = (struct C) { 9 }; // warning suppressed for struct with single element r = (struct D) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}} + s = (struct F) { 0 }; // no-warning + t = (struct F) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}} return 0; } Index: clang/lib/AST/Expr.cpp === --- clang/lib/AST/Expr.cpp +++ clang/lib/AST/Expr.cpp @@ -2175,7 +2175,7 @@ return false; } - const IntegerLiteral *Lit = dyn_cast(getInit(0)); + const IntegerLiteral *Lit = dyn_cast(getInit(0)->IgnoreImplicit()); return Lit && Lit->getValue() == 0; } Index: clang/test/Sema/zero-initializer.c === --- clang/test/Sema/zero-initializer.c +++ clang/test/Sema/zero-initializer.c @@ -7,6 +7,8 @@ struct B { struct A a; }; struct C { struct B b; }; struct D { struct C c; int n; }; +struct E { short e; }; +struct F { struct E e; int n; }; int main(void) { @@ -23,6 +25,9 @@ struct C p = { 0 }; // no-warning struct C q = { 9 }; // warning suppressed for struct with single element struct D r = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}} + struct F s = { 0 }; // no-warning + struct F t = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}} + f = (struct foo ) { 0 }; // no-warning g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' initializer}} h = (struct foo ) { 9, 9 }; // no-warning @@ -36,6 +41,8 @@ p = (struct C) { 0 }; // no-warning q = (struct C) { 9 }; // warning suppressed for struct with single element r = (struct D) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}} + s = (struct F) { 0 }; // no-warning + t = (struct F) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}} return 0; } Index: clang/lib/AST/Expr.cpp === --- clang/lib/AST/Expr.cpp +++ clang/lib/AST/Expr.cpp @@ -2175,7 +2175,7 @@ return false; } - const IntegerLiteral *Lit = dyn_cast(getInit(0)); + const IntegerLiteral *Lit = dyn_cast(getInit(0)->IgnoreImplicit()); return Lit && Lit->getValue() == 0; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61838: [Sema] Suppress additional warnings for C's zero initializer
rsmith added inline comments. Comment at: clang/lib/AST/Expr.cpp:2092-2096 const IntegerLiteral *Lit = dyn_cast(getInit(0)); + if (!Lit) { +if (const ImplicitCastExpr *ICE = dyn_cast(getInit(0))) + Lit = dyn_cast(ICE->getSubExpr()); + } Use `Expr::IgnoreImplicit` rather than checking for an `ImplicitCastExpr` here: ``` const IntegerLiteral *Lit = dyn_cast(getInit(0)->IgnoreImplicit()); ``` Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61838/new/ https://reviews.llvm.org/D61838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61838: [Sema] Suppress additional warnings for C's zero initializer
al3xtjames added a comment. Thanks for reviewing! I don't have commit access, so I can't commit this patch myself. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61838/new/ https://reviews.llvm.org/D61838 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.
Szelethus requested changes to this revision. Szelethus added a comment. This revision now requires changes to proceed. The more I think about this, the more I think it would be great to see this tested :) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61816/new/ https://reviews.llvm.org/D61816 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61570: [analyzer] PR41753: Include complex integer types in NonLoc::isCompoundType
This revision was automatically updated to reflect the committed changes. Closed by commit rL361099: [analyzer] PR41753: Include complex integer types in NonLoc::isCompoundType (authored by Szelethus, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D61570?vs=198181=200147#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61570/new/ https://reviews.llvm.org/D61570 Files: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h cfe/trunk/test/Analysis/complex.c cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -303,7 +303,7 @@ static bool isCompoundType(QualType T) { return T->isArrayType() || T->isRecordType() || - T->isComplexType() || T->isVectorType(); + T->isAnyComplexType() || T->isVectorType(); } private: Index: cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp === --- cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp +++ cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp @@ -1167,20 +1167,17 @@ __complex__ int y; }; -// FIXME: Currently this causes (unrelated to this checker) an assertion -// failure. -// -//struct ComplexInitTest { -// ComplexInitTest() { -//x = {1.0f, 1.0f}; -//y = {1, 1}; -// } -// __complex__ float x; -// __complex__ int y; -//}; +struct ComplexInitTest { + ComplexInitTest() { +x = {1.0f, 1.0f}; +y = {1, 1}; + } + __complex__ float x; + __complex__ int y; +}; void fComplexTest() { -// ComplexInitTest x; + ComplexInitTest x; // TODO: we should emit a warning for x2.x and x2.y. ComplexUninitTest x2; Index: cfe/trunk/test/Analysis/complex.c === --- cfe/trunk/test/Analysis/complex.c +++ cfe/trunk/test/Analysis/complex.c @@ -1,9 +1,13 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -verify -Wno-unreachable-code -ffreestanding %s +// RUN: %clang_analyze_cc1 -verify %s \ +// RUN: -Wno-unreachable-code -ffreestanding \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=debug.ExprInspection #include +int clang_analyzer_eval(int); + void f1(int * p) { - // This branch should be infeasible // because __imag__ p is 0. if (!p && __imag__ (intptr_t) p) @@ -15,3 +19,25 @@ *p = 2; // expected-warning{{Dereference of null pointer}} } + +void complexFloat(__complex__ float f) { + clang_analyzer_eval(__real__(f) == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(__imag__(f) == 1); // expected-warning{{UNKNOWN}} + + __real__(f) = 1; + __imag__(f) = 1; + + clang_analyzer_eval(__real__(f) == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(__imag__(f) == 1); // expected-warning{{UNKNOWN}} +} + +void complexInt(__complex__ int f) { + clang_analyzer_eval(__real__(f) == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(__imag__(f) == 1); // expected-warning{{UNKNOWN}} + + __real__(f) = 1; + __imag__(f) = 1; + + clang_analyzer_eval(__real__(f) == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(__imag__(f) == 1); // expected-warning{{UNKNOWN}} +} Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h === --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h @@ -303,7 +303,7 @@ static bool isCompoundType(QualType T) { return T->isArrayType() || T->isRecordType() || - T->isComplexType() || T->isVectorType(); + T->isAnyComplexType() || T->isVectorType(); } private: Index: cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp === --- cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp +++ cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp @@ -1167,20 +1167,17 @@ __complex__ int y; }; -// FIXME: Currently this causes (unrelated to this checker) an assertion -// failure. -// -//struct ComplexInitTest { -// ComplexInitTest() { -//x = {1.0f, 1.0f}; -//y = {1, 1}; -// } -// __complex__ float x; -// __complex__ int y; -//}; +struct ComplexInitTest { + ComplexInitTest() { +x = {1.0f, 1.0f}; +y = {1, 1}; + } + __complex__ float x; + __complex__ int y; +}; void fComplexTest() { -// ComplexInitTest x; + ComplexInitTest x; // TODO: we should emit a warning for x2.x and x2.y. ComplexUninitTest x2; Index: cfe/trunk/test/Analysis/complex.c
r361099 - [analyzer] PR41753: Include complex integer types in NonLoc::isCompoundType
Author: szelethus Date: Sat May 18 05:34:08 2019 New Revision: 361099 URL: http://llvm.org/viewvc/llvm-project?rev=361099=rev Log: [analyzer] PR41753: Include complex integer types in NonLoc::isCompoundType https://bugs.llvm.org/show_bug.cgi?id=41753 Differential Revision: https://reviews.llvm.org/D61570 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h cfe/trunk/test/Analysis/complex.c cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h?rev=361099=361098=361099=diff == --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h Sat May 18 05:34:08 2019 @@ -303,7 +303,7 @@ public: static bool isCompoundType(QualType T) { return T->isArrayType() || T->isRecordType() || - T->isComplexType() || T->isVectorType(); + T->isAnyComplexType() || T->isVectorType(); } private: Modified: cfe/trunk/test/Analysis/complex.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/complex.c?rev=361099=361098=361099=diff == --- cfe/trunk/test/Analysis/complex.c (original) +++ cfe/trunk/test/Analysis/complex.c Sat May 18 05:34:08 2019 @@ -1,9 +1,13 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region -verify -Wno-unreachable-code -ffreestanding %s +// RUN: %clang_analyze_cc1 -verify %s \ +// RUN: -Wno-unreachable-code -ffreestanding \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=debug.ExprInspection #include +int clang_analyzer_eval(int); + void f1(int * p) { - // This branch should be infeasible // because __imag__ p is 0. if (!p && __imag__ (intptr_t) p) @@ -15,3 +19,25 @@ void f1(int * p) { *p = 2; // expected-warning{{Dereference of null pointer}} } + +void complexFloat(__complex__ float f) { + clang_analyzer_eval(__real__(f) == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(__imag__(f) == 1); // expected-warning{{UNKNOWN}} + + __real__(f) = 1; + __imag__(f) = 1; + + clang_analyzer_eval(__real__(f) == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(__imag__(f) == 1); // expected-warning{{UNKNOWN}} +} + +void complexInt(__complex__ int f) { + clang_analyzer_eval(__real__(f) == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(__imag__(f) == 1); // expected-warning{{UNKNOWN}} + + __real__(f) = 1; + __imag__(f) = 1; + + clang_analyzer_eval(__real__(f) == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(__imag__(f) == 1); // expected-warning{{UNKNOWN}} +} Modified: cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp?rev=361099=361098=361099=diff == --- cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp (original) +++ cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp Sat May 18 05:34:08 2019 @@ -1167,20 +1167,17 @@ struct ComplexUninitTest { __complex__ int y; }; -// FIXME: Currently this causes (unrelated to this checker) an assertion -// failure. -// -//struct ComplexInitTest { -// ComplexInitTest() { -//x = {1.0f, 1.0f}; -//y = {1, 1}; -// } -// __complex__ float x; -// __complex__ int y; -//}; +struct ComplexInitTest { + ComplexInitTest() { +x = {1.0f, 1.0f}; +y = {1, 1}; + } + __complex__ float x; + __complex__ int y; +}; void fComplexTest() { -// ComplexInitTest x; + ComplexInitTest x; // TODO: we should emit a warning for x2.x and x2.y. ComplexUninitTest x2; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r361098 - ScalarExprEmitter::EmitCompoundAssign - fix uninitialized variable warning. NFCI.
Author: rksimon Date: Sat May 18 05:17:15 2019 New Revision: 361098 URL: http://llvm.org/viewvc/llvm-project?rev=361098=rev Log: ScalarExprEmitter::EmitCompoundAssign - fix uninitialized variable warning. NFCI. Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=361098=361097=361098=diff == --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat May 18 05:17:15 2019 @@ -2984,7 +2984,7 @@ LValue ScalarExprEmitter::EmitCompoundAs Value *ScalarExprEmitter::EmitCompoundAssign(const CompoundAssignOperator *E, Value *(ScalarExprEmitter::*Func)(const BinOpInfo &)) { bool Ignore = TestAndClearIgnoreResultAssign(); - Value *RHS; + Value *RHS = nullptr; LValue LHS = EmitCompoundAssignLValue(E, Func, RHS); // If the result is clearly ignored, return now. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D62093: [analyzer] Divide checkers into 3 categories: released, alpha, developer
Szelethus added a comment. Let's come to a consensus on this, and followup patches, but as soon as that's done, this REALLY NEEDS to be documented in the release notes. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D62093/new/ https://reviews.llvm.org/D62093 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r361097 - MIGChecker - assert we have a non-null LocationContext. NFCI.
Author: rksimon Date: Sat May 18 04:42:19 2019 New Revision: 361097 URL: http://llvm.org/viewvc/llvm-project?rev=361097=rev Log: MIGChecker - assert we have a non-null LocationContext. NFCI. Fixes scan-build warning. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp?rev=361097=361096=361097=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp Sat May 18 04:42:19 2019 @@ -144,6 +144,8 @@ static const ParmVarDecl *getOriginParam static bool isInMIGCall(CheckerContext ) { const LocationContext *LC = C.getLocationContext(); + assert(LC && "Unknown location context"); + const StackFrameContext *SFC; // Find the top frame. while (LC) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r361096 - ASTNodeImporter - fix uninitialized variable warnings. NFCI.
Author: rksimon Date: Sat May 18 04:33:27 2019 New Revision: 361096 URL: http://llvm.org/viewvc/llvm-project?rev=361096=rev Log: ASTNodeImporter - fix uninitialized variable warnings. NFCI. Modified: cfe/trunk/lib/AST/ASTImporter.cpp Modified: cfe/trunk/lib/AST/ASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=361096=361095=361096=diff == --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Sat May 18 04:33:27 2019 @@ -5325,7 +5325,7 @@ ExpectedDecl ASTNodeImporter::VisitVarTe return ImportedDefOrErr.takeError(); } - VarTemplateDecl *VarTemplate; + VarTemplateDecl *VarTemplate = nullptr; if (Error Err = importInto(VarTemplate, D->getSpecializedTemplate())) return std::move(Err); @@ -8010,7 +8010,7 @@ ASTImporter::Import(NestedNameSpecifierL while (!NestedNames.empty()) { NNS = NestedNames.pop_back_val(); -NestedNameSpecifier *Spec; +NestedNameSpecifier *Spec = nullptr; if (Error Err = importInto(Spec, NNS.getNestedNameSpecifier())) return std::move(Err); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61909: Add Clang shared library with C++ exports
sylvestre.ledru added a comment. @beanz Great doc, thanks! I will see what I could use for Debian/Ubuntu packages (as we have a lot users and packages organized in a specific way, it isn't always easy to make huge changes) Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61909/new/ https://reviews.llvm.org/D61909 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits