Skip to content

Commit

Permalink
Merge from 'main' to 'sycl-web' (125 commits)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in clang/lib/Driver/Driver.cpp
  • Loading branch information
mdfazlay committed Jan 3, 2025
2 parents 81af5d6 + cd19f3f commit 1a28982
Show file tree
Hide file tree
Showing 347 changed files with 9,151 additions and 3,887 deletions.
27 changes: 21 additions & 6 deletions clang-tools-extra/clangd/tool/ClangdMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ opt<std::string> FallbackStyle{
init(clang::format::DefaultFallbackStyle),
};

opt<int> EnableFunctionArgSnippets{
opt<std::string> EnableFunctionArgSnippets{
"function-arg-placeholders",
cat(Features),
desc("When disabled (0), completions contain only parentheses for "
"function calls. When enabled (1), completions also contain "
"placeholders for method parameters"),
init(-1),
init("-1"),
};

opt<CodeCompleteOptions::IncludeInsertion> HeaderInsertion{
Expand Down Expand Up @@ -636,6 +636,22 @@ loadExternalIndex(const Config::ExternalIndexSpec &External,
llvm_unreachable("Invalid ExternalIndexKind.");
}

std::optional<bool> shouldEnableFunctionArgSnippets() {
std::string Val = EnableFunctionArgSnippets;
// Accept the same values that a bool option parser would, but also accept
// -1 to indicate "unspecified", in which case the ArgumentListsPolicy
// config option will be respected.
if (Val == "1" || Val == "true" || Val == "True" || Val == "TRUE")
return true;
if (Val == "0" || Val == "false" || Val == "False" || Val == "FALSE")
return false;
if (Val != "-1")
elog("Value specified by --function-arg-placeholders is invalid. Provide a "
"boolean value or leave unspecified to use ArgumentListsPolicy from "
"config instead.");
return std::nullopt;
}

class FlagsConfigProvider : public config::Provider {
private:
config::CompiledFragment Frag;
Expand Down Expand Up @@ -696,10 +712,9 @@ class FlagsConfigProvider : public config::Provider {
BGPolicy = Config::BackgroundPolicy::Skip;
}

if (EnableFunctionArgSnippets >= 0) {
ArgumentLists = EnableFunctionArgSnippets
? Config::ArgumentListsPolicy::FullPlaceholders
: Config::ArgumentListsPolicy::Delimiters;
if (std::optional<bool> Enable = shouldEnableFunctionArgSnippets()) {
ArgumentLists = *Enable ? Config::ArgumentListsPolicy::FullPlaceholders
: Config::ArgumentListsPolicy::Delimiters;
}

Frag = [=](const config::Params &, Config &C) {
Expand Down
68 changes: 0 additions & 68 deletions clang-tools-extra/clangd/unittests/Matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,74 +127,6 @@ PolySubsequenceMatcher<Args...> HasSubsequence(Args &&... M) {
llvm::consumeError(ComputedValue.takeError()); \
} while (false)

// Implements the HasValue(m) matcher for matching an Optional whose
// value matches matcher m.
template <typename InnerMatcher> class OptionalMatcher {
public:
explicit OptionalMatcher(const InnerMatcher &matcher) : matcher_(matcher) {}
OptionalMatcher(const OptionalMatcher&) = default;
OptionalMatcher &operator=(const OptionalMatcher&) = delete;

// This type conversion operator template allows Optional(m) to be
// used as a matcher for any Optional type whose value type is
// compatible with the inner matcher.
//
// The reason we do this instead of relying on
// MakePolymorphicMatcher() is that the latter is not flexible
// enough for implementing the DescribeTo() method of Optional().
template <typename Optional> operator Matcher<Optional>() const {
return MakeMatcher(new Impl<Optional>(matcher_));
}

private:
// The monomorphic implementation that works for a particular optional type.
template <typename Optional>
class Impl : public ::testing::MatcherInterface<Optional> {
public:
using Value = typename std::remove_const<
typename std::remove_reference<Optional>::type>::type::value_type;

explicit Impl(const InnerMatcher &matcher)
: matcher_(::testing::MatcherCast<const Value &>(matcher)) {}

Impl(const Impl&) = default;
Impl &operator=(const Impl&) = delete;

virtual void DescribeTo(::std::ostream *os) const {
*os << "has a value that ";
matcher_.DescribeTo(os);
}

virtual void DescribeNegationTo(::std::ostream *os) const {
*os << "does not have a value that ";
matcher_.DescribeTo(os);
}

virtual bool
MatchAndExplain(Optional optional,
::testing::MatchResultListener *listener) const {
if (!optional)
return false;

*listener << "which has a value ";
return MatchPrintAndExplain(*optional, matcher_, listener);
}

private:
const Matcher<const Value &> matcher_;
};

const InnerMatcher matcher_;
};

// Creates a matcher that matches an Optional that has a value
// that matches inner_matcher.
template <typename InnerMatcher>
inline OptionalMatcher<InnerMatcher>
HasValue(const InnerMatcher &inner_matcher) {
return OptionalMatcher<InnerMatcher>(inner_matcher);
}

} // namespace clangd
} // namespace clang
#endif
11 changes: 6 additions & 5 deletions clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using ::testing::ElementsAre;
using ::testing::Field;
using ::testing::IsEmpty;
using ::testing::Matcher;
using ::testing::Optional;
using ::testing::SizeIs;
using ::testing::UnorderedElementsAre;

Expand All @@ -38,12 +39,12 @@ MATCHER_P(selectionRangeIs, R, "") { return arg.selectionRange == R; }
template <class... ParentMatchers>
::testing::Matcher<TypeHierarchyItem> parents(ParentMatchers... ParentsM) {
return Field(&TypeHierarchyItem::parents,
HasValue(UnorderedElementsAre(ParentsM...)));
Optional(UnorderedElementsAre(ParentsM...)));
}
template <class... ChildMatchers>
::testing::Matcher<TypeHierarchyItem> children(ChildMatchers... ChildrenM) {
return Field(&TypeHierarchyItem::children,
HasValue(UnorderedElementsAre(ChildrenM...)));
Optional(UnorderedElementsAre(ChildrenM...)));
}
// Note: "not resolved" is different from "resolved but empty"!
MATCHER(parentsNotResolved, "") { return !arg.parents; }
Expand Down Expand Up @@ -790,7 +791,7 @@ struct Child : Parent1, Parent2 {};
Children,
UnorderedElementsAre(
AllOf(withName("Child"),
withResolveParents(HasValue(UnorderedElementsAre(withResolveID(
withResolveParents(Optional(UnorderedElementsAre(withResolveID(
getSymbolID(&findDecl(AST, "Parent1")).str())))))));
}

Expand All @@ -810,9 +811,9 @@ struct Chil^d : Parent {};
ASSERT_THAT(Result, SizeIs(1));
auto Parents = superTypes(Result.front(), Index.get());

EXPECT_THAT(Parents, HasValue(UnorderedElementsAre(
EXPECT_THAT(Parents, Optional(UnorderedElementsAre(
AllOf(withName("Parent"),
withResolveParents(HasValue(IsEmpty()))))));
withResolveParents(Optional(IsEmpty()))))));
}
} // namespace
} // namespace clangd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,7 @@ temporary object into ``this`` (needs a move assignment operator):
.. option:: WarnOnlyIfThisHasSuspiciousField

