[PATCH] D28543: Eliminates uninitialized warning for volatile variables.
lethalantidote added a comment. Is there any subgroup that one could suggest for this warning to fall under? https://reviews.llvm.org/D28543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D29737: Updates documentation to include command to run clang-tidy tests.
lethalantidote created this revision. Herald added a subscriber: JDevlieghere. Adds the commandline need to run clang-tidy tests. https://reviews.llvm.org/D29737 Files: clang-tools-extra/docs/clang-tidy/index.rst Index: clang-tools-extra/docs/clang-tidy/index.rst === --- clang-tools-extra/docs/clang-tidy/index.rst +++ clang-tools-extra/docs/clang-tidy/index.rst @@ -537,6 +537,12 @@ Testing Checks -- +To run tests for :program:`clang-tidy` use the command: + +.. code-block:: console + + $ ninja check-clang-tools + :program:`clang-tidy` checks can be tested using either unit tests or `lit`_ tests. Unit tests may be more convenient to test complex replacements with strict checks. `Lit`_ tests allow using partial text matching and regular Index: clang-tools-extra/docs/clang-tidy/index.rst === --- clang-tools-extra/docs/clang-tidy/index.rst +++ clang-tools-extra/docs/clang-tidy/index.rst @@ -537,6 +537,12 @@ Testing Checks -- +To run tests for :program:`clang-tidy` use the command: + +.. code-block:: console + + $ ninja check-clang-tools + :program:`clang-tidy` checks can be tested using either unit tests or `lit`_ tests. Unit tests may be more convenient to test complex replacements with strict checks. `Lit`_ tests allow using partial text matching and regular ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.
lethalantidote added a comment. Any updates on this? https://reviews.llvm.org/D28543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28973: Supresses misc-move-constructor-init warning for const fields.
lethalantidote updated this revision to Diff 87484. lethalantidote marked an inline comment as done. lethalantidote added a comment. - Addresses alexfh's comments. https://reviews.llvm.org/D28973 Files: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp Index: clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp === --- clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp +++ clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp @@ -84,6 +84,16 @@ N(N &) : Mem(move(RHS.Mem)) {} }; +struct O { + O(O&& other) : b(other.b) {} // ok + const B b; +}; + +struct P { + P(O&& other) : b(other.b) {} // ok + B b; +}; + struct Movable { Movable(Movable &&) = default; Movable(const Movable &) = default; Index: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp === --- clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp +++ clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp @@ -57,6 +57,9 @@ if (QT.isTriviallyCopyableType(*Result.Context)) return; + if (QT.isConstQualified()) +return; + const auto *RD = QT->getAsCXXRecordDecl(); if (RD && RD->isTriviallyCopyable()) return; Index: clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp === --- clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp +++ clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp @@ -84,6 +84,16 @@ N(N &) : Mem(move(RHS.Mem)) {} }; +struct O { + O(O&& other) : b(other.b) {} // ok + const B b; +}; + +struct P { + P(O&& other) : b(other.b) {} // ok + B b; +}; + struct Movable { Movable(Movable &&) = default; Movable(const Movable &) = default; Index: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp === --- clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp +++ clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp @@ -57,6 +57,9 @@ if (QT.isTriviallyCopyableType(*Result.Context)) return; + if (QT.isConstQualified()) +return; + const auto *RD = QT->getAsCXXRecordDecl(); if (RD && RD->isTriviallyCopyable()) return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28973: Supresses misc-move-constructor-init warning for const fields.
lethalantidote created this revision. Supresses misc-move-constructor init warning for const fields. https://reviews.llvm.org/D28973 Files: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp Index: clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp === --- clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp +++ clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp @@ -84,6 +84,11 @@ N(N &) : Mem(move(RHS.Mem)) {} }; +struct O { + O(O&& other) : b(other.b) {} // ok + const B b; +} + struct Movable { Movable(Movable &&) = default; Movable(const Movable &) = default; Index: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp === --- clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp +++ clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp @@ -57,6 +57,9 @@ if (QT.isTriviallyCopyableType(*Result.Context)) return; + if (QT.isConstQualified()) +return; + const auto *RD = QT->getAsCXXRecordDecl(); if (RD && RD->isTriviallyCopyable()) return; Index: clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp === --- clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp +++ clang-tools-extra/test/clang-tidy/misc-move-constructor-init.cpp @@ -84,6 +84,11 @@ N(N &) : Mem(move(RHS.Mem)) {} }; +struct O { + O(O&& other) : b(other.b) {} // ok + const B b; +} + struct Movable { Movable(Movable &&) = default; Movable(const Movable &) = default; Index: clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp === --- clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp +++ clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp @@ -57,6 +57,9 @@ if (QT.isTriviallyCopyableType(*Result.Context)) return; + if (QT.isConstQualified()) +return; + const auto *RD = QT->getAsCXXRecordDecl(); if (RD && RD->isTriviallyCopyable()) return; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.
lethalantidote updated this revision to Diff 84045. lethalantidote added a comment. Moves check in IsTracked(). https://reviews.llvm.org/D28543 Files: clang/lib/Analysis/UninitializedValues.cpp clang/lib/Sema/AnalysisBasedWarnings.cpp clang/test/Sema/uninit-variables.c Index: clang/test/Sema/uninit-variables.c === --- clang/test/Sema/uninit-variables.c +++ clang/test/Sema/uninit-variables.c @@ -22,7 +22,7 @@ int test4() { int x; // expected-note{{initialize the variable 'x' to silence this warning}} ++x; // expected-warning{{variable 'x' is uninitialized when used here}} - return x; + return x; } int test5() { @@ -442,6 +442,21 @@ struct { struct { void *p; } a; } test55 = { { }}; // no-warning struct { struct { void *p; } a; } test56 = { { &(test56.a) }}; // no-warning +int test57() { + volatile int x; + return x; // no-warning +} + +int init(volatile int* num) { + return 1; +} + +int test58() { + volatile int a, b, c; + if (init() || init() || init()) {} + return a+b+c; // no-warning +} + void uninit_in_loop() { int produce(void); void consume(int); Index: clang/lib/Sema/AnalysisBasedWarnings.cpp === --- clang/lib/Sema/AnalysisBasedWarnings.cpp +++ clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -80,7 +80,7 @@ } S.Diag(L, diag) << R1 << R2; - + SourceLocation Open = SilenceableCondVal.getBegin(); if (Open.isValid()) { SourceLocation Close = SilenceableCondVal.getEnd(); Index: clang/lib/Analysis/UninitializedValues.cpp === --- clang/lib/Analysis/UninitializedValues.cpp +++ clang/lib/Analysis/UninitializedValues.cpp @@ -36,7 +36,8 @@ static bool isTrackedVar(const VarDecl *vd, const DeclContext *dc) { if (vd->isLocalVarDecl() && !vd->hasGlobalStorage() && !vd->isExceptionVariable() && !vd->isInitCapture() && - !vd->isImplicit() && vd->getDeclContext() == dc) { + !vd->isImplicit() && !vd->getType().isVolatileQualified() && + vd->getDeclContext() == dc) { QualType ty = vd->getType(); return ty->isScalarType() || ty->isVectorType() || ty->isRecordType(); } Index: clang/test/Sema/uninit-variables.c === --- clang/test/Sema/uninit-variables.c +++ clang/test/Sema/uninit-variables.c @@ -22,7 +22,7 @@ int test4() { int x; // expected-note{{initialize the variable 'x' to silence this warning}} ++x; // expected-warning{{variable 'x' is uninitialized when used here}} - return x; + return x; } int test5() { @@ -442,6 +442,21 @@ struct { struct { void *p; } a; } test55 = { { }}; // no-warning struct { struct { void *p; } a; } test56 = { { &(test56.a) }}; // no-warning +int test57() { + volatile int x; + return x; // no-warning +} + +int init(volatile int* num) { + return 1; +} + +int test58() { + volatile int a, b, c; + if (init() || init() || init()) {} + return a+b+c; // no-warning +} + void uninit_in_loop() { int produce(void); void consume(int); Index: clang/lib/Sema/AnalysisBasedWarnings.cpp === --- clang/lib/Sema/AnalysisBasedWarnings.cpp +++ clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -80,7 +80,7 @@ } S.Diag(L, diag) << R1 << R2; - + SourceLocation Open = SilenceableCondVal.getBegin(); if (Open.isValid()) { SourceLocation Close = SilenceableCondVal.getEnd(); Index: clang/lib/Analysis/UninitializedValues.cpp === --- clang/lib/Analysis/UninitializedValues.cpp +++ clang/lib/Analysis/UninitializedValues.cpp @@ -36,7 +36,8 @@ static bool isTrackedVar(const VarDecl *vd, const DeclContext *dc) { if (vd->isLocalVarDecl() && !vd->hasGlobalStorage() && !vd->isExceptionVariable() && !vd->isInitCapture() && - !vd->isImplicit() && vd->getDeclContext() == dc) { + !vd->isImplicit() && !vd->getType().isVolatileQualified() && + vd->getDeclContext() == dc) { QualType ty = vd->getType(); return ty->isScalarType() || ty->isVectorType() || ty->isRecordType(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.
lethalantidote added a comment. So I tried the update you suggested (moving it up into IsTracked) and it seems to work and the reasoning makes sense to me. https://reviews.llvm.org/D28543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.
lethalantidote updated this revision to Diff 84026. lethalantidote marked an inline comment as done. lethalantidote added a comment. Addresses moving check further up, during analysis. Adds test to check for sometimes branch. Please review. https://reviews.llvm.org/D28543 Files: clang/lib/Analysis/UninitializedValues.cpp clang/lib/Sema/AnalysisBasedWarnings.cpp clang/test/Sema/uninit-variables.c Index: clang/test/Sema/uninit-variables.c === --- clang/test/Sema/uninit-variables.c +++ clang/test/Sema/uninit-variables.c @@ -22,7 +22,7 @@ int test4() { int x; // expected-note{{initialize the variable 'x' to silence this warning}} ++x; // expected-warning{{variable 'x' is uninitialized when used here}} - return x; + return x; } int test5() { @@ -442,6 +442,21 @@ struct { struct { void *p; } a; } test55 = { { }}; // no-warning struct { struct { void *p; } a; } test56 = { { &(test56.a) }}; // no-warning +int test57() { + volatile int x; + return x; // no-warning +} + +int init(volatile int* num) { + return 1; +} + +int test58() { + volatile int a, b, c; + if (init() || init() || init()) {} + return a+b+c; // no-warning +} + void uninit_in_loop() { int produce(void); void consume(int); Index: clang/lib/Sema/AnalysisBasedWarnings.cpp === --- clang/lib/Sema/AnalysisBasedWarnings.cpp +++ clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -80,7 +80,7 @@ } S.Diag(L, diag) << R1 << R2; - + SourceLocation Open = SilenceableCondVal.getBegin(); if (Open.isValid()) { SourceLocation Close = SilenceableCondVal.getEnd(); Index: clang/lib/Analysis/UninitializedValues.cpp === --- clang/lib/Analysis/UninitializedValues.cpp +++ clang/lib/Analysis/UninitializedValues.cpp @@ -767,7 +767,7 @@ // appropriately, but we need to continue to analyze subsequent uses // of the variable. vals[VD] = Uninitialized; - } else if (VD->getInit()) { + } else if (VD->getInit() || VD->getType().isVolatileQualified()) { // Treat the new variable as initialized. vals[VD] = Initialized; } else { Index: clang/test/Sema/uninit-variables.c === --- clang/test/Sema/uninit-variables.c +++ clang/test/Sema/uninit-variables.c @@ -22,7 +22,7 @@ int test4() { int x; // expected-note{{initialize the variable 'x' to silence this warning}} ++x; // expected-warning{{variable 'x' is uninitialized when used here}} - return x; + return x; } int test5() { @@ -442,6 +442,21 @@ struct { struct { void *p; } a; } test55 = { { }}; // no-warning struct { struct { void *p; } a; } test56 = { { &(test56.a) }}; // no-warning +int test57() { + volatile int x; + return x; // no-warning +} + +int init(volatile int* num) { + return 1; +} + +int test58() { + volatile int a, b, c; + if (init() || init() || init()) {} + return a+b+c; // no-warning +} + void uninit_in_loop() { int produce(void); void consume(int); Index: clang/lib/Sema/AnalysisBasedWarnings.cpp === --- clang/lib/Sema/AnalysisBasedWarnings.cpp +++ clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -80,7 +80,7 @@ } S.Diag(L, diag) << R1 << R2; - + SourceLocation Open = SilenceableCondVal.getBegin(); if (Open.isValid()) { SourceLocation Close = SilenceableCondVal.getEnd(); Index: clang/lib/Analysis/UninitializedValues.cpp === --- clang/lib/Analysis/UninitializedValues.cpp +++ clang/lib/Analysis/UninitializedValues.cpp @@ -767,7 +767,7 @@ // appropriately, but we need to continue to analyze subsequent uses // of the variable. vals[VD] = Uninitialized; - } else if (VD->getInit()) { + } else if (VD->getInit() || VD->getType().isVolatileQualified()) { // Treat the new variable as initialized. vals[VD] = Initialized; } else { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.
lethalantidote added inline comments. Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:907 else DiagUninitUse(S, VD, Use, true); } thakis wrote: > Should the check be in DiagUninitUse()? Or is there a reason this one should > happen for volatiles? Good point. Thanks for catching that. I hoped I understood this use case correctly, lemme know if the update makes sense. https://reviews.llvm.org/D28543 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.
lethalantidote created this revision. lethalantidote added a reviewer: thakis. lethalantidote added a subscriber: cfe-commits. Elliminates uninitialized warning for volitile variables. https://reviews.llvm.org/D28543 Files: clang/lib/Sema/AnalysisBasedWarnings.cpp Index: clang/lib/Sema/AnalysisBasedWarnings.cpp === --- clang/lib/Sema/AnalysisBasedWarnings.cpp +++ clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -864,7 +864,7 @@ /// false. static bool DiagnoseUninitializedUse(Sema , const VarDecl *VD, const UninitUse , - bool alwaysReportSelfInit = false) { + bool alwaysReportSelfInit = false) { if (const DeclRefExpr *DRE = dyn_cast(Use.getUser())) { // Inspect the initializer of the variable declaration which is // being referenced prior to its initialization. We emit @@ -891,6 +891,11 @@ } } +// If volatile, we don't raise this warning. +if (VD->getType().isVolatileQualified()) { + return false; +} + DiagUninitUse(S, VD, Use, false); } else { const BlockExpr *BE = cast(Use.getUser()); Index: clang/lib/Sema/AnalysisBasedWarnings.cpp === --- clang/lib/Sema/AnalysisBasedWarnings.cpp +++ clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -864,7 +864,7 @@ /// false. static bool DiagnoseUninitializedUse(Sema , const VarDecl *VD, const UninitUse , - bool alwaysReportSelfInit = false) { + bool alwaysReportSelfInit = false) { if (const DeclRefExpr *DRE = dyn_cast(Use.getUser())) { // Inspect the initializer of the variable declaration which is // being referenced prior to its initialization. We emit @@ -891,6 +891,11 @@ } } +// If volatile, we don't raise this warning. +if (VD->getType().isVolatileQualified()) { + return false; +} + DiagUninitUse(S, VD, Use, false); } else { const BlockExpr *BE = cast(Use.getUser()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits