[clang] 090f9d5 - Fix MSVC "not all control paths return a value" warning. NFC.
Author: Simon Pilgrim Date: 2020-08-08T19:12:11+01:00 New Revision: 090f9d5a55338ee815f5a6ef7aaa1ed712f65e05 URL: https://github.com/llvm/llvm-project/commit/090f9d5a55338ee815f5a6ef7aaa1ed712f65e05 DIFF: https://github.com/llvm/llvm-project/commit/090f9d5a55338ee815f5a6ef7aaa1ed712f65e05.diff LOG: Fix MSVC "not all control paths return a value" warning. NFC. Added: Modified: clang/lib/Tooling/Syntax/BuildTree.cpp Removed: diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index 21ac6b8bda62..4e76b3825b6f 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -769,6 +769,7 @@ class BuildTreeVisitor : public RecursiveASTVisitor { llvm::report_fatal_error("We don't yet support the __super specifier", true); } +llvm_unreachable("Unhandled NestedNameSpecifier::SpecifierKind enum"); } // FIXME: Fix `NestedNameSpecifierLoc::getLocalSourceRange` for the ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 18212cb - Remove duplicate/unreachable break (PR47029)
Author: Simon Pilgrim Date: 2020-08-07T11:48:48+01:00 New Revision: 18212cbcdadd130e5b2d1bc2bb38e4396ef8a46f URL: https://github.com/llvm/llvm-project/commit/18212cbcdadd130e5b2d1bc2bb38e4396ef8a46f DIFF: https://github.com/llvm/llvm-project/commit/18212cbcdadd130e5b2d1bc2bb38e4396ef8a46f.diff LOG: Remove duplicate/unreachable break (PR47029) Added: Modified: clang/lib/Sema/SemaType.cpp Removed: diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index ff5223c0795e..b2be31ac0990 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1543,7 +1543,8 @@ static QualType ConvertDeclSpecToType(TypeProcessingState ) { << "__float128"; Result = Context.Float128Ty; break; - case DeclSpec::TST_bool: Result = Context.BoolTy; break; // _Bool or bool + case DeclSpec::TST_bool: +Result = Context.BoolTy; // _Bool or bool break; case DeclSpec::TST_decimal32:// _Decimal32 case DeclSpec::TST_decimal64:// _Decimal64 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ffd258f - Remove unreachable return (PR47028)
Author: Simon Pilgrim Date: 2020-08-07T11:33:23+01:00 New Revision: ffd258f7bbba2a65800970fcea6648fb285d95f4 URL: https://github.com/llvm/llvm-project/commit/ffd258f7bbba2a65800970fcea6648fb285d95f4 DIFF: https://github.com/llvm/llvm-project/commit/ffd258f7bbba2a65800970fcea6648fb285d95f4.diff LOG: Remove unreachable return (PR47028) Added: Modified: clang/lib/Driver/ToolChains/Arch/Mips.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp b/clang/lib/Driver/ToolChains/Arch/Mips.cpp index 7b4dd703c0c7..5a509dbb2bd3 100644 --- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp +++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp @@ -452,8 +452,6 @@ bool mips::isNaN2008(const ArgList , const llvm::Triple ) { return llvm::StringSwitch(getCPUName(Args, Triple)) .Cases("mips32r6", "mips64r6", true) .Default(false); - - return false; } bool mips::isFP64ADefault(const llvm::Triple , StringRef CPUName) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 24cca30 - Remove unreachable return (PR47026)
Author: Simon Pilgrim Date: 2020-08-07T11:23:43+01:00 New Revision: 24cca30f7f0de49e77af7e8c7719680daec2418e URL: https://github.com/llvm/llvm-project/commit/24cca30f7f0de49e77af7e8c7719680daec2418e DIFF: https://github.com/llvm/llvm-project/commit/24cca30f7f0de49e77af7e8c7719680daec2418e.diff LOG: Remove unreachable return (PR47026) Added: Modified: clang/lib/Basic/Targets/Mips.cpp Removed: diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp index ead5e91f7c8f..3a32fd492c6b 100644 --- a/clang/lib/Basic/Targets/Mips.cpp +++ b/clang/lib/Basic/Targets/Mips.cpp @@ -41,7 +41,6 @@ bool MipsTargetInfo::processorSupportsGPR64() const { .Case("octeon", true) .Case("octeon+", true) .Default(false); - return false; } static constexpr llvm::StringLiteral ValidCPUNames[] = { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 83cb98f - Fix sphinx indentation warnings by adding explicit line breaks to address space hierarchy
Author: Simon Pilgrim Date: 2020-08-04T17:48:54+01:00 New Revision: 83cb98f9e7a57360e137b32b26500fca630df617 URL: https://github.com/llvm/llvm-project/commit/83cb98f9e7a57360e137b32b26500fca630df617 DIFF: https://github.com/llvm/llvm-project/commit/83cb98f9e7a57360e137b32b26500fca630df617.diff LOG: Fix sphinx indentation warnings by adding explicit line breaks to address space hierarchy Added: Modified: clang/include/clang/Basic/AttrDocs.td Removed: diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 76a075a97ee1..83990721d7f7 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -3134,11 +3134,12 @@ distinguish USM (Unified Shared Memory) pointers that access global device memory from those that access global host memory. These new address spaces are a subset of the ``__global/opencl_global`` address space, the full address space set model for OpenCL 2.0 with the extension looks as follows: - generic->global->host - ->device - ->private - ->local - constant + + | generic->global->host + |->device + |->private + |->local + | constant As ``global_device`` and ``global_host`` are a subset of ``__global/opencl_global`` address spaces it is allowed to convert ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5e0a9dc - Separate code-block tag with a newline to fix code snippet html output
Author: Simon Pilgrim Date: 2020-08-04T16:36:00+01:00 New Revision: 5e0a9dc0ad7704b7c49995101629010f5ff98cd2 URL: https://github.com/llvm/llvm-project/commit/5e0a9dc0ad7704b7c49995101629010f5ff98cd2 DIFF: https://github.com/llvm/llvm-project/commit/5e0a9dc0ad7704b7c49995101629010f5ff98cd2.diff LOG: Separate code-block tag with a newline to fix code snippet html output Added: Modified: clang/include/clang/Basic/AttrDocs.td Removed: diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index b9fcf9af323b..76a075a97ee1 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -1084,6 +1084,7 @@ not made control-dependent on any additional values, e.g., unrolling a loop executed by all work items. Sample usage: + .. code-block:: c void convfunc(void) __attribute__((convergent)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 90dab1a - Remove unused param tag to fix Wdocumentation warning. NFC.
Author: Simon Pilgrim Date: 2020-08-02T15:12:01+01:00 New Revision: 90dab1aece7100ace855321162c0d2a09b31c1b3 URL: https://github.com/llvm/llvm-project/commit/90dab1aece7100ace855321162c0d2a09b31c1b3 DIFF: https://github.com/llvm/llvm-project/commit/90dab1aece7100ace855321162c0d2a09b31c1b3.diff LOG: Remove unused param tag to fix Wdocumentation warning. NFC. Added: Modified: clang/lib/Parse/ParseOpenMP.cpp Removed: diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 8a92a8259c44..f24cb3d3f0b7 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -3191,7 +3191,6 @@ static void parseMapType(Parser , Parser::OpenMPVarListDataTy ) { /// Parses simple expression in parens for single-expression clauses of OpenMP /// constructs. -/// \param RLoc Returned location of right paren. ExprResult Parser::ParseOpenMPIteratorsExpr() { assert(Tok.is(tok::identifier) && PP.getSpelling(Tok) == "iterator" && "Expected 'iterator' token."); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 397c682 - Fix MSVC "not all control paths return a value" warning. NFC.
Author: Simon Pilgrim Date: 2020-07-09T11:06:39+01:00 New Revision: 397c68202a990c80a71de2816cee413cd5b5865e URL: https://github.com/llvm/llvm-project/commit/397c68202a990c80a71de2816cee413cd5b5865e DIFF: https://github.com/llvm/llvm-project/commit/397c68202a990c80a71de2816cee413cd5b5865e.diff LOG: Fix MSVC "not all control paths return a value" warning. NFC. Added: Modified: clang/lib/Tooling/Syntax/BuildTree.cpp Removed: diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index 361455e69f5a..f9fdf47bff26 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -192,6 +192,7 @@ static syntax::NodeKind getOperatorNodeKind(const CXXOperatorCallExpr ) { case OO_None: llvm_unreachable("Not an overloadable operator"); } + llvm_unreachable("Unknown OverloadedOperatorKind enum"); } /// Gets the range of declarator as defined by the C++ grammar. E.g. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 36aaffb - Fix Wdocumentation warnings due to outdated parameter list. NFC.
Author: Simon Pilgrim Date: 2020-07-01T12:01:18+01:00 New Revision: 36aaffbf56913ebe1e3987d7d0ac76573be65cbc URL: https://github.com/llvm/llvm-project/commit/36aaffbf56913ebe1e3987d7d0ac76573be65cbc DIFF: https://github.com/llvm/llvm-project/commit/36aaffbf56913ebe1e3987d7d0ac76573be65cbc.diff LOG: Fix Wdocumentation warnings due to outdated parameter list. NFC. Added: Modified: clang/lib/CodeGen/CGDecl.cpp Removed: diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index e4cb849e79d1..09593531af83 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -1880,9 +1880,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission ) { /// /// \param init the initializing expression /// \param D the object to act as if we're initializing -/// \param loc the address to initialize; its type is a pointer -/// to the LLVM mapping of the object's type -/// \param alignment the alignment of the address +/// \param lvalue the lvalue to initialize /// \param capturedByInit true if \p D is a __block variable /// whose address is potentially changed by the initializer void CodeGenFunction::EmitExprAsInit(const Expr *init, const ValueDecl *D, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0069824 - Revert rGf0bab7875e78e01c149d12302dcc4b6d4c43e25c - "Triple.h - reduce Twine.h include to forward declarations. NFC."
Author: Simon Pilgrim Date: 2020-06-26T14:46:40+01:00 New Revision: 0069824feab0af5ade571d975deb1efd893c2466 URL: https://github.com/llvm/llvm-project/commit/0069824feab0af5ade571d975deb1efd893c2466 DIFF: https://github.com/llvm/llvm-project/commit/0069824feab0af5ade571d975deb1efd893c2466.diff LOG: Revert rGf0bab7875e78e01c149d12302dcc4b6d4c43e25c - "Triple.h - reduce Twine.h include to forward declarations. NFC." This causes ICEs on the clang-ppc64be buildbots and I've limited ability to triage the problem. Added: Modified: clang/lib/Basic/IdentifierTable.cpp clang/lib/Basic/Targets/Mips.h llvm/include/llvm/ADT/Triple.h llvm/include/llvm/Support/TargetRegistry.h llvm/lib/MC/MCSectionELF.cpp llvm/lib/Support/Triple.cpp llvm/unittests/ADT/TripleTest.cpp llvm/unittests/Frontend/OpenMPContextTest.cpp llvm/unittests/Support/ThreadPool.cpp Removed: diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 55d3f6a447b2..36b26d9b7c68 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -23,7 +23,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/Twine.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h index e2fcda3329ab..b475c03889a1 100644 --- a/clang/lib/Basic/Targets/Mips.h +++ b/clang/lib/Basic/Targets/Mips.h @@ -16,7 +16,6 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetOptions.h" #include "llvm/ADT/Triple.h" -#include "llvm/ADT/Twine.h" #include "llvm/Support/Compiler.h" namespace clang { diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index c039d424487d..89679619dd55 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -9,8 +9,7 @@ #ifndef LLVM_ADT_TRIPLE_H #define LLVM_ADT_TRIPLE_H -#include "llvm/ADT/StringRef.h" -#include +#include "llvm/ADT/Twine.h" // Some system headers or GCC predefined macros conflict with identifiers in // this file. Undefine them here. @@ -20,7 +19,6 @@ namespace llvm { -class Twine; class VersionTuple; /// Triple - Helper class for working with autoconf configuration names. For diff --git a/llvm/include/llvm/Support/TargetRegistry.h b/llvm/include/llvm/Support/TargetRegistry.h index 5592879630de..d91eabae8235 100644 --- a/llvm/include/llvm/Support/TargetRegistry.h +++ b/llvm/include/llvm/Support/TargetRegistry.h @@ -22,7 +22,6 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" -#include "llvm/ADT/Twine.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/ErrorHandling.h" diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp index ce94409a5429..77c259c27a04 100644 --- a/llvm/lib/MC/MCSectionELF.cpp +++ b/llvm/lib/MC/MCSectionELF.cpp @@ -8,7 +8,6 @@ #include "llvm/MC/MCSectionELF.h" #include "llvm/ADT/Triple.h" -#include "llvm/ADT/Twine.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCExpr.h" diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index c35ca9641f60..75ec257e15b5 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -11,7 +11,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" -#include "llvm/ADT/Twine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Host.h" #include "llvm/Support/SwapByteOrder.h" @@ -19,7 +18,6 @@ #include "llvm/Support/VersionTuple.h" #include #include - using namespace llvm; StringRef Triple::getArchTypeName(ArchType Kind) { diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp index 1dd6b32cb8eb..dc7a28c72f20 100644 --- a/llvm/unittests/ADT/TripleTest.cpp +++ b/llvm/unittests/ADT/TripleTest.cpp @@ -7,7 +7,6 @@ //===--===// #include "llvm/ADT/Triple.h" -#include "llvm/ADT/Twine.h" #include "llvm/Support/VersionTuple.h" #include "gtest/gtest.h" diff --git a/llvm/unittests/Frontend/OpenMPContextTest.cpp b/llvm/unittests/Frontend/OpenMPContextTest.cpp index 9cdbd783ae18..eb505be042cb 100644 --- a/llvm/unittests/Frontend/OpenMPContextTest.cpp +++ b/llvm/unittests/Frontend/OpenMPContextTest.cpp @@ -8,7 +8,6 @@ #include "llvm/Frontend/OpenMP/OMPConstants.h" #include "llvm/Frontend/OpenMP/OMPContext.h" -#include "llvm/ADT/Twine.h" #include "gtest/gtest.h" using namespace llvm; diff --git a/llvm/unittests/Support/ThreadPool.cpp b/llvm/unittests/Support/ThreadPool.cpp index 1f0b6804338b..43882d0f3cee
[clang] f0bab78 - Triple.h - reduce Twine.h include to forward declarations. NFC.
Author: Simon Pilgrim Date: 2020-06-26T13:06:57+01:00 New Revision: f0bab7875e78e01c149d12302dcc4b6d4c43e25c URL: https://github.com/llvm/llvm-project/commit/f0bab7875e78e01c149d12302dcc4b6d4c43e25c DIFF: https://github.com/llvm/llvm-project/commit/f0bab7875e78e01c149d12302dcc4b6d4c43e25c.diff LOG: Triple.h - reduce Twine.h include to forward declarations. NFC. Move include down to a number of other files that had an implicit dependency on the Twine class. Added: Modified: clang/lib/Basic/IdentifierTable.cpp clang/lib/Basic/Targets/Mips.h llvm/include/llvm/ADT/Triple.h llvm/include/llvm/Support/TargetRegistry.h llvm/lib/MC/MCSectionELF.cpp llvm/lib/Support/Triple.cpp llvm/unittests/ADT/TripleTest.cpp llvm/unittests/Frontend/OpenMPContextTest.cpp llvm/unittests/Support/ThreadPool.cpp Removed: diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index 36b26d9b7c68..55d3f6a447b2 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -23,6 +23,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h index b475c03889a1..e2fcda3329ab 100644 --- a/clang/lib/Basic/Targets/Mips.h +++ b/clang/lib/Basic/Targets/Mips.h @@ -16,6 +16,7 @@ #include "clang/Basic/TargetInfo.h" #include "clang/Basic/TargetOptions.h" #include "llvm/ADT/Triple.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/Compiler.h" namespace clang { diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index 89679619dd55..c039d424487d 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -9,7 +9,8 @@ #ifndef LLVM_ADT_TRIPLE_H #define LLVM_ADT_TRIPLE_H -#include "llvm/ADT/Twine.h" +#include "llvm/ADT/StringRef.h" +#include // Some system headers or GCC predefined macros conflict with identifiers in // this file. Undefine them here. @@ -19,6 +20,7 @@ namespace llvm { +class Twine; class VersionTuple; /// Triple - Helper class for working with autoconf configuration names. For diff --git a/llvm/include/llvm/Support/TargetRegistry.h b/llvm/include/llvm/Support/TargetRegistry.h index d91eabae8235..5592879630de 100644 --- a/llvm/include/llvm/Support/TargetRegistry.h +++ b/llvm/include/llvm/Support/TargetRegistry.h @@ -22,6 +22,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" +#include "llvm/ADT/Twine.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/ErrorHandling.h" diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp index 77c259c27a04..ce94409a5429 100644 --- a/llvm/lib/MC/MCSectionELF.cpp +++ b/llvm/lib/MC/MCSectionELF.cpp @@ -8,6 +8,7 @@ #include "llvm/MC/MCSectionELF.h" #include "llvm/ADT/Triple.h" +#include "llvm/ADT/Twine.h" #include "llvm/BinaryFormat/ELF.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCExpr.h" diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index 75ec257e15b5..c35ca9641f60 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -11,6 +11,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Host.h" #include "llvm/Support/SwapByteOrder.h" @@ -18,6 +19,7 @@ #include "llvm/Support/VersionTuple.h" #include #include + using namespace llvm; StringRef Triple::getArchTypeName(ArchType Kind) { diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp index dc7a28c72f20..1dd6b32cb8eb 100644 --- a/llvm/unittests/ADT/TripleTest.cpp +++ b/llvm/unittests/ADT/TripleTest.cpp @@ -7,6 +7,7 @@ //===--===// #include "llvm/ADT/Triple.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/VersionTuple.h" #include "gtest/gtest.h" diff --git a/llvm/unittests/Frontend/OpenMPContextTest.cpp b/llvm/unittests/Frontend/OpenMPContextTest.cpp index eb505be042cb..9cdbd783ae18 100644 --- a/llvm/unittests/Frontend/OpenMPContextTest.cpp +++ b/llvm/unittests/Frontend/OpenMPContextTest.cpp @@ -8,6 +8,7 @@ #include "llvm/Frontend/OpenMP/OMPConstants.h" #include "llvm/Frontend/OpenMP/OMPContext.h" +#include "llvm/ADT/Twine.h" #include "gtest/gtest.h" using namespace llvm; diff --git a/llvm/unittests/Support/ThreadPool.cpp b/llvm/unittests/Support/ThreadPool.cpp index 43882d0f3cee..1f0b6804338b 100644 --- a/llvm/unittests/Support/ThreadPool.cpp +++
[clang] 2168d69 - Mangle.cpp - fix implicit Format.h dependency. NFC.
Author: Simon Pilgrim Date: 2020-06-23T14:42:30+01:00 New Revision: 2168d69d1f304cb2ab5eec2a6c55cf8c1498f08d URL: https://github.com/llvm/llvm-project/commit/2168d69d1f304cb2ab5eec2a6c55cf8c1498f08d DIFF: https://github.com/llvm/llvm-project/commit/2168d69d1f304cb2ab5eec2a6c55cf8c1498f08d.diff LOG: Mangle.cpp - fix implicit Format.h dependency. NFC. ProfileSummary was depending on other headers (notably via WithColor.h) to define format(). Added: Modified: clang/lib/AST/Mangle.cpp Removed: diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index 53f1a48d69a5..a732325006c6 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -25,6 +25,7 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/Mangler.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" using namespace clang; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 948b206 - Add missing lambda capture from rGf529c0a8a149.
Author: Simon Pilgrim Date: 2020-06-11T13:57:39+01:00 New Revision: 948b206fc236502caa20e51cf39b9d4d0fda00b6 URL: https://github.com/llvm/llvm-project/commit/948b206fc236502caa20e51cf39b9d4d0fda00b6 DIFF: https://github.com/llvm/llvm-project/commit/948b206fc236502caa20e51cf39b9d4d0fda00b6.diff LOG: Add missing lambda capture from rGf529c0a8a149. Added: Modified: clang/unittests/StaticAnalyzer/ParamRegionTest.cpp Removed: diff --git a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp index 52789fdf5b9d..7ec032a7beae 100644 --- a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp +++ b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp @@ -19,9 +19,9 @@ class ParamRegionTestConsumer : public ExprEngineConsumer { void checkForSameParamRegions(MemRegionManager , const StackFrameContext *SFC, const ParmVarDecl *PVD) { -assert(llvm::all_of(PVD->redecls(), [](const clang::VarDecl *D2) { +assert(llvm::all_of(PVD->redecls(), [&](const clang::VarDecl *D2) { return MRMgr.getVarRegion(PVD, SFC) == - MRMgr.getVarRegion(cast(D2), SFC) + MRMgr.getVarRegion(cast(D2), SFC); })); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f529c0a - Fix unused variable warning. NFCI.
Author: Simon Pilgrim Date: 2020-06-11T13:48:42+01:00 New Revision: f529c0a8a149ce6d027400a12a1637eda19e03b5 URL: https://github.com/llvm/llvm-project/commit/f529c0a8a149ce6d027400a12a1637eda19e03b5 DIFF: https://github.com/llvm/llvm-project/commit/f529c0a8a149ce6d027400a12a1637eda19e03b5.diff LOG: Fix unused variable warning. NFCI. We're only using the D2 iteration value inside the assert (the only component of the loop) - move the entire loop inside the assert by using llvm::all_of. Added: Modified: clang/unittests/StaticAnalyzer/ParamRegionTest.cpp Removed: diff --git a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp index 4edbeb30df1c..52789fdf5b9d 100644 --- a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp +++ b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp @@ -19,10 +19,10 @@ class ParamRegionTestConsumer : public ExprEngineConsumer { void checkForSameParamRegions(MemRegionManager , const StackFrameContext *SFC, const ParmVarDecl *PVD) { -for (const auto *D2: PVD->redecls()) { - assert(MRMgr.getVarRegion(PVD, SFC) == - MRMgr.getVarRegion(cast(D2), SFC)); -} +assert(llvm::all_of(PVD->redecls(), [](const clang::VarDecl *D2) { + return MRMgr.getVarRegion(PVD, SFC) == + MRMgr.getVarRegion(cast(D2), SFC) +})); } void performTest(const Decl *D) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a30b5c5 - Fix MSVC "not all control paths return a value" warning. NFC.
Author: Simon Pilgrim Date: 2020-06-05T10:45:59+01:00 New Revision: a30b5c5a51f95dc81fdfbeea42cc01b451cd5a08 URL: https://github.com/llvm/llvm-project/commit/a30b5c5a51f95dc81fdfbeea42cc01b451cd5a08 DIFF: https://github.com/llvm/llvm-project/commit/a30b5c5a51f95dc81fdfbeea42cc01b451cd5a08.diff LOG: Fix MSVC "not all control paths return a value" warning. NFC. Add llvm_unreachable after switch statement for TestLanguage enum Added: Modified: clang/lib/Testing/CommandLineArgs.cpp Removed: diff --git a/clang/lib/Testing/CommandLineArgs.cpp b/clang/lib/Testing/CommandLineArgs.cpp index 7375dbc6ee70..cd4d8c188da9 100644 --- a/clang/lib/Testing/CommandLineArgs.cpp +++ b/clang/lib/Testing/CommandLineArgs.cpp @@ -64,6 +64,7 @@ StringRef getFilenameForTesting(TestLanguage Lang) { case Lang_OBJCXX: return "input.mm"; } + llvm_unreachable("Unhandled TestLanguage enum"); } } // end namespace clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e6ba0a5 - Fix MSVC "not all control paths return a value" warning. NFC.
Author: Simon Pilgrim Date: 2020-06-03T11:12:43+01:00 New Revision: e6ba0a55fd39b600f3f431308f4a7e36e48f91ae URL: https://github.com/llvm/llvm-project/commit/e6ba0a55fd39b600f3f431308f4a7e36e48f91ae DIFF: https://github.com/llvm/llvm-project/commit/e6ba0a55fd39b600f3f431308f4a7e36e48f91ae.diff LOG: Fix MSVC "not all control paths return a value" warning. NFC. Add llvm_unreachable after switch statement for CheckerRegistry::StateFromCmdLine enum Added: Modified: clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp index f4d5db1e7a4b..401cd1d57bb3 100644 --- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp @@ -112,6 +112,7 @@ static StringRef toString(CheckerRegistry::StateFromCmdLine Kind) { case CheckerRegistry::StateFromCmdLine::State_Unspecified: return "Unspecified"; } + llvm_unreachable("Unhandled CheckerRegistry::StateFromCmdLine enum"); } LLVM_DUMP_METHOD void ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b5b0087 - SpecialCaseList.h - reduce unnecessary includes to forward declarations. NFC.
Author: Simon Pilgrim Date: 2020-05-27T15:51:03+01:00 New Revision: b5b00877221ec7817b9de9cd65571e1c05e80145 URL: https://github.com/llvm/llvm-project/commit/b5b00877221ec7817b9de9cd65571e1c05e80145 DIFF: https://github.com/llvm/llvm-project/commit/b5b00877221ec7817b9de9cd65571e1c05e80145.diff LOG: SpecialCaseList.h - reduce unnecessary includes to forward declarations. NFC. Remove Regex forward declaration as we already require the Regex.h include. Add missing VirtualFileSystem.h include to dependent source files. Added: Modified: clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/XRayArgs.cpp llvm/include/llvm/Support/SpecialCaseList.h Removed: diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index 35e982a502ef..9beca156e93e 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -14,10 +14,10 @@ #include "clang/Driver/ToolChain.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" -#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/SpecialCaseList.h" #include "llvm/Support/TargetParser.h" +#include "llvm/Support/VirtualFileSystem.h" #include using namespace clang; diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp index 54c15685d389..f233267b4984 100644 --- a/clang/lib/Driver/XRayArgs.cpp +++ b/clang/lib/Driver/XRayArgs.cpp @@ -13,10 +13,10 @@ #include "clang/Driver/ToolChain.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" -#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/SpecialCaseList.h" +#include "llvm/Support/VirtualFileSystem.h" using namespace clang; using namespace clang::driver; diff --git a/llvm/include/llvm/Support/SpecialCaseList.h b/llvm/include/llvm/Support/SpecialCaseList.h index 5b5b7f6124d6..330e96a7b9ac 100644 --- a/llvm/include/llvm/Support/SpecialCaseList.h +++ b/llvm/include/llvm/Support/SpecialCaseList.h @@ -52,18 +52,20 @@ #define LLVM_SUPPORT_SPECIALCASELIST_H #include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringSet.h" #include "llvm/Support/Regex.h" #include "llvm/Support/TrigramIndex.h" -#include "llvm/Support/VirtualFileSystem.h" +#include #include #include namespace llvm { class MemoryBuffer; -class Regex; class StringRef; +namespace vfs { +class FileSystem; +}; + class SpecialCaseList { public: /// Parses the special case list entries from files. On failure, returns ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 72210ce - Fix Wdocumentation warnings after argument renaming. NFC.
Author: Simon Pilgrim Date: 2020-05-24T11:18:20+01:00 New Revision: 72210ce7f57192652414ebbdf9f643f86532d700 URL: https://github.com/llvm/llvm-project/commit/72210ce7f57192652414ebbdf9f643f86532d700 DIFF: https://github.com/llvm/llvm-project/commit/72210ce7f57192652414ebbdf9f643f86532d700.diff LOG: Fix Wdocumentation warnings after argument renaming. NFC. Added: Modified: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 7fae3a62211d..a7c62a7e8046 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -445,7 +445,7 @@ class MallocChecker /// Perform a zero-allocation check. /// - /// \param [in] E The expression that allocates memory. + /// \param [in] Call The expression that allocates memory. /// \param [in] IndexOfSizeArg Index of the argument that specifies the size /// of the memory that needs to be allocated. E.g. for malloc, this would be /// 0. @@ -469,7 +469,7 @@ class MallocChecker /// - first: name of the resource (e.g. 'malloc') /// - (OPTIONAL) second: size of the allocated region /// - /// \param [in] CE The expression that allocates memory. + /// \param [in] Call The expression that allocates memory. /// \param [in] Att The ownership_returns attribute. /// \param [in] State The \c ProgramState right before allocation. /// \returns The ProgramState right after allocation. @@ -480,7 +480,7 @@ class MallocChecker /// Models memory allocation. /// - /// \param [in] CE The expression that allocates memory. + /// \param [in] Call The expression that allocates memory. /// \param [in] SizeEx Size of the memory that needs to be allocated. /// \param [in] Init The value the allocated memory needs to be initialized. /// with. For example, \c calloc initializes the allocated memory to 0, @@ -495,7 +495,7 @@ class MallocChecker /// Models memory allocation. /// - /// \param [in] CE The expression that allocates memory. + /// \param [in] Call The expression that allocates memory. /// \param [in] Size Size of the memory that needs to be allocated. /// \param [in] Init The value the allocated memory needs to be initialized. /// with. For example, \c calloc initializes the allocated memory to 0, @@ -532,7 +532,7 @@ class MallocChecker /// - first: name of the resource (e.g. 'malloc') /// - second: index of the parameter the attribute applies to /// - /// \param [in] CE The expression that frees memory. + /// \param [in] Call The expression that frees memory. /// \param [in] Att The ownership_takes or ownership_holds attribute. /// \param [in] State The \c ProgramState right before allocation. /// \returns The ProgramState right after deallocation. @@ -543,7 +543,7 @@ class MallocChecker /// Models memory deallocation. /// - /// \param [in] CE The expression that frees memory. + /// \param [in] Call The expression that frees memory. /// \param [in] State The \c ProgramState right before allocation. /// \param [in] Num Index of the argument that needs to be freed. This is /// normally 0, but for custom free functions it may be diff erent. @@ -570,7 +570,7 @@ class MallocChecker /// Models memory deallocation. /// /// \param [in] ArgExpr The variable who's pointee needs to be freed. - /// \param [in] ParentExpr The expression that frees the memory. + /// \param [in] Call The expression that frees the memory. /// \param [in] State The \c ProgramState right before allocation. /// normally 0, but for custom free functions it may be diff erent. /// \param [in] Hold Whether the parameter at \p Index has the ownership_holds @@ -599,7 +599,7 @@ class MallocChecker // /// Models memory reallocation. /// - /// \param [in] CE The expression that reallocated memory + /// \param [in] Call The expression that reallocated memory /// \param [in] ShouldFreeOnFail Whether if reallocation fails, the supplied /// memory should be freed. /// \param [in] State The \c ProgramState right before reallocation. @@ -623,7 +623,7 @@ class MallocChecker /// Models zero initialized array allocation. /// - /// \param [in] CE The expression that reallocated memory + /// \param [in] Call The expression that reallocated memory /// \param [in] State The \c ProgramState right before reallocation. /// \returns The ProgramState right after allocation. LLVM_NODISCARD ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bf897e6 - Remove superfluous semicolon to stop Wpedantic warning. NFCI.
Author: Simon Pilgrim Date: 2020-05-22T12:05:56+01:00 New Revision: bf897e6ea122c07b8848133beee749fd96895c14 URL: https://github.com/llvm/llvm-project/commit/bf897e6ea122c07b8848133beee749fd96895c14 DIFF: https://github.com/llvm/llvm-project/commit/bf897e6ea122c07b8848133beee749fd96895c14.diff LOG: Remove superfluous semicolon to stop Wpedantic warning. NFCI. Added: Modified: clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index cb76f576ac34..168cfd511170 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -55,7 +55,7 @@ const CXXRecordDecl *isRefCountable(const CXXBaseSpecifier *Base) { return nullptr; return hasPublicRefAndDeref(R) ? R : nullptr; -}; +} bool isRefCountable(const CXXRecordDecl *R) { assert(R); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 733505a - Replace dyn_cast<> with isa<> to fix unused variable warning. NFCI.
Author: Simon Pilgrim Date: 2020-05-22T12:05:56+01:00 New Revision: 733505abf471b66458a9eab24521dba9a4b6239e URL: https://github.com/llvm/llvm-project/commit/733505abf471b66458a9eab24521dba9a4b6239e DIFF: https://github.com/llvm/llvm-project/commit/733505abf471b66458a9eab24521dba9a4b6239e.diff LOG: Replace dyn_cast<> with isa<> to fix unused variable warning. NFCI. Added: Modified: clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp index adb6253df965..cb76f576ac34 100644 --- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp @@ -114,7 +114,7 @@ bool isUncountedPtr(const Type *T) { bool isGetterOfRefCounted(const CXXMethodDecl *M) { assert(M); - if (auto *calleeMethodDecl = dyn_cast(M)) { + if (isa(M)) { const CXXRecordDecl *calleeMethodsClass = M->getParent(); auto className = safeGetName(calleeMethodsClass); auto methodName = safeGetName(M); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 6e99199 - Fix "not all control paths return a value" warning on MSVC builds.
Author: Simon Pilgrim Date: 2020-05-19T13:16:24+01:00 New Revision: 6e99199419d95f39ae9d8a11d8632caac7b405b4 URL: https://github.com/llvm/llvm-project/commit/6e99199419d95f39ae9d8a11d8632caac7b405b4 DIFF: https://github.com/llvm/llvm-project/commit/6e99199419d95f39ae9d8a11d8632caac7b405b4.diff LOG: Fix "not all control paths return a value" warning on MSVC builds. Use llvm_unreachable as typeName(Metric::MetricType T) should handle all enum values. Added: Modified: clang-tools-extra/clangd/support/Trace.cpp Removed: diff --git a/clang-tools-extra/clangd/support/Trace.cpp b/clang-tools-extra/clangd/support/Trace.cpp index 10ae461221ee..7ab09cd23e6a 100644 --- a/clang-tools-extra/clangd/support/Trace.cpp +++ b/clang-tools-extra/clangd/support/Trace.cpp @@ -225,6 +225,7 @@ class CSVMetricTracer : public EventTracer { case Metric::Distribution: return "d"; } +llvm_unreachable("Unknown Metric::MetricType enum"); } static bool needsQuote(llvm::StringRef Text) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0b97833 - LTO.h - reduce includes to forward declarations. NFC.
Author: Simon Pilgrim Date: 2020-05-09T15:10:51+01:00 New Revision: 0b9783350b3a9644dc6e0ba94c0f6a87ca45cb36 URL: https://github.com/llvm/llvm-project/commit/0b9783350b3a9644dc6e0ba94c0f6a87ca45cb36 DIFF: https://github.com/llvm/llvm-project/commit/0b9783350b3a9644dc6e0ba94c0f6a87ca45cb36.diff LOG: LTO.h - reduce includes to forward declarations. NFC. Add missing ToolOutputFile.h dependency to BackendUtil.cpp Added: Modified: clang/lib/CodeGen/BackendUtil.cpp llvm/include/llvm/LTO/LTO.h Removed: diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index ba61a93a4d1a..efbc775323f5 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -46,6 +46,7 @@ #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TimeProfiler.h" #include "llvm/Support/Timer.h" +#include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" diff --git a/llvm/include/llvm/LTO/LTO.h b/llvm/include/llvm/LTO/LTO.h index 0a635b45e5a2..c25aa077304b 100644 --- a/llvm/include/llvm/LTO/LTO.h +++ b/llvm/include/llvm/LTO/LTO.h @@ -17,28 +17,24 @@ #include "llvm/ADT/MapVector.h" #include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringSet.h" -#include "llvm/IR/DiagnosticInfo.h" -#include "llvm/IR/LLVMRemarkStreamer.h" #include "llvm/IR/ModuleSummaryIndex.h" #include "llvm/LTO/Config.h" -#include "llvm/Linker/IRMover.h" #include "llvm/Object/IRSymtab.h" #include "llvm/Support/Error.h" -#include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/thread.h" -#include "llvm/Target/TargetOptions.h" #include "llvm/Transforms/IPO/FunctionImport.h" namespace llvm { class BitcodeModule; class Error; +class IRMover; class LLVMContext; class MemoryBufferRef; class Module; -class Target; class raw_pwrite_stream; +class Target; +class ToolOutputFile; /// Resolve linkage for prevailing symbols in the \p Index. Linkage changes /// recorded in the index and the ThinLTO backends must apply the changes to ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] db97a12 - Fix Wparentheses gcc warning. NFC.
Author: Simon Pilgrim Date: 2020-04-29T12:21:05+01:00 New Revision: db97a12454a95556dd7cd812105088c7e8852d92 URL: https://github.com/llvm/llvm-project/commit/db97a12454a95556dd7cd812105088c7e8852d92 DIFF: https://github.com/llvm/llvm-project/commit/db97a12454a95556dd7cd812105088c7e8852d92.diff LOG: Fix Wparentheses gcc warning. NFC. It should be either a float(32) or an int(32). Added: Modified: clang/lib/CodeGen/CGCall.cpp Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 7672d95219fa..55f106e7c300 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -3070,7 +3070,7 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src, llvm::Value *CodeGenFunction::EmitCMSEClearFP16(llvm::Value *Src) { llvm::Type *RetTy = Src->getType(); assert(RetTy->isFloatTy() || - RetTy->isIntegerTy() && RetTy->getIntegerBitWidth() == 32); + (RetTy->isIntegerTy() && RetTy->getIntegerBitWidth() == 32)); if (RetTy->isFloatTy()) { llvm::Value *T0 = Builder.CreateBitCast(Src, Builder.getIntNTy(32)); llvm::Value *T1 = Builder.CreateAnd(T0, 0x, "cmse.clear"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 440b445 - [clang-objc-fuzzer] Add LLVMFuzzerInitialize to fix msvc builds (PR44414)
Author: Simon Pilgrim Date: 2020-04-14T13:37:27+01:00 New Revision: 440b445fff848aded09fe5f7d69ff690113e44e2 URL: https://github.com/llvm/llvm-project/commit/440b445fff848aded09fe5f7d69ff690113e44e2 DIFF: https://github.com/llvm/llvm-project/commit/440b445fff848aded09fe5f7d69ff690113e44e2.diff LOG: [clang-objc-fuzzer] Add LLVMFuzzerInitialize to fix msvc builds (PR44414) The (supposedly superfluous) LLVMFuzzerInitialize function was removed when this file was copied from clang-fuzzer, but this is causing link errors on some targets. @morehouse confirmed on D69171 that it was OK to add back. Added: Modified: clang/tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp Removed: diff --git a/clang/tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp b/clang/tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp index 908778f3d765..40fb07d3332f 100644 --- a/clang/tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp +++ b/clang/tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp @@ -16,6 +16,8 @@ using namespace clang_fuzzer; +extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { return 0; } + extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { std::string s(reinterpret_cast(data), size); HandleCXX(s, "./test.m", {"-O2"}); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 43eca88 - Fix "control reaches end of non-void function" warning. NFCI.
Author: Simon Pilgrim Date: 2020-04-01T14:08:48+01:00 New Revision: 43eca880c6eda10fd191c4e9e04bf04830c9c6f2 URL: https://github.com/llvm/llvm-project/commit/43eca880c6eda10fd191c4e9e04bf04830c9c6f2 DIFF: https://github.com/llvm/llvm-project/commit/43eca880c6eda10fd191c4e9e04bf04830c9c6f2.diff LOG: Fix "control reaches end of non-void function" warning. NFCI. Added: Modified: clang-tools-extra/clangd/SemanticHighlighting.cpp Removed: diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index 77b2cbce40d9..59af922d4005 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -520,6 +520,7 @@ llvm::StringRef toSemanticTokenType(HighlightingKind Kind) { case HighlightingKind::InactiveCode: return "comment"; } + llvm_unreachable("unhandled HighlightingKind"); } std::vector ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fe0723d - Fix -Wdocumentation warning. NFC.
Author: Simon Pilgrim Date: 2020-03-29T19:51:37+01:00 New Revision: fe0723dc9d45acfa4511961b208b7817b09297ec URL: https://github.com/llvm/llvm-project/commit/fe0723dc9d45acfa4511961b208b7817b09297ec DIFF: https://github.com/llvm/llvm-project/commit/fe0723dc9d45acfa4511961b208b7817b09297ec.diff LOG: Fix -Wdocumentation warning. NFC. gcc was misinterpreting the template code snippet as html. Added: Modified: clang/include/clang/AST/PrettyPrinter.h Removed: diff --git a/clang/include/clang/AST/PrettyPrinter.h b/clang/include/clang/AST/PrettyPrinter.h index f42a6c0c1442..21e5ca94f6c4 100644 --- a/clang/include/clang/AST/PrettyPrinter.h +++ b/clang/include/clang/AST/PrettyPrinter.h @@ -184,7 +184,8 @@ struct PrintingPolicy { /// with zero parameters. unsigned UseVoidForZeroParams : 1; - /// Whether nested templates must be closed like a > rather than a>. + /// Whether nested templates must be closed like 'a >' rather than + /// 'a>'. unsigned SplitTemplateClosers : 1; /// Provide a 'terse' output. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 896fa30 - Fix unused variable warning
Author: Simon Pilgrim Date: 2020-03-24T11:51:49Z New Revision: 896fa30fc03091f7ea679f38616cae05166fb4be URL: https://github.com/llvm/llvm-project/commit/896fa30fc03091f7ea679f38616cae05166fb4be DIFF: https://github.com/llvm/llvm-project/commit/896fa30fc03091f7ea679f38616cae05166fb4be.diff LOG: Fix unused variable warning Added: Modified: clang/lib/Tooling/Syntax/BuildTree.cpp Removed: diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp index 4103a4d92c7d..82c87ba02b74 100644 --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -1059,7 +1059,7 @@ void syntax::TreeBuilder::markStmtChild(Stmt *Child, NodeRole Role) { // This is an expression in a statement position, consume the trailing // semicolon and form an 'ExpressionStatement' node. - if (auto *E = dyn_cast(Child)) { + if (isa(Child)) { setRole(ChildNode, NodeRole::ExpressionStatement_expression); ChildNode = new (allocator()) syntax::ExpressionStatement; // (!) 'getStmtRange()' ensures this covers a trailing semicolon. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1a4421a - [analyzer] ConstraintManager - use EXPENSIVE_CHECKS instead of (gcc specific) __OPTIMIZE__ guard
Author: Simon Pilgrim Date: 2020-03-23T21:03:14Z New Revision: 1a4421a5e860ffc63c77594c9fb40787f84241aa URL: https://github.com/llvm/llvm-project/commit/1a4421a5e860ffc63c77594c9fb40787f84241aa DIFF: https://github.com/llvm/llvm-project/commit/1a4421a5e860ffc63c77594c9fb40787f84241aa.diff LOG: [analyzer] ConstraintManager - use EXPENSIVE_CHECKS instead of (gcc specific) __OPTIMIZE__ guard This was noticed on D71817, which removed another use of __OPTIMIZE__ Differential Revision: https://reviews.llvm.org/D76622 Added: Modified: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h Removed: diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h index f85c37379158..935b2bb7b937 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h @@ -96,11 +96,7 @@ class ConstraintManager { // If StTrue is infeasible, asserting the falseness of Cond is unnecessary // because the existing constraints already establish this. if (!StTrue) { -#ifndef __OPTIMIZE__ - // This check is expensive and should be disabled even in Release+Asserts - // builds. - // FIXME: __OPTIMIZE__ is a GNU extension that Clang implements but MSVC - // does not. Is there a good equivalent there? +#ifdef EXPENSIVE_CHECKS assert(assume(State, Cond, false) && "System is over constrained."); #endif return ProgramStatePair((ProgramStateRef)nullptr, State); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a678724 - Fix Wdocumentation warning. NFCI.
Author: Simon Pilgrim Date: 2020-03-21T11:23:52Z New Revision: a678724401088997f1ed594f30935c6660bf0ac0 URL: https://github.com/llvm/llvm-project/commit/a678724401088997f1ed594f30935c6660bf0ac0 DIFF: https://github.com/llvm/llvm-project/commit/a678724401088997f1ed594f30935c6660bf0ac0.diff LOG: Fix Wdocumentation warning. NFCI. Added: Modified: clang/lib/Sema/SemaDeclCXX.cpp Removed: diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 37a5be48b97b..b65dc5c6427b 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -6322,7 +6322,6 @@ static bool canPassInRegisters(Sema , CXXRecordDecl *D, /// /// \param DiagID the primary error to report. /// \param MD the overriding method. -/// \param OEK which overrides to include as notes. static bool ReportOverrides(Sema , unsigned DiagID, const CXXMethodDecl *MD, llvm::function_ref Report) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 336530b - CGOpenMPRuntime::emitDeclareTargetVarDefinition - fix static analyzer null dereference warning. NFCI.
Author: Simon Pilgrim Date: 2020-03-12T18:52:57Z New Revision: 336530be07256728e2f4e7ae3d332f2e8939dbad URL: https://github.com/llvm/llvm-project/commit/336530be07256728e2f4e7ae3d332f2e8939dbad DIFF: https://github.com/llvm/llvm-project/commit/336530be07256728e2f4e7ae3d332f2e8939dbad.diff LOG: CGOpenMPRuntime::emitDeclareTargetVarDefinition - fix static analyzer null dereference warning. NFCI. All paths test for or dereference the VD pointer, so just assert that its not null. Added: Modified: clang/lib/CodeGen/CGOpenMPRuntime.cpp Removed: diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index d769691ba26e..9e88b6ef9315 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -2933,12 +2933,14 @@ bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD, HasRequiresUnifiedSharedMemory)) return CGM.getLangOpts().OpenMPIsDevice; VD = VD->getDefinition(CGM.getContext()); - if (VD && !DeclareTargetWithDefinition.insert(CGM.getMangledName(VD)).second) + assert(VD && "Unknown VarDecl"); + + if (!DeclareTargetWithDefinition.insert(CGM.getMangledName(VD)).second) return CGM.getLangOpts().OpenMPIsDevice; QualType ASTTy = VD->getType(); - SourceLocation Loc = VD->getCanonicalDecl()->getBeginLoc(); + // Produce the unique prefix to identify the new target regions. We use // the source location of the variable declaration which we know to not // conflict with any target region. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1ef0d66 - Fix unused variable warning. NFCI.
Author: Simon Pilgrim Date: 2020-03-12T18:52:59Z New Revision: 1ef0d66343d64ca89d02083fd1f5b1323703bf65 URL: https://github.com/llvm/llvm-project/commit/1ef0d66343d64ca89d02083fd1f5b1323703bf65 DIFF: https://github.com/llvm/llvm-project/commit/1ef0d66343d64ca89d02083fd1f5b1323703bf65.diff LOG: Fix unused variable warning. NFCI. Added: Modified: clang/lib/AST/ExprConstant.cpp Removed: diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 1028ab96bfd2..5bb9fc319d48 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -3607,6 +3607,7 @@ static CompleteObject findCompleteObject(EvalInfo , const Expr *E, /// Nested immediate invocation have been previously removed so if we found /// a ConstantExpr it can only be the EvaluatingDecl. assert(CE->isImmediateInvocation() && CE == Info.EvaluatingDecl); +(void)CE; BaseVal = Info.EvaluatingDeclValue; } else if (const ValueDecl *D = LVal.Base.dyn_cast()) { // In C++98, const, non-volatile integers initialized with ICEs are ICEs. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] adeb8c5 - Replace getAs with castAs to fix null dereference static analyzer warning.
Author: Simon Pilgrim Date: 2020-03-12T18:52:58Z New Revision: adeb8c54285e754f7c34690b583a0bd9af19de78 URL: https://github.com/llvm/llvm-project/commit/adeb8c54285e754f7c34690b583a0bd9af19de78 DIFF: https://github.com/llvm/llvm-project/commit/adeb8c54285e754f7c34690b583a0bd9af19de78.diff LOG: Replace getAs with castAs to fix null dereference static analyzer warning. Use castAs as we know the cast should succeed (and castAs will assert if it doesn't) and we're dereferencing it directly in the BuildRCBlockVarRecordLayout call. Added: Modified: clang/lib/CodeGen/CGObjCMac.cpp Removed: diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 44c14a745a98..87fd51b5d8b1 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -2558,9 +2558,8 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, } if (FQT->isRecordType() && ElCount) { int OldIndex = RunSkipBlockVars.size() - 1; -const RecordType *RT = FQT->getAs(); -BuildRCBlockVarRecordLayout(RT, BytePos + FieldOffset, -HasUnion); +auto *RT = FQT->castAs(); +BuildRCBlockVarRecordLayout(RT, BytePos + FieldOffset, HasUnion); // Replicate layout information for each array element. Note that // one element is already done. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7bfc3bf - Replace getAs/dyn_cast with castAs/cast to fix null dereference static analyzer warnings.
Author: Simon Pilgrim Date: 2020-03-12T16:50:50Z New Revision: 7bfc3bf39b6d279657b480963e72b6c08191b2f2 URL: https://github.com/llvm/llvm-project/commit/7bfc3bf39b6d279657b480963e72b6c08191b2f2 DIFF: https://github.com/llvm/llvm-project/commit/7bfc3bf39b6d279657b480963e72b6c08191b2f2.diff LOG: Replace getAs/dyn_cast with castAs/cast to fix null dereference static analyzer warnings. Both these casts are immediately deferenced and the cast will assert for us that they are of the correct type. Added: Modified: clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp Removed: diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index f3a27804bcac..fff4a45c5330 100644 --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -2688,7 +2688,7 @@ Stmt *RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) { // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast); - const FunctionType *FT = msgSendType->getAs(); + auto *FT = msgSendType->castAs(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc); ReplaceStmt(Exp, CE); @@ -7501,8 +7501,7 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { RD = RD->getDefinition(); if (RD && !RD->getDeclName().getAsIdentifierInfo()) { // decltype(((Foo_IMPL*)0)->bar) * - ObjCContainerDecl *CDecl = -dyn_cast(D->getDeclContext()); + auto *CDecl = cast(D->getDeclContext()); // ivar in class extensions requires special treatment. if (ObjCCategoryDecl *CatDecl = dyn_cast(CDecl)) CDecl = CatDecl->getClassInterface(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6999335 - ObjCMethodDecl::findPropertyDecl - fix static analyzer null dereference warnings. NFCI.
Author: Simon Pilgrim Date: 2020-03-12T15:36:49Z New Revision: 69993350aeed08b6392f614c510697579302a39b URL: https://github.com/llvm/llvm-project/commit/69993350aeed08b6392f614c510697579302a39b DIFF: https://github.com/llvm/llvm-project/commit/69993350aeed08b6392f614c510697579302a39b.diff LOG: ObjCMethodDecl::findPropertyDecl - fix static analyzer null dereference warnings. NFCI. All paths dereference the ClassDecl pointer, so use a cast<> instead of dyn_cast<>, assert that its not null and remove the remaining null tests. Added: Modified: clang/lib/AST/DeclObjC.cpp Removed: diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 9a84e3c4a510..6492f07eb5b0 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -1361,25 +1361,23 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const { return Found; } else { // Determine whether the container is a class. - ClassDecl = dyn_cast(Container); + ClassDecl = cast(Container); } +assert(ClassDecl && "Failed to find main class"); // If we have a class, check its visible extensions. -if (ClassDecl) { - for (const auto *Ext : ClassDecl->visible_extensions()) { -if (Ext == Container) - continue; - -if (const auto *Found = findMatchingProperty(Ext)) - return Found; - } +for (const auto *Ext : ClassDecl->visible_extensions()) { + if (Ext == Container) +continue; + if (const auto *Found = findMatchingProperty(Ext)) +return Found; } assert(isSynthesizedAccessorStub() && "expected an accessor stub"); + for (const auto *Cat : ClassDecl->known_categories()) { if (Cat == Container) continue; - if (const auto *Found = findMatchingProperty(Cat)) return Found; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7c2b3c9 - Replace getAs with castAs to fix null dereference static analyzer warnings.
Author: Simon Pilgrim Date: 2020-03-12T14:56:51Z New Revision: 7c2b3c9dda37ab25a6849a3670f1bfda6aa17e5e URL: https://github.com/llvm/llvm-project/commit/7c2b3c9dda37ab25a6849a3670f1bfda6aa17e5e DIFF: https://github.com/llvm/llvm-project/commit/7c2b3c9dda37ab25a6849a3670f1bfda6aa17e5e.diff LOG: Replace getAs with castAs to fix null dereference static analyzer warnings. Use castAs as we know the cast should succeed (and castAs will assert if it doesn't) and we're dereferencing it directly in the getThisType/getThisObjectType calls. Added: Modified: clang/lib/AST/DeclCXX.cpp Removed: diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 3645169b8901..8e9258a8ab88 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -2364,17 +2364,15 @@ QualType CXXMethodDecl::getThisType() const { // volatile X*, and if the member function is declared const volatile, // the type of this is const volatile X*. assert(isInstance() && "No 'this' for static methods!"); - - return CXXMethodDecl::getThisType(getType()->getAs(), + return CXXMethodDecl::getThisType(getType()->castAs(), getParent()); } QualType CXXMethodDecl::getThisObjectType() const { // Ditto getThisType. assert(isInstance() && "No 'this' for static methods!"); - - return CXXMethodDecl::getThisObjectType(getType()->getAs(), - getParent()); + return CXXMethodDecl::getThisObjectType( + getType()->castAs(), getParent()); } bool CXXMethodDecl::hasInlineBody() const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5f9fcfb - Replace getAs with castAs to fix null dereference static analyzer warnings.
Author: Simon Pilgrim Date: 2020-03-12T14:56:50Z New Revision: 5f9fcfb29e4e30932909ce648ad556a3890e6dce URL: https://github.com/llvm/llvm-project/commit/5f9fcfb29e4e30932909ce648ad556a3890e6dce DIFF: https://github.com/llvm/llvm-project/commit/5f9fcfb29e4e30932909ce648ad556a3890e6dce.diff LOG: Replace getAs with castAs to fix null dereference static analyzer warnings. Use castAs as we know the cast should succeed (and castAs will assert if it doesn't) and we're dereferencing it directly in the canAssignObjCInterfaces call. Added: Modified: clang/lib/AST/ASTContext.cpp Removed: diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index e50d1d608397..436880968b1f 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -8698,8 +8698,8 @@ bool ASTContext::areComparableObjCPointerTypes(QualType LHS, QualType RHS) { bool ASTContext::canBindObjCObjectType(QualType To, QualType From) { return canAssignObjCInterfaces( -getObjCObjectPointerType(To)->getAs(), - getObjCObjectPointerType(From)->getAs()); + getObjCObjectPointerType(To)->castAs(), + getObjCObjectPointerType(From)->castAs()); } /// typesAreCompatible - C99 6.7.3p9: For two qualified types to be compatible, ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] dbde39e - Fix static analyzer null dereference warning. NFCI.
Author: Simon Pilgrim Date: 2020-03-12T14:56:51Z New Revision: dbde39e485b5c00b9ad809d169e1650aa2104114 URL: https://github.com/llvm/llvm-project/commit/dbde39e485b5c00b9ad809d169e1650aa2104114 DIFF: https://github.com/llvm/llvm-project/commit/dbde39e485b5c00b9ad809d169e1650aa2104114.diff LOG: Fix static analyzer null dereference warning. NFCI. Added: Modified: clang/lib/AST/DeclCXX.cpp Removed: diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 58e7e16d6817..3645169b8901 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -3096,7 +3096,7 @@ VarDecl *BindingDecl::getHoldingVar() const { if (!DRE) return nullptr; - auto *VD = dyn_cast(DRE->getDecl()); + auto *VD = cast(DRE->getDecl()); assert(VD->isImplicit() && "holding var for binding decl not implicit"); return VD; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a8648fd - Replace getAs with castAs to fix null dereference static analyzer warning.
Author: Simon Pilgrim Date: 2020-03-05T15:28:54Z New Revision: a8648fd19aecfe2aed3ce529f488930cc37db4c2 URL: https://github.com/llvm/llvm-project/commit/a8648fd19aecfe2aed3ce529f488930cc37db4c2 DIFF: https://github.com/llvm/llvm-project/commit/a8648fd19aecfe2aed3ce529f488930cc37db4c2.diff LOG: Replace getAs with castAs to fix null dereference static analyzer warning. Use castAs as we know the cast should succeed and we're dereferencing in the mangleBareFunctionType call. Added: Modified: clang/lib/AST/ItaniumMangle.cpp Removed: diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 5d485e000750..6d21869e2f11 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -1776,8 +1776,8 @@ void CXXNameMangler::mangleLambda(const CXXRecordDecl *Lambda) { void CXXNameMangler::mangleLambdaSig(const CXXRecordDecl *Lambda) { for (auto *D : Lambda->getLambdaExplicitTemplateParameters()) mangleTemplateParamDecl(D); - const FunctionProtoType *Proto = Lambda->getLambdaTypeInfo()->getType()-> - getAs(); + auto *Proto = + Lambda->getLambdaTypeInfo()->getType()->castAs(); mangleBareFunctionType(Proto, /*MangleReturnType=*/false, Lambda->getLambdaStaticInvoker()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 9488543 - Fix some getAs/castAs null dereference static analyzer warnings.
Author: Simon Pilgrim Date: 2020-03-04T11:25:50Z New Revision: 94885431e19687dcc8f2e2f23932b4a6d170b78d URL: https://github.com/llvm/llvm-project/commit/94885431e19687dcc8f2e2f23932b4a6d170b78d DIFF: https://github.com/llvm/llvm-project/commit/94885431e19687dcc8f2e2f23932b4a6d170b78d.diff LOG: Fix some getAs/castAs null dereference static analyzer warnings. Use castAs if we know the cast should succeed (or we're dereferencing without check), the castAs will assert as well so we can remove local non-null asserts. Added: Modified: clang/lib/Sema/SemaExprCXX.cpp Removed: diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e521ba1d4af1..b2e21bebd38f 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -2142,8 +2142,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, SmallVector AllPlaceArgs; if (OperatorNew) { -const FunctionProtoType *Proto = -OperatorNew->getType()->getAs(); +auto *Proto = OperatorNew->getType()->castAs(); VariadicCallType CallType = Proto->isVariadic() ? VariadicFunction : VariadicDoesNotApply; @@ -2658,8 +2657,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, // for template argument deduction and for comparison purposes. QualType ExpectedFunctionType; { - const FunctionProtoType *Proto -= OperatorNew->getType()->getAs(); + auto *Proto = OperatorNew->getType()->castAs(); SmallVector ArgTypes; ArgTypes.push_back(Context.VoidPtrTy); @@ -4359,9 +4357,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, // Case 2. _Complex x -> y } else { - const ComplexType *FromComplex = From->getType()->getAs(); - assert(FromComplex); - + auto *FromComplex = From->getType()->castAs(); QualType ElType = FromComplex->getElementType(); bool isFloatingComplex = ElType->isRealFloatingType(); @@ -4660,8 +4656,7 @@ static bool HasNoThrowOperator(const RecordType *RT, OverloadedOperatorKind Op, CXXMethodDecl *Operator = cast(*Op); if((Operator->*IsDesiredOp)()) { FoundOperator = true; -const FunctionProtoType *CPT = - Operator->getType()->getAs(); +auto *CPT = Operator->getType()->castAs(); CPT = Self.ResolveExceptionSpec(KeyLoc, CPT); if (!CPT || !CPT->isNothrow()) return false; @@ -4910,8 +4905,7 @@ static bool EvaluateUnaryTypeTrait(Sema , TypeTrait UTT, if (C.getLangOpts().AccessControl && Destructor->getAccess() != AS_public) return false; if (UTT == UTT_IsNothrowDestructible) { -const FunctionProtoType *CPT = -Destructor->getType()->getAs(); +auto *CPT = Destructor->getType()->castAs(); CPT = Self.ResolveExceptionSpec(KeyLoc, CPT); if (!CPT || !CPT->isNothrow()) return false; @@ -4999,8 +4993,7 @@ static bool EvaluateUnaryTypeTrait(Sema , TypeTrait UTT, auto *Constructor = cast(ND->getUnderlyingDecl()); if (Constructor->isCopyConstructor(FoundTQs)) { FoundConstructor = true; - const FunctionProtoType *CPT - = Constructor->getType()->getAs(); + auto *CPT = Constructor->getType()->castAs(); CPT = Self.ResolveExceptionSpec(KeyLoc, CPT); if (!CPT) return false; @@ -5038,8 +5031,7 @@ static bool EvaluateUnaryTypeTrait(Sema , TypeTrait UTT, auto *Constructor = cast(ND->getUnderlyingDecl()); if (Constructor->isDefaultConstructor()) { FoundConstructor = true; - const FunctionProtoType *CPT - = Constructor->getType()->getAs(); + auto *CPT = Constructor->getType()->castAs(); CPT = Self.ResolveExceptionSpec(KeyLoc, CPT); if (!CPT) return false; @@ -5924,7 +5916,7 @@ QualType Sema::CheckGNUVectorConditionalTypes(ExprResult , ExprResult , RHS = DefaultFunctionArrayLvalueConversion(RHS.get()); QualType CondType = Cond.get()->getType(); - const auto *CondVT = CondType->getAs(); + const auto *CondVT = CondType->castAs(); QualType CondElementTy = CondVT->getElementType(); unsigned CondElementCount = CondVT->getNumElements(); QualType LHSType = LHS.get()->getType(); @@ -5980,7 +5972,7 @@ QualType Sema::CheckGNUVectorConditionalTypes(ExprResult , ExprResult , return {}; } ResultType = Context.getVectorType( -ResultElementTy, CondType->getAs()->getNumElements(), +ResultElementTy, CondType->castAs()->getNumElements(), VectorType::GenericVector); LHS = ImpCastExprToType(LHS.get(), ResultType, CK_VectorSplat); @@ -5989,9 +5981,9 @@ QualType Sema::CheckGNUVectorConditionalTypes(ExprResult , ExprResult ,
[clang] dc8680e - [CodeGenPGO] Fix shadow variable warning. NFC.
Author: Simon Pilgrim Date: 2020-03-02T15:06:34Z New Revision: dc8680eceb7c992cf1d02f47ad963dca2e287eaf URL: https://github.com/llvm/llvm-project/commit/dc8680eceb7c992cf1d02f47ad963dca2e287eaf DIFF: https://github.com/llvm/llvm-project/commit/dc8680eceb7c992cf1d02f47ad963dca2e287eaf.diff LOG: [CodeGenPGO] Fix shadow variable warning. NFC. Added: Modified: clang/lib/CodeGen/CodeGenPGO.h Removed: diff --git a/clang/lib/CodeGen/CodeGenPGO.h b/clang/lib/CodeGen/CodeGenPGO.h index a3778b549910..dda8c66b6db2 100644 --- a/clang/lib/CodeGen/CodeGenPGO.h +++ b/clang/lib/CodeGen/CodeGenPGO.h @@ -40,8 +40,8 @@ class CodeGenPGO { uint64_t CurrentRegionCount; public: - CodeGenPGO(CodeGenModule ) - : CGM(CGM), FuncNameVar(nullptr), NumValueSites({{0}}), + CodeGenPGO(CodeGenModule ) + : CGM(CGModule), FuncNameVar(nullptr), NumValueSites({{0}}), NumRegionCounters(0), FunctionHash(0), CurrentRegionCount(0) {} /// Whether or not we have PGO region data for the current function. This is ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 736385c - EHScopeStack::Cleanup has virtual functions so the destructor should be too.
Author: Simon Pilgrim Date: 2020-03-02T15:06:34Z New Revision: 736385c0b49d42f398ffa1458883f0d182178ef4 URL: https://github.com/llvm/llvm-project/commit/736385c0b49d42f398ffa1458883f0d182178ef4 DIFF: https://github.com/llvm/llvm-project/commit/736385c0b49d42f398ffa1458883f0d182178ef4.diff LOG: EHScopeStack::Cleanup has virtual functions so the destructor should be too. Fixes cppcheck warning. Added: Modified: clang/lib/CodeGen/EHScopeStack.h Removed: diff --git a/clang/lib/CodeGen/EHScopeStack.h b/clang/lib/CodeGen/EHScopeStack.h index 0ed67aabcd62..4dd3da3e90e7 100644 --- a/clang/lib/CodeGen/EHScopeStack.h +++ b/clang/lib/CodeGen/EHScopeStack.h @@ -148,7 +148,7 @@ class EHScopeStack { virtual void anchor(); protected: -~Cleanup() = default; +virtual ~Cleanup() = default; public: Cleanup(const Cleanup &) = default; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 842c5c7 - Fix shadow variable warning. NFC.
Author: Simon Pilgrim Date: 2020-03-02T11:41:20Z New Revision: 842c5c79945ebe664bf113a108eaba495ac0b6d4 URL: https://github.com/llvm/llvm-project/commit/842c5c79945ebe664bf113a108eaba495ac0b6d4 DIFF: https://github.com/llvm/llvm-project/commit/842c5c79945ebe664bf113a108eaba495ac0b6d4.diff LOG: Fix shadow variable warning. NFC. Added: Modified: clang/lib/CodeGen/CGBuiltin.cpp Removed: diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index ba3b14cac217..fbb397ba3cfe 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -1521,8 +1521,7 @@ static llvm::Value *dumpRecord(CodeGenFunction , QualType RType, // We check whether we are in a recursive type if (CanonicalType->isRecordType()) { - Value *TmpRes = - dumpRecord(CGF, CanonicalType, FieldPtr, Align, Func, Lvl + 1); + TmpRes = dumpRecord(CGF, CanonicalType, FieldPtr, Align, Func, Lvl + 1); Res = CGF.Builder.CreateAdd(TmpRes, Res); continue; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7e9747b - [X86][F16C] Remove cvtph2ps intrinsics and use generic half2float conversion (PR37554)
Author: Simon Pilgrim Date: 2020-02-29T18:57:35Z New Revision: 7e9747b50bcb1be28d4a3236571e8050835497a6 URL: https://github.com/llvm/llvm-project/commit/7e9747b50bcb1be28d4a3236571e8050835497a6 DIFF: https://github.com/llvm/llvm-project/commit/7e9747b50bcb1be28d4a3236571e8050835497a6.diff LOG: [X86][F16C] Remove cvtph2ps intrinsics and use generic half2float conversion (PR37554) This removes everything but int_x86_avx512_mask_vcvtph2ps_512 which provides the SAE variant, but even this can use the fpext generic if the rounding control is the default. Differential Revision: https://reviews.llvm.org/D75162 Added: llvm/test/CodeGen/X86/f16c-intrinsics-upgrade.ll Modified: clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/avx512f-builtins-constrained.c clang/test/CodeGen/avx512f-builtins.c clang/test/CodeGen/avx512vl-builtins-constrained.c clang/test/CodeGen/avx512vl-builtins.c clang/test/CodeGen/f16c-builtins-constrained.c clang/test/CodeGen/f16c-builtins.c llvm/include/llvm/IR/IntrinsicsX86.td llvm/lib/IR/AutoUpgrade.cpp llvm/lib/Target/X86/X86IntrinsicsInfo.h llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/test/CodeGen/X86/avx512-intrinsics-fast-isel.ll llvm/test/CodeGen/X86/avx512-intrinsics-upgrade.ll llvm/test/CodeGen/X86/avx512-intrinsics.ll llvm/test/CodeGen/X86/avx512vl-intrinsics-fast-isel.ll llvm/test/CodeGen/X86/avx512vl-intrinsics-upgrade.ll llvm/test/CodeGen/X86/avx512vl-intrinsics.ll llvm/test/CodeGen/X86/f16c-intrinsics-fast-isel.ll llvm/test/CodeGen/X86/f16c-intrinsics.ll llvm/test/Transforms/InstCombine/X86/x86-f16c.ll Removed: diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 47b3abdc5fac..ba3b14cac217 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -10327,6 +10327,46 @@ Value *CodeGenFunction::EmitX86CpuIs(const CallExpr *E) { return EmitX86CpuIs(CPUStr); } +// Convert F16 halfs to floats. +static Value *EmitX86CvtF16ToFloatExpr(CodeGenFunction , + ArrayRef Ops, + llvm::Type *DstTy) { + assert((Ops.size() == 1 || Ops.size() == 3 || Ops.size() == 4) && + "Unknown cvtph2ps intrinsic"); + + // If the SAE intrinsic doesn't use default rounding then we can't upgrade. + if (Ops.size() == 4 && cast(Ops[3])->getZExtValue() != 4) { +Intrinsic::ID IID = Intrinsic::x86_avx512_mask_vcvtph2ps_512; +Function *F = +CGF.CGM.getIntrinsic(IID, {DstTy, Ops[0]->getType(), Ops[1]->getType(), + Ops[2]->getType(), Ops[3]->getType()}); +return CGF.Builder.CreateCall(F, {Ops[0], Ops[1], Ops[2], Ops[3]}); + } + + unsigned NumDstElts = DstTy->getVectorNumElements(); + Value *Src = Ops[0]; + + // Extract the subvector. + if (NumDstElts != Src->getType()->getVectorNumElements()) { +assert(NumDstElts == 4 && "Unexpected vector size"); +uint32_t ShuffleMask[4] = {0, 1, 2, 3}; +Src = CGF.Builder.CreateShuffleVector(Src, UndefValue::get(Src->getType()), + ShuffleMask); + } + + // Bitcast from vXi16 to vXf16. + llvm::Type *HalfTy = llvm::VectorType::get( + llvm::Type::getHalfTy(CGF.getLLVMContext()), NumDstElts); + Src = CGF.Builder.CreateBitCast(Src, HalfTy); + + // Perform the fp-extension. + Value *Res = CGF.Builder.CreateFPExt(Src, DstTy, "cvtph2ps"); + + if (Ops.size() >= 3) +Res = EmitX86Select(CGF, Ops[2], Res, Ops[1]); + return Res; +} + // Convert a BF16 to a float. static Value *EmitX86CvtBF16ToFloatExpr(CodeGenFunction , const CallExpr *E, @@ -12531,6 +12571,14 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, case X86::BI__builtin_ia32_cmpordsd: return getCmpIntrinsicCall(Intrinsic::x86_sse2_cmp_sd, 7); + // f16c half2float intrinsics + case X86::BI__builtin_ia32_vcvtph2ps: + case X86::BI__builtin_ia32_vcvtph2ps256: + case X86::BI__builtin_ia32_vcvtph2ps_mask: + case X86::BI__builtin_ia32_vcvtph2ps256_mask: + case X86::BI__builtin_ia32_vcvtph2ps512_mask: +return EmitX86CvtF16ToFloatExpr(*this, Ops, ConvertType(E->getType())); + // AVX512 bf16 intrinsics case X86::BI__builtin_ia32_cvtneps2bf16_128_mask: { Ops[2] = getMaskVecValue(*this, Ops[2], diff --git a/clang/test/CodeGen/avx512f-builtins-constrained.c b/clang/test/CodeGen/avx512f-builtins-constrained.c index dcddd243ef61..1ccc23431842 100644 --- a/clang/test/CodeGen/avx512f-builtins-constrained.c +++ b/clang/test/CodeGen/avx512f-builtins-constrained.c @@ -171,21 +171,32 @@ __m128 test_mm_maskz_sqrt_ss(__mmask8 __U, __m128 __A, __m128 __B){ __m512 test_mm512_cvtph_ps (__m256i __A) { // COMMON-LABEL: test_mm512_cvtph_ps - // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512 +
[clang] bfa0aaf - [AVX512] Add strict-fp cvtph2ps constrained tests
Author: Simon Pilgrim Date: 2020-02-28T16:55:00Z New Revision: bfa0aaf37f8d68cb7fb63eff5c825724c3829d09 URL: https://github.com/llvm/llvm-project/commit/bfa0aaf37f8d68cb7fb63eff5c825724c3829d09 DIFF: https://github.com/llvm/llvm-project/commit/bfa0aaf37f8d68cb7fb63eff5c825724c3829d09.diff LOG: [AVX512] Add strict-fp cvtph2ps constrained tests As suggested on D75162 Added: clang/test/CodeGen/avx512vl-builtins-constrained.c Modified: clang/test/CodeGen/avx512f-builtins-constrained.c clang/test/CodeGen/avx512f-builtins.c Removed: diff --git a/clang/test/CodeGen/avx512f-builtins-constrained.c b/clang/test/CodeGen/avx512f-builtins-constrained.c index f4a9697f9ca7..dcddd243ef61 100644 --- a/clang/test/CodeGen/avx512f-builtins-constrained.c +++ b/clang/test/CodeGen/avx512f-builtins-constrained.c @@ -70,6 +70,48 @@ __m512 test_mm512_maskz_sqrt_ps( __mmask16 __U, __m512 __A) return _mm512_maskz_sqrt_ps(__U ,__A); } +__m256i test_mm512_cvt_roundps_ph(__m512 __A) +{ +// COMMON-LABEL: test_mm512_cvt_roundps_ph +// COMMONIR: @llvm.x86.avx512.mask.vcvtps2ph.512 +return _mm512_cvt_roundps_ph(__A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +} + +__m256i test_mm512_mask_cvt_roundps_ph(__m256i __W , __mmask16 __U, __m512 __A) +{ +// COMMON-LABEL: test_mm512_mask_cvt_roundps_ph +// COMMONIR: @llvm.x86.avx512.mask.vcvtps2ph.512 +return _mm512_mask_cvt_roundps_ph(__W, __U, __A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +} + +__m256i test_mm512_maskz_cvt_roundps_ph(__mmask16 __U, __m512 __A) +{ +// COMMON-LABEL: test_mm512_maskz_cvt_roundps_ph +// COMMONIR: @llvm.x86.avx512.mask.vcvtps2ph.512 +return _mm512_maskz_cvt_roundps_ph(__U, __A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC); +} + +__m512 test_mm512_cvt_roundph_ps(__m256i __A) +{ +// COMMON-LABEL: test_mm512_cvt_roundph_ps +// COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512 +return _mm512_cvt_roundph_ps(__A, _MM_FROUND_NO_EXC); +} + +__m512 test_mm512_mask_cvt_roundph_ps(__m512 __W, __mmask16 __U, __m256i __A) +{ +// COMMON-LABEL: test_mm512_mask_cvt_roundph_ps +// COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512 +return _mm512_mask_cvt_roundph_ps(__W, __U, __A, _MM_FROUND_NO_EXC); +} + +__m512 test_mm512_maskz_cvt_roundph_ps(__mmask16 __U, __m256i __A) +{ +// COMMON-LABEL: test_mm512_maskz_cvt_roundph_ps +// COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512 +return _mm512_maskz_cvt_roundph_ps(__U, __A, _MM_FROUND_NO_EXC); +} + __m128d test_mm_mask_sqrt_sd(__m128d __W, __mmask8 __U, __m128d __A, __m128d __B){ // COMMON-LABEL: test_mm_mask_sqrt_sd // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0 @@ -125,3 +167,25 @@ __m128 test_mm_maskz_sqrt_ss(__mmask8 __U, __m128 __A, __m128 __B){ // COMMONIR-NEXT: insertelement <4 x float> %{{.*}}, float {{.*}}, i64 0 return _mm_maskz_sqrt_ss(__U,__A,__B); } + +__m512 test_mm512_cvtph_ps (__m256i __A) +{ + // COMMON-LABEL: test_mm512_cvtph_ps + // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512 + return _mm512_cvtph_ps (__A); +} + +__m512 test_mm512_mask_cvtph_ps (__m512 __W, __mmask16 __U, __m256i __A) +{ + // COMMON-LABEL: test_mm512_mask_cvtph_ps + // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512 + return _mm512_mask_cvtph_ps (__W,__U,__A); +} + +__m512 test_mm512_maskz_cvtph_ps (__mmask16 __U, __m256i __A) +{ + // COMMON-LABEL: test_mm512_maskz_cvtph_ps + // COMMONIR: @llvm.x86.avx512.mask.vcvtph2ps.512 + return _mm512_maskz_cvtph_ps (__U,__A); +} + diff --git a/clang/test/CodeGen/avx512f-builtins.c b/clang/test/CodeGen/avx512f-builtins.c index bd15424af889..390ea14faa68 100644 --- a/clang/test/CodeGen/avx512f-builtins.c +++ b/clang/test/CodeGen/avx512f-builtins.c @@ -9460,6 +9460,13 @@ __m256 test_mm512_maskz_cvtpd_ps (__mmask8 __U, __m512d __A) return _mm512_maskz_cvtpd_ps (__U,__A); } +__m512 test_mm512_cvtph_ps (__m256i __A) +{ + // CHECK-LABEL: @test_mm512_cvtph_ps + // CHECK: @llvm.x86.avx512.mask.vcvtph2ps.512 + return _mm512_cvtph_ps (__A); +} + __m512 test_mm512_mask_cvtph_ps (__m512 __W, __mmask16 __U, __m256i __A) { // CHECK-LABEL: @test_mm512_mask_cvtph_ps diff --git a/clang/test/CodeGen/avx512vl-builtins-constrained.c b/clang/test/CodeGen/avx512vl-builtins-constrained.c new file mode 100644 index ..0e2aa4e99fe4 --- /dev/null +++ b/clang/test/CodeGen/avx512vl-builtins-constrained.c @@ -0,0 +1,79 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -fexperimental-new-pass-manager -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +avx512f -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s +// RUN: %clang_cc1 -fexperimental-new-pass-manager -flax-vector-conversions=none -fms-extensions -fms-compatibility -ffreestanding %s
[clang] a06402c - [F16C] Add strict-fp constrained tests
Author: Simon Pilgrim Date: 2020-02-28T16:55:00Z New Revision: a06402cc69c07bc18c729b23bedb53b929411f36 URL: https://github.com/llvm/llvm-project/commit/a06402cc69c07bc18c729b23bedb53b929411f36 DIFF: https://github.com/llvm/llvm-project/commit/a06402cc69c07bc18c729b23bedb53b929411f36.diff LOG: [F16C] Add strict-fp constrained tests As suggested on D75162 Added: clang/test/CodeGen/f16c-builtins-constrained.c Modified: Removed: diff --git a/clang/test/CodeGen/f16c-builtins-constrained.c b/clang/test/CodeGen/f16c-builtins-constrained.c new file mode 100644 index ..74cf3d13182f --- /dev/null +++ b/clang/test/CodeGen/f16c-builtins-constrained.c @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +f16c -emit-llvm -ffp-exception-behavior=strict -o - -Wall -Werror | FileCheck %s + + +#include + +float test_cvtsh_ss(unsigned short a) { + // CHECK-LABEL: test_cvtsh_ss + // CHECK: insertelement <8 x i16> undef, i16 %{{.*}}, i32 0 + // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 1 + // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 2 + // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 3 + // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 4 + // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 5 + // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 6 + // CHECK: insertelement <8 x i16> %{{.*}}, i16 0, i32 7 + // CHECK: call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %{{.*}}) + // CHECK: extractelement <4 x float> %{{.*}}, i32 0 + return _cvtsh_ss(a); +} + +unsigned short test_cvtss_sh(float a) { + // CHECK-LABEL: test_cvtss_sh + // CHECK: insertelement <4 x float> undef, float %{{.*}}, i32 0 + // CHECK: call float @llvm.experimental.constrained.sitofp.f32.i32(i32 0, metadata !"round.tonearest", metadata !"fpexcept.strict") + // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 1 + // CHECK: call float @llvm.experimental.constrained.sitofp.f32.i32(i32 0, metadata !"round.tonearest", metadata !"fpexcept.strict") + // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 2 + // CHECK: call float @llvm.experimental.constrained.sitofp.f32.i32(i32 0, metadata !"round.tonearest", metadata !"fpexcept.strict") + // CHECK: insertelement <4 x float> %{{.*}}, float %{{.*}}, i32 3 + // CHECK: call <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float> %{{.*}}, i32 0) + // CHECK: extractelement <8 x i16> %{{.*}}, i32 0 + return _cvtss_sh(a, 0); +} + +__m128 test_mm_cvtph_ps(__m128i a) { + // CHECK-LABEL: test_mm_cvtph_ps + // CHECK: call <4 x float> @llvm.x86.vcvtph2ps.128(<8 x i16> %{{.*}}) + return _mm_cvtph_ps(a); +} + +__m256 test_mm256_cvtph_ps(__m128i a) { + // CHECK-LABEL: test_mm256_cvtph_ps + // CHECK: call <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16> %{{.*}}) + return _mm256_cvtph_ps(a); +} + +__m128i test_mm_cvtps_ph(__m128 a) { + // CHECK-LABEL: test_mm_cvtps_ph + // CHECK: call <8 x i16> @llvm.x86.vcvtps2ph.128(<4 x float> %{{.*}}, i32 0) + return _mm_cvtps_ph(a, 0); +} + +__m128i test_mm256_cvtps_ph(__m256 a) { + // CHECK-LABEL: test_mm256_cvtps_ph + // CHECK: call <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float> %{{.*}}, i32 0) + return _mm256_cvtps_ph(a, 0); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1723f21 - Fix MSVC "not all control paths return a value" warning. NFCI.
Author: Simon Pilgrim Date: 2020-02-21T18:23:55Z New Revision: 1723f219939e1d4dc1c53ec7caf10c9380822b99 URL: https://github.com/llvm/llvm-project/commit/1723f219939e1d4dc1c53ec7caf10c9380822b99 DIFF: https://github.com/llvm/llvm-project/commit/1723f219939e1d4dc1c53ec7caf10c9380822b99.diff LOG: Fix MSVC "not all control paths return a value" warning. NFCI. Added: Modified: clang/lib/ASTMatchers/GtestMatchers.cpp Removed: diff --git a/clang/lib/ASTMatchers/GtestMatchers.cpp b/clang/lib/ASTMatchers/GtestMatchers.cpp index 317bddd035f8..c99fdf6c0fcd 100644 --- a/clang/lib/ASTMatchers/GtestMatchers.cpp +++ b/clang/lib/ASTMatchers/GtestMatchers.cpp @@ -38,6 +38,7 @@ static DeclarationMatcher getComparisonDecl(GtestCmp Cmp) { case GtestCmp::Lt: return functionDecl(hasName("::testing::internal::CmpHelperLT")); } + llvm_unreachable("Unhandled GtestCmp enum"); } static llvm::StringRef getAssertMacro(GtestCmp Cmp) { @@ -55,6 +56,7 @@ static llvm::StringRef getAssertMacro(GtestCmp Cmp) { case GtestCmp::Lt: return "ASSERT_LT"; } + llvm_unreachable("Unhandled GtestCmp enum"); } static llvm::StringRef getExpectMacro(GtestCmp Cmp) { @@ -72,6 +74,7 @@ static llvm::StringRef getExpectMacro(GtestCmp Cmp) { case GtestCmp::Lt: return "EXPECT_LT"; } + llvm_unreachable("Unhandled GtestCmp enum"); } // In general, AST matchers cannot match calls to macros. However, we can ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e63abde - [clang][driver] Fix null pointer dereference warning inside PrintActions1 (PR43462)
Author: Simon Pilgrim Date: 2020-02-05T15:32:18Z New Revision: e63abde39f530028b0089ea477446c1b671a28f1 URL: https://github.com/llvm/llvm-project/commit/e63abde39f530028b0089ea477446c1b671a28f1 DIFF: https://github.com/llvm/llvm-project/commit/e63abde39f530028b0089ea477446c1b671a28f1.diff LOG: [clang][driver] Fix null pointer dereference warning inside PrintActions1 (PR43462) As detailed on PR43462, clang static analyzer is complaining about a null pointer dereference as we provide a 'host' toolchain fallback if the ToolChain pointer is null, but then use that pointer anyhow to report the triple. Tests indicate the ToolChain pointer is always valid and the 'host' code path is redundant. Differential Revision: https://reviews.llvm.org/D74046 Added: Modified: clang/lib/Driver/Driver.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 6db791ab8333..f35aab19e83d 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1848,6 +1848,7 @@ static unsigned PrintActions1(const Compilation , Action *A, bool IsFirst = true; OA->doOnEachDependence( [&](Action *A, const ToolChain *TC, const char *BoundArch) { + assert(TC && "Unknown host toolchain"); // E.g. for two CUDA device dependences whose bound arch is sm_20 and // sm_35 this will generate: // "cuda-device" (nvptx64-nvidia-cuda:sm_20) {#ID}, "cuda-device" @@ -1855,13 +1856,9 @@ static unsigned PrintActions1(const Compilation , Action *A, if (!IsFirst) os << ", "; os << '"'; - if (TC) -os << A->getOffloadingKindPrefix(); - else -os << "host"; + os << A->getOffloadingKindPrefix(); os << " ("; os << TC->getTriple().normalize(); - if (BoundArch) os << ":" << BoundArch; os << ")"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6198e1c - Fix MSVC signed/unsigned warning. NFCI.
Author: Simon Pilgrim Date: 2020-02-05T11:53:16Z New Revision: 6198e1c40abce7135ce68e2b91d433ec02454a50 URL: https://github.com/llvm/llvm-project/commit/6198e1c40abce7135ce68e2b91d433ec02454a50 DIFF: https://github.com/llvm/llvm-project/commit/6198e1c40abce7135ce68e2b91d433ec02454a50.diff LOG: Fix MSVC signed/unsigned warning. NFCI. Added: Modified: clang/lib/AST/Expr.cpp Removed: diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 0b6b1e39183c..ac4fa127af43 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -320,7 +320,7 @@ ConstantExpr *ConstantExpr::CreateEmpty(const ASTContext , } void ConstantExpr::MoveIntoResult(APValue , const ASTContext ) { - assert(getStorageKind(Value) <= ConstantExprBits.ResultKind && + assert((unsigned)getStorageKind(Value) <= ConstantExprBits.ResultKind && "Invalid storage for this value kind"); ConstantExprBits.APValueKind = Value.getKind(); switch (ConstantExprBits.ResultKind) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 17785cc - [clang-tidy] Fix "expression is redundant [misc-redundant-expression]" warning. NFCI. (PR44768)
Author: Simon Pilgrim Date: 2020-02-04T21:36:50Z New Revision: 17785cc7a105a56900ed827979336944ccfa8c9d URL: https://github.com/llvm/llvm-project/commit/17785cc7a105a56900ed827979336944ccfa8c9d DIFF: https://github.com/llvm/llvm-project/commit/17785cc7a105a56900ed827979336944ccfa8c9d.diff LOG: [clang-tidy] Fix "expression is redundant [misc-redundant-expression]" warning. NFCI. (PR44768) We only accept tok::TokenKind::comment enum values so no need to add other cases. Seems to be a cut+paste typo. Added: Modified: clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp index da0bef32c091..64e182c8 100644 --- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp @@ -42,7 +42,7 @@ SourceLocation forwardSkipWhitespaceAndComments(SourceLocation Loc, Loc = Loc.getLocWithOffset(1); tok::TokenKind TokKind = getTokenKind(Loc, SM, Context); -if (TokKind == tok::NUM_TOKENS || TokKind != tok::comment) +if (TokKind != tok::comment) return Loc; // Fast-forward current token. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8093d37 - Fix switch covers all cases static analyzer warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-29T17:26:22Z New Revision: 8093d37ed2548ff5c8d6d7c51bd0431afbbf4209 URL: https://github.com/llvm/llvm-project/commit/8093d37ed2548ff5c8d6d7c51bd0431afbbf4209 DIFF: https://github.com/llvm/llvm-project/commit/8093d37ed2548ff5c8d6d7c51bd0431afbbf4209.diff LOG: Fix switch covers all cases static analyzer warning. NFCI. Added: Modified: clang/lib/Format/TokenAnnotator.cpp Removed: diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index c4798f65592a..3dc88315c352 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -3160,6 +3160,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine , return (Left.NestingLevel == 0 && Line.Level == 0) && !Left.Children.empty(); } + llvm_unreachable("Unknown FormatStyle::ShortLambdaStyle enum"); } if (Right.is(tok::r_brace) && Left.is(tok::l_brace) && ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 201c646 - Remove extra '; ' to fix Wpedantic. NFCI.
Author: Simon Pilgrim Date: 2020-01-22T12:08:57Z New Revision: 201c646b2b9988cdebf6e95d523283009ae2e5ba URL: https://github.com/llvm/llvm-project/commit/201c646b2b9988cdebf6e95d523283009ae2e5ba DIFF: https://github.com/llvm/llvm-project/commit/201c646b2b9988cdebf6e95d523283009ae2e5ba.diff LOG: Remove extra ';' to fix Wpedantic. NFCI. Added: Modified: clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp index aad0ad94456a..c1b27a821ade 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp @@ -172,7 +172,7 @@ ReservedIdentifierCheck::GetDiagInfo(const NamingCheckId , diag << ID.second << getMessageSelectIndex(Failure.Info.KindName); }}; -}; +} } // namespace bugprone } // namespace tidy ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 25afe91 - Fix Wparentheses warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-17T11:26:25Z New Revision: 25afe91fd1b8e26258471007a24f856a0d4b14db URL: https://github.com/llvm/llvm-project/commit/25afe91fd1b8e26258471007a24f856a0d4b14db DIFF: https://github.com/llvm/llvm-project/commit/25afe91fd1b8e26258471007a24f856a0d4b14db.diff LOG: Fix Wparentheses warning. NFCI. Added: Modified: clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp index 969927fedc3d..1d0b85b9c4ce 100644 --- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp @@ -34,8 +34,9 @@ llvm::Optional findQualToken(const VarDecl *Decl, Qualifier Qual, // sure that we have a consistent `CharSourceRange`, located entirely in the // source file. - assert(Qual == Qualifier::Const || Qual == Qualifier::Volatile || - Qual == Qualifier::Restrict && "Invalid Qualifier"); + assert((Qual == Qualifier::Const || Qual == Qualifier::Volatile || + Qual == Qualifier::Restrict) && + "Invalid Qualifier"); SourceLocation BeginLoc = Decl->getQualifierLoc().getBeginLoc(); if (BeginLoc.isInvalid()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 19c5057 - Fix "pointer is null" static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-16T13:02:40Z New Revision: 19c5057e8df62e75b26e881dfc8f8f32686fe75c URL: https://github.com/llvm/llvm-project/commit/19c5057e8df62e75b26e881dfc8f8f32686fe75c DIFF: https://github.com/llvm/llvm-project/commit/19c5057e8df62e75b26e881dfc8f8f32686fe75c.diff LOG: Fix "pointer is null" static analyzer warnings. NFCI. Use castAs<> instead of getAs<> since the pointer is dereferenced immediately in all cases and castAs will perform the null assertion for us. Added: Modified: clang/lib/CodeGen/CodeGenModule.cpp Removed: diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 038078bbe88d..feb8d000eca3 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1357,7 +1357,7 @@ void CodeGenModule::GenOpenCLArgMetadata(llvm::Function *Fn, std::string typeName; if (isPipe) typeName = ty.getCanonicalType() - ->getAs() + ->castAs() ->getElementType() .getAsString(Policy); else @@ -1371,7 +1371,7 @@ void CodeGenModule::GenOpenCLArgMetadata(llvm::Function *Fn, std::string baseTypeName; if (isPipe) baseTypeName = ty.getCanonicalType() - ->getAs() + ->castAs() ->getElementType() .getCanonicalType() .getAsString(Policy); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ab9dbc1 - Fix "pointer is null" clang static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-14T16:31:17Z New Revision: ab9dbc1d124cdf288474073f5233e3fd6ee8e9c3 URL: https://github.com/llvm/llvm-project/commit/ab9dbc1d124cdf288474073f5233e3fd6ee8e9c3 DIFF: https://github.com/llvm/llvm-project/commit/ab9dbc1d124cdf288474073f5233e3fd6ee8e9c3.diff LOG: Fix "pointer is null" clang static analyzer warnings. NFCI. Use cast<>/castAs<> instead of dyn_cast<>/getAs<> since the pointers are always dereferenced and cast<>/castAs<> will perform the null assertion for us. Added: Modified: clang/lib/Sema/SemaOverload.cpp Removed: diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 56d9522eee01..0fd932fac970 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -2853,8 +2853,8 @@ void Sema::HandleFunctionTypeMismatch(PartialDiagnostic , // Get the function type from the pointers. if (FromType->isMemberPointerType() && ToType->isMemberPointerType()) { -const MemberPointerType *FromMember = FromType->getAs(), -*ToMember = ToType->getAs(); +const auto *FromMember = FromType->castAs(), + *ToMember = ToType->castAs(); if (!Context.hasSameType(FromMember->getClass(), ToMember->getClass())) { PDiag << ft_ diff erent_class << QualType(ToMember->getClass(), 0) << QualType(FromMember->getClass(), 0); @@ -3304,8 +3304,7 @@ static bool tryAtomicConversion(Sema , Expr *From, QualType ToType, static bool isFirstArgumentCompatibleWithType(ASTContext , CXXConstructorDecl *Constructor, QualType Type) { - const FunctionProtoType *CtorType = - Constructor->getType()->getAs(); + const auto *CtorType = Constructor->getType()->castAs(); if (CtorType->getNumParams() > 0) { QualType FirstArg = CtorType->getParamType(0); if (Context.hasSameUnqualifiedType(Type, FirstArg.getNonReferenceType())) @@ -4346,14 +4345,10 @@ CompareDerivedToBaseConversions(Sema , SourceLocation Loc, if (SCS1.Second == ICK_Pointer_Member && SCS2.Second == ICK_Pointer_Member && FromType1->isMemberPointerType() && FromType2->isMemberPointerType() && ToType1->isMemberPointerType() && ToType2->isMemberPointerType()) { -const MemberPointerType * FromMemPointer1 = -FromType1->getAs(); -const MemberPointerType * ToMemPointer1 = - ToType1->getAs(); -const MemberPointerType * FromMemPointer2 = - FromType2->getAs(); -const MemberPointerType * ToMemPointer2 = - ToType2->getAs(); +const auto *FromMemPointer1 = FromType1->castAs(); +const auto *ToMemPointer1 = ToType1->castAs(); +const auto *FromMemPointer2 = FromType2->castAs(); +const auto *ToMemPointer2 = ToType2->castAs(); const Type *FromPointeeType1 = FromMemPointer1->getClass(); const Type *ToPointeeType1 = ToMemPointer1->getClass(); const Type *FromPointeeType2 = FromMemPointer2->getClass(); @@ -4534,8 +4529,7 @@ FindConversionForRefInit(Sema , ImplicitConversionSequence , Expr *Init, QualType T2, bool AllowRvalues, bool AllowExplicit) { assert(T2->isRecordType() && "Can only find conversions of record types."); - CXXRecordDecl *T2RecordDecl -= dyn_cast(T2->castAs()->getDecl()); + auto *T2RecordDecl = cast(T2->castAs()->getDecl()); OverloadCandidateSet CandidateSet( DeclLoc, OverloadCandidateSet::CSK_InitByUserDefinedConversion); @@ -6097,7 +6091,7 @@ static bool IsAcceptableNonMemberOperatorCandidate(ASTContext , if (T1->isRecordType() || (!T2.isNull() && T2->isRecordType())) return true; - const FunctionProtoType *Proto = Fn->getType()->getAs(); + const auto *Proto = Fn->getType()->castAs(); if (Proto->getNumParams() < 1) return false; @@ -10403,7 +10397,7 @@ static void DiagnoseArityMismatch(Sema , NamedDecl *Found, Decl *D, FunctionDecl *Fn = cast(D); // TODO: treat calls to a missing default constructor as a special case - const FunctionProtoType *FnTy = Fn->getType()->getAs(); + const auto *FnTy = Fn->getType()->castAs(); unsigned MinParams = Fn->getMinRequiredArguments(); // at least / at most / exactly @@ -13970,7 +13964,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, ResultType = ResultType.getNonLValueExprType(Context); assert(Method && "Member call to something that isn't a method?"); - const auto *Proto = Method->getType()->getAs(); + const auto *Proto = Method->getType()->castAs(); CXXMemberCallExpr *TheCall = CXXMemberCallExpr::Create(Context, MemExprE, Args, ResultType, VK, RParenLoc,
[clang] cfd366b - Fix "pointer is null" static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-14T16:31:17Z New Revision: cfd366ba74c566038c6f417da9c9becc321fd737 URL: https://github.com/llvm/llvm-project/commit/cfd366ba74c566038c6f417da9c9becc321fd737 DIFF: https://github.com/llvm/llvm-project/commit/cfd366ba74c566038c6f417da9c9becc321fd737.diff LOG: Fix "pointer is null" static analyzer warnings. NFCI. Use castAs<> instead of getAs<> since the pointer is dereferenced immediately in all cases and castAs will perform the null assertion for us. Added: Modified: clang/lib/Sema/SemaDeclCXX.cpp Removed: diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 497e45631be4..9916d3be77e1 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1501,13 +1501,13 @@ void Sema::MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old) { // as pointers to member functions. if (const ReferenceType *R = NewType->getAs()) { NewType = R->getPointeeType(); -OldType = OldType->getAs()->getPointeeType(); +OldType = OldType->castAs()->getPointeeType(); } else if (const PointerType *P = NewType->getAs()) { NewType = P->getPointeeType(); -OldType = OldType->getAs()->getPointeeType(); +OldType = OldType->castAs()->getPointeeType(); } else if (const MemberPointerType *M = NewType->getAs()) { NewType = M->getPointeeType(); -OldType = OldType->getAs()->getPointeeType(); +OldType = OldType->castAs()->getPointeeType(); } if (!NewType->isFunctionProtoType()) @@ -1633,7 +1633,7 @@ static bool CheckConstexprParameterTypes(Sema , const FunctionDecl *FD, Sema::CheckConstexprKind Kind) { unsigned ArgIndex = 0; - const FunctionProtoType *FT = FD->getType()->getAs(); + const auto *FT = FD->getType()->castAs(); for (FunctionProtoType::param_type_iterator i = FT->param_type_begin(), e = FT->param_type_end(); i != e; ++i, ++ArgIndex) { @@ -9829,7 +9829,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator , QualType R, // Rebuild the function type "R" without any type qualifiers (in // case any of the errors above fired) and with "void" as the // return type, since constructors don't have return types. - const FunctionProtoType *Proto = R->getAs(); + const FunctionProtoType *Proto = R->castAs(); if (Proto->getReturnType() == Context.VoidTy && !D.isInvalidType()) return R; @@ -10027,7 +10027,7 @@ QualType Sema::CheckDestructorDeclarator(Declarator , QualType R, if (!D.isInvalidType()) return R; - const FunctionProtoType *Proto = R->getAs(); + const FunctionProtoType *Proto = R->castAs(); FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo(); EPI.Variadic = false; EPI.TypeQuals = Qualifiers(); @@ -10101,7 +10101,7 @@ void Sema::CheckConversionDeclarator(Declarator , QualType , D.setInvalidType(); } - const FunctionProtoType *Proto = R->getAs(); + const auto *Proto = R->castAs(); // Make sure we don't have any parameters. if (Proto->getNumParams() > 0) { @@ -13015,8 +13015,7 @@ void Sema::AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor) { // A declaration of a destructor that does not have an exception- // specification is implicitly considered to have the same exception- // specification as an implicit declaration. - const FunctionProtoType *DtorType = Destructor->getType()-> -getAs(); + const auto *DtorType = Destructor->getType()->castAs(); if (DtorType->hasExceptionSpec()) return; @@ -13996,8 +13995,8 @@ void Sema::DefineImplicitMoveAssignment(SourceLocation CurrentLocation, // The parameter for the "other" object, which we are move from. ParmVarDecl *Other = MoveAssignOperator->getParamDecl(0); - QualType OtherRefType = Other->getType()-> - getAs()->getPointeeType(); + QualType OtherRefType = + Other->getType()->castAs()->getPointeeType(); // Our location for everything implicitly-generated. SourceLocation Loc = MoveAssignOperator->getEndLoc().isValid() @@ -14791,9 +14790,7 @@ Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor, unsigned NumArgs = ArgsPtr.size(); Expr **Args = ArgsPtr.data(); - const FunctionProtoType *Proto -= Constructor->getType()->getAs(); - assert(Proto && "Constructor without a prototype?"); + const auto *Proto = Constructor->getType()->castAs(); unsigned NumParams = Proto->getNumParams(); // If too few arguments are available, we'll fill in the rest with defaults. @@ -14856,7 +14853,7 @@ CheckOperatorNewDeleteTypes(Sema , const FunctionDecl *FnDecl, unsigned DependentParamTypeDiag, unsigned InvalidParamTypeDiag) { QualType ResultType
[clang] 7ec7a6e - Fix "null pointer passed to nonnull argument" clang static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-14T14:00:36Z New Revision: 7ec7a6e5bfa745c285d5c651af02b93f2cb923e1 URL: https://github.com/llvm/llvm-project/commit/7ec7a6e5bfa745c285d5c651af02b93f2cb923e1 DIFF: https://github.com/llvm/llvm-project/commit/7ec7a6e5bfa745c285d5c651af02b93f2cb923e1.diff LOG: Fix "null pointer passed to nonnull argument" clang static analyzer warnings. NFCI. Assert that the memcpy arguments are valid. Added: Modified: clang/lib/AST/NestedNameSpecifier.cpp Removed: diff --git a/clang/lib/AST/NestedNameSpecifier.cpp b/clang/lib/AST/NestedNameSpecifier.cpp index 09d85102585b..137953fa8203 100644 --- a/clang/lib/AST/NestedNameSpecifier.cpp +++ b/clang/lib/AST/NestedNameSpecifier.cpp @@ -472,7 +472,7 @@ TypeLoc NestedNameSpecifierLoc::getTypeLoc() const { } static void Append(char *Start, char *End, char *, unsigned , - unsigned ) { + unsigned ) { if (Start == End) return; @@ -489,9 +489,9 @@ static void Append(char *Start, char *End, char *, unsigned , Buffer = NewBuffer; BufferCapacity = NewCapacity; } - + assert(Buffer && Start && End && End > Start && "Illegal memory buffer copy"); memcpy(Buffer + BufferSize, Start, End - Start); - BufferSize += End-Start; + BufferSize += End - Start; } /// Save a source location to the given buffer. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 25dc5c7 - Fix "pointer is null" static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-14T14:00:37Z New Revision: 25dc5c7cd159522ec2375544f473c757ee13a03b URL: https://github.com/llvm/llvm-project/commit/25dc5c7cd159522ec2375544f473c757ee13a03b DIFF: https://github.com/llvm/llvm-project/commit/25dc5c7cd159522ec2375544f473c757ee13a03b.diff LOG: Fix "pointer is null" static analyzer warnings. NFCI. Use castAs<> instead of getAs<> since the pointer is dereferenced immediately below and castAs will perform the null assertion for us. Added: Modified: clang/lib/CodeGen/CGObjC.cpp Removed: diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp index 3c11aa7f2f42..c52aa6bb5496 100644 --- a/clang/lib/CodeGen/CGObjC.cpp +++ b/clang/lib/CodeGen/CGObjC.cpp @@ -488,7 +488,7 @@ tryEmitSpecializedAllocInit(CodeGenFunction , const ObjCMessageExpr *OME) { Receiver = CGF.EmitScalarExpr(SelfInClassMethod); } else { QualType ReceiverType = SubOME->getClassReceiver(); -const ObjCObjectType *ObjTy = ReceiverType->getAs(); +const ObjCObjectType *ObjTy = ReceiverType->castAs(); const ObjCInterfaceDecl *ID = ObjTy->getInterface(); assert(ID && "null interface should be impossible here"); Receiver = CGF.CGM.getObjCRuntime().GetClass(CGF, ID); @@ -555,9 +555,7 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E, case ObjCMessageExpr::Class: { ReceiverType = E->getClassReceiver(); -const ObjCObjectType *ObjTy = ReceiverType->getAs(); -assert(ObjTy && "Invalid Objective-C class message send"); -OID = ObjTy->getInterface(); +OID = ReceiverType->castAs()->getInterface(); assert(OID && "Invalid Objective-C class message send"); Receiver = Runtime.GetClass(*this, OID); isClassMessage = true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7af6725 - Sema::getOwningModule - take const Decl* type.
Author: Simon Pilgrim Date: 2020-01-13T15:07:55Z New Revision: 7af67259cdd66811941514a263dd0f81c491d8f1 URL: https://github.com/llvm/llvm-project/commit/7af67259cdd66811941514a263dd0f81c491d8f1 DIFF: https://github.com/llvm/llvm-project/commit/7af67259cdd66811941514a263dd0f81c491d8f1.diff LOG: Sema::getOwningModule - take const Decl* type. Fixes static analyzer warning that const_cast was being used despite only const methods being called. Added: Modified: clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaOverload.cpp Removed: diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 851b25922f5a..b95a5017d907 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -1725,7 +1725,9 @@ class Sema final { public: /// Get the module owning an entity. - Module *getOwningModule(Decl *Entity) { return Entity->getOwningModule(); } + Module *getOwningModule(const Decl *Entity) { +return Entity->getOwningModule(); + } /// Make a merged definition of an existing hidden definition \p ND /// visible at the specified location. diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index be02a199a51a..56d9522eee01 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -9673,8 +9673,7 @@ bool Sema::isEquivalentInternalLinkageDeclaration(const NamedDecl *A, // entity in diff erent modules. if (!VA->getDeclContext()->getRedeclContext()->Equals( VB->getDeclContext()->getRedeclContext()) || - getOwningModule(const_cast(VA)) == - getOwningModule(const_cast(VB)) || + getOwningModule(VA) == getOwningModule(VB) || VA->isExternallyVisible() || VB->isExternallyVisible()) return false; @@ -9711,12 +9710,12 @@ void Sema::diagnoseEquivalentInternalLinkageDeclarations( SourceLocation Loc, const NamedDecl *D, ArrayRef Equiv) { Diag(Loc, diag::ext_equivalent_internal_linkage_decl_in_modules) << D; - Module *M = getOwningModule(const_cast(D)); + Module *M = getOwningModule(D); Diag(D->getLocation(), diag::note_equivalent_internal_linkage_decl) << !M << (M ? M->getFullModuleName() : ""); for (auto *E : Equiv) { -Module *M = getOwningModule(const_cast(E)); +Module *M = getOwningModule(E); Diag(E->getLocation(), diag::note_equivalent_internal_linkage_decl) << !M << (M ? M->getFullModuleName() : ""); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 40311f9 - Fix "pointer is null" static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-13T15:07:56Z New Revision: 40311f9724953541ab7b755fb6a96b31c1e63f00 URL: https://github.com/llvm/llvm-project/commit/40311f9724953541ab7b755fb6a96b31c1e63f00 DIFF: https://github.com/llvm/llvm-project/commit/40311f9724953541ab7b755fb6a96b31c1e63f00.diff LOG: Fix "pointer is null" static analyzer warnings. NFCI. Use castAs<> instead of getAs<> since the pointers are always dereferenced and castAs will perform the null assertion for us. Added: Modified: clang/lib/AST/ASTContext.cpp Removed: diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index d26e7f789d0a..0b2d8b4d1e23 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -8707,8 +8707,8 @@ QualType ASTContext::mergeFunctionParameterTypes(QualType lhs, QualType rhs, QualType ASTContext::mergeFunctionTypes(QualType lhs, QualType rhs, bool OfBlockPointer, bool Unqualified) { - const auto *lbase = lhs->getAs(); - const auto *rbase = rhs->getAs(); + const auto *lbase = lhs->castAs(); + const auto *rbase = rhs->castAs(); const auto *lproto = dyn_cast(lbase); const auto *rproto = dyn_cast(rbase); bool allLTypes = true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 54b2914 - Fix "pointer is null" static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-12T22:08:56Z New Revision: 54b2914accb4f5c9b58305fd6da405d20a47c452 URL: https://github.com/llvm/llvm-project/commit/54b2914accb4f5c9b58305fd6da405d20a47c452 DIFF: https://github.com/llvm/llvm-project/commit/54b2914accb4f5c9b58305fd6da405d20a47c452.diff LOG: Fix "pointer is null" static analyzer warnings. NFCI. Use castAs<> instead of getAs<> since the pointers are dereferenced immediately and castAs will perform the null assertion for us. Added: Modified: clang/lib/AST/VTableBuilder.cpp Removed: diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp index 5688042dadd9..2b5b74be5961 100644 --- a/clang/lib/AST/VTableBuilder.cpp +++ b/clang/lib/AST/VTableBuilder.cpp @@ -270,8 +270,8 @@ static BaseOffset ComputeReturnAdjustmentBaseOffset(ASTContext , const CXXMethodDecl *DerivedMD, const CXXMethodDecl *BaseMD) { - const FunctionType *BaseFT = BaseMD->getType()->getAs(); - const FunctionType *DerivedFT = DerivedMD->getType()->getAs(); + const auto *BaseFT = BaseMD->getType()->castAs(); + const auto *DerivedFT = DerivedMD->getType()->castAs(); // Canonicalize the return types. CanQualType CanDerivedReturnType = ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ada22c8 - Fix "pointer is null" static analyzer warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-12T21:48:00Z New Revision: ada22c804cd956f3ee7cc9dc82e6d54ead8a4ffe URL: https://github.com/llvm/llvm-project/commit/ada22c804cd956f3ee7cc9dc82e6d54ead8a4ffe DIFF: https://github.com/llvm/llvm-project/commit/ada22c804cd956f3ee7cc9dc82e6d54ead8a4ffe.diff LOG: Fix "pointer is null" static analyzer warning. NFCI. Added: Modified: clang/include/clang/Basic/SourceManager.h Removed: diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h index ec1b0bcf9897..d87e9ac810fa 100644 --- a/clang/include/clang/Basic/SourceManager.h +++ b/clang/include/clang/Basic/SourceManager.h @@ -831,6 +831,7 @@ class SourceManager : public RefCountedBase { FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID = 0, unsigned LoadedOffset = 0) { +assert(SourceFile && "Null source file!"); const SrcMgr::ContentCache *IR = getOrCreateContentCache(SourceFile, isSystem(FileCharacter)); assert(IR && "getOrCreateContentCache() cannot return NULL"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ad20169 - Fix "pointer is null" static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-12T14:36:59Z New Revision: ad201691d5cc0f15f6f885f3847dcc6440ee3de5 URL: https://github.com/llvm/llvm-project/commit/ad201691d5cc0f15f6f885f3847dcc6440ee3de5 DIFF: https://github.com/llvm/llvm-project/commit/ad201691d5cc0f15f6f885f3847dcc6440ee3de5.diff LOG: Fix "pointer is null" static analyzer warnings. NFCI. Use cast<> instead of dyn_cast<> and move into its users where its dereferenced immediately. Added: Modified: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Removed: diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index 0cf7056a0783..21c4bbc60264 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -1006,12 +1006,9 @@ ProgramStateRef CStringChecker::InvalidateBuffer(CheckerContext , bool CStringChecker::SummarizeRegion(raw_ostream , ASTContext , const MemRegion *MR) { - const TypedValueRegion *TVR = dyn_cast(MR); - switch (MR->getKind()) { case MemRegion::FunctionCodeRegionKind: { -const NamedDecl *FD = cast(MR)->getDecl(); -if (FD) +if (const auto *FD = cast(MR)->getDecl()) os << "the address of the function '" << *FD << '\''; else os << "the address of a function"; @@ -1025,16 +1022,20 @@ bool CStringChecker::SummarizeRegion(raw_ostream , ASTContext , return true; case MemRegion::CXXThisRegionKind: case MemRegion::CXXTempObjectRegionKind: -os << "a C++ temp object of type " << TVR->getValueType().getAsString(); +os << "a C++ temp object of type " + << cast(MR)->getValueType().getAsString(); return true; case MemRegion::VarRegionKind: -os << "a variable of type" << TVR->getValueType().getAsString(); +os << "a variable of type" + << cast(MR)->getValueType().getAsString(); return true; case MemRegion::FieldRegionKind: -os << "a field of type " << TVR->getValueType().getAsString(); +os << "a field of type " + << cast(MR)->getValueType().getAsString(); return true; case MemRegion::ObjCIvarRegionKind: -os << "an instance variable of type " << TVR->getValueType().getAsString(); +os << "an instance variable of type " + << cast(MR)->getValueType().getAsString(); return true; default: return false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fce887b - GlobalModuleIndex - Fix use-after-move clang static analyzer warning.
Author: Simon Pilgrim Date: 2020-01-11T16:43:02Z New Revision: fce887beb79780d0e0b19e8ab6176978a3dce9b8 URL: https://github.com/llvm/llvm-project/commit/fce887beb79780d0e0b19e8ab6176978a3dce9b8 DIFF: https://github.com/llvm/llvm-project/commit/fce887beb79780d0e0b19e8ab6176978a3dce9b8.diff LOG: GlobalModuleIndex - Fix use-after-move clang static analyzer warning. Shadow variable names meant we were referencing the Buffer input argument, not the GlobalModuleIndex member that its std::move()'d it. Added: Modified: clang/lib/Serialization/GlobalModuleIndex.cpp Removed: diff --git a/clang/lib/Serialization/GlobalModuleIndex.cpp b/clang/lib/Serialization/GlobalModuleIndex.cpp index 89a1c6cb8e69..462d29c2a0f1 100644 --- a/clang/lib/Serialization/GlobalModuleIndex.cpp +++ b/clang/lib/Serialization/GlobalModuleIndex.cpp @@ -125,11 +125,12 @@ typedef llvm::OnDiskIterableChainedHashTable } -GlobalModuleIndex::GlobalModuleIndex(std::unique_ptr Buffer, - llvm::BitstreamCursor Cursor) -: Buffer(std::move(Buffer)), IdentifierIndex(), NumIdentifierLookups(), +GlobalModuleIndex::GlobalModuleIndex( +std::unique_ptr IndexBuffer, +llvm::BitstreamCursor Cursor) +: Buffer(std::move(IndexBuffer)), IdentifierIndex(), NumIdentifierLookups(), NumIdentifierLookupHits() { - auto Fail = [](llvm::Error &) { + auto Fail = [&](llvm::Error &) { report_fatal_error("Module index '" + Buffer->getBufferIdentifier() + "' failed: " + toString(std::move(Err))); }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ded237b - Fix "pointer is null" static analyzer warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-11T16:02:22Z New Revision: ded237b58d56299f90ef44853ef79b039248b85e URL: https://github.com/llvm/llvm-project/commit/ded237b58d56299f90ef44853ef79b039248b85e DIFF: https://github.com/llvm/llvm-project/commit/ded237b58d56299f90ef44853ef79b039248b85e.diff LOG: Fix "pointer is null" static analyzer warning. NFCI. Use castAs<> instead of getAs<> since the pointer is dereferenced immediately below and castAs will perform the null assertion for us. Added: Modified: clang/lib/Sema/SemaDecl.cpp Removed: diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 468db9cfc7f8..507e4a6cd436 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -13936,8 +13936,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body, LSI->ReturnType.isNull() ? Context.VoidTy : LSI->ReturnType; // Update the return type to the deduced type. -const FunctionProtoType *Proto = -FD->getType()->getAs(); +const auto *Proto = FD->getType()->castAs(); FD->setType(Context.getFunctionType(RetType, Proto->getParamTypes(), Proto->getExtProtoInfo())); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fd8ded9 - Fix "pointer is null" static analyzer warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-10T17:41:26Z New Revision: fd8ded99fe6e9fcae2c98ccad25d6562c5fa8a14 URL: https://github.com/llvm/llvm-project/commit/fd8ded99fe6e9fcae2c98ccad25d6562c5fa8a14 DIFF: https://github.com/llvm/llvm-project/commit/fd8ded99fe6e9fcae2c98ccad25d6562c5fa8a14.diff LOG: Fix "pointer is null" static analyzer warning. NFCI. Use castAs<> instead of getAs<> since the pointer is dereferenced immediately below and castAs will perform the null assertion for us. Added: Modified: clang/lib/CodeGen/CGVTables.cpp Removed: diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index c22504ce2b13..a8dce3c2e859 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -336,7 +336,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::FunctionCallee Callee, for (const ParmVarDecl *PD : MD->parameters()) EmitDelegateCallArg(CallArgs, PD, SourceLocation()); - const FunctionProtoType *FPT = MD->getType()->getAs(); + const FunctionProtoType *FPT = MD->getType()->castAs(); #ifndef NDEBUG const CGFunctionInfo = CGM.getTypes().arrangeCXXMethodCall( ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cdc9592 - Fix "pointer is null" static analyzer warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-10T17:21:20Z New Revision: cdc9592bf1acb6d8012a4867d2a22458945dcceb URL: https://github.com/llvm/llvm-project/commit/cdc9592bf1acb6d8012a4867d2a22458945dcceb DIFF: https://github.com/llvm/llvm-project/commit/cdc9592bf1acb6d8012a4867d2a22458945dcceb.diff LOG: Fix "pointer is null" static analyzer warning. NFCI. Use cast<> instead of dyn_cast<> since we know that the pointer should be valid (and is dereferenced immediately). Added: Modified: clang/lib/ARCMigrate/ObjCMT.cpp Removed: diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index 4abb04fef5b8..8b3a4a3c39ce 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -1092,7 +1092,7 @@ static bool AvailabilityAttrsMatch(Attr *At1, Attr *At2) { const AvailabilityAttr *AA1 = dyn_cast(At1); if (!AA1) return true; - const AvailabilityAttr *AA2 = dyn_cast(At2); + const AvailabilityAttr *AA2 = cast(At2); VersionTuple Introduced1 = AA1->getIntroduced(); VersionTuple Deprecated1 = AA1->getDeprecated(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d462185 - Fix "pointer is null" static analyzer warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-09T12:37:38Z New Revision: d462185e8daa49889c31c8f5568749e379a5ddf9 URL: https://github.com/llvm/llvm-project/commit/d462185e8daa49889c31c8f5568749e379a5ddf9 DIFF: https://github.com/llvm/llvm-project/commit/d462185e8daa49889c31c8f5568749e379a5ddf9.diff LOG: Fix "pointer is null" static analyzer warning. NFCI. Use cast<> instead of dyn_cast<> since we know that the pointer should be valid (and is dereferenced immediately below). Added: Modified: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp Removed: diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index a8fc77fff7d5..98e05f099198 100755 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -655,11 +655,10 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList , LateAttrs->push_back(LateInstantiatedAttribute(TmplAttr, Saved, New)); } else { // Allow 'this' within late-parsed attributes. - NamedDecl *ND = dyn_cast(New); - CXXRecordDecl *ThisContext = - dyn_cast_or_null(ND->getDeclContext()); + auto *ND = cast(New); + auto *ThisContext = dyn_cast_or_null(ND->getDeclContext()); CXXThisScopeRAII ThisScope(*this, ThisContext, Qualifiers(), - ND && ND->isCXXInstanceMember()); + ND->isCXXInstanceMember()); Attr *NewAttr = sema::instantiateTemplateAttribute(TmplAttr, Context, *this, TemplateArgs); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e3e72a2 - Fix "pointer is null" static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-09T12:05:47Z New Revision: e3e72a2619ccec9654ef9ad45e1e926841fbaa58 URL: https://github.com/llvm/llvm-project/commit/e3e72a2619ccec9654ef9ad45e1e926841fbaa58 DIFF: https://github.com/llvm/llvm-project/commit/e3e72a2619ccec9654ef9ad45e1e926841fbaa58.diff LOG: Fix "pointer is null" static analyzer warnings. NFCI. Assert that the pointers are non-null before dereferencing them. Added: Modified: clang/lib/CodeGen/CGObjCGNU.cpp Removed: diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 479cd8ec77ce..a27b6d4ed637 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -1236,6 +1236,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { // The first Interface we find may be a @class, // which should only be treated as the source of // truth in the absence of a true declaration. +assert(OID && "Failed to find ObjCInterfaceDecl"); const ObjCInterfaceDecl *OIDDef = OID->getDefinition(); if (OIDDef != nullptr) OID = OIDDef; @@ -3036,6 +3037,7 @@ llvm::Value *CGObjCGNU::GenerateProtocolRef(CodeGenFunction , llvm::Constant * = ExistingProtocols[PD->getNameAsString()]; if (!protocol) GenerateProtocol(PD); + assert(protocol && "Unknown protocol"); llvm::Type *T = CGM.getTypes().ConvertType(CGM.getContext().getObjCProtoType()); return CGF.Builder.CreateBitCast(protocol, llvm::PointerType::getUnqual(T)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e315ce2 - Fix "pointer is null" static analyzer warnings. NFCI.
Author: Simon Pilgrim Date: 2020-01-09T12:05:48Z New Revision: e315ce2bd3a5347ab58d50fab2d449e8a4e60e00 URL: https://github.com/llvm/llvm-project/commit/e315ce2bd3a5347ab58d50fab2d449e8a4e60e00 DIFF: https://github.com/llvm/llvm-project/commit/e315ce2bd3a5347ab58d50fab2d449e8a4e60e00.diff LOG: Fix "pointer is null" static analyzer warnings. NFCI. Use castAs<> instead of getAs<> since the pointer is dereferenced immediately below and castAs will perform the null assertion for us. Added: Modified: clang/lib/Sema/SemaCoroutine.cpp Removed: diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp index 271c4a10f3e4..6dc9e342beb9 100644 --- a/clang/lib/Sema/SemaCoroutine.cpp +++ b/clang/lib/Sema/SemaCoroutine.cpp @@ -1228,7 +1228,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() { return false; if (RequiresNoThrowAlloc) { -const auto *FT = OperatorNew->getType()->getAs(); +const auto *FT = OperatorNew->getType()->castAs(); if (!FT->isNothrow(/*ResultIfDependent*/ false)) { S.Diag(OperatorNew->getLocation(), diag::err_coroutine_promise_new_requires_nothrow) @@ -1281,7 +1281,7 @@ bool CoroutineStmtBuilder::makeNewAndDeleteExpr() { // Check if we need to pass the size. const auto *OpDeleteType = - OpDeleteQualType.getTypePtr()->getAs(); + OpDeleteQualType.getTypePtr()->castAs(); if (OpDeleteType->getNumParams() > 1) DeleteArgs.push_back(FrameSize); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0d54079 - Fix MSVC unhandled enum warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-09T11:11:01Z New Revision: 0d5407987a36445f21f122656edccbb0d9234f62 URL: https://github.com/llvm/llvm-project/commit/0d5407987a36445f21f122656edccbb0d9234f62 DIFF: https://github.com/llvm/llvm-project/commit/0d5407987a36445f21f122656edccbb0d9234f62.diff LOG: Fix MSVC unhandled enum warning. NFCI. Added: Modified: clang/lib/CodeGen/CGOpenMPRuntime.cpp Removed: diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index 05d29fbadfe8..ee7a2e9204ac 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -11190,6 +11190,7 @@ bool checkContext( case llvm::Triple::wasm64: case llvm::Triple::renderscript32: case llvm::Triple::renderscript64: +case llvm::Triple::ve: return false; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5936717 - Fix "pointer is null" static analyzer warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-08T17:19:08Z New Revision: 5936717fa6537812257990143e2384bb78486ef9 URL: https://github.com/llvm/llvm-project/commit/5936717fa6537812257990143e2384bb78486ef9 DIFF: https://github.com/llvm/llvm-project/commit/5936717fa6537812257990143e2384bb78486ef9.diff LOG: Fix "pointer is null" static analyzer warning. NFCI. Use castAs<> instead of getAs<> since we know that the pointer will be valid (and is dereferenced immediately below). Added: Modified: clang/lib/CodeGen/CGOpenCLRuntime.cpp Removed: diff --git a/clang/lib/CodeGen/CGOpenCLRuntime.cpp b/clang/lib/CodeGen/CGOpenCLRuntime.cpp index 191a95c62992..dbe375294d17 100644 --- a/clang/lib/CodeGen/CGOpenCLRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenCLRuntime.cpp @@ -96,7 +96,7 @@ llvm::PointerType *CGOpenCLRuntime::getSamplerType(const Type *T) { } llvm::Value *CGOpenCLRuntime::getPipeElemSize(const Expr *PipeArg) { - const PipeType *PipeTy = PipeArg->getType()->getAs(); + const PipeType *PipeTy = PipeArg->getType()->castAs(); // The type of the last (implicit) argument to be passed. llvm::Type *Int32Ty = llvm::IntegerType::getInt32Ty(CGM.getLLVMContext()); unsigned TypeSize = CGM.getContext() @@ -106,7 +106,7 @@ llvm::Value *CGOpenCLRuntime::getPipeElemSize(const Expr *PipeArg) { } llvm::Value *CGOpenCLRuntime::getPipeElemAlign(const Expr *PipeArg) { - const PipeType *PipeTy = PipeArg->getType()->getAs(); + const PipeType *PipeTy = PipeArg->getType()->castAs(); // The type of the last (implicit) argument to be passed. llvm::Type *Int32Ty = llvm::IntegerType::getInt32Ty(CGM.getLLVMContext()); unsigned TypeSize = CGM.getContext() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3b417b7 - Fix "pointer is null" static analyzer warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-07T13:41:52Z New Revision: 3b417b7cf73b6b5a2953ad4c8178b4394ea4f20e URL: https://github.com/llvm/llvm-project/commit/3b417b7cf73b6b5a2953ad4c8178b4394ea4f20e DIFF: https://github.com/llvm/llvm-project/commit/3b417b7cf73b6b5a2953ad4c8178b4394ea4f20e.diff LOG: Fix "pointer is null" static analyzer warning. NFCI. Added: Modified: clang/lib/AST/Comment.cpp Removed: diff --git a/clang/lib/AST/Comment.cpp b/clang/lib/AST/Comment.cpp index 23dc7ba93591..a02cc9d119fe 100644 --- a/clang/lib/AST/Comment.cpp +++ b/clang/lib/AST/Comment.cpp @@ -379,11 +379,11 @@ StringRef TParamCommandComment::getParamName(const FullComment *FC) const { assert(isPositionValid()); const TemplateParameterList *TPL = FC->getDeclInfo()->TemplateParameters; for (unsigned i = 0, e = getDepth(); i != e; ++i) { -if (i == e-1) +assert(TPL && "Unknown TemplateParameterList"); +if (i == e - 1) return TPL->getParam(getIndex(i))->getName(); const NamedDecl *Param = TPL->getParam(getIndex(i)); -if (const TemplateTemplateParmDecl *TTP = - dyn_cast(Param)) +if (auto *TTP = dyn_cast(Param)) TPL = TTP->getTemplateParameters(); } return ""; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 7180d95 - Fix MSVC "not all control paths return a value" warning. NFCI.
Author: Simon Pilgrim Date: 2020-01-06T10:20:20Z New Revision: 7180d9568df7d9198a75cfb5a156d9e60329794a URL: https://github.com/llvm/llvm-project/commit/7180d9568df7d9198a75cfb5a156d9e60329794a DIFF: https://github.com/llvm/llvm-project/commit/7180d9568df7d9198a75cfb5a156d9e60329794a.diff LOG: Fix MSVC "not all control paths return a value" warning. NFCI. Added: Modified: clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp index a9c95e9f3810..dd7c24d0c7ef 100644 --- a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp +++ b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp @@ -95,6 +95,7 @@ static Optional changeValue(const VarDecl , return fixIfNotDangerous(*IgnoredParens, buildQualifier(Qualifier)); return None; } + llvm_unreachable("Unknown QualifierPolicy enum"); } static Optional changePointerItself(const VarDecl , ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] d4e006e - Fix unused variable warning. NFCI.
Author: Simon Pilgrim Date: 2019-11-21T16:09:19Z New Revision: d4e006e84461bb98977388bd8742413d45c245c4 URL: https://github.com/llvm/llvm-project/commit/d4e006e84461bb98977388bd8742413d45c245c4 DIFF: https://github.com/llvm/llvm-project/commit/d4e006e84461bb98977388bd8742413d45c245c4.diff LOG: Fix unused variable warning. NFCI. Added: Modified: clang-tools-extra/clangd/Hover.cpp Removed: diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index feba29dd605d..c14ff1b3fe63 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -227,7 +227,7 @@ void fillFunctionTypeAndParams(HoverInfo , const Decl *D, // Constructor's "return type" is the class type. HI.ReturnType = declaredType(CCD->getParent()).getAsString(Policy); // Don't provide any type for the constructor itself. - } else if (const auto* CDD = llvm::dyn_cast(FD)){ + } else if (llvm::isa(FD)){ HI.ReturnType = "void"; } else { HI.ReturnType = FD->getReturnType().getAsString(Policy); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 013f4ba - Fix Wshadow warning against global None variable. NFC.
Author: Simon Pilgrim Date: 2019-11-21T12:08:00Z New Revision: 013f4ba9c21f91accc516e5a70c70efc69d92b69 URL: https://github.com/llvm/llvm-project/commit/013f4ba9c21f91accc516e5a70c70efc69d92b69 DIFF: https://github.com/llvm/llvm-project/commit/013f4ba9c21f91accc516e5a70c70efc69d92b69.diff LOG: Fix Wshadow warning against global None variable. NFC. Added: Modified: clang/include/clang/AST/DeclTemplate.h Removed: diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index ec14adc7de97..3bebba5b9c14 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1557,8 +1557,8 @@ class TemplateTemplateParmDecl final /// Retrieve the default argument, if any. const TemplateArgumentLoc () const { -static const TemplateArgumentLoc None; -return DefaultArgument.isSet() ? *DefaultArgument.get() : None; +static const TemplateArgumentLoc NoneLoc; +return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc; } /// Retrieve the location of the default argument, if any. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8c8c941 - Remove useless param tag to fix Wdocumentation warning. NFCI.
Author: Simon Pilgrim Date: 2019-11-18T14:09:11Z New Revision: 8c8c941844080625fd2989bd4045cdd5db4bb908 URL: https://github.com/llvm/llvm-project/commit/8c8c941844080625fd2989bd4045cdd5db4bb908 DIFF: https://github.com/llvm/llvm-project/commit/8c8c941844080625fd2989bd4045cdd5db4bb908.diff LOG: Remove useless param tag to fix Wdocumentation warning. NFCI. Added: Modified: clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h Removed: diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h index a3a8c6988819..a0c1900f7ed9 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h @@ -23,9 +23,6 @@ namespace dependencies{ class DependencyScanningTool { public: /// Construct a dependency scanning tool. - /// - /// \param Compilations The reference to the compilation database that's - /// used by the clang tool. DependencyScanningTool(DependencyScanningService ); /// Print out the dependency information into a string using the dependency ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] b6cd799 - Fix filename typo in rG8d288a0668a5
Author: Simon Pilgrim Date: 2019-11-11T17:23:21Z New Revision: b6cd799e29a9a5cef4d1d722f267e3b59ef6aaca URL: https://github.com/llvm/llvm-project/commit/b6cd799e29a9a5cef4d1d722f267e3b59ef6aaca DIFF: https://github.com/llvm/llvm-project/commit/b6cd799e29a9a5cef4d1d722f267e3b59ef6aaca.diff LOG: Fix filename typo in rG8d288a0668a5 Added: Modified: clang-tools-extra/docs/ReleaseNotes.rst Removed: diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index a94ee3defd1e..5737dc3d288d 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -94,8 +94,8 @@ Improvements to clang-tidy Without the null terminator it can result in undefined behaviour when the string is read. -- New alias :doc:`cert-pos44-cpp - ` to +- New alias :doc:`cert-pos44-c + ` to :doc:`bugprone-bad-signal-to-kill-thread ` was added. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a0324e9 - SanitizerMask::bitPosToMask - fix operator precedence warnings. NFCI.
Author: Simon Pilgrim Date: 2019-11-04T15:12:01Z New Revision: a0324e911374441151903ed0d828e0fc1994c167 URL: https://github.com/llvm/llvm-project/commit/a0324e911374441151903ed0d828e0fc1994c167 DIFF: https://github.com/llvm/llvm-project/commit/a0324e911374441151903ed0d828e0fc1994c167.diff LOG: SanitizerMask::bitPosToMask - fix operator precedence warnings. NFCI. Fix static analyzer operator precedence warnings with suitable bracketing. Pull out the mask generation code so clang-format doesn't make such a mess of it. Added: Modified: clang/include/clang/Basic/Sanitizers.h Removed: diff --git a/clang/include/clang/Basic/Sanitizers.h b/clang/include/clang/Basic/Sanitizers.h index 5961abf2aa19..c6b0446cea4f 100644 --- a/clang/include/clang/Basic/Sanitizers.h +++ b/clang/include/clang/Basic/Sanitizers.h @@ -52,10 +52,11 @@ class SanitizerMask { /// Create a mask with a bit enabled at position Pos. static constexpr SanitizerMask bitPosToMask(const unsigned Pos) { -return SanitizerMask((Pos < kNumBitElem) ? 1ULL << Pos % kNumBitElem : 0, - (Pos >= kNumBitElem && Pos < kNumBitElem * 2) - ? 1ULL << Pos % kNumBitElem - : 0); +uint64_t mask1 = (Pos < kNumBitElem) ? 1ULL << (Pos % kNumBitElem) : 0; +uint64_t mask2 = (Pos >= kNumBitElem && Pos < (kNumBitElem * 2)) + ? 1ULL << (Pos % kNumBitElem) + : 0; +return SanitizerMask(mask1, mask2); } unsigned countPopulation() const { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d0f3c82 - Fix uninitialized variable warnings. NFCI.
Author: Simon Pilgrim Date: 2019-11-02T18:03:21Z New Revision: d0f3c822160e36e10588bc86dabde6ab8d63cf10 URL: https://github.com/llvm/llvm-project/commit/d0f3c822160e36e10588bc86dabde6ab8d63cf10 DIFF: https://github.com/llvm/llvm-project/commit/d0f3c822160e36e10588bc86dabde6ab8d63cf10.diff LOG: Fix uninitialized variable warnings. NFCI. Added: Modified: clang/utils/TableGen/ClangDiagnosticsEmitter.cpp Removed: diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 778375010041..f694c3e4380a 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -134,7 +134,7 @@ namespace { const Record *ExplicitDef; -GroupInfo() : ExplicitDef(nullptr) {} +GroupInfo() : IDNo(0), ExplicitDef(nullptr) {} }; } // end anonymous namespace. @@ -554,7 +554,7 @@ struct SelectPiece : Piece { ModifierType ModKind; std::vector Options; - int Index; + int Index = 0; static bool classof(const Piece *P) { return P->getPieceClass() == SelectPieceClass || @@ -566,7 +566,7 @@ struct PluralPiece : SelectPiece { PluralPiece() : SelectPiece(PluralPieceClass, MT_Plural) {} std::vector OptionPrefixes; - int Index; + int Index = 0; static bool classof(const Piece *P) { return P->getPieceClass() == PluralPieceClass; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f213207 - Lexer::ReadToEndOfLine - fix Token uninitialised value warnings. NFCI.
Author: Simon Pilgrim Date: 2019-10-28T18:28:18Z New Revision: f2132070d9a5a330400744aa14819344d0b44151 URL: https://github.com/llvm/llvm-project/commit/f2132070d9a5a330400744aa14819344d0b44151 DIFF: https://github.com/llvm/llvm-project/commit/f2132070d9a5a330400744aa14819344d0b44151.diff LOG: Lexer::ReadToEndOfLine - fix Token uninitialised value warnings. NFCI. Use Token::startToken to initialize Token. Added: Modified: clang/lib/Lex/Lexer.cpp Removed: diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 17f5ab1e035d..902b17397915 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -2656,6 +2656,7 @@ void Lexer::ReadToEndOfLine(SmallVectorImpl *Result) { assert(ParsingPreprocessorDirective && ParsingFilename == false && "Must be in a preprocessing directive!"); Token Tmp; + Tmp.startToken(); // CurPtr - Cache BufferPtr in an automatic variable. const char *CurPtr = BufferPtr; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 93a3128 - Remove extra ';'. NFCI.
Author: Simon Pilgrim Date: 2019-10-28T16:32:02Z New Revision: 93a3128a67cc4372696eb3199bed23d7bac4a183 URL: https://github.com/llvm/llvm-project/commit/93a3128a67cc4372696eb3199bed23d7bac4a183 DIFF: https://github.com/llvm/llvm-project/commit/93a3128a67cc4372696eb3199bed23d7bac4a183.diff LOG: Remove extra ';'. NFCI. Added: Modified: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp Removed: diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp index 8785db1a292b..6bce81bae306 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp @@ -386,7 +386,7 @@ class DefineInline : public Tweak { const FunctionDecl *Target = nullptr; }; -REGISTER_TWEAK(DefineInline); +REGISTER_TWEAK(DefineInline) } // namespace } // namespace clangd ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 126a72f - Fix MSVC "not all control paths return a value" warnings. NFCI.
Author: Simon Pilgrim Date: 2019-10-24T13:40:13-07:00 New Revision: 126a72fcbf7e5e4d958d3804033710c0a4efbe39 URL: https://github.com/llvm/llvm-project/commit/126a72fcbf7e5e4d958d3804033710c0a4efbe39 DIFF: https://github.com/llvm/llvm-project/commit/126a72fcbf7e5e4d958d3804033710c0a4efbe39.diff LOG: Fix MSVC "not all control paths return a value" warnings. NFCI. Added: Modified: clang/utils/TableGen/MveEmitter.cpp Removed: diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp index c4270ff586cf..9c3328e3bbfb 100644 --- a/clang/utils/TableGen/MveEmitter.cpp +++ b/clang/utils/TableGen/MveEmitter.cpp @@ -158,6 +158,7 @@ inline std::string toLetter(ScalarTypeKind kind) { case ScalarTypeKind::Float: return "f"; } + llvm_unreachable("Unhandled ScalarTypeKind enum"); } inline std::string toCPrefix(ScalarTypeKind kind) { switch (kind) { @@ -168,6 +169,7 @@ inline std::string toCPrefix(ScalarTypeKind kind) { case ScalarTypeKind::Float: return "float"; } + llvm_unreachable("Unhandled ScalarTypeKind enum"); } class VoidType : public Type { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r375443 - SemaTemplateDeduction - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Mon Oct 21 12:08:31 2019 New Revision: 375443 URL: http://llvm.org/viewvc/llvm-project?rev=375443=rev Log: SemaTemplateDeduction - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=375443=375442=375443=diff == --- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original) +++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Oct 21 12:08:31 2019 @@ -3826,8 +3826,7 @@ Sema::TemplateDeductionResult Sema::Dedu if (Args.size() < Function->getMinRequiredArguments() && !PartialOverloading) return TDK_TooFewArguments; else if (TooManyArguments(NumParams, Args.size(), PartialOverloading)) { -const FunctionProtoType *Proto - = Function->getType()->getAs(); +const auto *Proto = Function->getType()->castAs(); if (Proto->isTemplateVariadic()) /* Do nothing */; else if (!Proto->isVariadic()) @@ -3965,11 +3964,8 @@ QualType Sema::adjustCCAndNoReturn(QualT if (ArgFunctionType.isNull()) return ArgFunctionType; - const FunctionProtoType *FunctionTypeP = - FunctionType->castAs(); - const FunctionProtoType *ArgFunctionTypeP = - ArgFunctionType->getAs(); - + const auto *FunctionTypeP = FunctionType->castAs(); + const auto *ArgFunctionTypeP = ArgFunctionType->castAs(); FunctionProtoType::ExtProtoInfo EPI = ArgFunctionTypeP->getExtProtoInfo(); bool Rebuild = false; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r375440 - SemaExceptionSpec - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Mon Oct 21 11:28:31 2019 New Revision: 375440 URL: http://llvm.org/viewvc/llvm-project?rev=375440=rev Log: SemaExceptionSpec - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Modified: cfe/trunk/lib/Sema/SemaExceptionSpec.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExceptionSpec.cpp?rev=375440=375439=375440=diff == --- cfe/trunk/lib/Sema/SemaExceptionSpec.cpp (original) +++ cfe/trunk/lib/Sema/SemaExceptionSpec.cpp Mon Oct 21 11:28:31 2019 @@ -263,8 +263,7 @@ static bool hasImplicitExceptionSpec(Fun if (!Decl->getTypeSourceInfo()) return isa(Decl); - const FunctionProtoType *Ty = -Decl->getTypeSourceInfo()->getType()->getAs(); + auto *Ty = Decl->getTypeSourceInfo()->getType()->castAs(); return !Ty->hasExceptionSpec(); } @@ -965,9 +964,9 @@ bool Sema::CheckOverridingFunctionExcept PDiag(diag::err_deep_exception_specs_differ), PDiag(diag::note_overridden_virtual_function), PDiag(diag::ext_override_exception_spec), - Old->getType()->getAs(), + Old->getType()->castAs(), Old->getLocation(), - New->getType()->getAs(), + New->getType()->castAs(), New->getLocation()); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r375434 - Fix Wdocumentation warning. NFCI.
Author: rksimon Date: Mon Oct 21 10:45:18 2019 New Revision: 375434 URL: http://llvm.org/viewvc/llvm-project?rev=375434=rev Log: Fix Wdocumentation warning. NFCI. Modified: cfe/trunk/include/clang/AST/ExprCXX.h Modified: cfe/trunk/include/clang/AST/ExprCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=375434=375433=375434=diff == --- cfe/trunk/include/clang/AST/ExprCXX.h (original) +++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Oct 21 10:45:18 2019 @@ -262,8 +262,8 @@ public: /// - a != b -> !(a == b) /// - a != b -> !(b == a) /// - For \c \@ in \c <, \c <=, \c >, \c >=, \c <=>: -/// - a @ b -> (a <=> b) @ 0 -/// - a @ b -> 0 @ (b <=> a) +/// - a @ b -> (a <=> b) @ 0 +/// - a @ b -> 0 @ (b <=> a) /// /// This expression provides access to both the original syntax and the /// rewritten expression. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r375102 - clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Thu Oct 17 04:12:53 2019 New Revision: 375102 URL: http://llvm.org/viewvc/llvm-project?rev=375102=rev Log: clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp?rev=375102=375101=375102=diff == --- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp Thu Oct 17 04:12:53 2019 @@ -478,7 +478,7 @@ canOverloadedOperatorArgsBeModified(cons // These functions must be declared const in order to not be able to modify // the instance of the class they are called through. if (ParamCount == 1 && - !OperatorDecl->getType()->getAs()->isConst()) + !OperatorDecl->getType()->castAs()->isConst()) return true; if (isNonConstReferenceType(OperatorDecl->getParamDecl(0)->getType())) Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp?rev=375102=375101=375102=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp Thu Oct 17 04:12:53 2019 @@ -29,7 +29,7 @@ static StringRef getValueOfValueInit(con return "false"; case Type::STK_Integral: -switch (InitType->getAs()->getKind()) { +switch (InitType->castAs()->getKind()) { case BuiltinType::Char_U: case BuiltinType::UChar: case BuiltinType::Char_S: @@ -47,7 +47,7 @@ static StringRef getValueOfValueInit(con } case Type::STK_Floating: -switch (InitType->getAs()->getKind()) { +switch (InitType->castAs()->getKind()) { case BuiltinType::Half: case BuiltinType::Float: return "0.0f"; @@ -58,10 +58,10 @@ static StringRef getValueOfValueInit(con case Type::STK_FloatingComplex: case Type::STK_IntegralComplex: return getValueOfValueInit( -InitType->getAs()->getElementType()); +InitType->castAs()->getElementType()); case Type::STK_FixedPoint: -switch (InitType->getAs()->getKind()) { +switch (InitType->castAs()->getKind()) { case BuiltinType::ShortAccum: case BuiltinType::SatShortAccum: return "0.0hk"; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r375101 - SemaExprCXX - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Thu Oct 17 04:12:31 2019 New Revision: 375101 URL: http://llvm.org/viewvc/llvm-project?rev=375101=rev Log: SemaExprCXX - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=375101=375100=375101=diff == --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Oct 17 04:12:31 2019 @@ -3302,7 +3302,7 @@ Sema::ActOnCXXDelete(SourceLocation Star //itself in this case. return ExprError(); -QualType Pointee = Type->getAs()->getPointeeType(); +QualType Pointee = Type->castAs()->getPointeeType(); QualType PointeeElem = Context.getBaseElementType(Pointee); if (Pointee.getAddressSpace() != LangAS::Default && @@ -4034,8 +4034,8 @@ Sema::PerformImplicitConversion(Expr *Fr case ICK_Complex_Promotion: case ICK_Complex_Conversion: { -QualType FromEl = From->getType()->getAs()->getElementType(); -QualType ToEl = ToType->getAs()->getElementType(); +QualType FromEl = From->getType()->castAs()->getElementType(); +QualType ToEl = ToType->castAs()->getElementType(); CastKind CK; if (FromEl->isRealFloatingType()) { if (ToEl->isRealFloatingType()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r375097 - SemaDeclObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Thu Oct 17 03:35:29 2019 New Revision: 375097 URL: http://llvm.org/viewvc/llvm-project?rev=375097=rev Log: SemaDeclObjC - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=375097=375096=375097=diff == --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Oct 17 03:35:29 2019 @@ -586,7 +586,7 @@ ActOnSuperClassOfClassInterface(Scope *S dyn_cast_or_null(PrevDecl)) { QualType T = TDecl->getUnderlyingType(); if (T->isObjCObjectType()) { - if (NamedDecl *IDecl = T->getAs()->getInterface()) { + if (NamedDecl *IDecl = T->castAs()->getInterface()) { SuperClassDecl = dyn_cast(IDecl); SuperClassType = Context.getTypeDeclType(TDecl); @@ -1151,7 +1151,7 @@ Decl *Sema::ActOnCompatibilityAlias(Sour dyn_cast_or_null(CDeclU)) { QualType T = TDecl->getUnderlyingType(); if (T->isObjCObjectType()) { - if (NamedDecl *IDecl = T->getAs()->getInterface()) { + if (NamedDecl *IDecl = T->castAs()->getInterface()) { ClassName = IDecl->getIdentifier(); CDeclU = LookupSingleName(TUScope, ClassName, ClassLocation, LookupOrdinaryName, @@ -4876,7 +4876,7 @@ VarDecl *Sema::BuildObjCExceptionDecl(Ty } else if (!T->isObjCObjectPointerType()) { Invalid = true; Diag(IdLoc, diag::err_catch_param_not_objc_type); - } else if (!T->getAs()->getInterfaceType()) { + } else if (!T->castAs()->getInterfaceType()) { Invalid = true; Diag(IdLoc, diag::err_catch_param_not_objc_type); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374991 - RewriteModernObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Wed Oct 16 03:50:06 2019 New Revision: 374991 URL: http://llvm.org/viewvc/llvm-project?rev=374991=rev Log: RewriteModernObjC - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=374991=374990=374991=diff == --- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp (original) +++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp Wed Oct 16 03:50:06 2019 @@ -505,7 +505,7 @@ namespace { /// otherwise. bool convertBlockPointerToFunctionPointer(QualType ) { if (isTopLevelBlockPointerType(T)) { -const BlockPointerType *BPT = T->getAs(); +const auto *BPT = T->castAs(); T = Context->getPointerType(BPT->getPointeeType()); return true; } @@ -856,8 +856,7 @@ RewriteModernObjC::getIvarAccessString(O RD = RD->getDefinition(); if (RD && !RD->getDeclName().getAsIdentifierInfo()) { // decltype(((Foo_IMPL*)0)->bar) * - ObjCContainerDecl *CDecl = - dyn_cast(D->getDeclContext()); + auto *CDecl = cast(D->getDeclContext()); // ivar in class extensions requires special treatment. if (ObjCCategoryDecl *CatDecl = dyn_cast(CDecl)) CDecl = CatDecl->getClassInterface(); @@ -1332,6 +1331,7 @@ void RewriteModernObjC::RewriteObjCMetho void RewriteModernObjC::RewriteImplementationDecl(Decl *OID) { ObjCImplementationDecl *IMD = dyn_cast(OID); ObjCCategoryImplDecl *CID = dyn_cast(OID); + assert((IMD || CID) && "Unknown implementation type"); if (IMD) { if (IMD->getIvarRBraceLoc().isValid()) { @@ -2103,8 +2103,7 @@ RewriteModernObjC::SynthesizeCallToFunct ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay, DRE, nullptr, VK_RValue); - const FunctionType *FT = msgSendType->getAs(); - + const auto *FT = msgSendType->castAs(); CallExpr *Exp = CallExpr::Create( *Context, ICE, Args, FT->getCallResultType(*Context), VK_RValue, EndLoc); return Exp; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374987 - CGBuiltin - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Wed Oct 16 03:38:32 2019 New Revision: 374987 URL: http://llvm.org/viewvc/llvm-project?rev=374987=rev Log: CGBuiltin - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=374987=374986=374987=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Oct 16 03:38:32 2019 @@ -1396,9 +1396,8 @@ EmitCheckedMixedSignMultiply(CodeGenFunc static llvm::Value *dumpRecord(CodeGenFunction , QualType RType, Value *, CharUnits Align, llvm::FunctionCallee Func, int Lvl) { - const auto *RT = RType->getAs(); ASTContext = CGF.getContext(); - RecordDecl *RD = RT->getDecl()->getDefinition(); + RecordDecl *RD = RType->castAs()->getDecl()->getDefinition(); std::string Pad = std::string(Lvl * 4, ' '); Value *GString = @@ -3693,13 +3692,13 @@ RValue CodeGenFunction::EmitBuiltinExpr( case Builtin::BIget_pipe_num_packets: case Builtin::BIget_pipe_max_packets: { const char *BaseName; -const PipeType *PipeTy = E->getArg(0)->getType()->getAs(); +const auto *PipeTy = E->getArg(0)->getType()->castAs(); if (BuiltinID == Builtin::BIget_pipe_num_packets) BaseName = "__get_pipe_num_packets"; else BaseName = "__get_pipe_max_packets"; -auto Name = std::string(BaseName) + -std::string(PipeTy->isReadOnly() ? "_ro" : "_wo"); +std::string Name = std::string(BaseName) + + std::string(PipeTy->isReadOnly() ? "_ro" : "_wo"); // Building the generic function prototype. Value *Arg0 = EmitScalarExpr(E->getArg(0)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374989 - CGDebugInfo - silence static analyzer dyn_cast<> null dereference warnings. NFCI.
Author: rksimon Date: Wed Oct 16 03:38:49 2019 New Revision: 374989 URL: http://llvm.org/viewvc/llvm-project?rev=374989=rev Log: CGDebugInfo - silence static analyzer dyn_cast<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use cast<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=374989=374988=374989=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Oct 16 03:38:49 2019 @@ -1791,6 +1791,7 @@ CGDebugInfo::CollectTemplateParams(const CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset); V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars); } +assert(V && "Failed to find template parameter pointer"); V = V->stripPointerCasts(); } TemplateParams.push_back(DBuilder.createTemplateValueParameter( @@ -3327,13 +3328,13 @@ llvm::DISubprogram *CGDebugInfo::getFunc unsigned Line = getLineNumber(Loc); collectFunctionDeclProps(GD, Unit, Name, LinkageName, DContext, TParamsArray, Flags); - auto *FD = dyn_cast(GD.getDecl()); + auto *FD = cast(GD.getDecl()); // Build function type. SmallVector ArgTypes; - if (FD) -for (const ParmVarDecl *Parm : FD->parameters()) - ArgTypes.push_back(Parm->getType()); + for (const ParmVarDecl *Parm : FD->parameters()) +ArgTypes.push_back(Parm->getType()); + CallingConv CC = FD->getType()->castAs()->getCallConv(); QualType FnType = CGM.getContext().getFunctionType( FD->getReturnType(), ArgTypes, FunctionProtoType::ExtProtoInfo(CC)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374988 - CGExprConstant - silence static analyzer getAs<> null dereference warning. NFCI.
Author: rksimon Date: Wed Oct 16 03:38:40 2019 New Revision: 374988 URL: http://llvm.org/viewvc/llvm-project?rev=374988=rev Log: CGExprConstant - silence static analyzer getAs<> null dereference warning. NFCI. The static analyzer is warning about a potential null dereference, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=374988=374987=374988=diff == --- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed Oct 16 03:38:40 2019 @@ -1269,8 +1269,8 @@ public: return nullptr; // FIXME: We should not have to call getBaseElementType here. -const RecordType *RT = - CGM.getContext().getBaseElementType(Ty)->getAs(); +const auto *RT = +CGM.getContext().getBaseElementType(Ty)->castAs(); const CXXRecordDecl *RD = cast(RT->getDecl()); // If the class doesn't have a trivial destructor, we can't emit it as a ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374876 - Fix uninitialized variable warnings. NFCI.
Author: rksimon Date: Tue Oct 15 03:23:05 2019 New Revision: 374876 URL: http://llvm.org/viewvc/llvm-project?rev=374876=rev Log: 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=374876=374875=374876=diff == --- cfe/trunk/lib/AST/ASTImporter.cpp (original) +++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Oct 15 03:23:05 2019 @@ -2579,10 +2579,10 @@ ExpectedDecl ASTNodeImporter::VisitRecor } // Import the major distinguishing characteristics of this record. - DeclContext *DC, *LexicalDC; + DeclContext *DC = nullptr, *LexicalDC = nullptr; DeclarationName Name; SourceLocation Loc; - NamedDecl *ToD; + NamedDecl *ToD = nullptr; if (Error Err = ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc)) return std::move(Err); if (ToD) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r374717 - BlockInCriticalSectionChecker - silence static analyzer dyn_cast null dereference warning. NFCI.
Author: rksimon Date: Sun Oct 13 04:30:06 2019 New Revision: 374717 URL: http://llvm.org/viewvc/llvm-project?rev=374717=rev Log: BlockInCriticalSectionChecker - silence static analyzer dyn_cast null dereference warning. NFCI. The static analyzer is warning about a potential null dereference, but we should be able to use cast<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp?rev=374717=374716=374717=diff == --- cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Checkers/BlockInCriticalSectionChecker.cpp Sun Oct 13 04:30:06 2019 @@ -126,7 +126,7 @@ bool BlockInCriticalSectionChecker::isLo bool BlockInCriticalSectionChecker::isUnlockFunction(const CallEvent ) const { if (const auto *Dtor = dyn_cast()) { -const auto *DRecordDecl = dyn_cast(Dtor->getDecl()->getParent()); +const auto *DRecordDecl = cast(Dtor->getDecl()->getParent()); auto IdentifierInfo = DRecordDecl->getIdentifier(); if (IdentifierInfo == IILockGuard || IdentifierInfo == IIUniqueLock) return true; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r373918 - Codegen - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Mon Oct 7 09:42:25 2019 New Revision: 373918 URL: http://llvm.org/viewvc/llvm-project?rev=373918=rev Log: Codegen - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp cfe/trunk/lib/CodeGen/CGCXX.cpp cfe/trunk/lib/CodeGen/CGClass.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGObjCGNU.cpp cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp cfe/trunk/lib/CodeGen/TargetInfo.cpp Modified: cfe/trunk/lib/CodeGen/CGAtomic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGAtomic.cpp?rev=373918=373917=373918=diff == --- cfe/trunk/lib/CodeGen/CGAtomic.cpp (original) +++ cfe/trunk/lib/CodeGen/CGAtomic.cpp Mon Oct 7 09:42:25 2019 @@ -970,7 +970,7 @@ RValue CodeGenFunction::EmitAtomicExpr(A auto CastToGenericAddrSpace = [&](llvm::Value *V, QualType PT) { if (!E->isOpenCL()) return V; - auto AS = PT->getAs()->getPointeeType().getAddressSpace(); + auto AS = PT->castAs()->getPointeeType().getAddressSpace(); if (AS == LangAS::opencl_generic) return V; auto DestAS = getContext().getTargetAddressSpace(LangAS::opencl_generic); Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=373918=373917=373918=diff == --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Oct 7 09:42:25 2019 @@ -104,8 +104,8 @@ bool CodeGenModule::TryEmitBaseDestructo // Give up if the calling conventions don't match. We could update the call, // but it is probably not worth it. const CXXDestructorDecl *BaseD = UniqueBase->getDestructor(); - if (BaseD->getType()->getAs()->getCallConv() != - D->getType()->getAs()->getCallConv()) + if (BaseD->getType()->castAs()->getCallConv() != + D->getType()->castAs()->getCallConv()) return true; GlobalDecl AliasDecl(D, Dtor_Base); Modified: cfe/trunk/lib/CodeGen/CGClass.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=373918=373917=373918=diff == --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) +++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Oct 7 09:42:25 2019 @@ -739,7 +739,7 @@ bool CodeGenFunction::IsConstructorDeleg // We also disable the optimization for variadic functions because // it's impossible to "re-pass" varargs. - if (Ctor->getType()->getAs()->isVariadic()) + if (Ctor->getType()->castAs()->isVariadic()) return false; // FIXME: Decide if we can do a delegation of a delegating constructor. Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=373918=373917=373918=diff == --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Oct 7 09:42:25 2019 @@ -1659,7 +1659,7 @@ void CGDebugInfo::CollectCXXMemberFuncti if (!Method || Method->isImplicit() || Method->hasAttr()) continue; -if (Method->getType()->getAs()->getContainedAutoType()) +if (Method->getType()->castAs()->getContainedAutoType()) continue; // Reuse the existing member function declaration if it exists. @@ -4561,7 +4561,7 @@ void CGDebugInfo::EmitUsingDecl(const Us // return type in the definition) if (const auto *FD = dyn_cast(USD.getUnderlyingDecl())) if (const auto *AT = -FD->getType()->getAs()->getContainedAutoType()) +FD->getType()->castAs()->getContainedAutoType()) if (AT->getDeducedType().isNull()) return; if (llvm::DINode *Target = Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=373918=373917=373918=diff == --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 7 09:42:25 2019 @@ -997,7 +997,7 @@ EmitComplexPrePostIncDec(const UnaryOper // Add the inc/dec to the real part. NextVal = Builder.CreateAdd(InVal.first, NextVal, isInc ? "inc" : "dec"); } else { -QualType ElemTy = E->getType()->getAs()->getElementType(); +QualType ElemTy = E->getType()->castAs()->getElementType(); llvm::APFloat FVal(getContext().getFloatTypeSemantics(ElemTy), 1); if (!isInc) FVal.changeSign(); @@ -2194,7 +2194,7 @@ static void setObjCGCLValueClass(const A
r373911 - Sema - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Mon Oct 7 07:25:46 2019 New Revision: 373911 URL: http://llvm.org/viewvc/llvm-project?rev=373911=rev Log: Sema - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/Sema/SemaAccess.cpp cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/lib/Sema/SemaAccess.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAccess.cpp?rev=373911=373910=373911=diff == --- cfe/trunk/lib/Sema/SemaAccess.cpp (original) +++ cfe/trunk/lib/Sema/SemaAccess.cpp Mon Oct 7 07:25:46 2019 @@ -1551,7 +1551,7 @@ Sema::AccessResult Sema::CheckUnresolved QualType BaseType = E->getBaseType(); if (E->isArrow()) -BaseType = BaseType->getAs()->getPointeeType(); +BaseType = BaseType->castAs()->getPointeeType(); AccessTarget Entity(Context, AccessTarget::Member, E->getNamingClass(), Found, BaseType); Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=373911=373910=373911=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Oct 7 07:25:46 2019 @@ -484,7 +484,7 @@ static bool checkOpenCLBlockArgs(Sema const BlockPointerType *BPT = cast(BlockArg->getType().getCanonicalType()); ArrayRef Params = - BPT->getPointeeType()->getAs()->getParamTypes(); + BPT->getPointeeType()->castAs()->getParamTypes(); unsigned ArgCounter = 0; bool IllegalParams = false; // Iterate through the block parameters until either one is found that is not @@ -583,7 +583,7 @@ static bool checkOpenCLEnqueueVariadicAr const BlockPointerType *BPT = cast(BlockArg->getType().getCanonicalType()); unsigned NumBlockParams = - BPT->getPointeeType()->getAs()->getNumParams(); + BPT->getPointeeType()->castAs()->getNumParams(); unsigned TotalNumArgs = TheCall->getNumArgs(); // For each argument passed to the block, a corresponding uint needs to @@ -676,7 +676,7 @@ static bool SemaOpenCLBuiltinEnqueueKern // we have a block type, check the prototype const BlockPointerType *BPT = cast(Arg3->getType().getCanonicalType()); -if (BPT->getPointeeType()->getAs()->getNumParams() > 0) { +if (BPT->getPointeeType()->castAs()->getNumParams() > 0) { S.Diag(Arg3->getBeginLoc(), diag::err_opencl_enqueue_kernel_blocks_no_args); return true; @@ -4664,7 +4664,7 @@ ExprResult Sema::BuildAtomicExpr(SourceR << Ptr->getSourceRange(); return ExprError(); } -ValType = AtomTy->getAs()->getValueType(); +ValType = AtomTy->castAs()->getValueType(); } else if (Form != Load && Form != LoadCopy) { if (ValType.isConstQualified()) { Diag(ExprRange.getBegin(), diag::err_atomic_op_needs_non_const_pointer) @@ -5473,7 +5473,7 @@ static bool checkVAStartABI(Sema , uns if (IsX64 || IsAArch64) { CallingConv CC = CC_C; if (const FunctionDecl *FD = S.getCurFunctionDecl()) - CC = FD->getType()->getAs()->getCallConv(); + CC = FD->getType()->castAs()->getCallConv(); if (IsMSVAStart) { // Don't allow this in System V ABI functions. if (CC == CC_X86_64SysV || (!IsWindows && CC != CC_Win64)) @@ -5603,7 +5603,7 @@ bool Sema::SemaBuiltinVAStart(unsigned B return false; if (!Type->isEnumeralType()) return true; - const EnumDecl *ED = Type->getAs()->getDecl(); + const EnumDecl *ED = Type->castAs()->getDecl(); return !(ED && Context.typesAreCompatible(ED->getPromotionType(), Type)); }()) { @@ -10756,7 +10756,7 @@ static bool AnalyzeBitFieldAssignment(Se return false; if (BitfieldType->isEnumeralType()) { -EnumDecl *BitfieldEnumDecl = BitfieldType->getAs()->getDecl(); +EnumDecl *BitfieldEnumDecl = BitfieldType->castAs()->getDecl(); // If the underlying enum type was not explicitly specified as an unsigned // type and the enum contain only positive values, MSVC++ will cause an // inconsistency by storing this as a signed type. Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=373911=373910=373911=diff == --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Mon Oct 7 07:25:46 2019 @@ -83,7 +83,7 @@ static QualType lookupPromiseType(Sema & //
r373905 - RewriteModernObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Mon Oct 7 06:58:15 2019 New Revision: 373905 URL: http://llvm.org/viewvc/llvm-project?rev=373905=rev Log: RewriteModernObjC - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=373905=373904=373905=diff == --- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp (original) +++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp Mon Oct 7 06:58:15 2019 @@ -2752,7 +2752,7 @@ Stmt *RewriteModernObjC::RewriteObjCArra // Create a call to objc_getClass("NSArray"). It will be th 1st argument. ObjCInterfaceDecl *Class = -expType->getPointeeType()->getAs()->getInterface(); +expType->getPointeeType()->castAs()->getInterface(); IdentifierInfo *clsName = Class->getIdentifier(); ClsExprs.push_back(getStringLiteral(clsName->getName())); @@ -2806,7 +2806,7 @@ Stmt *RewriteModernObjC::RewriteObjCArra // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast); - const FunctionType *FT = msgSendType->getAs(); + const FunctionType *FT = msgSendType->castAs(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc); ReplaceStmt(Exp, CE); @@ -2894,7 +2894,7 @@ Stmt *RewriteModernObjC::RewriteObjCDict // Create a call to objc_getClass("NSArray"). It will be th 1st argument. ObjCInterfaceDecl *Class = - expType->getPointeeType()->getAs()->getInterface(); + expType->getPointeeType()->castAs()->getInterface(); IdentifierInfo *clsName = Class->getIdentifier(); ClsExprs.push_back(getStringLiteral(clsName->getName())); @@ -2957,7 +2957,7 @@ Stmt *RewriteModernObjC::RewriteObjCDict // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast); - const FunctionType *FT = msgSendType->getAs(); + const FunctionType *FT = msgSendType->castAs(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc); ReplaceStmt(Exp, CE); @@ -3309,7 +3309,7 @@ Stmt *RewriteModernObjC::SynthMessageExp case ObjCMessageExpr::Class: { SmallVector ClsExprs; ObjCInterfaceDecl *Class - = Exp->getClassReceiver()->getAs()->getInterface(); + = Exp->getClassReceiver()->castAs()->getInterface(); IdentifierInfo *clsName = Class->getIdentifier(); ClsExprs.push_back(getStringLiteral(clsName->getName())); CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl, ClsExprs, @@ -3530,7 +3530,7 @@ Stmt *RewriteModernObjC::SynthMessageExp // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast); - const FunctionType *FT = msgSendType->getAs(); + const FunctionType *FT = msgSendType->castAs(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc); Stmt *ReplacingStmt = CE; @@ -3660,7 +3660,7 @@ bool RewriteModernObjC::RewriteObjCField } } else if (Type->isEnumeralType()) { -EnumDecl *ED = Type->getAs()->getDecl(); +EnumDecl *ED = Type->castAs()->getDecl(); if (ED->isCompleteDefinition()) { Result += "\n\tenum "; Result += ED->getName(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r373904 - AST - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Mon Oct 7 06:58:05 2019 New Revision: 373904 URL: http://llvm.org/viewvc/llvm-project?rev=373904=rev Log: AST - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/AST/ExprCXX.cpp cfe/trunk/lib/AST/Interp/Program.cpp cfe/trunk/lib/AST/Mangle.cpp cfe/trunk/lib/AST/StmtPrinter.cpp cfe/trunk/lib/AST/TemplateBase.cpp cfe/trunk/lib/AST/TypePrinter.cpp Modified: cfe/trunk/lib/AST/ExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=373904=373903=373904=diff == --- cfe/trunk/lib/AST/ExprCXX.cpp (original) +++ cfe/trunk/lib/AST/ExprCXX.cpp Mon Oct 7 06:58:05 2019 @@ -251,7 +251,7 @@ QualType CXXDeleteExpr::getDestroyedType if (ArgType->isDependentType() && !ArgType->isPointerType()) return QualType(); - return ArgType->getAs()->getPointeeType(); + return ArgType->castAs()->getPointeeType(); } // CXXPseudoDestructorExpr @@ -1512,11 +1512,8 @@ CXXRecordDecl *UnresolvedMemberExpr::get // Otherwise the naming class must have been the base class. else { QualType BaseType = getBaseType().getNonReferenceType(); -if (isArrow()) { - const auto *PT = BaseType->getAs(); - assert(PT && "base of arrow member access is not pointer"); - BaseType = PT->getPointeeType(); -} +if (isArrow()) + BaseType = BaseType->castAs()->getPointeeType(); Record = BaseType->getAsCXXRecordDecl(); assert(Record && "base of member expression does not name record"); Modified: cfe/trunk/lib/AST/Interp/Program.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Interp/Program.cpp?rev=373904=373903=373904=diff == --- cfe/trunk/lib/AST/Interp/Program.cpp (original) +++ cfe/trunk/lib/AST/Interp/Program.cpp Mon Oct 7 06:58:05 2019 @@ -123,7 +123,7 @@ llvm::Optional Program::getOrC auto = Ctx.getASTContext(); // Create a pointer to an incomplete array of the specified elements. - QualType ElemTy = PD->getType()->getAs()->getPointeeType(); + QualType ElemTy = PD->getType()->castAs()->getPointeeType(); QualType Ty = ASTCtx.getIncompleteArrayType(ElemTy, ArrayType::Normal, 0); // Dedup blocks since they are immutable and pointers cannot be compared. Modified: cfe/trunk/lib/AST/Mangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Mangle.cpp?rev=373904=373903=373904=diff == --- cfe/trunk/lib/AST/Mangle.cpp (original) +++ cfe/trunk/lib/AST/Mangle.cpp Mon Oct 7 06:58:05 2019 @@ -386,7 +386,7 @@ public: auto hasDefaultCXXMethodCC = [](ASTContext , const CXXMethodDecl *MD) { auto DefaultCC = C.getDefaultCallingConvention(/*IsVariadic=*/false, /*IsCXXMethod=*/true); - auto CC = MD->getType()->getAs()->getCallConv(); + auto CC = MD->getType()->castAs()->getCallConv(); return CC == DefaultCC; }; Modified: cfe/trunk/lib/AST/StmtPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=373904=373903=373904=diff == --- cfe/trunk/lib/AST/StmtPrinter.cpp (original) +++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Oct 7 06:58:05 2019 @@ -1102,7 +1102,7 @@ void StmtPrinter::VisitIntegerLiteral(In OS << Node->getValue().toString(10, isSigned); // Emit suffixes. Integer literals are always a builtin integer type. - switch (Node->getType()->getAs()->getKind()) { + switch (Node->getType()->castAs()->getKind()) { default: llvm_unreachable("Unexpected type for integer literal!"); case BuiltinType::Char_S: case BuiltinType::Char_U:OS << "i8"; break; @@ -1123,7 +1123,7 @@ void StmtPrinter::VisitFixedPointLiteral return; OS << Node->getValueAsString(/*Radix=*/10); - switch (Node->getType()->getAs()->getKind()) { + switch (Node->getType()->castAs()->getKind()) { default: llvm_unreachable("Unexpected type for fixed point literal!"); case BuiltinType::ShortFract: OS << "hr"; break; case BuiltinType::ShortAccum: OS << "hk"; break; @@ -1152,7 +1152,7 @@ static void PrintFloatingLiteral(raw_ost return; // Emit suffixes. Float literals are always a builtin float type. - switch (Node->getType()->getAs()->getKind()) { + switch (Node->getType()->castAs()->getKind()) { default: llvm_unreachable("Unexpected type for float literal!"); case BuiltinType::Half: break; // FIXME: suffix? case BuiltinType::Double: break; // no suffix. @@ -1952,7 +1952,7 @@ void StmtPrinter::VisitLambdaExpr(Lambda
r373831 - Try to fix sphinx indentation error
Author: rksimon Date: Sat Oct 5 09:08:17 2019 New Revision: 373831 URL: http://llvm.org/viewvc/llvm-project?rev=373831=rev Log: Try to fix sphinx indentation error Modified: cfe/trunk/docs/ReleaseNotes.rst Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=373831=373830=373831=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Sat Oct 5 09:08:17 2019 @@ -212,13 +212,15 @@ clang-format - The ``Standard`` style option specifies which version of C++ should be used when parsing and formatting C++ code. The set of allowed values has changed: + - ``Latest`` will always enable new C++ language features. - ``c++03``, ``c++11``, ``c++14``, ``c++17``, ``c++20`` will pin to exactly that language version. - ``Auto`` is the default and detects style from the code (this is unchanged). - The previous values of ``Cpp03`` and ``Cpp11`` are deprecated. Note that - ``Cpp11`` is treated as ``Latest``, as this was always clang-format's behavior. - (One motivation for this change is the new name describes the behavior better). + + The previous values of ``Cpp03`` and ``Cpp11`` are deprecated. Note that + ``Cpp11`` is treated as ``Latest``, as this was always clang-format's behavior. + (One motivation for this change is the new name describes the behavior better). libclang ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r373829 - RewriteObjC - silence static analyzer getAs<> null dereference warnings. NFCI.
Author: rksimon Date: Sat Oct 5 06:42:14 2019 New Revision: 373829 URL: http://llvm.org/viewvc/llvm-project?rev=373829=rev Log: RewriteObjC - silence static analyzer getAs<> null dereference warnings. NFCI. The static analyzer is warning about potential null dereferences, but we should be able to use castAs<> directly and if not assert will fire for us. Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp?rev=373829=373828=373829=diff == --- cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp (original) +++ cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp Sat Oct 5 06:42:14 2019 @@ -416,7 +416,7 @@ namespace { /// otherwise. bool convertBlockPointerToFunctionPointer(QualType ) { if (isTopLevelBlockPointerType(T)) { -const BlockPointerType *BPT = T->getAs(); +const auto *BPT = T->castAs(); T = Context->getPointerType(BPT->getPointeeType()); return true; } @@ -1163,6 +1163,7 @@ void RewriteObjC::RewriteObjCMethodDecl( void RewriteObjC::RewriteImplementationDecl(Decl *OID) { ObjCImplementationDecl *IMD = dyn_cast(OID); ObjCCategoryImplDecl *CID = dyn_cast(OID); + assert((IMD || CID) && "Unknown ImplementationDecl"); InsertText(IMD ? IMD->getBeginLoc() : CID->getBeginLoc(), "// "); @@ -2017,7 +2018,7 @@ RewriteObjC::SynthesizeCallToFunctionDec ImplicitCastExpr::Create(*Context, pToFunc, CK_FunctionToPointerDecay, DRE, nullptr, VK_RValue); - const FunctionType *FT = msgSendType->getAs(); + const auto *FT = msgSendType->castAs(); CallExpr *Exp = CallExpr::Create( *Context, ICE, Args, FT->getCallResultType(*Context), VK_RValue, EndLoc); @@ -2285,7 +2286,7 @@ void RewriteObjC::RewriteBlockPointerTyp void RewriteObjC::RewriteBlockLiteralFunctionDecl(FunctionDecl *FD) { SourceLocation FunLocStart = FD->getTypeSpecStartLoc(); const FunctionType *funcType = FD->getType()->getAs(); - const FunctionProtoType *proto = dyn_cast(funcType); + const FunctionProtoType *proto = dyn_cast_or_null(funcType); if (!proto) return; QualType Type = proto->getReturnType(); @@ -2604,7 +2605,7 @@ CallExpr *RewriteObjC::SynthMsgSendStret // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast); - const FunctionType *FT = msgSendType->getAs(); + const auto *FT = msgSendType->castAs(); CallExpr *STCE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, SourceLocation()); return STCE; @@ -2735,8 +2736,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjC case ObjCMessageExpr::Class: { SmallVector ClsExprs; -ObjCInterfaceDecl *Class - = Exp->getClassReceiver()->getAs()->getInterface(); +auto *Class = +Exp->getClassReceiver()->castAs()->getInterface(); IdentifierInfo *clsName = Class->getIdentifier(); ClsExprs.push_back(getStringLiteral(clsName->getName())); CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl, ClsExprs, @@ -2957,7 +2958,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjC // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast); - const FunctionType *FT = msgSendType->getAs(); + const auto *FT = msgSendType->castAs(); CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(), VK_RValue, EndLoc); Stmt *ReplacingStmt = CE; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits