[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 381710.
salman-javed-nz added a comment.

Pre-merge checks failing because patch cannot be applied.
Therefore recreating patch to fix this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112356/new/

https://reviews.llvm.org/D112356

Files:
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-duration-conversion-cast.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-no-internal-dependencies.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-str-contains.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-open.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
  clang-tools-extra/docs/clang-tidy/checks/boost-use-to-string.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-branch-clone.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-implicit-widening-of-multiplication-result.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-macro-parentheses.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-sizeof-expression.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-exception-at-new.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-dcl21-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-err09-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop11-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
  clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-virtual-class-destructor.rst
  clang-tools-extra/docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst
  clang-tools-extra/docs/clang-tidy/checks/hicpp-signed-bitwise.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-static-assert.rst
  
clang-tools-extra/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-bind.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-c-arrays.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-pass-by-value.rst
  
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-default-member-init.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-noexcept.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-nullptr.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
  clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
  clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-algorithm.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-const-return-type.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-length.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-magic-numbers.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-redundant-declaration.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-string-compare.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -91,7 +91,7 @@
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
 diagnostics are displayed by :program:`clang-tidy` and can be filtered out using
 ``-checks=`` option. However, the ``-checks=`` option does not affect
-compilation arguments, so 

[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz added a comment.

A collection of minor corrections that I don't think deserve separate commits.

It shouldn't take much congitive load to remove it all as one patch.
But I have used Phabricator's "Update Revision" feature to break out the change 
into smaller chunks anyway.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112356/new/

https://reviews.llvm.org/D112356

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 381707.
salman-javed-nz added a comment.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Fix spelling and grammatical mistakes found across the .rst files.

// end of patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112356/new/

https://reviews.llvm.org/D112356

Files:
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-branch-clone.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-implicit-widening-of-multiplication-result.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-sizeof-expression.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-exception-at-new.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
  clang-tools-extra/docs/clang-tidy/checks/hicpp-multiway-paths-covered.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-static-assert.rst
  
clang-tools-extra/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-c-arrays.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
  
clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst
  clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-inefficient-algorithm.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-else-after-return.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-string-compare.rst
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -91,7 +91,7 @@
 Clang diagnostics are treated in a similar way as check diagnostics. Clang
 diagnostics are displayed by :program:`clang-tidy` and can be filtered out using
 ``-checks=`` option. However, the ``-checks=`` option does not affect
-compilation arguments, so it can not turn on Clang warnings which are not
+compilation arguments, so it cannot turn on Clang warnings which are not
 already turned on in build configuration. The ``-warnings-as-errors=`` option
 upgrades any warnings emitted under the ``-checks=`` flag to errors (but it
 does not enable any checks itself).
Index: clang-tools-extra/docs/clang-tidy/checks/readability-string-compare.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-string-compare.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-string-compare.rst
@@ -49,6 +49,6 @@
   if (str1.compare("foo") == 0) {
   }
 
-The above code examples shows the list of if-statements that this check will
+The above code examples show the list of if-statements that this check will
 give a warning for. All of them uses ``compare`` to check if equality or 
 inequality of two strings instead of using the correct operators.
Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
@@ -33,7 +33,7 @@
 Options
 ---
 
-The following options are describe below:
+The following options are described below:
 
  - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp`, :option:`AbstractClassHungarianPrefix`
  - :option:`AggressiveDependentMemberLookup`
Index: clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
@@ -67,8 +67,8 @@
 Nesting level
 ^
 
-While by itself the nesting level not change the function's Cognitive Complexity
-metric, it is tracked, and is used by the next, third building block.
+While by itself the nesting level does not change the function's Cognitive
+Complexity metric, it 

[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 381706.
salman-javed-nz added a comment.

Standardize to US English spelling for words such as "behavior" and 
"specialization".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112356/new/

https://reviews.llvm.org/D112356

Files:
  clang-tools-extra/docs/clang-tidy/checks/boost-use-to-string.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-macro-parentheses.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
  clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-virtual-class-destructor.rst
  clang-tools-extra/docs/clang-tidy/checks/hicpp-signed-bitwise.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-default-member-init.rst
  clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-redundant-declaration.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst

Index: clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
@@ -51,7 +51,7 @@
 
 foo(b, src);
 
-The abbreviations to recognise can be configured with the
+The abbreviations to recognize can be configured with the
 :ref:`Abbreviations` check option.
 This heuristic is case-insensitive.
 
Index: clang-tools-extra/docs/clang-tidy/checks/readability-redundant-declaration.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-redundant-declaration.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-redundant-declaration.rst
@@ -16,7 +16,7 @@
 
   extern int X;
 
-Such redundant declarations can be removed without changing program behaviour.
+Such redundant declarations can be removed without changing program behavior.
 They can for instance be unintentional left overs from previous refactorings
 when code has been moved around. Having redundant declarations could in worst
 case mean that there are typos in the code that cause bugs.
Index: clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
+++ clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
@@ -10,7 +10,7 @@
 possibly compound, with a single entry at the top and a single exit at the
 bottom. Which means, ``throw`` may not be used to 'exit' out of the
 structured block. If an exception is not caught in the same structured block
-it was thrown in, the behaviour is undefined.
+it was thrown in, the behavior is undefined.
 
 FIXME: this check does not model SEH, ``setjmp``/``longjmp``.
 
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-use-default-member-init.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-use-default-member-init.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-use-default-member-init.rst
@@ -36,7 +36,7 @@
 
 .. option:: UseAssignment
 
-   If this option is set to `true` (default is `false`), the check will initialise
+   If this option is set to `true` (default is `false`), the check will initialize
members with an assignment. For example:
 
 .. code-block:: c++
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
@@ -165,7 +165,7 @@
 
 There are certain situations where the tool may erroneously perform
 transformations that remove information and change semantics. Users of the tool
-should be aware of the behaviour and limitations of the check outlined by
+should be aware of the behavior and limitations of the check outlined by
 the cases below.
 
 Comments inside loop headers
Index: clang-tools-extra/docs/clang-tidy/checks/hicpp-signed-bitwise.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/hicpp-signed-bitwise.rst
+++ clang-tools-extra/docs/clang-tidy/checks/hicpp-signed-bitwise.rst
@@ -4,7 +4,7 @@
 
 
 Finds uses of bitwise operations on signed integer types, which may lead to 
-undefined or implementation defined behaviour.
+undefined or implementation defined 

[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 381704.
salman-javed-nz added a comment.
Herald added a reviewer: lebedev.ri.
Herald added a subscriber: lebedev.ri.

Remove repeated words, e.g. "for a a larger user input".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112356/new/

https://reviews.llvm.org/D112356

Files:
  clang-tools-extra/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-bind.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
  
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
  clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst


Index: clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
+++ clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
@@ -8,7 +8,7 @@
 
 As per the OpenMP specification, a structured block is an executable statement,
 possibly compound, with a single entry at the top and a single exit at the
-bottom. Which means, ``throw`` may not be used to to 'exit' out of the
+bottom. Which means, ``throw`` may not be used to 'exit' out of the
 structured block. If an exception is not caught in the same structured block
 it was thrown in, the behaviour is undefined.
 
Index: 
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst
@@ -7,7 +7,7 @@
 argument object lifetimes. When passing Objective-C objects as parameters
 to the ``NSInvocation`` methods ``getArgument:atIndex:`` and
 ``getReturnValue:``, the values are copied by value into the argument pointer,
-which leads to to incorrect releasing behavior if the object pointers are
+which leads to incorrect releasing behavior if the object pointers are
 not declared ``__unsafe_unretained``.
 
 For code:
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
@@ -138,7 +138,7 @@
 
Specify the function used to reverse an iterator pair, the function should 
accept a class with ``rbegin`` and ``rend`` methods and return a 
-   class with ``begin`` and ``end`` methods methods that call the ``rbegin`` 
and
+   class with ``begin`` and ``end`` methods that call the ``rbegin`` and
``rend`` methods respectively. Common examples are ``ranges::reverse_view``
and ``llvm::reverse``.
Default value is an empty string.
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-bind.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-bind.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-avoid-bind.rst
@@ -72,7 +72,7 @@
 return ignore_args(3, 3);
   }
 
-which will *not* compile, since the lambda does not contain an ``operator()`` 
that
+which will *not* compile, since the lambda does not contain an ``operator()``
 that accepts 2 arguments. With permissive parameter list, it instead generates
 
 .. code-block:: c++
Index: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/bugprone-too-small-loop-variable.rst
@@ -26,7 +26,7 @@
   }
 
 This algorithm works for small amount of objects, but will lead to freeze for a
-a larger user input.
+larger user input.
 
 .. option:: MagnitudeBitsUpperLimit
 


Index: clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
+++ clang-tools-extra/docs/clang-tidy/checks/openmp-exception-escape.rst
@@ -8,7 +8,7 @@
 
 As per the OpenMP specification, a structured block is an executable statement,
 possibly compound, with a single entry at the top and a single exit at the
-bottom. Which means, ``throw`` may not be used to to 'exit' out of the
+bottom. Which means, ``throw`` may not be used to 'exit' out of the
 structured block. If an exception is not caught in the same structured block
 it was thrown in, the behaviour is undefined.
 
Index: clang-tools-extra/docs/clang-tidy/checks/objc-nsinvocation-argument-lifetime.rst

[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 381703.
salman-javed-nz added a comment.

Standardize spelling of "e.g." and "i.e."


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112356/new/

https://reviews.llvm.org/D112356

Files:
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
  clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-nullptr.rst


Index: clang-tools-extra/docs/clang-tidy/checks/modernize-use-nullptr.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-use-nullptr.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-use-nullptr.rst
@@ -3,7 +3,7 @@
 modernize-use-nullptr
 =
 
-The check converts the usage of null pointer constants (eg. ``NULL``, ``0``)
+The check converts the usage of null pointer constants (e.g. ``NULL``, ``0``)
 to use the new C++11 ``nullptr`` keyword.
 
 Example
Index: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
@@ -3,7 +3,7 @@
 cppcoreguidelines-narrowing-conversions
 ===
 
-Checks for silent narrowing conversions, e.g: ``int i = 0; i += 0.1;``. While
+Checks for silent narrowing conversions, e.g.: ``int i = 0; i += 0.1;``. While
 the issue is obvious in this former example, it might not be so in the
 following: ``void MyClass::f(double d) { int_member_ += d; }``.
 
Index: clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
+++ clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
@@ -12,7 +12,7 @@
 concurrent programming if only a single thread is used (e.g. setenv(3)),
 however, some functions may track a state in global variables which
 would be clobbered by subsequent (non-parallel, but concurrent) calls to
-a related function. E.g. the following code suffers from unprotected
+a related function. e.g. the following code suffers from unprotected
 accesses to a global state:
 
 .. code-block:: c++
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-virtual-near-miss.rst
@@ -3,7 +3,7 @@
 bugprone-virtual-near-miss
 ==
 
-Warn if a function is a near miss (ie. the name is very similar and the 
function
+Warn if a function is a near miss (i.e. the name is very similar and the 
function
 signature is the same) to a virtual function from a base class.
 
 Example:
Index: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-string-compare.rst
@@ -14,7 +14,7 @@
 if (!strcmp(...))  // Won't warn
 if (strcmp(...) != 0)  // Won't warn
 
-Checks that compare function results (i,e, ``strcmp``) are compared to valid
+Checks that compare function results (i.e., ``strcmp``) are compared to valid
 constant. The resulting value is
 
 .. code::
Index: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
@@ -154,7 +154,7 @@
   ``a < b``.
 * The parameters are further passed to the same function to the same
   parameter of that function, of the same overload.
-  E.g. ``f(a, 1)`` and ``f(b, 2)`` to some ``f(T, int)``.
+  e.g. ``f(a, 1)`` and ``f(b, 2)`` to some ``f(T, int)``.
 
   .. note::
 


Index: clang-tools-extra/docs/clang-tidy/checks/modernize-use-nullptr.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-use-nullptr.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-use-nullptr.rst
@@ -3,7 +3,7 @@
 modernize-use-nullptr
 

[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 381702.
salman-javed-nz added a comment.
Herald added subscribers: kbarton, nemanjai.

Replace curly quote characters (‘ ’ “ ”) with standard straight ones (' ").
Replace en-dash (`–`) with standard hyphen (`-`).
In both cases, the latter is used more often in the doc files and is easier to 
type.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112356/new/

https://reviews.llvm.org/D112356

Files:
  clang-tools-extra/docs/clang-tidy/checks/abseil-no-internal-dependencies.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-pass-by-value.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-magic-numbers.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst


Index: 
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/readability-suspicious-call-argument.rst
@@ -109,10 +109,10 @@
 The default bounds are: below `50`\% dissimilar and above `66`\% similar.
 This heuristic is case-sensitive.
 
-Jaro–Winkler distance (as `JaroWinkler`)
+Jaro-Winkler distance (as `JaroWinkler`)
 
 
-The `Jaro–Winkler distance 
`_
+The `Jaro-Winkler distance 
`_
 is an edit distance like the Levenshtein distance.
 It is calculated from the amount of common characters that are sufficiently
 close to each other in position, and to-be-changed characters.
@@ -125,10 +125,10 @@
 The default bounds are: below `75`\% dissimilar and above `85`\% similar.
 This heuristic is case-insensitive.
 
-Sørensen–Dice coefficient (as `Dice`)
+Sørensen-Dice coefficient (as `Dice`)
 ^
 
-The `Sørensen–Dice coefficient 
`_
+The `Sørensen-Dice coefficient 
`_
 was originally defined to measure the similarity of two sets.
 Formally, the coefficient is calculated by dividing `2 * #(intersection)` with
 `#(set1) + #(set2)`, where `#()` is the cardinality function of sets.
Index: clang-tools-extra/docs/clang-tidy/checks/readability-magic-numbers.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-magic-numbers.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-magic-numbers.rst
@@ -9,7 +9,7 @@
 Many coding guidelines advise replacing the magic values with symbolic
 constants to improve readability. Here are a few references:
 
-   * `Rule ES.45: Avoid “magic constants”; use symbolic constants in C++ Core 
Guidelines 
`_
+   * `Rule ES.45: Avoid "magic constants"; use symbolic constants in C++ Core 
Guidelines 
`_
* `Rule 5.1.1 Use symbolic names instead of literal values in code in High 
Integrity C++ 
`_
* Item 17 in "C++ Coding Standards: 101 Rules, Guidelines and Best
  Practices" by Herb Sutter and Andrei Alexandrescu
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-pass-by-value.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-pass-by-value.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-pass-by-value.rst
@@ -124,7 +124,7 @@
 contexts; templated constructors, constructors in class templates, constructors
 of inner classes of template classes, etc., are not transformed. Delayed
 template parsing is enabled by default on Windows as a Microsoft extension:
-`Clang Compiler User’s Manual - Microsoft extensions`_.
+`Clang Compiler User's Manual - Microsoft extensions`_.
 
 Delayed template parsing can be enabled using the `-fdelayed-template-parsing`
 flag and disabled using `-fno-delayed-template-parsing`.
@@ -144,7 +144,7 @@
  +  C(std::string S) : S(std::move(S)) {}
};
 
-.. _Clang Compiler User’s Manual - Microsoft extensions: 
https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions
+.. _Clang Compiler User's Manual - Microsoft extensions: 
https://clang.llvm.org/docs/UsersManual.html#microsoft-extensions
 
 .. seealso::
 
Index: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
+++ 

[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz updated this revision to Diff 381701.
salman-javed-nz added a comment.
Herald added a subscriber: arphaman.

Change double spaces after commas and periods to single space.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112356/new/

https://reviews.llvm.org/D112356

Files:
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-duration-conversion-cast.rst
  clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-str-contains.rst
  clang-tools-extra/docs/clang-tidy/checks/android-cloexec-open.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-operator-in-strlen-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-auto.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-noexcept.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-const-return-type.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-length.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -281,10 +281,10 @@
 =
 
 :program:`clang-tidy` diagnostics are intended to call out code that does not
-adhere to a coding standard, or is otherwise problematic in some way.  However,
+adhere to a coding standard, or is otherwise problematic in some way. However,
 if the code is known to be correct, it may be useful to silence the warning.
 Some clang-tidy checks provide a check-specific way to silence the diagnostics,
-e.g.  `bugprone-use-after-move `_ can be
+e.g. `bugprone-use-after-move `_ can be
 silenced by re-initializing the variable after it has been moved out,
 `bugprone-string-integer-assignment
 `_ can be suppressed by
Index: clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
@@ -65,7 +65,7 @@
auto *Foo2 = cast(Bar2);
auto  = cast(Bar3);
 
-If AddConstToQualified is set to `false`,  it will be transformed into:
+If AddConstToQualified is set to `false`, it will be transformed into:
 
 .. code-block:: c++
 
Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-length.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-length.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-length.rst
@@ -109,7 +109,7 @@
 .. option:: IgnoredExceptionVariableNames
 
 Specifies a regular expression for exception variable names that are to
-be ignored.  The default value is `^[e]$` mainly for historical reasons.
+be ignored. The default value is `^[e]$` mainly for historical reasons.
 
 .. code-block:: c++
 
Index: clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-data-pointer.rst
@@ -4,8 +4,8 @@
 
 
 Finds cases where code could use ``data()`` rather than the address of the
-element at index 0 in a container.  This pattern is commonly used to materialize
-a pointer to the backing data of a container.  ``std::vector`` and
+element at index 0 in a container. This pattern is commonly used to materialize
+a pointer to the backing data of a container. ``std::vector`` and
 ``std::string`` provide a ``data()`` accessor to retrieve the data pointer which
 should be preferred.
 
Index: clang-tools-extra/docs/clang-tidy/checks/readability-const-return-type.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-const-return-type.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-const-return-type.rst
@@ -5,7 +5,7 @@
 
 Checks for functions with a ``const``-qualified return type and recommends
 removal of the ``const`` keyword. Such use of `const` is usually superfluous,
-and can prevent valuable compiler optimizations.  Does not (yet) fix trailing
+and can prevent valuable compiler optimizations. Does not (yet) fix trailing
 return types.
 
 Examples:
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-use-noexcept.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-use-noexcept.rst
+++ 

[PATCH] D112356: [NFC] Tidy up spelling, grammar, and inconsistencies in clang-tidy documentation

2021-10-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz created this revision.
salman-javed-nz added reviewers: aaron.ballman, whisperity, kazu.
salman-javed-nz added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, rnkovacs.
salman-javed-nz requested review of this revision.

- Fix spelling and grammatical mistakes found across the .rst files.

- Standardize to US English spelling for words such as "behavior" and 
"specialization".

- Remove repeated words, e.g. "for a a larger user input".

- Standardize spelling of "e.g." and "i.e."

- Replace curly quote characters (‘ ’ “ ”) with standard straight ones (' "). 
Replace en-dash (`–`) with standard hyphen (`-`). In both cases, the latter is 
used more often in the doc files and is easier to type.

- Change double spaces after commas and periods to single space.

- Ensure there is a empty line at the end of each .rst file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112356

Files:
  clang-tools-extra/docs/clang-tidy/checks/cert-dcl21-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-err09-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop11-cpp.rst


Index: clang-tools-extra/docs/clang-tidy/checks/cert-oop11-cpp.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cert-oop11-cpp.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cert-oop11-cpp.rst
@@ -13,4 +13,4 @@
 OOP11-CPP. Do not copy-initialize members or base classes from a move
 constructor. However, all of the CERT recommendations have been removed from
 public view, and so their justification for the behavior of this check requires
-an account on their wiki to view.
\ No newline at end of file
+an account on their wiki to view.
Index: clang-tools-extra/docs/clang-tidy/checks/cert-err09-cpp.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cert-err09-cpp.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cert-err09-cpp.rst
@@ -12,4 +12,4 @@
 This check corresponds to the CERT C++ Coding Standard recommendation
 ERR09-CPP. Throw anonymous temporaries. However, all of the CERT 
recommendations
 have been removed from public view, and so their justification for the behavior
-of this check requires an account on their wiki to view.
\ No newline at end of file
+of this check requires an account on their wiki to view.
Index: clang-tools-extra/docs/clang-tidy/checks/cert-dcl21-cpp.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cert-dcl21-cpp.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cert-dcl21-cpp.rst
@@ -21,4 +21,4 @@
 DCL21-CPP. Overloaded postfix increment and decrement operators should return a
 const object. However, all of the CERT recommendations have been removed from
 public view, and so their justification for the behavior of this check requires
-an account on their wiki to view.
\ No newline at end of file
+an account on their wiki to view.


Index: clang-tools-extra/docs/clang-tidy/checks/cert-oop11-cpp.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cert-oop11-cpp.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cert-oop11-cpp.rst
@@ -13,4 +13,4 @@
 OOP11-CPP. Do not copy-initialize members or base classes from a move
 constructor. However, all of the CERT recommendations have been removed from
 public view, and so their justification for the behavior of this check requires
-an account on their wiki to view.
\ No newline at end of file
+an account on their wiki to view.
Index: clang-tools-extra/docs/clang-tidy/checks/cert-err09-cpp.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cert-err09-cpp.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cert-err09-cpp.rst
@@ -12,4 +12,4 @@
 This check corresponds to the CERT C++ Coding Standard recommendation
 ERR09-CPP. Throw anonymous temporaries. However, all of the CERT recommendations
 have been removed from public view, and so their justification for the behavior
-of this check requires an account on their wiki to view.
\ No newline at end of file
+of this check requires an account on their wiki to view.
Index: clang-tools-extra/docs/clang-tidy/checks/cert-dcl21-cpp.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/cert-dcl21-cpp.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cert-dcl21-cpp.rst
@@ -21,4 +21,4 @@
 DCL21-CPP. Overloaded postfix increment and decrement operators should return a
 const object. However, all of the CERT recommendations have been removed from
 public view, and so their justification for the behavior of this check requires
-an account on their wiki to view.
\ No newline at end of file
+an account on their wiki to view.
___
cfe-commits mailing list

[PATCH] D109977: LLVM Driver Multicall tool

2021-10-22 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

@beanz Is this ready to land or do you plan on making any more changes?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109977/new/

https://reviews.llvm.org/D109977

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112353: [bazel] fixes for windows build

2021-10-22 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added a reviewer: GMNGeoffrey.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Giving Bazel a try on Win10 by following the README. It needs these fixes
to build through. Think that I should sent it out in case it is useful.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112353

Files:
  clang/unittests/libclang/TestUtils.h
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/config.bzl
  utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h

Index: utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
===
--- utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
+++ utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
@@ -174,7 +174,7 @@
 #define HAVE_PTHREAD_GETSPECIFIC 1
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_PTHREAD_H 1
+/* HAVE_PTHREAD_H defined in Bazel */
 
 /* Have pthread_mutex_lock */
 #define HAVE_PTHREAD_MUTEX_LOCK 1
@@ -186,7 +186,7 @@
 /* HAVE_SBRK defined in Bazel */
 
 /* Define to 1 if you have the `setenv' function. */
-#define HAVE_SETENV 1
+/* HAVE_SETENV defined in Bazel */
 
 /* Define to 1 if you have the `setrlimit' function. */
 #define HAVE_SETRLIMIT 1
@@ -216,7 +216,7 @@
 #define HAVE_SYS_PARAM_H 1
 
 /* Define to 1 if you have the  header file. */
-#define HAVE_SYS_RESOURCE_H 1
+/* HAVE_SYS_RESOURCE_H defined in Bazel */
 
 /* Define to 1 if you have the  header file. */
 #define HAVE_SYS_STAT_H 1
Index: utils/bazel/llvm-project-overlay/llvm/config.bzl
===
--- utils/bazel/llvm-project-overlay/llvm/config.bzl
+++ utils/bazel/llvm-project-overlay/llvm/config.bzl
@@ -27,6 +27,10 @@
 "LLVM_ENABLE_THREADS=1",
 "HAVE_SYSEXITS_H=1",
 "HAVE_UNISTD_H=1",
+"HAVE_PTHREAD_H=1",
+"HAVE_SYS_RESOURCE_H=1",
+"CLANG_HAVE_RLIMITS=1",
+"HAVE_SETENV=1",
 "HAVE_STRERROR_R=1",
 "HAVE_LIBPTHREAD=1",
 "HAVE_PTHREAD_GETNAME_NP=1",
@@ -56,8 +60,9 @@
 
 win32_defines = [
 # MSVC specific
-"stricmp=_stricmp",
-"strdup=_strdup",
+#"stricmp=_stricmp",
+#"strdup=_strdup",
+"CINDEX_NO_EXPORTS",
 
 # LLVM features
 r'LTDL_SHLIB_EXT=\".dll\"',
Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -3096,7 +3096,9 @@
 name = "llvm-mca",
 srcs = glob([
 "tools/llvm-mca/*.cpp",
+"tools/llvm-mca/*.h",
 "tools/llvm-mca/Views/*.cpp",
+"tools/llvm-mca/Views/*.h",
 ]),
 copts = llvm_copts,
 stamp = 0,
Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -75,7 +75,7 @@
 /* #undef CLANG_HAVE_LIBXML */
 
 /* Define if we have sys/resource.h (rlimits) */
-#define CLANG_HAVE_RLIMITS 1
+/* #undef CLANG_HAVE_RLIMITS */
 
 /* The LLVM product name and version */
 #define BACKEND_PACKAGE_STRING "LLVM 12.0.0git"
Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -1332,6 +1332,10 @@
 "//llvm:Target",
 "//llvm:config",
 ],
+linkopts = select({
+"@bazel_tools//src/conditions:windows": ["/DEFAULTLIB:version.lib"],
+"//conditions:default": [],
+}),
 )
 
 gentbl(
@@ -1796,9 +1800,10 @@
 "tools/c-index-test/c-index-test.c",
 "tools/c-index-test/core_main.cpp",
 ],
-copts = [
-"-Wno-uninitialized",
-],
+copts = select({
+"@bazel_tools//src/conditions:windows": [],
+"//conditions:default": ["-Wno-uninitialized"],
+}),
 stamp = 0,
 deps = [
 ":ast",
Index: clang/unittests/libclang/TestUtils.h
===
--- clang/unittests/libclang/TestUtils.h
+++ clang/unittests/libclang/TestUtils.h
@@ -71,7 +71,7 @@
 UnsavedFiles.push_back({
 it.first->first->c_str(),   // filename
 it.first->second->c_str(),  // contents
-it.first->second->size()// length
+static_cast(it.first->second->size())// length
 });
   }
   template
@@ -91,4 +91,4 @@
   }
 };
 