When `true`, the check will warn only if the container class of the copy assignment operator
has any suspicious fields (pointer or C array). This option is set to `true` by default.
When `true`, the check will warn only if the container class of the copy
assignment operator has any suspicious fields (pointer, C array and C++ smart
pointer).
This option is set to `true` by default.
1 change: 1 addition & 0 deletions clang/docs/ClangFormat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ names. It has the following format:
* Patterns follow the rules specified in `POSIX 2.13.1, 2.13.2, and Rule 1 of
2.13.3 <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/
V3_chap02.html#tag_18_13>`_.
* Bash globstar (``**``) is supported.
* A pattern is negated if it starts with a bang (``!``).

To match all files in a directory, use e.g. ``foo/bar/*``. To match all files in
Expand Down
9 changes: 9 additions & 0 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6798,6 +6798,15 @@ the configuration (without a prefix: ``Auto``).



.. _VariableTemplates:

**VariableTemplates** (``List of Strings``) :versionbadge:`clang-format 20` :ref:`<VariableTemplates>`
A vector of non-keyword identifiers that should be interpreted as variable
template names.

A ``)`` after a variable template instantiation is **not** annotated as
the closing parenthesis of C-style cast operator.

.. _VerilogBreakBetweenInstancePorts:

**VerilogBreakBetweenInstancePorts** (``Boolean``) :versionbadge:`clang-format 17` :ref:`<VerilogBreakBetweenInstancePorts>`
Expand Down
10 changes: 10 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,7 @@ Bug Fixes to C++ Support
out of a module (which is the case e.g. in MSVC's implementation of ``std`` module). (#GH118218)
- Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042)
- Fixed a bug where captured structured bindings were modifiable inside non-mutable lambda (#GH95081)
- Fixed an issue while resolving type of expression indexing into a pack of values of non-dependent type (#GH121242)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -1124,6 +1125,8 @@ clang-format
- Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
- Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
- Adds ``AllowShortNamespacesOnASingleLine`` option.
- Adds ``VariableTemplates`` option.
- Adds support for bash globstar in ``.clang-format-ignore``.

libclang
--------
Expand Down Expand Up @@ -1154,6 +1157,13 @@ New features
Crash and bug fixes
^^^^^^^^^^^^^^^^^^^

- In loops where the loop condition is opaque (i.e. the analyzer cannot
determine whether it's true or false), the analyzer will no longer assume
execution paths that perform more that two iterations. These unjustified
assumptions caused false positive reports (e.g. 100+ out-of-bounds reports in
the FFMPEG codebase) in loops where the programmer intended only two or three
steps but the analyzer wasn't able to understand that the loop is limited.

Improvements
^^^^^^^^^^^^

Expand Down
10 changes: 6 additions & 4 deletions clang/include/clang/Basic/arm_immcheck_incl.td
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ class ImmCheckType<int val> {
int Value = val;
}

// These must be kept in sync with the flags in include/clang/Basic/TargetBuiltins.h

// For SVE, container_size refers to the width of a vector segment (128b).
// For NEON, container_size refers to the vector width (64b or 128b).
def ImmCheck0_31 : ImmCheckType<0>; // 0..31 (used for e.g. predicate patterns)
def ImmCheck1_16 : ImmCheckType<1>; // 1..16
def ImmCheckExtract : ImmCheckType<2>; // 0..(2048/sizeinbits(elt) - 1)
def ImmCheckShiftRight : ImmCheckType<3>; // 1..sizeinbits(elt)
def ImmCheckShiftRightNarrow : ImmCheckType<4>; // 1..sizeinbits(elt)/2
def ImmCheckShiftLeft : ImmCheckType<5>; // 0..(sizeinbits(elt) - 1)
def ImmCheck0_7 : ImmCheckType<6>; // 0..7
def ImmCheckLaneIndex : ImmCheckType<7>; // 0..(sizeinbits(vec)/(sizeinbits(elt)) - 1)
def ImmCheckLaneIndex : ImmCheckType<7>; // 0..(container_size/(sizeinbits(elt)) - 1)
def ImmCheckCvt : ImmCheckType<8>; // 1..sizeinbits(elt) (same as ShiftRight)
def ImmCheckLaneIndexCompRotate : ImmCheckType<9>; // 0..(sizeinbits(vec)/(2*sizeinbits(elt)) - 1)
def ImmCheckLaneIndexDot : ImmCheckType<10>; // 0..(sizeinbits(vec)/(4*sizeinbits(elt)) - 1)
def ImmCheckLaneIndexCompRotate : ImmCheckType<9>; // 0..(container_size/(2*sizeinbits(elt)) - 1)
def ImmCheckLaneIndexDot : ImmCheckType<10>; // 0..(container_size/(4*sizeinbits(elt)) - 1)
def ImmCheckComplexRot90_270 : ImmCheckType<11>; // [90,270]
def ImmCheckComplexRotAll90 : ImmCheckType<12>; // [0, 90, 180,270]
def ImmCheck0_13 : ImmCheckType<13>; // 0..13
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,8 @@ def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], "libomptarget-amdgcn-bc-path
HelpText<"Path to libomptarget-amdgcn bitcode library">, Alias<libomptarget_amdgpu_bc_path_EQ>;
def libomptarget_nvptx_bc_path_EQ : Joined<["--"], "libomptarget-nvptx-bc-path=">, Group<i_Group>,
HelpText<"Path to libomptarget-nvptx bitcode library">;
def libomptarget_spirv_bc_path_EQ : Joined<["--"], "libomptarget-spirv-bc-path=">, Group<i_Group>,
HelpText<"Path to libomptarget-spirv bitcode library">;
def dD : Flag<["-"], "dD">, Group<d_Group>, Visibility<[ClangOption, CC1Option]>,
HelpText<"Print macro definitions in -E mode in addition to normal output">;
def dI : Flag<["-"], "dI">, Group<d_Group>, Visibility<[ClangOption, CC1Option]>,
Expand Down
11 changes: 10 additions & 1 deletion clang/include/clang/Format/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -5103,6 +5103,15 @@ struct FormatStyle {
/// \version 3.7
UseTabStyle UseTab;

/// A vector of non-keyword identifiers that should be interpreted as variable
/// template names.
///
/// A ``)`` after a variable template instantiation is **not** annotated as
/// the closing parenthesis of C-style cast operator.
///
/// \version 20
std::vector<std::string> VariableTemplates;

/// For Verilog, put each port on its own line in module instantiations.
/// \code
/// true:
Expand Down Expand Up @@ -5314,7 +5323,7 @@ struct FormatStyle {
TableGenBreakInsideDAGArg == R.TableGenBreakInsideDAGArg &&
TabWidth == R.TabWidth && TemplateNames == R.TemplateNames &&
TypeNames == R.TypeNames && TypenameMacros == R.TypenameMacros &&
UseTab == R.UseTab &&
UseTab == R.UseTab && VariableTemplates == R.VariableTemplates &&
VerilogBreakBetweenInstancePorts ==
R.VerilogBreakBetweenInstancePorts &&
WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Frontend/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class DependencyFileGenerator : public DependencyCollector {
private:
void outputDependencyFile(DiagnosticsEngine &Diags);

llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
std::string OutputFile;
std::vector<std::string> DependencyFilter;
std::vector<std::string> Targets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ class CoreEngine {
ExplodedNode *generateCallExitBeginNode(ExplodedNode *N,
const ReturnStmt *RS);

/// Helper function called by `HandleBranch()`. If the currently handled
/// branch corresponds to a loop, this returns the number of already
/// completed iterations in that loop, otherwise the return value is
/// `std::nullopt`. Note that this counts _all_ earlier iterations, including
/// ones that were performed within an earlier iteration of an outer loop.
std::optional<unsigned> getCompletedIterationCount(const CFGBlock *B,
ExplodedNode *Pred) const;

public:
/// Construct a CoreEngine object to analyze the provided CFG.
CoreEngine(ExprEngine &exprengine,
Expand Down
18 changes: 10 additions & 8 deletions clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,14 @@ class ExprEngine {
NodeBuilderWithSinks &nodeBuilder,
ExplodedNode *Pred);

/// ProcessBranch - Called by CoreEngine. Used to generate successor
/// nodes by processing the 'effects' of a branch condition.
void processBranch(const Stmt *Condition,
NodeBuilderContext& BuilderCtx,
ExplodedNode *Pred,
ExplodedNodeSet &Dst,
const CFGBlock *DstT,
const CFGBlock *DstF);
/// ProcessBranch - Called by CoreEngine. Used to generate successor nodes by
/// processing the 'effects' of a branch condition. If the branch condition
/// is a loop condition, IterationsCompletedInLoop is the number of completed
/// iterations (otherwise it's std::nullopt).
void processBranch(const Stmt *Condition, NodeBuilderContext &BuilderCtx,
ExplodedNode *Pred, ExplodedNodeSet &Dst,
const CFGBlock *DstT, const CFGBlock *DstF,
std::optional<unsigned> IterationsCompletedInLoop);

/// Called by CoreEngine.
/// Used to generate successor nodes for temporary destructors depending
Expand Down Expand Up @@ -588,6 +588,8 @@ class ExprEngine {
void evalEagerlyAssumeBifurcation(ExplodedNodeSet &Dst, ExplodedNodeSet &Src,
const Expr *Ex);

bool didEagerlyAssumeBifurcateAt(ProgramStateRef State, const Expr *Ex) const;

static std::pair<const ProgramPointTag *, const ProgramPointTag *>
getEagerlyAssumeBifurcationTags();

Expand Down
Loading

0 comments on commit 1a28982

Please sign in to comment.