-#endif // LLVM_CLANG_TEST_TESTUTILS_H
\ No newline at end of file
+#endif // 

[PATCH] D109632: [clang] de-duplicate methods from AST files

2021-10-22 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

We are targeting the use case where in impl.m we have

  @import ImmediateDep1;
  @import ImmediateDep2;
  ...
  @import ImmediateDepN;

and each of ImmediateDep has `@import SharedDep;`.

For simplicity we'll consider that we are working with a single selector as 
each of them is processed separately and independently. When clang encounters a 
selector, it wants to collect methods corresponding to this selector from all 
modules to a GlobalMethodPool. As in GlobalMethodPool  we store methods in a 
list, adding a new method requires traversing this list. It is possible to 
change the list to something else but this change isn't about that, in `O(L*X)` 
complexity we are reducing `X` (which can be ~10) and not `L` (which is 
closer to ~1000).

In the baseline METHOD_POOL for each "ImmediateDep" contains methods from 
"SharedDep". When we add methods to the GlobalMethodPool, we try to add methods 
from all "ImmediateDep". As the result we iterate through GlobalMethodPool 
method list multiple time for each method from "SharedDep" as they are 
available in each "ImmediateDep".

Richard's idea is to put a DenseSet of encountered methods in front of 
GlobalMethodPool method list. This way duplicates from "SharedDep" can be 
detected and discarded quickly so we traverse a list only for each unique 
method and not for duplicates.

My idea is not to store any duplicates in METHOD_POOL. This is achieved by each 
module storing only their own methods and not storing any [transitively] 
imported methods. In turn, populating GlobalMethodPool requires traversing the 
full dependency graph once and loading methods from METHOD_POOL in 
corresponding modules compared to traversing only immediate dependencies as in 
the baseline.

I believe MultiOnDiskHashTable isn't really applicable to this performance 
issue. Even if we use it to store methods, it doesn't affect the amount of 
methods we process. And right now processing all the duplicates is the 
expensive part.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109632/new/

https://reviews.llvm.org/D109632

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

Good point.  I did not find that.  At this point, I don't know if we need this 
change.  I checked gnu, gnu allow this :-(


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112334: [clang-tidy] Suppress readability-static-access-through-instance for CUDA built-in variables

2021-10-22 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 381644.
carlosgalvezp added a comment.

Replace search with StringRef::contains.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112334/new/

https://reviews.llvm.org/D112334

Files:
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
@@ -248,3 +248,38 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
   // CHECK-FIXES: {{^}}  Outer::S::I;{{$}}
 }
+
+namespace Bugzilla_48758 {
+
+// From __clang_cuda_builtin_vars.h
+struct __cuda_builtin_threadIdx_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_blockIdx_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_blockDim_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_gridDim_t {
+  static unsigned int x;
+};
+
+__cuda_builtin_threadIdx_t threadIdx;
+__cuda_builtin_blockIdx_t blockIdx;
+__cuda_builtin_blockDim_t blockDim;
+__cuda_builtin_gridDim_t gridDim;
+
+unsigned int x1 = threadIdx.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x2 = blockIdx.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x3 = blockDim.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x4 = gridDim.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+
+} // namespace Bugzilla_48758
Index: 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
@@ -9,6 +9,7 @@
 #include "StaticAccessedThroughInstanceCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/StringRef.h"
 
 using namespace clang::ast_matchers;
 
@@ -54,7 +55,7 @@
 
   const Expr *BaseExpr = MemberExpression->getBase();
 
-  // Do not warn for overlaoded -> operators.
+  // Do not warn for overloaded -> operators.
   if (isa(BaseExpr))
 return;
 
@@ -70,6 +71,10 @@
   std::string BaseTypeName =
   BaseType.getAsString(PrintingPolicyWithSupressedTag);
 
+  // Do not warn for CUDA built-in variables.
+  if (StringRef(BaseTypeName).contains("__cuda_builtin_"))
+return;
+
   SourceLocation MemberExprStartLoc = MemberExpression->getBeginLoc();
   auto Diag =
   diag(MemberExprStartLoc, "static member accessed through instance");


Index: clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
@@ -248,3 +248,38 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
   // CHECK-FIXES: {{^}}  Outer::S::I;{{$}}
 }
+
+namespace Bugzilla_48758 {
+
+// From __clang_cuda_builtin_vars.h
+struct __cuda_builtin_threadIdx_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_blockIdx_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_blockDim_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_gridDim_t {
+  static unsigned int x;
+};
+
+__cuda_builtin_threadIdx_t threadIdx;
+__cuda_builtin_blockIdx_t blockIdx;
+__cuda_builtin_blockDim_t blockDim;
+__cuda_builtin_gridDim_t gridDim;
+
+unsigned int x1 = threadIdx.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x2 = blockIdx.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x3 = blockDim.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x4 = gridDim.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+
+} // namespace Bugzilla_48758
Index: clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
@@ -9,6 +9,7 @@
 #include "StaticAccessedThroughInstanceCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/StringRef.h"
 
 using namespace clang::ast_matchers;
 
@@ -54,7 +55,7 @@
 
   const Expr *BaseExpr = MemberExpression->getBase();
 
-  // Do not warn 

[PATCH] D111639: [Sema] check PseudoObject when rebuilding CXXOperatorCallExpr in template instantiation

2021-10-22 Thread Bruno De Fraine via Phabricator via cfe-commits
brunodf updated this revision to Diff 381639.
brunodf marked 3 inline comments as done.
brunodf added a comment.

I'm adding a new patch to (partially) address the comments from @rnk.

An ObjC test case was included in the commit from @akyrtzi, I've updated it to 
also cover the case of a unary operator (and the increment/decrement), and the 
case of a type dependent on a template parameter. I moved my changes to the 
original position of the code for ObjC properties in RebuildCXXOperatorCallExpr.

With regard to OO_Subscript, OO_Arrow and OO_Amp, I have tried a number of 
things, but I have not succeeded in triggering that an CXXOperatorCallExpr is 
created for these operators (they end up as an ArraySubscriptExpr, 
CXXDependentScopeMemberExpr and UnaryOperator respectively). At the moment, I 
don't know how to test the code paths for these operators in 
RebuildCXXOperatorCallExpr.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111639/new/

https://reviews.llvm.org/D111639

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/PR51855.cpp
  clang/test/SemaObjCXX/instantiate-property-access.mm

Index: clang/test/SemaObjCXX/instantiate-property-access.mm
===
--- clang/test/SemaObjCXX/instantiate-property-access.mm
+++ clang/test/SemaObjCXX/instantiate-property-access.mm
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -DDEPENDENT -verify %s
 // expected-no-diagnostics
 
 class C {};
@@ -9,6 +10,10 @@
 
 C operator += (C c1, C c2);
 
+C operator++(C c1);
+
+bool operator!(C c1);
+
 enum TextureType { TextureType3D  };
 
 @interface Texture
@@ -16,9 +21,13 @@
 @property  C c;
 @end
 
-template  class Framebuffer {
+template  class Framebuffer {
 public:
-  Texture **color_attachment;  
+#ifdef DEPENDENT
+  T **color_attachment;
+#else
+  Texture **color_attachment;
+#endif
   Framebuffer();
 };
 
@@ -28,8 +37,15 @@
   (void)(color_attachment[0].c == color_attachment[0].c);
   (void)(color_attachment[0].c == 1);
   (void)(1 == color_attachment[0].c);
+  (void)(!color_attachment[0].textureType);
+  ++color_attachment[0].textureType;
+  (void)(!color_attachment[0].c);
 }
 
 void foo() {
+#ifdef DEPENDENT
+  Framebuffer();
+#else
   Framebuffer();
+#endif
 }
Index: clang/test/SemaCXX/PR51855.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR51855.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -S -triple %itanium_abi_triple -fms-extensions -emit-llvm %s -o - | FileCheck %s
+
+struct F {};
+
+F operator*=(F , int rhs);
+
+F operator++(F );
+
+struct S {
+  short _m;
+  S(short _m) : _m(_m) {}
+
+  void putM(short rhs) { _m = rhs; }
+  short getM() { return _m; }
+
+  __declspec(property(get = getM, put = putM)) short theData;
+};
+
+int test1a(int i) {
+  S tmp(i);
+  tmp.theData *= 2;
+  return tmp.theData;
+}
+
+// CHECK-LABEL: define {{.*}} @_Z6test1ai(
+// CHECK: call {{.*}} @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+
+template 
+int test1b(int i) {
+  T tmp(i);
+  tmp.theData *= 2;
+  return tmp.theData;
+}
+
+template int test1b(int);
+
+// CHECK-LABEL: define {{.*}} @_Z6test1bI1SEii(
+// CHECK: call {{.*}} @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+
+int test2a(int i) {
+  S tmp(i);
+  ++tmp.theData;
+  return tmp.theData;
+}
+
+// CHECK-LABEL: define {{.*}} i32 @_Z6test2ai(
+// CHECK: call {{.*}} @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+
+template 
+int test2b(int i) {
+  T tmp(i);
+  ++tmp.theData;
+  return tmp.theData;
+}
+
+template int test2b(int);
+
+// CHECK-LABEL: define {{.*}} i32 @_Z6test2bI1SEii(
+// CHECK: call void @_ZN1SC1Es(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
+// CHECK: call {{.*}} @_ZN1S4putMEs(
+// CHECK: call {{.*}} @_ZN1S4getMEv(
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -14569,18 +14569,28 @@
   Expr *Callee = OrigCallee->IgnoreParenCasts();
   bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
 
-  if (First->getObjectKind() == OK_ObjCProperty) {
-BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
-if (BinaryOperator::isAssignmentOp(Opc))
-  return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc, Opc,
- First, Second);
+  if (const BuiltinType *pty = First->getType()->getAsPlaceholderType()) {
+if (Second && !isPostIncDec) {
+  BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
+  if (pty->getKind() == BuiltinType::PseudoObject &&
+  

[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Deepak Eachempati via Phabricator via cfe-commits
dreachem added a comment.

There still exists a restriction that the loop variable must not be 
threadprivate in OpenMP 5.1. See Canonical Loop Nest restrictions, p125, line 7:

> The loop iteration variable may not appear in a threadprivate directive.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112102: [RISCV] Reduce the number of RISCV vector builtins by an order of magnitude.

2021-10-22 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Looks good to me too. Thanks a lot @craig.topper !


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112102/new/

https://reviews.llvm.org/D112102

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112280: Support: Use Expected::moveInto() in a few places

2021-10-22 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2410fb4616b2: Support: Use ExpectedT::moveInto() in 
a few places (authored by dexonsmith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112280/new/

https://reviews.llvm.org/D112280

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
  llvm/lib/Object/ObjectFile.cpp
  llvm/lib/XRay/InstrumentationMap.cpp

Index: llvm/lib/XRay/InstrumentationMap.cpp
===
--- llvm/lib/XRay/InstrumentationMap.cpp
+++ llvm/lib/XRay/InstrumentationMap.cpp
@@ -86,10 +86,8 @@
 "Failed to find XRay instrumentation map.",
 std::make_error_code(std::errc::executable_format_error));
 
-  if (Expected E = I->getContents())
-Contents = *E;
-  else
-return E.takeError();
+  if (Error E = I->getContents().moveInto(Contents))
+return E;
 
   RelocMap Relocs;
   if (ObjFile.getBinary()->isELF()) {
Index: llvm/lib/Object/ObjectFile.cpp
===
--- llvm/lib/Object/ObjectFile.cpp
+++ llvm/lib/Object/ObjectFile.cpp
@@ -55,14 +55,15 @@
 }
 
 Expected ObjectFile::getSymbolValue(DataRefImpl Ref) const {
-  if (Expected FlagsOrErr = getSymbolFlags(Ref)) {
-if (*FlagsOrErr & SymbolRef::SF_Undefined)
-  return 0;
-if (*FlagsOrErr & SymbolRef::SF_Common)
-  return getCommonSymbolSize(Ref);
-  } else
+  uint32_t Flags;
+  if (Error E = getSymbolFlags(Ref).moveInto(Flags))
 // TODO: Test this error.
-return FlagsOrErr.takeError();
+return std::move(E);
+
+  if (Flags & SymbolRef::SF_Undefined)
+return 0;
+  if (Flags & SymbolRef::SF_Common)
+return getCommonSymbolSize(Ref);
   return getSymbolValueImpl(Ref);
 }
 
Index: llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
===
--- llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -280,10 +280,7 @@
 return false;
   for (const SectionRef  : Obj->sections()) {
 StringRef Name;
-if (Expected NameOrErr = Section.getName())
-  Name = *NameOrErr;
-else
-  consumeError(NameOrErr.takeError());
+consumeError(Section.getName().moveInto(Name));
 
 Name = Name.substr(Name.find_first_not_of("._"));
 if (Name == "gnu_debuglink") {
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -179,10 +179,8 @@
 
   while (true) {
 BitstreamEntry Entry;
-if (Expected Res = Stream.advance())
-  Entry = Res.get();
-else
-  return Res.takeError();
+if (Error E = Stream.advance().moveInto(Entry))
+  return std::move(E);
 
 switch (Entry.Kind) {
 default:
@@ -226,10 +224,8 @@
   return "";
 
 BitstreamEntry Entry;
-if (Expected Res = Stream.advance())
-  Entry = std::move(Res.get());
-else
-  return Res.takeError();
+if (Error E = Stream.advance().moveInto(Entry))
+  return std::move(E);
 
 switch (Entry.Kind) {
 case BitstreamEntry::EndBlock:
@@ -305,10 +301,8 @@
   // need to understand them all.
   while (true) {
 BitstreamEntry Entry;
-if (Expected Res = Stream.advance())
-  Entry = std::move(Res.get());
-else
-  return Res.takeError();
+if (Error E = Stream.advance().moveInto(Entry))
+  return std::move(E);
 
 switch (Entry.Kind) {
 case BitstreamEntry::Error:
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1657,16 +1657,17 @@
 // If we are performing a ThinLTO importing compile, load the function index
 // into memory and pass it into runThinLTOBackend, which will run the
 // function importer and invoke LTO passes.
-Expected> IndexOrErr =
-llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile,
-   /*IgnoreEmptyThinLTOIndexFile*/true);
-if (!IndexOrErr) {
-  logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
+std::unique_ptr CombinedIndex;
+if (Error E = llvm::getModuleSummaryIndexForFile(
+  CGOpts.ThinLTOIndexFile,
+  /*IgnoreEmptyThinLTOIndexFile*/ true)
+  .moveInto(CombinedIndex)) {
+  logAllUnhandledErrors(std::move(E), errs(),
 "Error loading index file '" +
 CGOpts.ThinLTOIndexFile + "': ");
   return;
 }
-std::unique_ptr CombinedIndex = std::move(*IndexOrErr);
+
 // A null CombinedIndex means we should 

[clang] 2410fb4 - Support: Use Expected::moveInto() in a few places

2021-10-22 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2021-10-22T12:40:10-07:00
New Revision: 2410fb4616b2c08bbaddd44e6c11da8285fbd1d3

URL: 
https://github.com/llvm/llvm-project/commit/2410fb4616b2c08bbaddd44e6c11da8285fbd1d3
DIFF: 
https://github.com/llvm/llvm-project/commit/2410fb4616b2c08bbaddd44e6c11da8285fbd1d3.diff

LOG: Support: Use Expected::moveInto() in a few places

These are some usage examples for `Expected::moveInto()`.

Differential Revision: https://reviews.llvm.org/D112280

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/lib/Object/ObjectFile.cpp
llvm/lib/XRay/InstrumentationMap.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index ff76ef1d9dd8..30f81b8ae473 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1657,16 +1657,17 @@ void clang::EmitBackendOutput(DiagnosticsEngine ,
 // If we are performing a ThinLTO importing compile, load the function 
index
 // into memory and pass it into runThinLTOBackend, which will run the
 // function importer and invoke LTO passes.
-Expected> IndexOrErr =
-llvm::getModuleSummaryIndexForFile(CGOpts.ThinLTOIndexFile,
-   
/*IgnoreEmptyThinLTOIndexFile*/true);
-if (!IndexOrErr) {
-  logAllUnhandledErrors(IndexOrErr.takeError(), errs(),
+std::unique_ptr CombinedIndex;
+if (Error E = llvm::getModuleSummaryIndexForFile(
+  CGOpts.ThinLTOIndexFile,
+  /*IgnoreEmptyThinLTOIndexFile*/ true)
+  .moveInto(CombinedIndex)) {
+  logAllUnhandledErrors(std::move(E), errs(),
 "Error loading index file '" +
 CGOpts.ThinLTOIndexFile + "': ");
   return;
 }
-std::unique_ptr CombinedIndex = std::move(*IndexOrErr);
+
 // A null CombinedIndex means we should skip ThinLTO compilation
 // (LLVM will optionally ignore empty index files, returning null instead
 // of an error).

diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp 
b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 349d40e1a63c..301145939904 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -179,10 +179,8 @@ static Expected 
readIdentificationBlock(BitstreamCursor ) {
 
   while (true) {
 BitstreamEntry Entry;
-if (Expected Res = Stream.advance())
-  Entry = Res.get();
-else
-  return Res.takeError();
+if (Error E = Stream.advance().moveInto(Entry))
+  return std::move(E);
 
 switch (Entry.Kind) {
 default:
@@ -226,10 +224,8 @@ static Expected 
readIdentificationCode(BitstreamCursor ) {
   return "";
 
 BitstreamEntry Entry;
-if (Expected Res = Stream.advance())
-  Entry = std::move(Res.get());
-else
-  return Res.takeError();
+if (Error E = Stream.advance().moveInto(Entry))
+  return std::move(E);
 
 switch (Entry.Kind) {
 case BitstreamEntry::EndBlock:
@@ -305,10 +301,8 @@ static Expected hasObjCCategory(BitstreamCursor 
) {
   // need to understand them all.
   while (true) {
 BitstreamEntry Entry;
-if (Expected Res = Stream.advance())
-  Entry = std::move(Res.get());
-else
-  return Res.takeError();
+if (Error E = Stream.advance().moveInto(Entry))
+  return std::move(E);
 
 switch (Entry.Kind) {
 case BitstreamEntry::Error:

diff  --git a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp 
b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
index 6da0b6907786..f3f09584fdc9 100644
--- a/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
+++ b/llvm/lib/DebugInfo/Symbolize/Symbolize.cpp
@@ -280,10 +280,7 @@ bool getGNUDebuglinkContents(const ObjectFile *Obj, 
std::string ,
 return false;
   for (const SectionRef  : Obj->sections()) {
 StringRef Name;
-if (Expected NameOrErr = Section.getName())
-  Name = *NameOrErr;
-else
-  consumeError(NameOrErr.takeError());
+consumeError(Section.getName().moveInto(Name));
 
 Name = Name.substr(Name.find_first_not_of("._"));
 if (Name == "gnu_debuglink") {

diff  --git a/llvm/lib/Object/ObjectFile.cpp b/llvm/lib/Object/ObjectFile.cpp
index 5c894439ff67..6fd02f3b9592 100644
--- a/llvm/lib/Object/ObjectFile.cpp
+++ b/llvm/lib/Object/ObjectFile.cpp
@@ -55,14 +55,15 @@ bool SectionRef::containsSymbol(SymbolRef S) const {
 }
 
 Expected ObjectFile::getSymbolValue(DataRefImpl Ref) const {
-  if (Expected FlagsOrErr = getSymbolFlags(Ref)) {
-if (*FlagsOrErr & SymbolRef::SF_Undefined)
-  return 0;
-if (*FlagsOrErr & SymbolRef::SF_Common)
-  return getCommonSymbolSize(Ref);
-  } else
+  uint32_t Flags;
+  if (Error E = getSymbolFlags(Ref).moveInto(Flags))
 // TODO: Test this error.
- 

[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-10-22 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

LGTM, then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108482/new/

https://reviews.llvm.org/D108482

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libunwind] e6f39c8 - [libunwind] Fix path to libunwind for per-target-runtime-dir builds

2021-10-22 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2021-10-22T14:36:14-04:00
New Revision: e6f39c8b4891242c0d0d8e7a78041614d9bcdefc

URL: 
https://github.com/llvm/llvm-project/commit/e6f39c8b4891242c0d0d8e7a78041614d9bcdefc
DIFF: 
https://github.com/llvm/llvm-project/commit/e6f39c8b4891242c0d0d8e7a78041614d9bcdefc.diff

LOG: [libunwind] Fix path to libunwind for per-target-runtime-dir builds

We recently introduced a from-scratch config to run the libunwind tests.
However, that config was always looking for libunwind in /lib,
and never in //lib, which is necessary for tests to
work when the per-target-runtime-dir configuration is enabled.

This commit fixes that. I believe this is what caused the CI failures we
saw after 5a8ad80b6fa5 and caused it to be reverted.

Differential Revision: https://reviews.llvm.org/D112322

Added: 


Modified: 
libunwind/test/configs/llvm-libunwind-shared.cfg.in
libunwind/test/configs/llvm-libunwind-static.cfg.in

Removed: 




diff  --git a/libunwind/test/configs/llvm-libunwind-shared.cfg.in 
b/libunwind/test/configs/llvm-libunwind-shared.cfg.in
index 5ba78521709c..b60c9ffbf42d 100644
--- a/libunwind/test/configs/llvm-libunwind-shared.cfg.in
+++ b/libunwind/test/configs/llvm-libunwind-shared.cfg.in
@@ -47,7 +47,7 @@ config.substitutions.append(('%{compile_flags}',
 '-nostdinc++ -I {}/include {}'.format('@LIBUNWIND_SOURCE_DIR@', ' 
'.join(compile_flags))
 ))
 config.substitutions.append(('%{link_flags}',
-'-nodefaultlibs -L {0}/lib -Wl,-rpath,{0}/lib -lunwind -ldl -lc 
{1}'.format('@CMAKE_BINARY_DIR@', ' '.join(link_flags))
+'-nodefaultlibs -L {0} -Wl,-rpath,{0} -lunwind -ldl -lc 
{1}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags))
 ))
 config.substitutions.append(('%{exec}',
 '{} {}/utils/run.py --execdir %T -- '.format(sys.executable, 
'@LIBUNWIND_LIBCXX_PATH@')

diff  --git a/libunwind/test/configs/llvm-libunwind-static.cfg.in 
b/libunwind/test/configs/llvm-libunwind-static.cfg.in
index 6d3f4f0185e1..327f048b1e0f 100644
--- a/libunwind/test/configs/llvm-libunwind-static.cfg.in
+++ b/libunwind/test/configs/llvm-libunwind-static.cfg.in
@@ -49,7 +49,7 @@ config.substitutions.append(('%{compile_flags}',
 '-nostdinc++ -I {}/include {}'.format('@LIBUNWIND_SOURCE_DIR@', ' 
'.join(compile_flags))
 ))
 config.substitutions.append(('%{link_flags}',
-'-nodefaultlibs {}/lib/libunwind.a -ldl -lc 
{}'.format('@CMAKE_BINARY_DIR@', ' '.join(link_flags))
+'-nodefaultlibs {}/libunwind.a -ldl -lc 
{}'.format('@LIBUNWIND_LIBRARY_DIR@', ' '.join(link_flags))
 ))
 config.substitutions.append(('%{exec}',
 '{} {}/utils/run.py --execdir %T -- '.format(sys.executable, 
'@LIBUNWIND_LIBCXX_PATH@')



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-22 Thread Keith Smiley via Phabricator via cfe-commits
keith added inline comments.



Comment at: llvm/unittests/Support/VirtualFileSystemTest.cpp:1738
+
+TEST_F(VFSFromYAMLTest, RelativePathHitWithoutCWD) {
+  IntrusiveRefCntPtr BaseFS(

So this test case is actually failing. The difference between it and the others 
is I don't call `FS->setCurrentWorkingDirectory("//root/foo")`. This results in 
us (with my most recent change here) performing this logic:

1. Fetch the absolute //root/foo/vfsname
2. This results in `realname` being returned
3. We attempt to canonicalize `realname`, but we have no `pwd`, so this doesn't 
result in a valid path
4. everything fails past this

It seems to me, without having a ton of context here, that the value returned 
from the VFS lookup should actually be `//root/foo/realname`, since otherwise 
we could likely hit one of the same issues as those discussed above where if 
you actually had this situation:

- `mkdir /root/foo /root/bar`
- `touch /root/foo/realname /root/bar/realname`
- `cd /root/bar`
- lookup `/root/foo/vfsname`, get back `realname`
- canonicalize `realname` to the wrong path `/root/bar/realname`

You'd end up with the wrong file, but I don't think this is actually new 
behavior with my change?

@dexonsmith  wdyt?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109128/new/

https://reviews.llvm.org/D109128

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112336: [Serialization] Fix a uniqueness check

2021-10-22 Thread Kazu Hirata via Phabricator via cfe-commits
kazu created this revision.
kazu added a reviewer: rsmith.
kazu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The function is intended to maintain uniqueness of two sets -- Found
and Data.  Now, we can reach the for loop shown in the patch only when
Found.empty().  This means that we never execute the body of the for
loop.

The patch fixes the problem by replacing Found with Data.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112336

Files:
  clang/lib/Serialization/ASTReaderInternals.h


Index: clang/lib/Serialization/ASTReaderInternals.h
===
--- clang/lib/Serialization/ASTReaderInternals.h
+++ clang/lib/Serialization/ASTReaderInternals.h
@@ -62,7 +62,7 @@
   // Just use a linear scan unless we have more than a few IDs.
   if (Found.empty() && !Data.empty()) {
 if (Data.size() <= 4) {
-  for (auto I : Found)
+  for (auto I : Data)
 if (I == ID)
   return;
   Data.push_back(ID);


Index: clang/lib/Serialization/ASTReaderInternals.h
===
--- clang/lib/Serialization/ASTReaderInternals.h
+++ clang/lib/Serialization/ASTReaderInternals.h
@@ -62,7 +62,7 @@
   // Just use a linear scan unless we have more than a few IDs.
   if (Found.empty() && !Data.empty()) {
 if (Data.size() <= 4) {
-  for (auto I : Found)
+  for (auto I : Data)
 if (I == ID)
   return;
   Data.push_back(ID);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 381604.
jyu2 added a comment.

fix format problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/distribute_simd_loop_messages.cpp
  clang/test/OpenMP/for_loop_messages.cpp
  clang/test/OpenMP/for_simd_loop_messages.cpp
  clang/test/OpenMP/master_taskloop_loop_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/parallel_for_loop_messages.cpp
  clang/test/OpenMP/parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/simd_loop_messages.cpp
  clang/test/OpenMP/target_parallel_for_loop_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/target_simd_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp
  clang/test/OpenMP/taskloop_loop_messages.cpp
  clang/test/OpenMP/taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp

Index: clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
@@ -14,7 +14,7 @@
 };
 
 static int sii;
-// expected-note@+1 {{defined as threadprivate or thread local}}
+// no note expected @+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -303,7 +303,7 @@
 
 #pragma omp target
 #pragma omp teams distribute simd
-// expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be threadprivate or thread local, predetermined as linear}}
+// no error expected @+1 {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be threadprivate or thread local, predetermined as linear}}
   for (sii = 0; sii < 10; sii++)
 c[sii] = a[sii];
 
Index: clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
@@ -14,7 +14,7 @@
 };
 
 static int sii;
-// expected-note@+1 {{defined as threadprivate or thread local}}
+// no note expected @+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -303,7 +303,7 @@
 
 #pragma omp target
 #pragma omp teams distribute parallel for simd
-// expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
+// no error expected @+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
   for (sii = 0; sii < 10; sii++)
 c[sii] = a[sii];
 
Index: clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
@@ -14,7 +14,7 @@
 };
 
 static int sii;
-// expected-note@+1 {{defined as threadprivate or thread local}}
+// no note expected @+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -301,7 +301,8 @@
 
 #pragma omp target
 #pragma omp teams distribute parallel for
-// expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be threadprivate or thread local, predetermined as private}}
+// loop var with threadprivate or thread local is predetermined as threadprivate
+// no error expected @+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be threadprivate or thread local, predetermined as private}}
   for (sii = 0; sii < 10; sii++)
 c[sii] = a[sii];
 
Index: clang/test/OpenMP/teams_distribute_loop_messages.cpp
===
--- 

[PATCH] D112334: [clang-tidy] Suppress readability-static-access-through-instance for CUDA built-in variables

2021-10-22 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Btw, regarding this `CHECK-MESSAGES-NOT`, how does it work? I can't find it in 
`check_clang_tidy.py`. Wouldn't the test fail anyway if unexpected warnings are 
printed?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112334/new/

https://reviews.llvm.org/D112334

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D109128: [VFS] Use original path when falling back to external FS

2021-10-22 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: llvm/lib/Support/VirtualFileSystem.cpp:1179-1180
 
+  if (ExternalFS)
+ExternalFS->setCurrentWorkingDirectory(Path);
+

keith wrote:
> dexonsmith wrote:
> > keith wrote:
> > > JDevlieghere wrote:
> > > > I'm pretty sure there was a reason we stopped doing this. There should 
> > > > be some discussion about that in my original patch. 
> > > So it sounds like it was related to this:
> > > 
> > > > [fallthrough] ... but not for relative paths that would get resolved 
> > > > incorrectly at the lower layer (for example, in case of the 
> > > > RealFileSystem, because the strictly virtual path does not exist).
> > > 
> > > But if I remove that 2 of my new tests `ReturnsInternalPathVFSHit` and 
> > > `ReturnsExternalPathVFSHit` do not pass. I think the behavior of them is 
> > > what we want, what do you think?
> > We stopped doing this because it puts ExternalFS in an unknown state since 
> > `Path` may not exist there. Future calls with relative paths could do very 
> > strange things.
> > 
> > E.g., here's a simple testcase that demonstrates something going very wrong:
> > - external FS has file `/1/a`
> > - redirecting FS has file `/2/b` (and passes through to external FS)
> > - execute: `cd /1 && cd /2 && stat a`
> > 
> > The correct result is for the `stat` to fail because `/2/a` doesn't exist. 
> > But your change above will instead find `/1/a` in ExternalFS.
> > 
> > Another example:
> > - external FS has file `/1/a` and `/1/nest/c`
> > - redirecting FS has file `/2/b`
> > - execute: `cd /1/nest && cd /2 && cd .. && stat a`
> > 
> > External FS will have CWD of `/1`, redirecting will have CWD of `/`, and 
> > `stat a` will erroneously give the result for `/1/a` instead of `/a`.
> > 
> > (Probably it'd be good to add tests for cases like this...)
> > 
> > To safely call `ExternalFS->setCurrentWorkingDirectory()`, you'll need 
> > extra state (and checks anywhere `ExternalFS` is used) tracking whether it 
> > has a valid working directory. If it does not, then it should not be 
> > queried, or it should only be sent absolute paths, or (etc.); and there 
> > should also be a way to re-establish a valid working directory.
> > 
> Ok I definitely understand the use case now. This is probably something we 
> should add tests for I guess, since I didn't seem to break anything with all 
> my changes here.
> 
> I've updated the logic here, the core issue my new tests were failing without 
> this is because the redirect from the VFS that is returned is not 
> canonicalized itself, meaning when you asked for `vfsname` you would get 
> `vfsmappedname` back, instead of `//absolute/path/to/vfsmappedname`. Since we 
> stopped doing this `cd`, that wasn't enough. With my new change here we're 
> now canonicalizing the return path as well, which is canonicalized against 
> the working directory of the VFS itself.
> 
> The one thing I'm unusure about here, is why this isn't being done by the 
> values returned from the VFS instead. I've added a new test here 
> `VFSFromYAMLTest.RelativePathHitWithoutCWD` that illustrates the behavior I'm 
> talking about. Requesting the absolute file path still fails because my 
> canonicalization of the remapped path is incorrect, and it should be based on 
> the directory's root instead of the VFS's PWD.
> This is probably something we should add tests for I guess, since I didn't 
> seem to break anything with all my changes here.

It'd be awesome if you could do that if you're up for it, while your head is in 
this... (maybe in parallel with or after this patch?)

> The one thing I'm unusure about here, is why this isn't being done by the 
> values returned from the VFS instead. I've added a new test here 
> `VFSFromYAMLTest.RelativePathHitWithoutCWD` that illustrates the behavior I'm 
> talking about. Requesting the absolute file path still fails because my 
> canonicalization of the remapped path is incorrect, and it should be based on 
> the directory's root instead of the VFS's PWD.

I'm sorry, I'm not quite following; not sure if I'm thinking slowly today or if 
it's just that this stuff is complicated :). Can you add an inline comment in 
context to the testcase in question (just on Phab) that explains which 
behaviour/lines of code/etc. are unexpected/why/etc?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109128/new/

https://reviews.llvm.org/D109128

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112334: [clang-tidy] Suppress readability-static-access-through-instance for CUDA built-in variables

2021-10-22 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp created this revision.
carlosgalvezp added a project: clang-tools-extra.
Herald added subscribers: xazax.hun, yaxunl.
carlosgalvezp requested review of this revision.

clang-tidy can be used to statically analyze CUDA code,
thanks to clang being able to compile CUDA code natively.
This makes clang-tidy the one and only open-source
static analyzer for CUDA.

However it currently warns for native CUDA built-in
variables, like threadIdx, due to the way they
are implemented in clang.

Users don't need to know the details of the clang
implementation, and they should continue to write
idiomatic code. Therefore, suppress the warning
if a CUDA built-in variable is encountered.

Fixes https://bugs.llvm.org/show_bug.cgi?id=48758


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112334

Files:
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
@@ -248,3 +248,38 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
   // CHECK-FIXES: {{^}}  Outer::S::I;{{$}}
 }
+
+namespace Bugzilla_48758 {
+
+// From __clang_cuda_builtin_vars.h
+struct __cuda_builtin_threadIdx_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_blockIdx_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_blockDim_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_gridDim_t {
+  static unsigned int x;
+};
+
+__cuda_builtin_threadIdx_t threadIdx;
+__cuda_builtin_blockIdx_t blockIdx;
+__cuda_builtin_blockDim_t blockDim;
+__cuda_builtin_gridDim_t gridDim;
+
+unsigned int x1 = threadIdx.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x2 = blockIdx.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x3 = blockDim.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x4 = gridDim.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+
+} // namespace Bugzilla_48758
Index: 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ 
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
@@ -54,7 +54,7 @@
 
   const Expr *BaseExpr = MemberExpression->getBase();
 
-  // Do not warn for overlaoded -> operators.
+  // Do not warn for overloaded -> operators.
   if (isa(BaseExpr))
 return;
 
@@ -70,6 +70,10 @@
   std::string BaseTypeName =
   BaseType.getAsString(PrintingPolicyWithSupressedTag);
 
+  // Do not warn for CUDA built-in variables.
+  if (BaseTypeName.find("__cuda_builtin_") != std::string::npos)
+return;
+
   SourceLocation MemberExprStartLoc = MemberExpression->getBeginLoc();
   auto Diag =
   diag(MemberExprStartLoc, "static member accessed through instance");


Index: clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-static-accessed-through-instance.cpp
@@ -248,3 +248,38 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
   // CHECK-FIXES: {{^}}  Outer::S::I;{{$}}
 }
+
+namespace Bugzilla_48758 {
+
+// From __clang_cuda_builtin_vars.h
+struct __cuda_builtin_threadIdx_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_blockIdx_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_blockDim_t {
+  static unsigned int x;
+};
+
+struct __cuda_builtin_gridDim_t {
+  static unsigned int x;
+};
+
+__cuda_builtin_threadIdx_t threadIdx;
+__cuda_builtin_blockIdx_t blockIdx;
+__cuda_builtin_blockDim_t blockDim;
+__cuda_builtin_gridDim_t gridDim;
+
+unsigned int x1 = threadIdx.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x2 = blockIdx.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x3 = blockDim.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+unsigned int x4 = gridDim.x;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
+
+} // namespace Bugzilla_48758
Index: clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ 

[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-10-22 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

I actually see lots of these as well:

  clang: ../lib/Support/APInt.cpp:284: int llvm::APInt::compareSigned(const 
llvm::APInt &) const: Assertion `BitWidth == RHS.BitWidth && "Bit widths must 
be same for comparison"' failed.

Although I haven't verified if those are related to this patch as well yet.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106102/new/

https://reviews.llvm.org/D106102

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-10-22 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

I get failures after having merged this patch:

  /llvm/build-all/bin/clang -Xanalyzer -analyzer-output=text -Xanalyzer 
-analyzer-checker='nullability,optin.portability.UnixAPI,security,valist' 
-Xanalyzer -analyzer-disable-checker='security.insecureAPI.strcpy' --analyze 
crash.c
  clang: ../include/llvm/ADT/APSInt.h:148: bool llvm::APSInt::operator<(const 
llvm::APSInt &) const: Assertion `IsUnsigned == RHS.IsUnsigned && "Signedness 
mismatch!"' failed.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.  Program arguments: /llvm/build-all/bin/clang -Xanalyzer 
-analyzer-output=text -Xanalyzer 
-analyzer-checker=nullability,optin.portability.UnixAPI,security,valist 
-Xanalyzer -analyzer-disable-checker=security.insecureAPI.strcpy --analyze 
crash.c
  1.   parser at end of file
  2.  While analyzing stack: 
  #0 Calling func_59
  3.  build-all/runtest/csmith/csmith-3790728623.c:1368:79: Error 
evaluating statement
  4.  build-all/runtest/csmith/csmith-3790728623.c:1368:79: Error 
evaluating statement
   #0 0x02cd99a3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/llvm/build-all/bin/clang+0x2cd99a3)
   #1 0x02cd761e llvm::sys::RunSignalHandlers() 
(/llvm/build-all/bin/clang+0x2cd761e)
   #2 0x02cd8d42 llvm::sys::CleanupOnSignal(unsigned long) 
(/llvm/build-all/bin/clang+0x2cd8d42)
   #3 0x02c4c893 (anonymous 
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) 
CrashRecoveryContext.cpp:0:0
   #4 0x02c4ca3d CrashRecoverySignalHandler(int) 
CrashRecoveryContext.cpp:0:0
   #5 0x7f877102c630 __restore_rt sigaction.c:0:0
   #6 0x7f876e75f387 raise (/lib64/libc.so.6+0x36387)
   #7 0x7f876e760a78 abort (/lib64/libc.so.6+0x37a78)
   #8 0x7f876e7581a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)
   #9 0x7f876e758252 (/lib64/libc.so.6+0x2f252)
  #10 0x0435bd4f (anonymous 
namespace)::SymbolicRangeInferrer::VisitBinaryOperator(clang::ento::RangeSet, 
clang::BinaryOperatorKind, clang::ento::RangeSet, clang::QualType) 
RangeConstraintManager.cpp:0:0
  #11 0x0435a757 (anonymous 
namespace)::SymbolicRangeInferrer::infer(clang::ento::SymExpr const*) 
RangeConstraintManager.cpp:0:0
  #12 0x0434e7b5 (anonymous 
namespace)::RangeConstraintManager::assumeSymNE(llvm::IntrusiveRefCntPtr, clang::ento::SymExpr const*, llvm::APSInt const&, llvm::APSInt const&) 
RangeConstraintManager.cpp:0:0
  #13 0x04361e52 
clang::ento::RangedConstraintManager::assumeSymUnsupported(llvm::IntrusiveRefCntPtr, clang::ento::SymExpr const*, bool) 
(/llvm/build-all/bin/clang+0x4361e52)
  #14 0x0437e419 
clang::ento::SimpleConstraintManager::assumeAux(llvm::IntrusiveRefCntPtr, clang::ento::NonLoc, bool) (/llvm/build-all/bin/clang+0x437e419)
  #15 0x0437e278 
clang::ento::SimpleConstraintManager::assume(llvm::IntrusiveRefCntPtr, clang::ento::NonLoc, bool) (/llvm/build-all/bin/clang+0x437e278)
  #16 0x0437e18b 
clang::ento::SimpleConstraintManager::assume(llvm::IntrusiveRefCntPtr, clang::ento::DefinedSVal, bool) (/llvm/build-all/bin/clang+0x437e18b)
  #17 0x03f4967c 
clang::ento::ConstraintManager::assumeDual(llvm::IntrusiveRefCntPtr, clang::ento::DefinedSVal) crtstuff.c:0:0
  #18 0x042ed7cf 
clang::ento::ExprEngine::evalEagerlyAssumeBinOpBifurcation(clang::ento::ExplodedNodeSet&,
 clang::ento::ExplodedNodeSet&, clang::Expr const*) 
(/llvm/build-all/bin/clang+0x42ed7cf)
  #19 0x042ea5db clang::ento::ExprEngine::Visit(clang::Stmt const*, 
clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) 
(/llvm/build-all/bin/clang+0x42ea5db)
  #20 0x042e58ee clang::ento::ExprEngine::ProcessStmt(clang::Stmt 
const*, clang::ento::ExplodedNode*) (/llvm/build-all/bin/clang+0x42e58ee)
  #21 0x042e5609 
clang::ento::ExprEngine::processCFGElement(clang::CFGElement, 
clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) 
(/llvm/build-all/bin/clang+0x42e5609)
  #22 0x042cd850 
clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, 
clang::ento::ExplodedNode*) (/llvm/build-all/bin/clang+0x42cd850)
  #23 0x042cc8e4 
clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, 
unsigned int, llvm::IntrusiveRefCntPtr) 
(/llvm/build-all/bin/clang+0x42cc8e4)
  #24 0x03f1fa5c (anonymous 
namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, 
clang::ento::ExprEngine::InliningModes, llvm::DenseSet >*) AnalysisConsumer.cpp:0:0
  #25 0x03f035c7 (anonymous 
namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) 
AnalysisConsumer.cpp:0:0

Here is the crash.c input F19785350: crash.c 


I see lots of these. Probably worth a revert.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
 

[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-10-22 Thread Jason Rice via Phabricator via cfe-commits
ricejasonf added a comment.

Can this be accepted if there are no other issues?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108482/new/

https://reviews.llvm.org/D108482

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In D112292#3080945 , @lebedev.ri 
wrote:

> In which standard version was that rule introduced, is this missing some 
> checks for the OpenMP version?

I check back to omp 45, the rule was there.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99797: [analyzer] Implemented RangeSet::Factory::unite function to handle intersections and adjacency

2021-10-22 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@martong 
Thanks for your inlines. I'll update the patch.




Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:81
   const llvm::APSInt (BaseType X) {
-llvm::APSInt Dummy = Base;
-Dummy = X;
-return BVF.getValue(Dummy);
+static llvm::APSInt Base{sizeof(BaseType) * 8,
+ std::is_unsigned::value};

steakhal wrote:
> ASDenysPetrov wrote:
> > steakhal wrote:
> > > Shouldn't you use `sizeof(BaseType) * CHAR_BIT` instead?
> > Agree. It's better to avoid magic numbers. I'll fix.
> It's not only that but just imagine testing a clang on a special hardware 
> where they have let's say 9 bit bytes, for parity or something similar stuff.
> The test would suddenly break.
> Although I suspect there would be many more things to break TBH xD
I am always skeptical about using`CHAR_BIT`, beacuse it represents bit number 
in `char`. And what if it would be 16 for instance (aka 2 bytes). But my 
intention is to get an amount of bits for a particular type. And I want 
something to represent a number of bits in a byte as a fundamental unit, but 
not something that depends on a `char` size on a particular platform.
I would better introduce something like `constexpr size_t BITS_IN_BYTE = 8;`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99797/new/

https://reviews.llvm.org/D99797

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In which standard version was that rule introduced, is this missing some checks 
for the OpenMP version?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with a nit.




Comment at: clang/lib/Sema/SemaOpenMP.cpp:8658
   !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
+  DVar.CKind != OMPC_threadprivate &&
   DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&

Need to fix the formatting.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:8653
 ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : 
OMPC_linear)
-: OMPC_private;
-if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
-  (LangOpts.OpenMP <= 45 || (DVar.CKind != OMPC_lastprivate &&
- DVar.CKind != OMPC_private))) ||
- ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
-   DKind == OMPD_master_taskloop ||
-   DKind == OMPD_parallel_master_taskloop ||
-   isOpenMPDistributeDirective(DKind)) &&
-  !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
-(DVar.CKind != OMPC_private || DVar.RefExpr)) {
+: DVar.CKind == OMPC_lastprivate ? OMPC_lastprivate
+ : OMPC_private;

ABataev wrote:
> jyu2 wrote:
> > ABataev wrote:
> > > jyu2 wrote:
> > > > ABataev wrote:
> > > > > Why need this change?
> > > > The rule:
> > > > The loop iteration variable in any associated loop of a loop construct 
> > > > is lastprivate.
> > > > 
> > > > So if there is lastprivate clause, should be predetermined as 
> > > > lastprivate.
> > > The patch is for threadprivates, better to do it in a separate patch(or 
> > > patches). 
> > That is already there but in different in the if statement on line 8657 in 
> > old code:
> > 
> >  DVar.CKind != OMPC_lastprivate)) &
> > 
> > I just want to merge that into PredetermindCKind.
> > 
> Can you do it in a separate NFC patch (if this is actually NFC)?
Okay, will do in sperate change.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 381564.
jyu2 edited the summary of this revision.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/distribute_simd_loop_messages.cpp
  clang/test/OpenMP/for_loop_messages.cpp
  clang/test/OpenMP/for_simd_loop_messages.cpp
  clang/test/OpenMP/master_taskloop_loop_messages.cpp
  clang/test/OpenMP/master_taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/parallel_for_loop_messages.cpp
  clang/test/OpenMP/parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_loop_messages.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/simd_loop_messages.cpp
  clang/test/OpenMP/target_parallel_for_loop_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/target_simd_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_loop_messages.cpp
  clang/test/OpenMP/taskloop_loop_messages.cpp
  clang/test/OpenMP/taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp

Index: clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_simd_loop_messages.cpp
@@ -14,7 +14,7 @@
 };
 
 static int sii;
-// expected-note@+1 {{defined as threadprivate or thread local}}
+// no note expected @+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -303,7 +303,7 @@
 
 #pragma omp target
 #pragma omp teams distribute simd
-// expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be threadprivate or thread local, predetermined as linear}}
+// no error expected @+1 {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be threadprivate or thread local, predetermined as linear}}
   for (sii = 0; sii < 10; sii++)
 c[sii] = a[sii];
 
Index: clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
@@ -14,7 +14,7 @@
 };
 
 static int sii;
-// expected-note@+1 {{defined as threadprivate or thread local}}
+// no note expected @+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -303,7 +303,7 @@
 
 #pragma omp target
 #pragma omp teams distribute parallel for simd
-// expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
+// no error expected @+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
   for (sii = 0; sii < 10; sii++)
 c[sii] = a[sii];
 
Index: clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_loop_messages.cpp
@@ -14,7 +14,7 @@
 };
 
 static int sii;
-// expected-note@+1 {{defined as threadprivate or thread local}}
+// no note expected @+1 {{defined as threadprivate or thread local}}
 #pragma omp threadprivate(sii)
 static int globalii;
 
@@ -301,7 +301,8 @@
 
 #pragma omp target
 #pragma omp teams distribute parallel for
-// expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be threadprivate or thread local, predetermined as private}}
+// loop var with threadprivate or thread local is predetermined as threadprivate
+// no error expected @+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be threadprivate or thread local, predetermined as private}}
   for (sii = 0; sii < 10; sii++)
 c[sii] = a[sii];
 
Index: clang/test/OpenMP/teams_distribute_loop_messages.cpp
===
--- 

[PATCH] D111654: [analyzer] Retrieve a value from list initialization of multi-dimensional array declaration.

2021-10-22 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 381562.
ASDenysPetrov added a comment.

Improved. Rebased on top of D107339 .
@martong kind ping.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111654/new/

https://reviews.llvm.org/D111654

Files:
  clang/include/clang/AST/Type.h
  clang/lib/AST/Type.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/initialization.c
  clang/test/Analysis/initialization.cpp

Index: clang/test/Analysis/initialization.cpp
===
--- clang/test/Analysis/initialization.cpp
+++ clang/test/Analysis/initialization.cpp
@@ -14,13 +14,6 @@
   clang_analyzer_eval(sarr[i].a); // expected-warning{{UNKNOWN}}
 }
 
-int const arr[2][2] = {};
-void arr2init() {
-  int i = 1;
-  // FIXME: Should recognize that it is 0.
-  clang_analyzer_eval(arr[i][0]); // expected-warning{{UNKNOWN}}
-}
-
 int const glob_arr1[3] = {};
 void glob_array_index1() {
   clang_analyzer_eval(glob_arr1[0] == 0); // expected-warning{{TRUE}}
@@ -60,79 +53,56 @@
   return glob_arr3[0]; // no-warning (garbage or undefined)
 }
 
-// TODO: Support multidimensional array.
 int const glob_arr4[4][2] = {};
 void glob_array_index2() {
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr4[1][0] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr4[1][1] == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(glob_arr4[0][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr4[1][1] == 0); // expected-warning{{TRUE}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index3() {
   int idx = -42;
-  // FIXME: Should warn {{garbage or undefined}}.
-  auto x = glob_arr4[1][idx]; // no-warning
+  auto x = glob_arr4[1][idx]; // expected-warning{{garbage or undefined}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index4() {
   const int *ptr = glob_arr4[1];
   int idx = -42;
-  // FIXME: Should warn {{garbage or undefined}}.
-  auto x = ptr[idx]; // no-warning
+  auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
 }
 
-// TODO: Support multidimensional array.
 int const glob_arr5[4][2] = {{1}, 3, 4, 5};
 void glob_array_index3() {
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[0][0] == 1); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[0][1] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[1][0] == 3); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[1][1] == 4); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[2][0] == 5); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[2][1] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[3][0] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(glob_arr5[3][1] == 0); // expected-warning{{UNKNOWN}}
-}
-
-// TODO: Support multidimensional array.
+  clang_analyzer_eval(glob_arr5[0][0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[0][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[1][0] == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[1][1] == 4); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[2][0] == 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[2][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[3][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr5[3][1] == 0); // expected-warning{{TRUE}}
+}
+
 void glob_ptr_index2() {
   int const *ptr = glob_arr5[1];
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(ptr[0] == 3); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be TRUE.
-  clang_analyzer_eval(ptr[1] == 4); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be UNDEFINED.
-  clang_analyzer_eval(ptr[2] == 5); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be UNDEFINED.
-  clang_analyzer_eval(ptr[3] == 0); // expected-warning{{UNKNOWN}}
-  // FIXME: Should be UNDEFINED.
-  clang_analyzer_eval(ptr[4] == 0); // expected-warning{{UNKNOWN}}
+  // FIXME: Should be TRUE
+  clang_analyzer_eval(ptr[0] == 3); // expected-warning{{UNDEFINED}}
+  // FIXME: Should be TRUE
+  clang_analyzer_eval(ptr[1] == 4); // expected-warning{{UNDEFINED}}
+  clang_analyzer_eval(ptr[2] == 5); // expected-warning{{UNDEFINED}}
+  clang_analyzer_eval(ptr[3] == 0); // expected-warning{{UNDEFINED}}
+  clang_analyzer_eval(ptr[4] == 0); // expected-warning{{UNDEFINED}}
 }
 
-// TODO: Support multidimensional array.
 void glob_invalid_index5() {
   int idx = -42;
-  // FIXME: Should warn {{garbage or undefined}}.
-  auto x = glob_arr5[1][idx]; // 

[PATCH] D112102: [RISCV] Reduce the number of RISCV vector builtins by an order of magnitude.

2021-10-22 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

It looks good to me. Wait for others' opinions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112102/new/

https://reviews.llvm.org/D112102

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:8653
 ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : 
OMPC_linear)
-: OMPC_private;
-if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
-  (LangOpts.OpenMP <= 45 || (DVar.CKind != OMPC_lastprivate &&
- DVar.CKind != OMPC_private))) ||
- ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
-   DKind == OMPD_master_taskloop ||
-   DKind == OMPD_parallel_master_taskloop ||
-   isOpenMPDistributeDirective(DKind)) &&
-  !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
-(DVar.CKind != OMPC_private || DVar.RefExpr)) {
+: DVar.CKind == OMPC_lastprivate ? OMPC_lastprivate
+ : OMPC_private;

jyu2 wrote:
> ABataev wrote:
> > jyu2 wrote:
> > > ABataev wrote:
> > > > Why need this change?
> > > The rule:
> > > The loop iteration variable in any associated loop of a loop construct is 
> > > lastprivate.
> > > 
> > > So if there is lastprivate clause, should be predetermined as lastprivate.
> > The patch is for threadprivates, better to do it in a separate patch(or 
> > patches). 
> That is already there but in different in the if statement on line 8657 in 
> old code:
> 
>  DVar.CKind != OMPC_lastprivate)) &
> 
> I just want to merge that into PredetermindCKind.
> 
Can you do it in a separate NFC patch (if this is actually NFC)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:8653
 ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : 
OMPC_linear)
-: OMPC_private;
-if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
-  (LangOpts.OpenMP <= 45 || (DVar.CKind != OMPC_lastprivate &&
- DVar.CKind != OMPC_private))) ||
- ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
-   DKind == OMPD_master_taskloop ||
-   DKind == OMPD_parallel_master_taskloop ||
-   isOpenMPDistributeDirective(DKind)) &&
-  !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
-(DVar.CKind != OMPC_private || DVar.RefExpr)) {
+: DVar.CKind == OMPC_lastprivate ? OMPC_lastprivate
+ : OMPC_private;

ABataev wrote:
> jyu2 wrote:
> > ABataev wrote:
> > > Why need this change?
> > The rule:
> > The loop iteration variable in any associated loop of a loop construct is 
> > lastprivate.
> > 
> > So if there is lastprivate clause, should be predetermined as lastprivate.
> The patch is for threadprivates, better to do it in a separate patch(or 
> patches). 
That is already there but in different in the if statement on line 8657 in old 
code:

 DVar.CKind != OMPC_lastprivate)) &

I just want to merge that into PredetermindCKind.




Comment at: clang/lib/Sema/SemaOpenMP.cpp:8662-8667
+if (LangOpts.OpenMP > 45 && isOpenMPSimdDirective(DKind)) {
+  if (DVar.CKind == OMPC_lastprivate)
+PredeterminedCKind = OMPC_lastprivate;
+  else if (DVar.CKind == OMPC_private)
+PredeterminedCKind = OMPC_private;
+}

ABataev wrote:
> jyu2 wrote:
> > ABataev wrote:
> > > Again, why do we need this?
> > In the comment:  for OpenMP 5.0 and up:
> > 
> > If a simd construct has just one associated loop, the variable may be  
> > listed in a private, lastprivate or linear.
> > 
> > The linear part is set on line 8652, there just need to set private and 
> > lastprivate.
> > 
> > 
> Same here, better to split this change
It is also in old code on line 8650:  I just want to merge them into 
PredetermindCKind.

(LangOpts.OpenMP <= 45 || (DVar.CKind != OMPC_lastprivate &&
 DVar.CKind != OMPC_private)))


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:8653
 ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : 
OMPC_linear)
-: OMPC_private;
-if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
-  (LangOpts.OpenMP <= 45 || (DVar.CKind != OMPC_lastprivate &&
- DVar.CKind != OMPC_private))) ||
- ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
-   DKind == OMPD_master_taskloop ||
-   DKind == OMPD_parallel_master_taskloop ||
-   isOpenMPDistributeDirective(DKind)) &&
-  !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
-(DVar.CKind != OMPC_private || DVar.RefExpr)) {
+: DVar.CKind == OMPC_lastprivate ? OMPC_lastprivate
+ : OMPC_private;

jyu2 wrote:
> ABataev wrote:
> > Why need this change?
> The rule:
> The loop iteration variable in any associated loop of a loop construct is 
> lastprivate.
> 
> So if there is lastprivate clause, should be predetermined as lastprivate.
The patch is for threadprivates, better to do it in a separate patch(or 
patches). 



Comment at: clang/lib/Sema/SemaOpenMP.cpp:8662-8667
+if (LangOpts.OpenMP > 45 && isOpenMPSimdDirective(DKind)) {
+  if (DVar.CKind == OMPC_lastprivate)
+PredeterminedCKind = OMPC_lastprivate;
+  else if (DVar.CKind == OMPC_private)
+PredeterminedCKind = OMPC_private;
+}

jyu2 wrote:
> ABataev wrote:
> > Again, why do we need this?
> In the comment:  for OpenMP 5.0 and up:
> 
> If a simd construct has just one associated loop, the variable may be  listed 
> in a private, lastprivate or linear.
> 
> The linear part is set on line 8652, there just need to set private and 
> lastprivate.
> 
> 
Same here, better to split this change


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

Hi Alexey, Thanks for review.




Comment at: clang/lib/Sema/SemaOpenMP.cpp:8653
 ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : 
OMPC_linear)
-: OMPC_private;
-if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
-  (LangOpts.OpenMP <= 45 || (DVar.CKind != OMPC_lastprivate &&
- DVar.CKind != OMPC_private))) ||
- ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
-   DKind == OMPD_master_taskloop ||
-   DKind == OMPD_parallel_master_taskloop ||
-   isOpenMPDistributeDirective(DKind)) &&
-  !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
-(DVar.CKind != OMPC_private || DVar.RefExpr)) {
+: DVar.CKind == OMPC_lastprivate ? OMPC_lastprivate
+ : OMPC_private;

ABataev wrote:
> Why need this change?
The rule:
The loop iteration variable in any associated loop of a loop construct is 
lastprivate.

So if there is lastprivate clause, should be predetermined as lastprivate.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:8662-8667
+if (LangOpts.OpenMP > 45 && isOpenMPSimdDirective(DKind)) {
+  if (DVar.CKind == OMPC_lastprivate)
+PredeterminedCKind = OMPC_lastprivate;
+  else if (DVar.CKind == OMPC_private)
+PredeterminedCKind = OMPC_private;
+}

ABataev wrote:
> Again, why do we need this?
In the comment:  for OpenMP 5.0 and up:

If a simd construct has just one associated loop, the variable may be  listed 
in a private, lastprivate or linear.

The linear part is set on line 8652, there just need to set private and 
lastprivate.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98895: [X86][clang] Disable long double type for -mno-x87 option

2021-10-22 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic updated this revision to Diff 381538.
asavonic retitled this revision from "[X86][Draft] Disable long double type for 
-mno-x87 option" to "[X86][clang] Disable long double type for -mno-x87 option".
asavonic edited the summary of this revision.
asavonic added a comment.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Rebased the patch on top of D109315 .

Since the diagnostic is now shared with other targets (SYCL and
OpenMP), I decided to drop all assumptions on optimizations that
we previously discussed. There seems to be no actual use case
where it is important to have them (other than compatibility with
GCC), and they make rules a bit inconsistent.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98895/new/

https://reviews.llvm.org/D98895

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/x86-no-x87.c
  clang/test/Sema/x86_64-no-x87.c

Index: clang/test/Sema/x86_64-no-x87.c
===
--- /dev/null
+++ clang/test/Sema/x86_64-no-x87.c
@@ -0,0 +1,137 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x87
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -DNOERROR
+
+#ifdef NOERROR
+// expected-no-diagnostics
+#endif
+
+typedef long double long_double;
+
+// Declaration is fine, unless it is called or defined.
+double decl(long_double x, long_double y);
+
+#ifndef NOERROR
+// expected-error@+4{{'def' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+// expected-note@+3{{'def' defined here}}
+// expected-note@+2{{'x' defined here}}
+#endif
+int def(long_double x) {
+#ifndef NOERROR
+// expected-error@+2{{'x' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  return (int)x;
+}
+
+#ifndef NOERROR
+// expected-note@+3{{'ld_args' defined here}}
+// expected-note@+2{{'ld_args' defined here}}
+#endif
+int ld_args(long_double x, long_double y);
+
+int call1(float x, float y) {
+#ifndef NOERROR
+  // expected-error@+2 2{{'ld_args' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  return ld_args(x, y);
+}
+
+#ifndef NOERROR
+// expected-note@+2{{'ld_ret' defined here}}
+#endif
+long_double ld_ret(double x, double y);
+
+int call2(float x, float y) {
+#ifndef NOERROR
+  // expected-error@+2{{'ld_ret' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  return (int)ld_ret(x, y);
+}
+
+int binop(double x, double y) {
+#ifndef NOERROR
+  // expected-error@+2 2{{expression requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  double z = (long_double)x * (long_double)y;
+  return (int)z;
+}
+
+void assign1(long_double *ret, double x) {
+#ifndef NOERROR
+  // expected-error@+2{{expression requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  *ret = x;
+}
+
+struct st_long_double1 {
+#ifndef NOERROR
+  // expected-note@+2{{'ld' defined here}}
+#endif
+  long_double ld;
+};
+
+struct st_long_double2 {
+#ifndef NOERROR
+  // expected-note@+2{{'ld' defined here}}
+#endif
+  long_double ld;
+};
+
+struct st_long_double3 {
+#ifndef NOERROR
+  // expected-note@+2{{'ld' defined here}}
+#endif
+  long_double ld;
+};
+
+void assign2() {
+  struct st_long_double1 st;
+#ifndef NOERROR
+  // expected-error@+3{{expression requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+  // expected-error@+2{{'ld' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  st.ld = 0.42;
+}
+
+void assign3() {
+  struct st_long_double2 st;
+#ifndef NOERROR
+  // expected-error@+3{{expression requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+  // expected-error@+2{{'ld' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+#endif
+  st.ld = 42;
+}
+
+void assign4(double d) {
+  struct st_long_double3 st;
+#ifndef NOERROR
+  // expected-error@+3{{expression requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
+  // expected-error@+2{{'ld' requires  'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' 

[PATCH] D111642: [Analyzer][solver] Simplification: reorganize equalities with adjustment

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D111642#3059467 , @steakhal wrote:

> The coverage report of the test shows that L2124 is uncovered. Please add a 
> test demonstrating that path as well.

I've added such a test, thanks for the notice!




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2126-2130
+  // Initiate the reorganization of the equality information. E.g., if we
+  // have `c + 1 == 0` then we'd like to express that `c == -1`. It makes
+  // sense to do this only with `SymIntExpr`s.
+  // TODO Handle `IntSymExpr` as well, once computeAdjustment can handle
+  // them.

steakhal wrote:
> Can the simplification of a `SymSymExpr` result in `IntSymExpr`? If it can 
> happen, then we could see such instances and we should do the right thing 
> with them as well.
> WDYT?
> Can the simplification of a `SymSymExpr` result in `IntSymExpr`?
Yes it can. However, in order to handle them we should extend 
`computeAdjustment` properly, which is absolutely not trivial - considering the 
test cases in `additive-folding.cpp` -  So, I'd rather address that in another 
patch.




Comment at: clang/test/Analysis/solver-sym-simplification-adjustment.c:36
+  clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  if (b != 1)  // b == 1  --> c + 1: [-1,0] --> c: [-2,-1]
+return;

steakhal wrote:
> Please express that `C: [-2,-1]` is then intersected with the already 
> associated range which is `[-1,1]`, thus we get `c: [-1,-1]`.
Ok, I've added that comment.



Comment at: clang/test/Analysis/solver-sym-simplification-adjustment.c:55
+  if (b != 1) // b == 1  --> c + 1 == 0 --> c == -1 contradiction
+return;
+  clang_analyzer_warnIfReached(); // no warning

steakhal wrote:
> Can we infer within this true branch that `b` must be `0` to make this path 
> feasible?
> If we already can infer this, can we put there the appropriate assertion?
> If not, an assertion would be justified with a FIXME.
> Can we infer within this true branch that `b` must be `0` to make this path 
> feasible?
Yes, we can.

> If we already can infer this, can we put there the appropriate assertion?
Ok, I've added the appropriate `clang_analyzer_eval` to check this.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111642/new/

https://reviews.llvm.org/D111642

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111642: [Analyzer][solver] Simplification: reorganize equalities with adjustment

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 381536.
martong added a comment.

- Add a test to cover `if (OldState == State)`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111642/new/

https://reviews.llvm.org/D111642

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/solver-sym-simplification-adjustment.c

Index: clang/test/Analysis/solver-sym-simplification-adjustment.c
===
--- /dev/null
+++ clang/test/Analysis/solver-sym-simplification-adjustment.c
@@ -0,0 +1,110 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+void clang_analyzer_warnIfReached();
+void clang_analyzer_eval();
+
+void test_simplification_adjustment_concrete_int(int b, int c) {
+  if (b < 0 || b > 1)  // b: [0,1]
+return;
+  if (c < -1 || c > 1) // c: [-1,1]
+return;
+  if (c + b != 0)  // c + b == 0
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (b != 1)  // b == 1  --> c + 1 == 0 --> c == -1
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_eval(c == -1);   // expected-warning{{TRUE}}
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
+
+void test_simplification_adjustment_range(int b, int c) {
+  if (b < 0 || b > 1)  // b: [0,1]
+return;
+  if (c < -1 || c > 1) // c: [-1,1]
+return;
+  if (c + b < -1 || c + b > 0) // c + b: [-1,0]
+return;
+  clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  if (b != 1)  // b == 1  --> c + 1: [-1,0] --> c: [-2,-1]
+return;
+   // c: [-2,-1] is intersected with the
+   // already associated range which is [-1,1],
+   // thus we get c: [-1,-1]
+  clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  clang_analyzer_eval(c == -1);// expected-warning{{TRUE}}
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
+
+void test_simplification_adjustment_to_infeasible_concrete_int(int b, int c) {
+  if (b < 0 || b > 1) // b: [0,1]
+return;
+  if (c < 0 || c > 1) // c: [0,1]
+return;
+  if (c + b != 0) // c + b == 0
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (b != 1) {   // b == 1  --> c + 1 == 0 --> c == -1 contradiction
+clang_analyzer_eval(b == 0);  // expected-warning{{TRUE}}
+// Keep the symbols and the constraints! alive.
+(void)(b * c);
+return;
+  }
+  clang_analyzer_warnIfReached(); // no warning
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
+
+void test_simplification_adjustment_to_infeassible_range(int b, int c) {
+  if (b < 0 || b > 1)  // b: [0,1]
+return;
+  if (c < 0 || c > 1)  // c: [0,1]
+return;
+  if (c + b < -1 || c + b > 0) // c + b: [-1,0]
+return;
+  clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  if (b != 1)  // b == 1  --> c + 1: [-1,0] --> c: [-2,-1] contradiction
+return;
+  clang_analyzer_warnIfReached();  // no warning
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
+
+void test_simplification_adjusment_no_infinite_loop(int a, int b, int c) {
+  if (a == b)// a != b
+return;
+  if (c != 0)// c == 0
+return;
+
+  if (b != 0)// b == 0
+return;
+  // The above simplification of `b == 0` could result in an infinite loop
+  // unless we detect that the State is unchanged.
+  // The loop:
+  // 1) Simplification of the trivial equivalence class
+  //  "symbol": "(reg_$0) == (reg_$1)", "range": "{ [0, 0] }"
+  //results in
+  //  "symbol": "(reg_$0) == 0", "range": "{ [0, 0] }" }
+  //which in turn creates a non-trivial equivalence class
+  //  [ "(reg_$0) == (reg_$1)", "(reg_$0) == 0" ]
+  // 2) We call assumeSymInclusiveRange("(reg_$0) == 0")
+  //and that calls **simplify** on the associated non-trivial equivalence
+  //class. During the simplification the State does not change, we reached
+  //the fixpoint.
+
+  (void)(a * b * c);
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -602,10 +602,9 @@
   areEqual(ProgramStateRef State, SymbolRef First, SymbolRef Second);
 
   /// Iterate over all symbols and try to simplify them.
-  LLVM_NODISCARD static inline ProgramStateRef simplify(SValBuilder ,
-   

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-22 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 381533.
ASDenysPetrov added a comment.

Fixed test unpassing in `array-struct-region.c`. Added examples in comments 
according to suggestions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107339/new/

https://reviews.llvm.org/D107339

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/initialization.cpp

Index: clang/test/Analysis/initialization.cpp
===
--- clang/test/Analysis/initialization.cpp
+++ clang/test/Analysis/initialization.cpp
@@ -146,3 +146,110 @@
 void struct_arr_index1() {
   clang_analyzer_eval(S2::arr_no_init[2]); // expected-warning{{UNKNOWN}}
 }
+
+char const glob_arr6[5] = "123";
+void glob_array_index5() {
+  clang_analyzer_eval(glob_arr6[0] == '1');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr6[1] == '2');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr6[2] == '3');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr6[3] == '\0'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr6[4] == '\0'); // expected-warning{{TRUE}}
+}
+
+void glob_ptr_index3() {
+  char const *ptr = glob_arr6;
+  clang_analyzer_eval(ptr[-42] == '\0'); // expected-warning{{UNDEFINED}}
+  clang_analyzer_eval(ptr[0] == '1');// expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[1] == '2');// expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[2] == '3');// expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[3] == '\0');   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[4] == '\0');   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[5] == '\0');   // expected-warning{{UNDEFINED}}
+  clang_analyzer_eval(ptr[6] == '\0');   // expected-warning{{UNDEFINED}}
+}
+
+void glob_invalid_index7() {
+  int idx = -42;
+  auto x = glob_arr6[idx]; // expected-warning{{garbage or undefined}}
+}
+
+void glob_invalid_index8() {
+  const char *ptr = glob_arr6;
+  int idx = 42;
+  auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
+}
+
+char const glob_arr7[5] = {"123"};
+void glob_array_index6() {
+  clang_analyzer_eval(glob_arr7[0] == '1');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr7[1] == '2');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr7[2] == '3');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr7[3] == '\0'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr7[4] == '\0'); // expected-warning{{TRUE}}
+}
+
+void glob_invalid_index9() {
+  int idx = -42;
+  auto x = glob_arr7[idx]; // expected-warning{{garbage or undefined}}
+}
+
+void glob_invalid_index10() {
+  const char *ptr = glob_arr7;
+  int idx = 42;
+  auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
+}
+
+char const *const glob_ptr8 = "123";
+void glob_ptr_index4() {
+  clang_analyzer_eval(glob_ptr8[0] == '1');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr8[1] == '2');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr8[2] == '3');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr8[3] == '\0'); // expected-warning{{TRUE}}
+  // FIXME: Should be UNDEFINED.
+  // We should take into account a declaration in which the literal is used.
+  clang_analyzer_eval(glob_ptr8[4] == '\0'); // expected-warning{{TRUE}}
+}
+
+void glob_invalid_index11() {
+  int idx = -42;
+  auto x = glob_ptr8[idx]; // expected-warning{{garbage or undefined}}
+}
+
+void glob_invalid_index12() {
+  int idx = 42;
+  // FIXME: Should warn {{garbage or undefined}}
+  // We should take into account a declaration in which the literal is used.
+  auto x = glob_ptr8[idx]; // no-warning
+}
+
+const char16_t *const glob_ptr9 = u"абв";
+void glob_ptr_index5() {
+  clang_analyzer_eval(glob_ptr9[0] == u'а'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr9[1] == u'б'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr9[2] == u'в'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr9[3] == '\0'); // expected-warning{{TRUE}}
+}
+
+const char32_t *const glob_ptr10 = U"\U0001F607\U0001F608\U0001F609";
+void glob_ptr_index6() {
+  clang_analyzer_eval(glob_ptr10[0] == U'\U0001F607'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr10[1] == U'\U0001F608'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr10[2] == U'\U0001F609'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr10[3] == '\0');  // expected-warning{{TRUE}}
+}
+
+const wchar_t *const glob_ptr11 = L"\123\u0041\xFF";
+void glob_ptr_index7() {
+  clang_analyzer_eval(glob_ptr11[0] == L'\123');   // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr11[1] == L'\u0041'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr11[2] == L'\xFF');   // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr11[3] == L'\0'); // expected-warning{{TRUE}}
+}
+
+const char *const glob_ptr12 = u8"abc";
+void glob_ptr_index8() {
+  

[PATCH] D112299: Replace references to Makefile.sphinx

2021-10-22 Thread Sylvestre Ledru via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfd5e3f36f218: Replace references to Makefile.sphinx 
(authored by sylvestre.ledru).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112299/new/

https://reviews.llvm.org/D112299

Files:
  clang/include/clang/Basic/AttrDocs.td
  llvm/docs/README.txt


Index: llvm/docs/README.txt
===
--- llvm/docs/README.txt
+++ llvm/docs/README.txt
@@ -14,7 +14,7 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_HTML=true 
 make -j3 docs-llvm-html
-$BROWSER /docs//html/index.html
+$BROWSER /docs/html/index.html
 
 The mapping between reStructuredText files and generated documentation is
 `docs/Foo.rst` <-> `/docs//html/Foo.html` <-> 
`https://llvm.org/docs/Foo.html`.
@@ -35,7 +35,7 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true 
 make -j3 docs-llvm-man
-man -l >build-dir>/docs/man/FileCheck.1
+man -l /docs/man/FileCheck.1
 
 The correspondence between .rst files and man pages is
 `docs/CommandGuide/Foo.rst` <-> `/docs//man/Foo.1`.
@@ -49,8 +49,9 @@
 The reachability of external links in the documentation can be checked by
 running:
 
-cd docs/
-make -f Makefile.sphinx linkcheck
+cd llvm/docs/
+sphinx-build -b linkcheck . _build/lintcheck/
+# report will be generated in _build/lintcheck/output.txt
 
 Doxygen page Output
 ==
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -22,7 +22,7 @@
 // Windows (from within the clang\docs directory):
 //   make.bat html
 // Non-Windows (from within the clang\docs directory):
-//   make -f Makefile.sphinx html
+//   sphinx-build -b html _build/html
 
 def GlobalDocumentation {
   code Intro =[{..


Index: llvm/docs/README.txt
===
--- llvm/docs/README.txt
+++ llvm/docs/README.txt
@@ -14,7 +14,7 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_HTML=true 
 make -j3 docs-llvm-html
-$BROWSER /docs//html/index.html
+$BROWSER /docs/html/index.html
 
 The mapping between reStructuredText files and generated documentation is
 `docs/Foo.rst` <-> `/docs//html/Foo.html` <-> `https://llvm.org/docs/Foo.html`.
@@ -35,7 +35,7 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true 
 make -j3 docs-llvm-man
-man -l >build-dir>/docs/man/FileCheck.1
+man -l /docs/man/FileCheck.1
 
 The correspondence between .rst files and man pages is
 `docs/CommandGuide/Foo.rst` <-> `/docs//man/Foo.1`.
@@ -49,8 +49,9 @@
 The reachability of external links in the documentation can be checked by
 running:
 
-cd docs/
-make -f Makefile.sphinx linkcheck
+cd llvm/docs/
+sphinx-build -b linkcheck . _build/lintcheck/
+# report will be generated in _build/lintcheck/output.txt
 
 Doxygen page Output
 ==
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -22,7 +22,7 @@
 // Windows (from within the clang\docs directory):
 //   make.bat html
 // Non-Windows (from within the clang\docs directory):
-//   make -f Makefile.sphinx html
+//   sphinx-build -b html _build/html
 
 def GlobalDocumentation {
   code Intro =[{..
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fd5e3f3 - Replace references to Makefile.sphinx

2021-10-22 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2021-10-22T15:32:12+02:00
New Revision: fd5e3f36f2186855966978c0e11b716277eee387

URL: 
https://github.com/llvm/llvm-project/commit/fd5e3f36f2186855966978c0e11b716277eee387
DIFF: 
https://github.com/llvm/llvm-project/commit/fd5e3f36f2186855966978c0e11b716277eee387.diff

LOG: Replace references to Makefile.sphinx

and fix some typos

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D112299

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td
llvm/docs/README.txt

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 71f947687a08f..09477d6c4423d 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -22,7 +22,7 @@
 // Windows (from within the clang\docs directory):
 //   make.bat html
 // Non-Windows (from within the clang\docs directory):
-//   make -f Makefile.sphinx html
+//   sphinx-build -b html _build/html
 
 def GlobalDocumentation {
   code Intro =[{..

diff  --git a/llvm/docs/README.txt b/llvm/docs/README.txt
index c36a533fb0050..074606c7bd36e 100644
--- a/llvm/docs/README.txt
+++ b/llvm/docs/README.txt
@@ -14,7 +14,7 @@ Sphinx  and then do:
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_HTML=true 
 make -j3 docs-llvm-html
-$BROWSER /docs//html/index.html
+$BROWSER /docs/html/index.html
 
 The mapping between reStructuredText files and generated documentation is
 `docs/Foo.rst` <-> `/docs//html/Foo.html` <-> 
`https://llvm.org/docs/Foo.html`.
@@ -35,7 +35,7 @@ directory `/docs/man/`.
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true 
 make -j3 docs-llvm-man
-man -l >build-dir>/docs/man/FileCheck.1
+man -l /docs/man/FileCheck.1
 
 The correspondence between .rst files and man pages is
 `docs/CommandGuide/Foo.rst` <-> `/docs//man/Foo.1`.
@@ -49,8 +49,9 @@ Checking links
 The reachability of external links in the documentation can be checked by
 running:
 
-cd docs/
-make -f Makefile.sphinx linkcheck
+cd llvm/docs/
+sphinx-build -b linkcheck . _build/lintcheck/
+# report will be generated in _build/lintcheck/output.txt
 
 Doxygen page Output
 ==



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112292: [Clang][OpenMP] Allow loop iteration var with threadprivate directive

2021-10-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:8653
 ? (DSAStack->hasMutipleLoops() ? OMPC_lastprivate : 
OMPC_linear)
-: OMPC_private;
-if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
-  (LangOpts.OpenMP <= 45 || (DVar.CKind != OMPC_lastprivate &&
- DVar.CKind != OMPC_private))) ||
- ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
-   DKind == OMPD_master_taskloop ||
-   DKind == OMPD_parallel_master_taskloop ||
-   isOpenMPDistributeDirective(DKind)) &&
-  !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-  DVar.CKind != OMPC_private && DVar.CKind != OMPC_lastprivate)) &&
-(DVar.CKind != OMPC_private || DVar.RefExpr)) {
+: DVar.CKind == OMPC_lastprivate ? OMPC_lastprivate
+ : OMPC_private;

Why need this change?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:8662-8667
+if (LangOpts.OpenMP > 45 && isOpenMPSimdDirective(DKind)) {
+  if (DVar.CKind == OMPC_lastprivate)
+PredeterminedCKind = OMPC_lastprivate;
+  else if (DVar.CKind == OMPC_private)
+PredeterminedCKind = OMPC_private;
+}

Again, why do we need this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112292/new/

https://reviews.llvm.org/D112292

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111642: [Analyzer][solver] Simplification: reorganize equalities with adjustment

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 381520.
martong marked 3 inline comments as done.
martong added a comment.

- Add comment about intersection in the test file
- Add check in the feasible case in the test file


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111642/new/

https://reviews.llvm.org/D111642

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/solver-sym-simplification-adjustment.c

Index: clang/test/Analysis/solver-sym-simplification-adjustment.c
===
--- /dev/null
+++ clang/test/Analysis/solver-sym-simplification-adjustment.c
@@ -0,0 +1,85 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -verify
+
+void clang_analyzer_warnIfReached();
+void clang_analyzer_eval();
+
+void test_simplification_adjustment_concrete_int(int b, int c) {
+  if (b < 0 || b > 1)  // b: [0,1]
+return;
+  if (c < -1 || c > 1) // c: [-1,1]
+return;
+  if (c + b != 0)  // c + b == 0
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (b != 1)  // b == 1  --> c + 1 == 0 --> c == -1
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  clang_analyzer_eval(c == -1);   // expected-warning{{TRUE}}
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
+
+void test_simplification_adjustment_range(int b, int c) {
+  if (b < 0 || b > 1)  // b: [0,1]
+return;
+  if (c < -1 || c > 1) // c: [-1,1]
+return;
+  if (c + b < -1 || c + b > 0) // c + b: [-1,0]
+return;
+  clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  if (b != 1)  // b == 1  --> c + 1: [-1,0] --> c: [-2,-1]
+return;
+   // c: [-2,-1] is intersected with the
+   // already associated range which is [-1,1],
+   // thus we get c: [-1,-1]
+  clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  clang_analyzer_eval(c == -1);// expected-warning{{TRUE}}
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
+
+void test_simplification_adjustment_to_infeasible_concrete_int(int b, int c) {
+  if (b < 0 || b > 1) // b: [0,1]
+return;
+  if (c < 0 || c > 1) // c: [0,1]
+return;
+  if (c + b != 0) // c + b == 0
+return;
+  clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
+  if (b != 1) {   // b == 1  --> c + 1 == 0 --> c == -1 contradiction
+clang_analyzer_eval(b == 0);  // expected-warning{{TRUE}}
+// Keep the symbols and the constraints! alive.
+(void)(b * c);
+return;
+  }
+  clang_analyzer_warnIfReached(); // no warning
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
+
+void test_simplification_adjustment_to_infeassible_range(int b, int c) {
+  if (b < 0 || b > 1)  // b: [0,1]
+return;
+  if (c < 0 || c > 1)  // c: [0,1]
+return;
+  if (c + b < -1 || c + b > 0) // c + b: [-1,0]
+return;
+  clang_analyzer_warnIfReached();  // expected-warning{{REACHABLE}}
+  if (b != 1)  // b == 1  --> c + 1: [-1,0] --> c: [-2,-1] contradiction
+return;
+  clang_analyzer_warnIfReached();  // no warning
+
+  // Keep the symbols and the constraints! alive.
+  (void)(b * c);
+  return;
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -602,10 +602,9 @@
   areEqual(ProgramStateRef State, SymbolRef First, SymbolRef Second);
 
   /// Iterate over all symbols and try to simplify them.
-  LLVM_NODISCARD static inline ProgramStateRef simplify(SValBuilder ,
-RangeSet::Factory ,
-ProgramStateRef State,
-EquivalenceClass Class);
+  LLVM_NODISCARD static inline ProgramStateRef
+  simplify(SValBuilder , RangeSet::Factory , RangedConstraintManager ,
+   ProgramStateRef State, EquivalenceClass Class);
 
   void dumpToStream(ProgramStateRef State, raw_ostream ) const;
   LLVM_DUMP_METHOD void dump(ProgramStateRef State) const {
@@ -1710,7 +1709,8 @@
   ClassMembersTy Members = State->get();
   for (std::pair ClassToSymbolSet : Members) {
 EquivalenceClass Class = ClassToSymbolSet.first;
-State = EquivalenceClass::simplify(Builder, RangeFactory, State, Class);
+State =
+EquivalenceClass::simplify(Builder, RangeFactory, RCM, State, Class);
 if 

[PATCH] D112299: Replace references to Makefile.sphinx

2021-10-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112299/new/

https://reviews.llvm.org/D112299

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111992: [MLIR][OpenMP] Added omp.atomic.read and omp.atomic.write

2021-10-22 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan accepted this revision.
kiranchandramohan added a comment.
This revision is now accepted and ready to land.

LGTM.

My preference is the following one. If you agree then please make the change, 
otherwise, you can keep it as is. Also, wait a couple of days to see whether 
others have comments.

  %8 = omp.atomic.read %addr hint(speculative, contended) memory_order(seq_cst) 
: memref -> i32


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111992/new/

https://reviews.llvm.org/D111992

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D106102#3080339 , @manas wrote:

> I have received a failed build on clang-ppc64be-linux 
> (https://lab.llvm.org/buildbot/#/builders/52/builds/11704). Although, I 
> haven't verified the commit. Is there something wrong with this commit? Is 
> the function VisitBinaryOperator reachable?

No worries, that seems to be a test suite python error that is unrelated:

  Traceback (most recent call last):
File 
"/home/buildbots/ppc64be-clang-test/clang-ppc64be/llvm/llvm/utils/lit/lit.py", 
line 6, in 
  main()
File 
"/home/buildbots/ppc64be-clang-test/clang-ppc64be/llvm/llvm/utils/lit/lit/main.py",
 line 44, in main
  opts.indirectlyRunCheck)
File 
"/home/buildbots/ppc64be-clang-test/clang-ppc64be/llvm/llvm/utils/lit/lit/discovery.py",
 line 279, in find_tests_for_inputs
  local_config_cache, indirectlyRunCheck)[1])
File 
"/home/buildbots/ppc64be-clang-test/clang-ppc64be/llvm/llvm/utils/lit/lit/discovery.py",
 line 130, in getTests
  ts,path_in_suite = getTestSuite(path, litConfig, testSuiteCache)
File 
"/home/buildbots/ppc64be-clang-test/clang-ppc64be/llvm/llvm/utils/lit/lit/discovery.py",
 line 91, in getTestSuite
  ts, relative = search(item)
File 
"/home/buildbots/ppc64be-clang-test/clang-ppc64be/llvm/llvm/utils/lit/lit/discovery.py",
 line 75, in search
  cache[real_path] = res = search1(path)
File "/home/buildbots/ppc64be-clang-test/clang-ppc64be/l


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106102/new/

https://reviews.llvm.org/D106102

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111790: [AArch64][Driver][SVE] Allow -msve-vector-bits=+ syntax to mean no maximum vscale

2021-10-22 Thread Bradley Smith via Phabricator via cfe-commits
bsmith updated this revision to Diff 381511.
bsmith added a comment.

- Don't define SVE target bits macros when vscale min != max
- Add tests for above change
- Use correct (unsigned) version of getAsInteger


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111790/new/

https://reviews.llvm.org/D111790

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp
  clang/test/CodeGen/aarch64-sve-vector-bits-codegen.c
  clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
  clang/test/CodeGenCXX/aarch64-mangle-sve-fixed-vectors.cpp
  clang/test/CodeGenCXX/aarch64-sve-fixedtypeinfo.cpp
  clang/test/Driver/aarch64-sve-vector-bits.c
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
  clang/test/Sema/aarch64-sve-lax-vector-conversions.c
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
  clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
  clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Index: clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
===
--- clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
+++ clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -std=c++11 -msve-vector-bits=512 -fallow-half-arguments-and-returns -Wconversion %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -std=c++11 -mvscale-min=4 -mvscale-max=4 -fallow-half-arguments-and-returns -Wconversion %s
 // expected-no-diagnostics
 
 #include 
Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===
--- clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -mvscale-min=4 -mvscale-max=4 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
 
 #include 
 
Index: clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
===
--- clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
+++ clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature 

[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-10-22 Thread Manas Gupta via Phabricator via cfe-commits
manas added a comment.

I have received a failed build on clang-ppc64be-linux 
(https://lab.llvm.org/buildbot/#/builders/52/builds/11704). Although, I haven't 
verified the commit. Is there something wrong with this commit? Is the function 
VisitBinaryOperator reachable?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106102/new/

https://reviews.llvm.org/D106102

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 49e1753 - Mark baremetal.cpp test as unsupported on Windows.

2021-10-22 Thread Kristof Beyls via cfe-commits

Author: Kristof Beyls
Date: 2021-10-22T11:46:50+01:00
New Revision: 49e1753c5ef9dbedfca890992cd25a70e2cbb470

URL: 
https://github.com/llvm/llvm-project/commit/49e1753c5ef9dbedfca890992cd25a70e2cbb470
DIFF: 
https://github.com/llvm/llvm-project/commit/49e1753c5ef9dbedfca890992cd25a70e2cbb470.diff

LOG: Mark baremetal.cpp test as unsupported on Windows.

A new check was added in 3b93dc68, which seems to not be possible to get
working correctly on windows systems:

The test first "captures" the install directory of the clang toolchain
running the test as follows:
// CHECK-AARCH64-NO-HOST-INC: InstalledDir: [[INSTALLEDDIR:.+]]
Then, in a check line a bit later, it uses this to check if a particular
directory in the toolchain installation directory is included when
targeting aarch64-none-elf:
// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}aarch64-none-elf{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"

Even though the test aims to take into account forward vs backward slash
differences between Windows and Unix paths, it still fails on Windows.

It seems that on Windows (this is based on the output log from a Windows
bot), the INSTALLEDDIR variable has the following value:

note: with "INSTALLEDDIR" equal to 
"c:bslaveclang-x64-windows-msvcbuildstage1bin"

However the actual "InstalledDir:" output produced by the clang
toolchain on that Windows bot was:

InstalledDir: c:\b\slave\clang-x64-windows-msvc\build\stage1\bin

It is unclear where the explosion of backslashes happens. Maybe this is
a bug in FileCheck somewhere?
Anyway, marking this test as not supported on Windows to make the bots
green again.

Added: 


Modified: 
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index 131f2f76e1f6..7c11fe67155a 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -1,3 +1,5 @@
+// UNSUPPORTED: system-windows
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: -T semihosted.lds \



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110833: [clang-format] Refactor SpaceBeforeParens to add flags

2021-10-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Fundamentally this looks ok to me, the biggest concern is fathoming out the 
change in TokenAnnotator.cpp to mean the same thing, but I think that is what 
the tests should be for I think.

One think I do is use the output of this

https://clang.llvm.org/docs/ClangFormattedStatus.html

it creates a file in `clang/docs/tools/clang-formatted-files.txt` these are all 
the files that when we last checked were 100% clang-formatted (all 7949) of 
them..

Now be careful because people don't always maintain that clean status (naughty 
them!), but I use to ensure I'm not breaking clang-format (for at least the 
default LLVM style)

so build your own clang-format and then in the llvm-project directory I run

  clang-format -verbose -n -files clang/docs/tools/clang-formatted-files.txt

This will check all the files (reasonably quickly YMMV)

  $ clang-format -verbose -n -files clang/docs/tools/clang-formatted-files.txt
  Clang-formating 7950 files
  Formatting [1/7949] clang/bindings/python/tests/cindex/INPUTS/header1.h
  Formatting [2/7949] clang/bindings/python/tests/cindex/INPUTS/header2.h
  Formatting [3/7949] clang/bindings/python/tests/cindex/INPUTS/header3.h
  Formatting [4/7949] clang/examples/Attribute/Attribute.cpp
  Formatting [5/7949] clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp
  Formatting [6/7949] clang/include/clang/Analysis/AnalysisDiagnostic.h
  Formatting [7/7949] clang/include/clang/Analysis/BodyFarm.h
  

if your (or they more likely) have broken anything then you'll get a warning 
(in this case it was their fault)

  Formatting [134/7949] 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h:19:16: 
warning: code should be clang-formatted [-Wclang-format-violations]
  namespace clang{

But this is a good way of giving clang-format a quick check to ensure its not 
broken anything (over large code base) - You will get failures (as this file is 
out of date)




Comment at: clang/include/clang/Format/Format.h:3416
+  /// \version 14
+  SpaceBeforeParensCustom SpaceBeforeParensFlags;
+

HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > I'm not a massive fan of the word `Flags` here and thoughts?
> Yeah, neither, but Options is taken.
> 
> But Flags indicate that these will always be booleans, and we know that may 
> change in the future.
> 
> Is it possible the reuse SpaceBeforeParensOptions as struct and still parse 
> the old enum? (Yes of course, but is it feasible in terms of needed work?)
but "Options" as in SpaceBeforeParensOptions  is the type not the name so we 
could use SpaceBeforeParensOptions 

personally I would change the typename of SpaceBeforeParensOptions  to avoid 
confusion but its not essential as it would be 

`SpaceBeforeParensCustom  SpaceBeforeParensOptions;`

for me I sometimes like using Struct anyway

`SpaceBeforeParensStruct SpaceBeforeParensOptions;`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110833/new/

https://reviews.llvm.org/D110833

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

I've fixed the compilation error and pushed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106102/new/

https://reviews.llvm.org/D106102

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106102: [analyzer][solver] Introduce reasoning for not equal to operator

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcac8808f154c: [analyzer][solver] Introduce reasoning for not 
equal to operator (authored by manas, committed by martong).

Changed prior to commit:
  https://reviews.llvm.org/D106102?vs=376363=381496#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106102/new/

https://reviews.llvm.org/D106102

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constant-folding.c

Index: clang/test/Analysis/constant-folding.c
===
--- clang/test/Analysis/constant-folding.c
+++ clang/test/Analysis/constant-folding.c
@@ -281,3 +281,49 @@
 clang_analyzer_eval((b % a) < x + 10); // expected-warning{{TRUE}}
   }
 }
+
+void testDisequalityRules(unsigned int u1, unsigned int u2, int s1, int s2) {
+  // Checks when ranges are not overlapping
+  if (u1 <= 10 && u2 >= 20) {
+// u1: [0,10], u2: [20,UINT_MAX]
+clang_analyzer_eval((u1 != u2) != 0); // expected-warning{{TRUE}}
+  }
+
+  if (s1 <= INT_MIN + 10 && s2 >= INT_MAX - 10) {
+// s1: [INT_MIN,INT_MIN + 10], s2: [INT_MAX - 10,INT_MAX]
+clang_analyzer_eval((s1 != s2) == 0); // expected-warning{{FALSE}}
+  }
+
+  // Checks when ranges are completely overlapping and have more than one point
+  if (u1 >= 20 && u1 <= 50 && u2 >= 20 && u2 <= 50) {
+// u1: [20,50], u2: [20,50]
+clang_analyzer_eval((u1 != u2) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (s1 >= -20 && s1 <= 20 && s2 >= -20 && s2 <= 20) {
+// s1: [-20,20], s2: [-20,20]
+clang_analyzer_eval((s1 != s2) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks when ranges are partially overlapping
+  if (u1 >= 100 && u1 <= 200 && u2 >= 150 && u2 <= 300) {
+// u1: [100,200], u2: [150,300]
+clang_analyzer_eval((u1 != u2) != 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (s1 >= -80 && s1 <= -50 && s2 >= -100 && s2 <= -75) {
+// s1: [-80,-50], s2: [-100,-75]
+clang_analyzer_eval((s1 != s2) == 0); // expected-warning{{UNKNOWN}}
+  }
+
+  // Checks for ranges which are subset of one-another
+  if (u1 >= 500 && u1 <= 1000 && u2 >= 750 && u2 <= 1000) {
+// u1: [500,1000], u2: [750,1000]
+clang_analyzer_eval((u1 != u2) == 0); // expected-warning{{UNKNOWN}}
+  }
+
+  if (s1 >= -1000 && s1 <= -500 && s2 <= -500 && s2 >= -750) {
+// s1: [-1000,-500], s2: [-500,-750]
+clang_analyzer_eval((s1 != s2) == 0); // expected-warning{{UNKNOWN}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -20,8 +20,8 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -955,18 +955,7 @@
   }
 
   RangeSet VisitBinaryOperator(RangeSet LHS, BinaryOperator::Opcode Op,
-   RangeSet RHS, QualType T) {
-switch (Op) {
-case BO_Or:
-  return VisitBinaryOperator(LHS, RHS, T);
-case BO_And:
-  return VisitBinaryOperator(LHS, RHS, T);
-case BO_Rem:
-  return VisitBinaryOperator(LHS, RHS, T);
-default:
-  return infer(T);
-}
-  }
+   RangeSet RHS, QualType T);
 
   //===--===//
   // Ranges and operators
@@ -1231,6 +1220,29 @@
 //   Range-based reasoning about symbolic operations
 //===--===//
 
+template <>
+RangeSet SymbolicRangeInferrer::VisitBinaryOperator(RangeSet LHS,
+   RangeSet RHS,
+   QualType T) {
+  // When both the RangeSets are non-overlapping then all possible pairs of
+  // (x, y) in LHS, RHS respectively, will satisfy expression (x != y).
+  if ((LHS.getMaxValue() < RHS.getMinValue()) ||
+  (LHS.getMinValue() > RHS.getMaxValue())) {
+return getTrueRange(T);
+  }
+
+  // If both RangeSets contain only one Point which is equal then the
+  // expression will always return true.
+  if ((LHS.getMinValue() == RHS.getMaxValue()) &&
+  (LHS.getMaxValue() == RHS.getMaxValue()) &&
+  (LHS.getMinValue() == RHS.getMinValue())) {
+return getFalseRange(T);
+  }
+
+  // In all other cases, the resulting range cannot be deduced.
+  return infer(T);
+}
+
 template <>
 RangeSet SymbolicRangeInferrer::VisitBinaryOperator(Range LHS, Range RHS,
QualType T) {

[clang] cac8808 - [analyzer][solver] Introduce reasoning for not equal to operator

2021-10-22 Thread Gabor Marton via cfe-commits

Author: Manas
Date: 2021-10-22T12:00:08+02:00
New Revision: cac8808f154cef6446e507d55aba5721c3bd5352

URL: 
https://github.com/llvm/llvm-project/commit/cac8808f154cef6446e507d55aba5721c3bd5352
DIFF: 
https://github.com/llvm/llvm-project/commit/cac8808f154cef6446e507d55aba5721c3bd5352.diff

LOG: [analyzer][solver] Introduce reasoning for not equal to operator

Prior to this, the solver was only able to verify whether two symbols
are equal/unequal, only when constants were involved. This patch allows
the solver to work over ranges as well.

Reviewed By: steakhal, martong

Differential Revision: https://reviews.llvm.org/D106102

Patch by: @manas (Manas Gupta)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/test/Analysis/constant-folding.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index e75a207ee86a..2f69191a1792 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -20,8 +20,8 @@
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/ImmutableSet.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -955,18 +955,7 @@ class SymbolicRangeInferrer
   }
 
   RangeSet VisitBinaryOperator(RangeSet LHS, BinaryOperator::Opcode Op,
-   RangeSet RHS, QualType T) {
-switch (Op) {
-case BO_Or:
-  return VisitBinaryOperator(LHS, RHS, T);
-case BO_And:
-  return VisitBinaryOperator(LHS, RHS, T);
-case BO_Rem:
-  return VisitBinaryOperator(LHS, RHS, T);
-default:
-  return infer(T);
-}
-  }
+   RangeSet RHS, QualType T);
 
   
//===--===//
   // Ranges and operators
@@ -1231,6 +1220,29 @@ class SymbolicRangeInferrer
 //   Range-based reasoning about symbolic operations
 
//===--===//
 
+template <>
+RangeSet SymbolicRangeInferrer::VisitBinaryOperator(RangeSet LHS,
+   RangeSet RHS,
+   QualType T) {
+  // When both the RangeSets are non-overlapping then all possible pairs of
+  // (x, y) in LHS, RHS respectively, will satisfy expression (x != y).
+  if ((LHS.getMaxValue() < RHS.getMinValue()) ||
+  (LHS.getMinValue() > RHS.getMaxValue())) {
+return getTrueRange(T);
+  }
+
+  // If both RangeSets contain only one Point which is equal then the
+  // expression will always return true.
+  if ((LHS.getMinValue() == RHS.getMaxValue()) &&
+  (LHS.getMaxValue() == RHS.getMaxValue()) &&
+  (LHS.getMinValue() == RHS.getMinValue())) {
+return getFalseRange(T);
+  }
+
+  // In all other cases, the resulting range cannot be deduced.
+  return infer(T);
+}
+
 template <>
 RangeSet SymbolicRangeInferrer::VisitBinaryOperator(Range LHS, Range 
RHS,
QualType T) {
@@ -1391,6 +1403,23 @@ RangeSet 
SymbolicRangeInferrer::VisitBinaryOperator(Range LHS,
   return {RangeFactory, ValueFactory.getValue(Min), 
ValueFactory.getValue(Max)};
 }
 
+RangeSet SymbolicRangeInferrer::VisitBinaryOperator(RangeSet LHS,
+BinaryOperator::Opcode Op,
+RangeSet RHS, QualType T) {
+  switch (Op) {
+  case BO_NE:
+return VisitBinaryOperator(LHS, RHS, T);
+  case BO_Or:
+return VisitBinaryOperator(LHS, RHS, T);
+  case BO_And:
+return VisitBinaryOperator(LHS, RHS, T);
+  case BO_Rem:
+return VisitBinaryOperator(LHS, RHS, T);
+  default:
+return infer(T);
+  }
+}
+
 
//===--===//
 //  Constraint manager implementation details
 
//===--===//

diff  --git a/clang/test/Analysis/constant-folding.c 
b/clang/test/Analysis/constant-folding.c
index 116e74b746b4..9dab78e3e198 100644
--- a/clang/test/Analysis/constant-folding.c
+++ b/clang/test/Analysis/constant-folding.c
@@ -281,3 +281,49 @@ void testRemainderRules(unsigned int a, unsigned int b, 
int c, int d) {
 clang_analyzer_eval((b % a) < x + 10); // expected-warning{{TRUE}}
   }
 }
+
+void testDisequalityRules(unsigned int u1, unsigned int u2, int s1, int s2) {
+  // Checks when ranges are not overlapping
+  if (u1 <= 10 && u2 >= 20) {
+// u1: [0,10], u2: [20,UINT_MAX]
+clang_analyzer_eval((u1 != u2) 

[PATCH] D110833: [clang-format] Refactor SpaceBeforeParens to add flags

2021-10-22 Thread Christian Rayroud via Phabricator via cfe-commits
crayroud added inline comments.



Comment at: clang/include/clang/Format/Format.h:3422
   ///true:  false:
-  ///for (auto v : values) {}   vs. for(auto v: values) {}
+  ///for (auto v : values) {}   vs. for (auto v: values) {}
   /// \endcode

HazardyKnusperkeks wrote:
> Please remove again. :)
I changed the documentation to have a space added or removed only before the 
for loop colon. Indeed the space after the for is handled by 
SpaceBeforeParens... and not SpaceBeforeRangeBasedForLoopColon. Why do you 
think it is better to keep it as before ?



Comment at: clang/lib/Format/Format.cpp:1221
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
+  LLVMStyle.SpaceBeforeParensFlags.AfterControlStatements = true;
+  LLVMStyle.SpaceBeforeParensFlags.AfterOperators = true;

HazardyKnusperkeks wrote:
> Is this needed? Shouldn't the expand take care of that?
Indeed the expand takes care of that and it would be nice not to have to repeat 
it here.
I had to add it for the test FormatTest.ConfigurationRoundTripTest, as it is 
done for LLVMStyle.BraceWrapping.
What do you think is best ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110833/new/

https://reviews.llvm.org/D110833

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e5b87fb - Fix baremetal.cpp test to handle windows paths.

2021-10-22 Thread Kristof Beyls via cfe-commits

Author: Kristof Beyls
Date: 2021-10-22T10:24:04+01:00
New Revision: e5b87fb7222c0f16ca52c6e72540ed24c204638a

URL: 
https://github.com/llvm/llvm-project/commit/e5b87fb7222c0f16ca52c6e72540ed24c204638a
DIFF: 
https://github.com/llvm/llvm-project/commit/e5b87fb7222c0f16ca52c6e72540ed24c204638a.diff

LOG: Fix baremetal.cpp test to handle windows paths.

Added: 


Modified: 
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index 74208968f92e..131f2f76e1f6 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -108,9 +108,9 @@
 // Verify that the bare metal driver does not include any host system paths:
 // CHECK-AARCH64-NO-HOST-INC: InstalledDir: [[INSTALLEDDIR:.+]]
 // CHECK-AARCH64-NO-HOST-INC: "-resource-dir" "[[RESOURCE:[^"]+]]"
-// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include/c++/v1"
-// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[RESOURCE]]/include"
-// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}aarch64-none-elf{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[RESOURCE]]{{[/\\]+}}include"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[INSTALLEDDIR]]{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}aarch64-none-elf{{[/\\]+}}include"
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target riscv64-unknown-elf \



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112299: Replace references to Makefile.sphinx

2021-10-22 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
sylvestre.ledru added a reviewer: tstellar.
Herald added a reviewer: aaron.ballman.
sylvestre.ledru requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

and fix some typos


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112299

Files:
  clang/include/clang/Basic/AttrDocs.td
  llvm/docs/README.txt


Index: llvm/docs/README.txt
===
--- llvm/docs/README.txt
+++ llvm/docs/README.txt
@@ -14,7 +14,7 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_HTML=true 
 make -j3 docs-llvm-html
-$BROWSER /docs//html/index.html
+$BROWSER /docs/html/index.html
 
 The mapping between reStructuredText files and generated documentation is
 `docs/Foo.rst` <-> `/docs//html/Foo.html` <-> 
`https://llvm.org/docs/Foo.html`.
@@ -35,7 +35,7 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true 
 make -j3 docs-llvm-man
-man -l >build-dir>/docs/man/FileCheck.1
+man -l /docs/man/FileCheck.1
 
 The correspondence between .rst files and man pages is
 `docs/CommandGuide/Foo.rst` <-> `/docs//man/Foo.1`.
@@ -49,8 +49,9 @@
 The reachability of external links in the documentation can be checked by
 running:
 
-cd docs/
-make -f Makefile.sphinx linkcheck
+cd llvm/docs/
+sphinx-build -b linkcheck . _build/lintcheck/
+# report will be generated in _build/lintcheck/output.txt
 
 Doxygen page Output
 ==
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -22,7 +22,7 @@
 // Windows (from within the clang\docs directory):
 //   make.bat html
 // Non-Windows (from within the clang\docs directory):
-//   make -f Makefile.sphinx html
+//   sphinx-build -b html _build/html
 
 def GlobalDocumentation {
   code Intro =[{..


Index: llvm/docs/README.txt
===
--- llvm/docs/README.txt
+++ llvm/docs/README.txt
@@ -14,7 +14,7 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_HTML=true 
 make -j3 docs-llvm-html
-$BROWSER /docs//html/index.html
+$BROWSER /docs/html/index.html
 
 The mapping between reStructuredText files and generated documentation is
 `docs/Foo.rst` <-> `/docs//html/Foo.html` <-> `https://llvm.org/docs/Foo.html`.
@@ -35,7 +35,7 @@
 cd 
 cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true 
 make -j3 docs-llvm-man
-man -l >build-dir>/docs/man/FileCheck.1
+man -l /docs/man/FileCheck.1
 
 The correspondence between .rst files and man pages is
 `docs/CommandGuide/Foo.rst` <-> `/docs//man/Foo.1`.
@@ -49,8 +49,9 @@
 The reachability of external links in the documentation can be checked by
 running:
 
-cd docs/
-make -f Makefile.sphinx linkcheck
+cd llvm/docs/
+sphinx-build -b linkcheck . _build/lintcheck/
+# report will be generated in _build/lintcheck/output.txt
 
 Doxygen page Output
 ==
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -22,7 +22,7 @@
 // Windows (from within the clang\docs directory):
 //   make.bat html
 // Non-Windows (from within the clang\docs directory):
-//   make -f Makefile.sphinx html
+//   sphinx-build -b html _build/html
 
 def GlobalDocumentation {
   code Intro =[{..
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112030: [docs] Remove Makefile.sphinx files

2021-10-22 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Adjustment made on my side:
https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/-/commit/daf38c1634954d9aad7a1393eef0828c57f41a53

@tstellar  Maybe you could add this to the release notes? (I think others are 
probably using it)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112030/new/

https://reviews.llvm.org/D112030

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
martong marked an inline comment as done.
Closed by commit rG5f8dca023504: [Analyzer] Extend ConstraintAssignor to handle 
remainder op (authored by martong).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110357/new/

https://reviews.llvm.org/D110357

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint-assignor.c

Index: clang/test/Analysis/constraint-assignor.c
===
--- /dev/null
+++ clang/test/Analysis/constraint-assignor.c
@@ -0,0 +1,69 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -verify
+
+// expected-no-diagnostics
+
+void clang_analyzer_warnIfReached();
+
+void rem_constant_rhs_ne_zero(int x, int y) {
+  if (x % 3 == 0) // x % 3 != 0 -> x != 0
+return;
+  if (x * y != 0) // x * y == 0
+return;
+  if (y != 1) // y == 1 -> x == 0
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_symbolic_rhs_ne_zero(int x, int y, int z) {
+  if (x % z == 0) // x % z != 0 -> x != 0
+return;
+  if (x * y != 0) // x * y == 0
+return;
+  if (y != 1) // y == 1 -> x == 0
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_symbolic_rhs_ne_zero_nested(int w, int x, int y, int z) {
+  if (w % x % z == 0) // w % x % z != 0 -> w % x != 0
+return;
+  if (w % x * y != 0) // w % x * y == 0
+return;
+  if (y != 1) // y == 1 -> w % x == 0
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)(w * x); // keep the constraints alive.
+}
+
+void rem_constant_rhs_ne_zero_early_contradiction(int x, int y) {
+  if ((x + y) != 0) // (x + y) == 0
+return;
+  if ((x + y) % 3 == 0) // (x + y) % 3 != 0 -> (x + y) != 0 -> contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_symbolic_rhs_ne_zero_early_contradiction(int x, int y, int z) {
+  if ((x + y) != 0) // (x + y) == 0
+return;
+  if ((x + y) % z == 0) // (x + y) % z != 0 -> (x + y) != 0 -> contradiction
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void internal_unsigned_signed_mismatch(unsigned a) {
+  int d = a;
+  // Implicit casts are not handled, thus the analyzer models `d % 2` as
+  // `(reg_$0) % 2`
+  // However, this should not result in internal signedness mismatch error when
+  // we assign new constraints below.
+  if (d % 2 != 0)
+return;
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1610,7 +1610,28 @@
 return Assignor.assign(CoS, NewConstraint);
   }
 
+  /// Handle expressions like: a % b != 0.
+  template 
+  bool handleRemainderOp(const SymT *Sym, RangeSet Constraint) {
+if (Sym->getOpcode() != BO_Rem)
+  return true;
+const SymbolRef LHS = Sym->getLHS();
+const llvm::APSInt  =
+Builder.getBasicValueFactory().getValue(0, Sym->getType());
+// a % b != 0 implies that a != 0.
+if (!Constraint.containsZero()) {
+  State = RCM.assumeSymNE(State, LHS, Zero, Zero);
+  if (!State)
+return false;
+}
+return true;
+  }
+
   inline bool assignSymExprToConst(const SymExpr *Sym, Const Constraint);
+  inline bool assignSymIntExprToRangeSet(const SymIntExpr *Sym,
+ RangeSet Constraint) {
+return handleRemainderOp(Sym, Constraint);
+  }
   inline bool assignSymSymExprToRangeSet(const SymSymExpr *Sym,
  RangeSet Constraint);
 
@@ -1688,9 +1709,7 @@
 if (Constraint.getConcreteValue())
   return !Constraint.getConcreteValue()->isZero();
 
-APSIntType T{Constraint.getMinValue()};
-Const Zero = T.getZeroValue();
-if (!Constraint.contains(Zero))
+if (!Constraint.containsZero())
   return true;
 
 return llvm::None;
@@ -1734,6 +1753,9 @@
 
 bool ConstraintAssignor::assignSymSymExprToRangeSet(const SymSymExpr *Sym,
 RangeSet Constraint) {
+  if (!handleRemainderOp(Sym, Constraint))
+return false;
+
   Optional ConstraintAsBool = interpreteAsBool(Constraint);
 
   if (!ConstraintAsBool)
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h

[clang] 5f8dca0 - [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-22 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-10-22T10:47:25+02:00
New Revision: 5f8dca023504ed21490a40ddc3a0241029782910

URL: 
https://github.com/llvm/llvm-project/commit/5f8dca023504ed21490a40ddc3a0241029782910
DIFF: 
https://github.com/llvm/llvm-project/commit/5f8dca023504ed21490a40ddc3a0241029782910.diff

LOG: [Analyzer] Extend ConstraintAssignor to handle remainder op

Summary:
`a % b != 0` implies that `a != 0` for any `a` and `b`. This patch
extends the ConstraintAssignor to do just that. In fact, we could do
something similar with division and in case of multiplications we could
have some other inferences, but I'd like to keep these for future
patches.

Fixes https://bugs.llvm.org/show_bug.cgi?id=51940

Reviewers: noq, vsavchenko, steakhal, szelethus, asdenyspetrov

Subscribers:

Differential Revision: https://reviews.llvm.org/D110357

Added: 
clang/test/Analysis/constraint-assignor.c

Modified: 

clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
index 599e4ec812a1b..153b8a732166f 100644
--- 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -282,6 +282,11 @@ class RangeSet {
   /// where N = size(this)
   bool contains(llvm::APSInt Point) const { return containsImpl(Point); }
 
+  bool containsZero() const {
+APSIntType T{getMinValue()};
+return contains(T.getZeroValue());
+  }
+
   void dump(raw_ostream ) const;
   void dump() const;
 

diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 7df9027b373d9..e75a207ee86ab 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1610,7 +1610,28 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
 return Assignor.assign(CoS, NewConstraint);
   }
 
+  /// Handle expressions like: a % b != 0.
+  template 
+  bool handleRemainderOp(const SymT *Sym, RangeSet Constraint) {
+if (Sym->getOpcode() != BO_Rem)
+  return true;
+const SymbolRef LHS = Sym->getLHS();
+const llvm::APSInt  =
+Builder.getBasicValueFactory().getValue(0, Sym->getType());
+// a % b != 0 implies that a != 0.
+if (!Constraint.containsZero()) {
+  State = RCM.assumeSymNE(State, LHS, Zero, Zero);
+  if (!State)
+return false;
+}
+return true;
+  }
+
   inline bool assignSymExprToConst(const SymExpr *Sym, Const Constraint);
+  inline bool assignSymIntExprToRangeSet(const SymIntExpr *Sym,
+ RangeSet Constraint) {
+return handleRemainderOp(Sym, Constraint);
+  }
   inline bool assignSymSymExprToRangeSet(const SymSymExpr *Sym,
  RangeSet Constraint);
 
@@ -1688,9 +1709,7 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
 if (Constraint.getConcreteValue())
   return !Constraint.getConcreteValue()->isZero();
 
-APSIntType T{Constraint.getMinValue()};
-Const Zero = T.getZeroValue();
-if (!Constraint.contains(Zero))
+if (!Constraint.containsZero())
   return true;
 
 return llvm::None;
@@ -1734,6 +1753,9 @@ bool ConstraintAssignor::assignSymExprToConst(const 
SymExpr *Sym,
 
 bool ConstraintAssignor::assignSymSymExprToRangeSet(const SymSymExpr *Sym,
 RangeSet Constraint) {
+  if (!handleRemainderOp(Sym, Constraint))
+return false;
+
   Optional ConstraintAsBool = interpreteAsBool(Constraint);
 
   if (!ConstraintAsBool)

diff  --git a/clang/test/Analysis/constraint-assignor.c 
b/clang/test/Analysis/constraint-assignor.c
new file mode 100644
index 0..1c041e3e0ce45
--- /dev/null
+++ b/clang/test/Analysis/constraint-assignor.c
@@ -0,0 +1,69 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -verify
+
+// expected-no-diagnostics
+
+void clang_analyzer_warnIfReached();
+
+void rem_constant_rhs_ne_zero(int x, int y) {
+  if (x % 3 == 0) // x % 3 != 0 -> x != 0
+return;
+  if (x * y != 0) // x * y == 0
+return;
+  if (y != 1) // y == 1 -> x == 0
+return;
+  clang_analyzer_warnIfReached(); // no-warning
+  (void)x; // keep the constraints alive.
+}
+
+void rem_symbolic_rhs_ne_zero(int x, int y, int z) {
+  if (x % z == 0) // x % z != 0 -> x != 0
+return;
+  if (x * y != 0) // x * y == 0
+return;
+  if (y != 1) // y == 1 -> x == 0
+return;
+  

[PATCH] D111640: [Analyzer][NFC] Add RangedConstraintManager to ConstraintAssignor

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe2a2c8328f57: [Analyzer][NFC] Add RangedConstraintManager to 
ConstraintAssignor (authored by martong).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111640/new/

https://reviews.llvm.org/D111640

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1600,12 +1600,13 @@
 public:
   template 
   LLVM_NODISCARD static ProgramStateRef
-  assign(ProgramStateRef State, SValBuilder , RangeSet::Factory ,
- ClassOrSymbol CoS, RangeSet NewConstraint) {
+  assign(ProgramStateRef State, RangeConstraintManager ,
+ SValBuilder , RangeSet::Factory , ClassOrSymbol CoS,
+ RangeSet NewConstraint) {
 if (!State || NewConstraint.isEmpty())
   return nullptr;
 
-ConstraintAssignor Assignor{State, Builder, F};
+ConstraintAssignor Assignor{State, RCM, Builder, F};
 return Assignor.assign(CoS, NewConstraint);
   }
 
@@ -1614,9 +1615,9 @@
  RangeSet Constraint);
 
 private:
-  ConstraintAssignor(ProgramStateRef State, SValBuilder ,
- RangeSet::Factory )
-  : State(State), Builder(Builder), RangeFactory(F) {}
+  ConstraintAssignor(ProgramStateRef State, RangeConstraintManager ,
+ SValBuilder , RangeSet::Factory )
+  : State(State), RCM(RCM), Builder(Builder), RangeFactory(F) {}
   using Base = ConstraintAssignorBase;
 
   /// Base method for handling new constraints for symbols.
@@ -1696,6 +1697,7 @@
   }
 
   ProgramStateRef State;
+  RangeConstraintManager 
   SValBuilder 
   RangeSet::Factory 
 };
@@ -2420,7 +2422,8 @@
 ProgramStateRef RangeConstraintManager::setRange(ProgramStateRef State,
  SymbolRef Sym,
  RangeSet Range) {
-  return ConstraintAssignor::assign(State, getSValBuilder(), F, Sym, Range);
+  return ConstraintAssignor::assign(State, *this, getSValBuilder(), F, Sym,
+Range);
 }
 
 
//======


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1600,12 +1600,13 @@
 public:
   template 
   LLVM_NODISCARD static ProgramStateRef
-  assign(ProgramStateRef State, SValBuilder , RangeSet::Factory ,
- ClassOrSymbol CoS, RangeSet NewConstraint) {
+  assign(ProgramStateRef State, RangeConstraintManager ,
+ SValBuilder , RangeSet::Factory , ClassOrSymbol CoS,
+ RangeSet NewConstraint) {
 if (!State || NewConstraint.isEmpty())
   return nullptr;
 
-ConstraintAssignor Assignor{State, Builder, F};
+ConstraintAssignor Assignor{State, RCM, Builder, F};
 return Assignor.assign(CoS, NewConstraint);
   }
 
@@ -1614,9 +1615,9 @@
  RangeSet Constraint);
 
 private:
-  ConstraintAssignor(ProgramStateRef State, SValBuilder ,
- RangeSet::Factory )
-  : State(State), Builder(Builder), RangeFactory(F) {}
+  ConstraintAssignor(ProgramStateRef State, RangeConstraintManager ,
+ SValBuilder , RangeSet::Factory )
+  : State(State), RCM(RCM), Builder(Builder), RangeFactory(F) {}
   using Base = ConstraintAssignorBase;
 
   /// Base method for handling new constraints for symbols.
@@ -1696,6 +1697,7 @@
   }
 
   ProgramStateRef State;
+  RangeConstraintManager 
   SValBuilder 
   RangeSet::Factory 
 };
@@ -2420,7 +2422,8 @@
 ProgramStateRef RangeConstraintManager::setRange(ProgramStateRef State,
  SymbolRef Sym,
  RangeSet Range) {
-  return ConstraintAssignor::assign(State, getSValBuilder(), F, Sym, Range);
+  return ConstraintAssignor::assign(State, *this, getSValBuilder(), F, Sym,
+Range);
 }
 
 //======
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D110387: [Analyzer][NFC] Move RangeConstraintManager's def before ConstraintAssignor's def

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG01b4ddbfbbad: [Analyzer][NFC] Move 
RangeConstraintManagers def before ConstraintAssignors… (authored 
by martong).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110387/new/

https://reviews.llvm.org/D110387

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1391,6 +1391,113 @@
   return {RangeFactory, ValueFactory.getValue(Min), ValueFactory.getValue(Max)};
 }
 
+//===--===//
+//  Constraint manager implementation details
+//===--===//
+
+class RangeConstraintManager : public RangedConstraintManager {
+public:
+  RangeConstraintManager(ExprEngine *EE, SValBuilder )
+  : RangedConstraintManager(EE, SVB), F(getBasicVals()) {}
+
+  //===--===//
+  // Implementation for interface from ConstraintManager.
+  //===--===//
+
+  bool haveEqualConstraints(ProgramStateRef S1,
+ProgramStateRef S2) const override {
+// NOTE: ClassMembers are as simple as back pointers for ClassMap,
+//   so comparing constraint ranges and class maps should be
+//   sufficient.
+return S1->get() == S2->get() &&
+   S1->get() == S2->get();
+  }
+
+  bool canReasonAbout(SVal X) const override;
+
+  ConditionTruthVal checkNull(ProgramStateRef State, SymbolRef Sym) override;
+
+  const llvm::APSInt *getSymVal(ProgramStateRef State,
+SymbolRef Sym) const override;
+
+  ProgramStateRef removeDeadBindings(ProgramStateRef State,
+ SymbolReaper ) override;
+
+  void printJson(raw_ostream , ProgramStateRef State, const char *NL = "\n",
+ unsigned int Space = 0, bool IsDot = false) const override;
+  void printConstraints(raw_ostream , ProgramStateRef State,
+const char *NL = "\n", unsigned int Space = 0,
+bool IsDot = false) const;
+  void printEquivalenceClasses(raw_ostream , ProgramStateRef State,
+   const char *NL = "\n", unsigned int Space = 0,
+   bool IsDot = false) const;
+  void printDisequalities(raw_ostream , ProgramStateRef State,
+  const char *NL = "\n", unsigned int Space = 0,
+  bool IsDot = false) const;
+
+  //===--===//
+  // Implementation for interface from RangedConstraintManager.
+  //===--===//
+
+  ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymLE(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymGE(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymWithinInclusiveRange(
+  ProgramStateRef State, SymbolRef Sym, const llvm::APSInt ,
+  const llvm::APSInt , const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymOutsideInclusiveRange(
+  ProgramStateRef State, SymbolRef Sym, const llvm::APSInt ,
+  const llvm::APSInt , const llvm::APSInt ) override;
+
+private:
+  RangeSet::Factory F;
+
+  RangeSet getRange(ProgramStateRef State, SymbolRef Sym);
+  RangeSet getRange(ProgramStateRef State, EquivalenceClass Class);
+  ProgramStateRef setRange(ProgramStateRef State, SymbolRef Sym,
+   RangeSet Range);
+  ProgramStateRef setRange(ProgramStateRef State, 

[clang] e2a2c83 - [Analyzer][NFC] Add RangedConstraintManager to ConstraintAssignor

2021-10-22 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-10-22T10:46:28+02:00
New Revision: e2a2c8328f573c792dcf8707b6adb88fa38cca11

URL: 
https://github.com/llvm/llvm-project/commit/e2a2c8328f573c792dcf8707b6adb88fa38cca11
DIFF: 
https://github.com/llvm/llvm-project/commit/e2a2c8328f573c792dcf8707b6adb88fa38cca11.diff

LOG: [Analyzer][NFC] Add RangedConstraintManager to ConstraintAssignor

In this patch we store a reference to `RangedConstraintManager` in the
`ConstraintAssignor`. This way it is possible to call back and reuse some
functions of it. This patch is exclusively needed for its child patches,
it is not intended to be a standalone patch.

Differential Revision: https://reviews.llvm.org/D111640

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 8df0a58914a7..7df9027b373d 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1600,12 +1600,13 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
 public:
   template 
   LLVM_NODISCARD static ProgramStateRef
-  assign(ProgramStateRef State, SValBuilder , RangeSet::Factory ,
- ClassOrSymbol CoS, RangeSet NewConstraint) {
+  assign(ProgramStateRef State, RangeConstraintManager ,
+ SValBuilder , RangeSet::Factory , ClassOrSymbol CoS,
+ RangeSet NewConstraint) {
 if (!State || NewConstraint.isEmpty())
   return nullptr;
 
-ConstraintAssignor Assignor{State, Builder, F};
+ConstraintAssignor Assignor{State, RCM, Builder, F};
 return Assignor.assign(CoS, NewConstraint);
   }
 
@@ -1614,9 +1615,9 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
  RangeSet Constraint);
 
 private:
-  ConstraintAssignor(ProgramStateRef State, SValBuilder ,
- RangeSet::Factory )
-  : State(State), Builder(Builder), RangeFactory(F) {}
+  ConstraintAssignor(ProgramStateRef State, RangeConstraintManager ,
+ SValBuilder , RangeSet::Factory )
+  : State(State), RCM(RCM), Builder(Builder), RangeFactory(F) {}
   using Base = ConstraintAssignorBase;
 
   /// Base method for handling new constraints for symbols.
@@ -1696,6 +1697,7 @@ class ConstraintAssignor : public 
ConstraintAssignorBase {
   }
 
   ProgramStateRef State;
+  RangeConstraintManager 
   SValBuilder 
   RangeSet::Factory 
 };
@@ -2420,7 +2422,8 @@ RangeSet RangeConstraintManager::getRange(ProgramStateRef 
State,
 ProgramStateRef RangeConstraintManager::setRange(ProgramStateRef State,
  SymbolRef Sym,
  RangeSet Range) {
-  return ConstraintAssignor::assign(State, getSValBuilder(), F, Sym, Range);
+  return ConstraintAssignor::assign(State, *this, getSValBuilder(), F, Sym,
+Range);
 }
 
 
//======



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 01b4ddb - [Analyzer][NFC] Move RangeConstraintManager's def before ConstraintAssignor's def

2021-10-22 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-10-22T10:46:28+02:00
New Revision: 01b4ddbfbbad575437fb157e8c6e3e2ffb8f0cea

URL: 
https://github.com/llvm/llvm-project/commit/01b4ddbfbbad575437fb157e8c6e3e2ffb8f0cea
DIFF: 
https://github.com/llvm/llvm-project/commit/01b4ddbfbbad575437fb157e8c6e3e2ffb8f0cea.diff

LOG: [Analyzer][NFC] Move RangeConstraintManager's def before 
ConstraintAssignor's def

In this patch we simply move the definition of RangeConstraintManager before
the definition of ConstraintAssignor. This patch is exclusively needed for it's
child patch, so in the child the diff would be clean and the review would be
easier.

Differential Revision: https://reviews.llvm.org/D110387

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index d1113569c59db..8df0a58914a7f 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1391,6 +1391,113 @@ RangeSet 
SymbolicRangeInferrer::VisitBinaryOperator(Range LHS,
   return {RangeFactory, ValueFactory.getValue(Min), 
ValueFactory.getValue(Max)};
 }
 
+//===--===//
+//  Constraint manager implementation details
+//===--===//
+
+class RangeConstraintManager : public RangedConstraintManager {
+public:
+  RangeConstraintManager(ExprEngine *EE, SValBuilder )
+  : RangedConstraintManager(EE, SVB), F(getBasicVals()) {}
+
+  //===--===//
+  // Implementation for interface from ConstraintManager.
+  //===--===//
+
+  bool haveEqualConstraints(ProgramStateRef S1,
+ProgramStateRef S2) const override {
+// NOTE: ClassMembers are as simple as back pointers for ClassMap,
+//   so comparing constraint ranges and class maps should be
+//   sufficient.
+return S1->get() == S2->get() &&
+   S1->get() == S2->get();
+  }
+
+  bool canReasonAbout(SVal X) const override;
+
+  ConditionTruthVal checkNull(ProgramStateRef State, SymbolRef Sym) override;
+
+  const llvm::APSInt *getSymVal(ProgramStateRef State,
+SymbolRef Sym) const override;
+
+  ProgramStateRef removeDeadBindings(ProgramStateRef State,
+ SymbolReaper ) override;
+
+  void printJson(raw_ostream , ProgramStateRef State, const char *NL = 
"\n",
+ unsigned int Space = 0, bool IsDot = false) const override;
+  void printConstraints(raw_ostream , ProgramStateRef State,
+const char *NL = "\n", unsigned int Space = 0,
+bool IsDot = false) const;
+  void printEquivalenceClasses(raw_ostream , ProgramStateRef State,
+   const char *NL = "\n", unsigned int Space = 0,
+   bool IsDot = false) const;
+  void printDisequalities(raw_ostream , ProgramStateRef State,
+  const char *NL = "\n", unsigned int Space = 0,
+  bool IsDot = false) const;
+
+  //===--===//
+  // Implementation for interface from RangedConstraintManager.
+  //===--===//
+
+  ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymLE(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymGE(ProgramStateRef State, SymbolRef Sym,
+  const llvm::APSInt ,
+  const llvm::APSInt ) override;
+
+  ProgramStateRef assumeSymWithinInclusiveRange(
+  ProgramStateRef State, SymbolRef Sym, const llvm::APSInt ,
+  const llvm::APSInt , const llvm::APSInt ) override;
+
+  

[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1618-1627
+const SymbolRef LHS = Sym->getLHS();
+const llvm::APSInt  =
+Builder.getBasicValueFactory().getValue(0, Sym->getType());
+// a % b != 0 implies that a != 0.
+if (!Constraint.containsZero()) {
+  State = RCM.assumeSymNE(State, LHS, Zero, Zero);
+  if (!State)

ASDenysPetrov wrote:
> How about using the family of `ProgramState::isNonNull` or 
> `ProgramState::isNull` or `RangeConstraintManager::checkNull` functoins for 
> this stuff?
I've been checking this and turend out that `ProgramState::isNull` does not 
modify the State (this is aligned with being a `const` member function). So, 
these functions do not "assume" anything, they can be used only to query some 
property of an SVal (or Symbol) from the State.

However, this comment and your other previous comment made me to do further 
investigations towards exploiting the "assume" machinery better. The result is 
a new child patch, where we can handle "adjustments" as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110357/new/

https://reviews.llvm.org/D110357

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112296: [Analyzer][solver] Handle adjustments in constraint assignor remainder

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: steakhal, ASDenysPetrov, NoQ.
Herald added subscribers: manas, gamesh411, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun, 
whisperity.
Herald added a reviewer: Szelethus.
martong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We can reuse the "adjustment" handling logic in the higher level
of the solver by calling `assumeSymRel`.

(Actually, this shows us that there is no point in separating the
`RangeConstraintManager` from the `RangedConstraintManager`, that
separation is in fact artificial. A follow-up NFC patch might
address this.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112296

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint-assignor.c


Index: clang/test/Analysis/constraint-assignor.c
===
--- clang/test/Analysis/constraint-assignor.c
+++ clang/test/Analysis/constraint-assignor.c
@@ -3,9 +3,8 @@
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -verify
 
-// expected-no-diagnostics
-
 void clang_analyzer_warnIfReached();
+void clang_analyzer_eval();
 
 void rem_constant_rhs_ne_zero(int x, int y) {
   if (x % 3 == 0) // x % 3 != 0 -> x != 0
@@ -67,3 +66,11 @@
   if (d % 2 != 0)
 return;
 }
+
+void remainder_with_adjustment(int x, int y) {
+  if ((x + 1) % 3 == 0) // (x + 1) % 3 != 0 -> x + 1 != 0 -> x != -1
+return;
+  clang_analyzer_eval(x + 1 != 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(x != -1);// expected-warning{{TRUE}}
+  (void)x; // keep the constraints alive.
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1620,7 +1620,7 @@
 Builder.getBasicValueFactory().getValue(0, Sym->getType());
 // a % b != 0 implies that a != 0.
 if (!Constraint.containsZero()) {
-  State = RCM.assumeSymNE(State, LHS, Zero, Zero);
+  State = RCM.assumeSymRel(State, LHS, BO_NE, Zero);
   if (!State)
 return false;
 }
Index: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -342,7 +342,6 @@
   ProgramStateRef assumeSymUnsupported(ProgramStateRef State, SymbolRef Sym,
bool Assumption) override;
 
-protected:
   /// Assume a constraint between a symbolic expression and a concrete integer.
   virtual ProgramStateRef assumeSymRel(ProgramStateRef State, SymbolRef Sym,
BinaryOperator::Opcode op,


Index: clang/test/Analysis/constraint-assignor.c
===
--- clang/test/Analysis/constraint-assignor.c
+++ clang/test/Analysis/constraint-assignor.c
@@ -3,9 +3,8 @@
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -verify
 
-// expected-no-diagnostics
-
 void clang_analyzer_warnIfReached();
+void clang_analyzer_eval();
 
 void rem_constant_rhs_ne_zero(int x, int y) {
   if (x % 3 == 0) // x % 3 != 0 -> x != 0
@@ -67,3 +66,11 @@
   if (d % 2 != 0)
 return;
 }
+
+void remainder_with_adjustment(int x, int y) {
+  if ((x + 1) % 3 == 0) // (x + 1) % 3 != 0 -> x + 1 != 0 -> x != -1
+return;
+  clang_analyzer_eval(x + 1 != 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(x != -1);// expected-warning{{TRUE}}
+  (void)x; // keep the constraints alive.
+}
Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1620,7 +1620,7 @@
 Builder.getBasicValueFactory().getValue(0, Sym->getType());
 // a % b != 0 implies that a != 0.
 if (!Constraint.containsZero()) {
-  State = RCM.assumeSymNE(State, LHS, Zero, Zero);
+  State = RCM.assumeSymRel(State, LHS, BO_NE, Zero);
   if (!State)
 return false;
 }
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -342,7 +342,6 @@
   ProgramStateRef assumeSymUnsupported(ProgramStateRef State, 

[PATCH] D112013: [clang][ASTImporter] Fix for importing functions with EST_Unevaluated prototype.

2021-10-22 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4ff103c02400: [clang][ASTImporter] Fix for importing 
functions with EST_Unevaluated prototype. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112013/new/

https://reviews.llvm.org/D112013

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6145,6 +6145,50 @@
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportFunctionDeclWithTypeSourceInfoWithSourceDecl) {
+  // This code results in a lambda with implicit constructor.
+  // The constructor's TypeSourceInfo points out the function prototype.
+  // This prototype has an EST_Unevaluated in its exception information and a
+  // SourceDecl that is the function declaration itself.
+  // The test verifies that AST import of such AST does not crash.
+  // (Here the function's TypeSourceInfo references the function itself.)
+  Decl *FromTU = getTuDecl(
+  R"(
+template void f(T) { auto X = [](){}; }
+void g() { f(10); }
+)",
+  Lang_CXX11, "input0.cc");
+
+  // Use LastDeclMatcher to find the LambdaExpr in the template specialization.
+  CXXRecordDecl *FromL = LastDeclMatcher()
+ .match(FromTU, lambdaExpr())
+ ->getLambdaClass();
+
+  CXXConstructorDecl *FromCtor = *FromL->ctor_begin();
+  ASSERT_TRUE(FromCtor->isCopyConstructor());
+  ASSERT_TRUE(FromCtor->getTypeSourceInfo());
+  const auto *FromFPT = FromCtor->getType()->getAs();
+  ASSERT_TRUE(FromFPT);
+  EXPECT_EQ(FromCtor->getTypeSourceInfo()->getType().getTypePtr(), FromFPT);
+  FunctionProtoType::ExtProtoInfo FromEPI = FromFPT->getExtProtoInfo();
+  // If type is EST_Unevaluated, SourceDecl should be set to the parent Decl.
+  EXPECT_EQ(FromEPI.ExceptionSpec.Type, EST_Unevaluated);
+  EXPECT_EQ(FromEPI.ExceptionSpec.SourceDecl, FromCtor);
+
+  auto ToL = Import(FromL, Lang_CXX11);
+
+  // Check if the import was correct.
+  CXXConstructorDecl *ToCtor = *ToL->ctor_begin();
+  EXPECT_TRUE(ToCtor->getTypeSourceInfo());
+  const auto *ToFPT = ToCtor->getType()->getAs();
+  ASSERT_TRUE(ToFPT);
+  EXPECT_EQ(ToCtor->getTypeSourceInfo()->getType().getTypePtr(), ToFPT);
+  FunctionProtoType::ExtProtoInfo ToEPI = ToFPT->getExtProtoInfo();
+  EXPECT_EQ(ToEPI.ExceptionSpec.Type, EST_Unevaluated);
+  EXPECT_EQ(ToEPI.ExceptionSpec.SourceDecl, ToCtor);
+}
+
 struct ImportAutoFunctions : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportAutoFunctions, ReturnWithTypedefDeclaredInside) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3422,11 +3422,14 @@
 return std::move(Err);
 
   QualType FromTy = D->getType();
+  TypeSourceInfo *FromTSI = D->getTypeSourceInfo();
   // Set to true if we do not import the type of the function as is. There are
   // cases when the original type would result in an infinite recursion during
   // the import. To avoid an infinite recursion when importing, we create the
   // FunctionDecl with a simplified function type and update it only after the
   // relevant AST nodes are already imported.
+  // The type is related to TypeSourceInfo (it references the type), so we must
+  // do the same with TypeSourceInfo.
   bool UsedDifferentProtoType = false;
   if (const auto *FromFPT = FromTy->getAs()) {
 QualType FromReturnTy = FromFPT->getReturnType();
@@ -3453,11 +3456,13 @@
 }
 FromTy = Importer.getFromContext().getFunctionType(
 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
+FromTSI = Importer.getFromContext().getTrivialTypeSourceInfo(
+FromTy, D->getBeginLoc());
   }
 
   Error Err = Error::success();
   auto T = importChecked(Err, FromTy);
-  auto TInfo = importChecked(Err, D->getTypeSourceInfo());
+  auto TInfo = importChecked(Err, FromTSI);
   auto ToInnerLocStart = importChecked(Err, D->getInnerLocStart());
   auto ToEndLoc = importChecked(Err, D->getEndLoc());
   auto ToQualifierLoc = importChecked(Err, D->getQualifierLoc());
@@ -3635,6 +3640,10 @@
   ToFunction->setType(*TyOrErr);
 else
   return TyOrErr.takeError();
+if (Expected TSIOrErr = import(D->getTypeSourceInfo()))
+  ToFunction->setTypeSourceInfo(*TSIOrErr);
+else
+  return TSIOrErr.takeError();
   }
 
   // FIXME: Other bits to merge?


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6145,6 +6145,50 @@
 2u);
 }
 

[clang] 4ff103c - [clang][ASTImporter] Fix for importing functions with EST_Unevaluated prototype.

2021-10-22 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-10-22T09:42:41+02:00
New Revision: 4ff103c024005fea997143a4bdb7918edd8712eb

URL: 
https://github.com/llvm/llvm-project/commit/4ff103c024005fea997143a4bdb7918edd8712eb
DIFF: 
https://github.com/llvm/llvm-project/commit/4ff103c024005fea997143a4bdb7918edd8712eb.diff

LOG: [clang][ASTImporter] Fix for importing functions with EST_Unevaluated 
prototype.

Fix for importing functions where the TypeSourceInfo is set and the
exception specification information contains reference to the function
declaration itself.

Reviewed By: martong, steakhal

Differential Revision: https://reviews.llvm.org/D112013

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f0fcdd66560e5..1afc1e13d25a7 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -3422,11 +3422,14 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
 return std::move(Err);
 
   QualType FromTy = D->getType();
+  TypeSourceInfo *FromTSI = D->getTypeSourceInfo();
   // Set to true if we do not import the type of the function as is. There are
   // cases when the original type would result in an infinite recursion during
   // the import. To avoid an infinite recursion when importing, we create the
   // FunctionDecl with a simplified function type and update it only after the
   // relevant AST nodes are already imported.
+  // The type is related to TypeSourceInfo (it references the type), so we must
+  // do the same with TypeSourceInfo.
   bool UsedDifferentProtoType = false;
   if (const auto *FromFPT = FromTy->getAs()) {
 QualType FromReturnTy = FromFPT->getReturnType();
@@ -3453,11 +3456,13 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
 }
 FromTy = Importer.getFromContext().getFunctionType(
 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
+FromTSI = Importer.getFromContext().getTrivialTypeSourceInfo(
+FromTy, D->getBeginLoc());
   }
 
   Error Err = Error::success();
   auto T = importChecked(Err, FromTy);
-  auto TInfo = importChecked(Err, D->getTypeSourceInfo());
+  auto TInfo = importChecked(Err, FromTSI);
   auto ToInnerLocStart = importChecked(Err, D->getInnerLocStart());
   auto ToEndLoc = importChecked(Err, D->getEndLoc());
   auto ToQualifierLoc = importChecked(Err, D->getQualifierLoc());
@@ -3635,6 +3640,10 @@ ExpectedDecl 
ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
   ToFunction->setType(*TyOrErr);
 else
   return TyOrErr.takeError();
+if (Expected TSIOrErr = import(D->getTypeSourceInfo()))
+  ToFunction->setTypeSourceInfo(*TSIOrErr);
+else
+  return TSIOrErr.takeError();
   }
 
   // FIXME: Other bits to merge?

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 724de6c67f0f6..29b1500fcd76d 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -6145,6 +6145,50 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportDefaultConstructibleLambdas) {
 2u);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportFunctionDeclWithTypeSourceInfoWithSourceDecl) {
+  // This code results in a lambda with implicit constructor.
+  // The constructor's TypeSourceInfo points out the function prototype.
+  // This prototype has an EST_Unevaluated in its exception information and a
+  // SourceDecl that is the function declaration itself.
+  // The test verifies that AST import of such AST does not crash.
+  // (Here the function's TypeSourceInfo references the function itself.)
+  Decl *FromTU = getTuDecl(
+  R"(
+template void f(T) { auto X = [](){}; }
+void g() { f(10); }
+)",
+  Lang_CXX11, "input0.cc");
+
+  // Use LastDeclMatcher to find the LambdaExpr in the template specialization.
+  CXXRecordDecl *FromL = LastDeclMatcher()
+ .match(FromTU, lambdaExpr())
+ ->getLambdaClass();
+
+  CXXConstructorDecl *FromCtor = *FromL->ctor_begin();
+  ASSERT_TRUE(FromCtor->isCopyConstructor());
+  ASSERT_TRUE(FromCtor->getTypeSourceInfo());
+  const auto *FromFPT = FromCtor->getType()->getAs();
+  ASSERT_TRUE(FromFPT);
+  EXPECT_EQ(FromCtor->getTypeSourceInfo()->getType().getTypePtr(), FromFPT);
+  FunctionProtoType::ExtProtoInfo FromEPI = FromFPT->getExtProtoInfo();
+  // If type is EST_Unevaluated, SourceDecl should be set to the parent Decl.
+  EXPECT_EQ(FromEPI.ExceptionSpec.Type, EST_Unevaluated);
+  EXPECT_EQ(FromEPI.ExceptionSpec.SourceDecl, FromCtor);
+
+  auto ToL = Import(FromL, Lang_CXX11);
+
+  // Check if the import was correct.
+  CXXConstructorDecl *ToCtor = *ToL->ctor_begin();
+  EXPECT_TRUE(ToCtor->getTypeSourceInfo());
+  const auto *ToFPT = 

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1708-1710
+  // Handle StringLiteral.
+  if (const auto *SL = dyn_cast(Init))
+return getSValFromStringLiteral(SL, Offset, R->getElementType());

ASDenysPetrov wrote:
> martong wrote:
> > I am wondering why this hunk is needed? `getSValFromInitListExpr` is 
> > handling this case at L1725, isn't it?
> L1710 handles `const char x[] = "abc";`
> L1725 handles `const char x[] = {"abc"};`
> I think I should give an example in comments.
Okay, thanks for the explanation.

> I think I should give an example in comments.
Yes, that's a good idea!



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107339/new/

https://reviews.llvm.org/D107339

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111134: Add basic aarch64-none-elf bare metal driver.

2021-10-22 Thread Kristof Beyls via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b93dc6880f7: Add basic aarch64-none-elf bare metal driver. 
(authored by kristof.beyls).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D34/new/

https://reviews.llvm.org/D34

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/gcc_forward.c


Index: clang/test/Driver/gcc_forward.c
===
--- clang/test/Driver/gcc_forward.c
+++ clang/test/Driver/gcc_forward.c
@@ -1,4 +1,4 @@
-// RUN: %clang -### %s -target aarch64-none-elf \
+// RUN: %clang -### %s -target x86-none-elf \
 // RUN:   --coverage -e _start -fuse-ld=lld --ld-path=ld -nostartfiles \
 // RUN:   -nostdlib -r -rdynamic -specs=nosys.specs -static -static-pie \
 // RUN:   2>&1 | FileCheck --check-prefix=FORWARD %s
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -102,6 +102,16 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
 // CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:  -target aarch64-none-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-AARCH64-NO-HOST-INC %s
+// Verify that the bare metal driver does not include any host system paths:
+// CHECK-AARCH64-NO-HOST-INC: InstalledDir: [[INSTALLEDDIR:.+]]
+// CHECK-AARCH64-NO-HOST-INC: "-resource-dir" "[[RESOURCE:[^"]+]]"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include/c++/v1"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[RESOURCE]]/include"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target riscv64-unknown-elf \
 // RUN: -L some/directory/user/asked/for \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -125,6 +125,20 @@
   return true;
 }
 
+/// Is the triple aarch64-none-elf?
+static bool isAArch64BareMetal(const llvm::Triple ) {
+  if (Triple.getArch() != llvm::Triple::aarch64)
+return false;
+
+  if (Triple.getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (Triple.getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  return Triple.getEnvironmentName() == "elf";
+}
+
 static bool isRISCVBareMetal(const llvm::Triple ) {
   if (Triple.getArch() != llvm::Triple::riscv32 &&
   Triple.getArch() != llvm::Triple::riscv64)
@@ -151,7 +165,8 @@
 }
 
 bool BareMetal::handlesTarget(const llvm::Triple ) {
-  return isARMBareMetal(Triple) || isRISCVBareMetal(Triple);
+  return isARMBareMetal(Triple) || isAArch64BareMetal(Triple) ||
+ isRISCVBareMetal(Triple);
 }
 
 Tool *BareMetal::buildLinker() const {


Index: clang/test/Driver/gcc_forward.c
===
--- clang/test/Driver/gcc_forward.c
+++ clang/test/Driver/gcc_forward.c
@@ -1,4 +1,4 @@
-// RUN: %clang -### %s -target aarch64-none-elf \
+// RUN: %clang -### %s -target x86-none-elf \
 // RUN:   --coverage -e _start -fuse-ld=lld --ld-path=ld -nostartfiles \
 // RUN:   -nostdlib -r -rdynamic -specs=nosys.specs -static -static-pie \
 // RUN:   2>&1 | FileCheck --check-prefix=FORWARD %s
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -102,6 +102,16 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
 // CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:  -target aarch64-none-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-AARCH64-NO-HOST-INC %s
+// Verify that the bare metal driver does not include any host system paths:
+// CHECK-AARCH64-NO-HOST-INC: InstalledDir: [[INSTALLEDDIR:.+]]
+// CHECK-AARCH64-NO-HOST-INC: "-resource-dir" "[[RESOURCE:[^"]+]]"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include/c++/v1"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[RESOURCE]]/include"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target riscv64-unknown-elf \
 // RUN: -L some/directory/user/asked/for \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp

[clang] 3b93dc6 - Add basic aarch64-none-elf bare metal driver.

2021-10-22 Thread Kristof Beyls via cfe-commits

Author: Kristof Beyls
Date: 2021-10-22T08:06:17+01:00
New Revision: 3b93dc6880f7ac94469e46980f1136901760d564

URL: 
https://github.com/llvm/llvm-project/commit/3b93dc6880f7ac94469e46980f1136901760d564
DIFF: 
https://github.com/llvm/llvm-project/commit/3b93dc6880f7ac94469e46980f1136901760d564.diff

LOG: Add basic aarch64-none-elf bare metal driver.

Differential Revision: https://reviews.llvm.org/D34

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp
clang/test/Driver/gcc_forward.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index ce73e39d1456d..cd07692be3583 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -125,6 +125,20 @@ static bool isARMBareMetal(const llvm::Triple ) {
   return true;
 }
 
+/// Is the triple aarch64-none-elf?
+static bool isAArch64BareMetal(const llvm::Triple ) {
+  if (Triple.getArch() != llvm::Triple::aarch64)
+return false;
+
+  if (Triple.getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (Triple.getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  return Triple.getEnvironmentName() == "elf";
+}
+
 static bool isRISCVBareMetal(const llvm::Triple ) {
   if (Triple.getArch() != llvm::Triple::riscv32 &&
   Triple.getArch() != llvm::Triple::riscv64)
@@ -151,7 +165,8 @@ void BareMetal::findMultilibs(const Driver , const 
llvm::Triple ,
 }
 
 bool BareMetal::handlesTarget(const llvm::Triple ) {
-  return isARMBareMetal(Triple) || isRISCVBareMetal(Triple);
+  return isARMBareMetal(Triple) || isAArch64BareMetal(Triple) ||
+ isRISCVBareMetal(Triple);
 }
 
 Tool *BareMetal::buildLinker() const {

diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index fb760abbb9779..74208968f92e1 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -102,6 +102,16 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
 // CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:  -target aarch64-none-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-AARCH64-NO-HOST-INC %s
+// Verify that the bare metal driver does not include any host system paths:
+// CHECK-AARCH64-NO-HOST-INC: InstalledDir: [[INSTALLEDDIR:.+]]
+// CHECK-AARCH64-NO-HOST-INC: "-resource-dir" "[[RESOURCE:[^"]+]]"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include/c++/v1"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" "[[RESOURCE]]/include"
+// CHECK-AARCH64-NO-HOST-INC-SAME: "-internal-isystem" 
"[[INSTALLEDDIR]]/../lib/clang-runtimes/aarch64-none-elf/include"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target riscv64-unknown-elf \
 // RUN: -L some/directory/user/asked/for \

diff  --git a/clang/test/Driver/gcc_forward.c b/clang/test/Driver/gcc_forward.c
index e6b0670d1a027..9e512d134b3e7 100644
--- a/clang/test/Driver/gcc_forward.c
+++ b/clang/test/Driver/gcc_forward.c
@@ -1,4 +1,4 @@
-// RUN: %clang -### %s -target aarch64-none-elf \
+// RUN: %clang -### %s -target x86-none-elf \
 // RUN:   --coverage -e _start -fuse-ld=lld --ld-path=ld -nostartfiles \
 // RUN:   -nostdlib -r -rdynamic -specs=nosys.specs -static -static-pie \
 // RUN:   2>&1 | FileCheck --check-prefix=FORWARD %s



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112098: [ASan] Added stack safety support in address sanitizer.

2021-10-22 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:813
+const StackSafetyGlobalInfo *SSI = nullptr;
+if (ClUseStackSafety) {
+  SSI = ().getResult();

usually we don't use {} for one liners.
But I'd prefer here:
const StackSafetyGlobalInfo *SSI = ClUseStackSafety ? get...: nullptr



Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:1343
 INITIALIZE_PASS_DEPENDENCY(ASanGlobalsMetadataWrapperPass)
 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
 INITIALIZE_PASS_END(

INITIALIZE_PASS_DEPENDENCY(StackSafetyGlobalInfoWrapperPass)



Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:1265
 GlobalsMetadata ASanGlobalsMetadataAnalysis::run(Module ,
  ModuleAnalysisManager ) {
   return GlobalsMetadata(M);

vitalybuka wrote:
> You can make this module pass to calculate StackSafetyGlobalAnalysis and use 
> cached one below.
> This way we will avoid exposure of this logic to PM
It should probably be in ModuleAddressSanitizerPass, so it wll return ::all() 
and we don't care about invalidation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112098/new/

https://reviews.llvm.org/D112098

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits