[PATCH] D78129: Add Marvell ThunderX3T110 support

2020-05-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78129



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


[PATCH] D79411: [VE] Clang toolchain for VE

2020-05-13 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 263638.
simoll added a comment.

- Simplified: stripped down to a basic C GNU Linux toolchain hard-float, no C++ 
stdlib.
- rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79411

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/VE.cpp
  clang/lib/Basic/Targets/VE.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Arch/VE.cpp
  clang/lib/Driver/ToolChains/Arch/VE.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/VE.cpp
  clang/lib/Driver/ToolChains/VE.h
  clang/test/CodeGen/ve-abi.c

Index: clang/test/CodeGen/ve-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/ve-abi.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple ve-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define { float, float } @p(float %a.coerce0, float %a.coerce1, float %b.coerce0, float %b.coerce1) #0 {
+float __complex__ p(float __complex__ a, float __complex__ b) {
+}
+
+// CHECK-LABEL: define { double, double } @q(double %a.coerce0, double %a.coerce1, double %b.coerce0, double %b.coerce1) #0 {
+double __complex__ q(double __complex__ a, double __complex__ b) {
+}
+
+void func() {
+  // CHECK-LABEL: %call = call i32 (i32, i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @hoge to i32 (i32, i32, i32, i32, i32, i32, i32, ...)*)(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7)
+  hoge(1, 2, 3, 4, 5, 6, 7);
+}
Index: clang/lib/Driver/ToolChains/VE.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/VE.h
@@ -0,0 +1,66 @@
+//===--- VE.h - VE ToolChain Implementations *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VE_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VE_H
+
+#include "Linux.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY VEToolChain : public Linux {
+public:
+  VEToolChain(const Driver &D, const llvm::Triple &Triple,
+  const llvm::opt::ArgList &Args);
+
+protected:
+  Tool *buildAssembler() const override;
+  Tool *buildLinker() const override;
+
+public:
+  bool isPICDefault() const override;
+  bool isPIEDefault() const override;
+  bool isPICDefaultForced() const override;
+  bool SupportsProfiling() const override;
+  bool hasBlocksRuntime() const override;
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
+  void
+  addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args,
+Action::OffloadKind DeviceOffloadKind) const override;
+  void AddClangCXXStdlibIncludeArgs(
+  const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
+
+  llvm::ExceptionHandling
+  GetExceptionModel(const llvm::opt::ArgList &Args) const override;
+
+  CXXStdlibType
+  GetCXXStdlibType(const llvm::opt::ArgList &Args) const override {
+return ToolChain::CST_Libcxx;
+  }
+
+  RuntimeLibType GetDefaultRuntimeLibType() const override {
+return ToolChain::RLT_CompilerRT;
+  }
+
+  const char *getDefaultLinker() const override { return "nld"; }
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_VE_H
Index: clang/lib/Driver/ToolChains/VE.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/VE.cpp
@@ -0,0 +1,119 @@
+//===--- VE.cpp - VE ToolChain Implementations --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "VE.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include 

[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-05-13 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a reviewer: erichkeane.
lebedev.ri added a comment.

Thanks for working on this.
Please upload patch with full context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D78350: [AST] Build recovery expressions by default for C++.

2020-05-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 263647.
hokein added a comment.

rebase to master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78350

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_namespace_1.cpp
  clang/test/CXX/class.access/p4.cpp
  clang/test/CXX/special/class.ctor/p5-0x.cpp
  clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constructor-initializer.cpp
  clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/enable_if.cpp
  clang/test/SemaCXX/for-range-dereference.cpp
  clang/test/SemaCXX/recovery-default-init.cpp
  clang/test/SemaCXX/recovery-initializer.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaCXX/virtual-base-used.cpp
  clang/test/SemaObjCXX/arc-0x.mm
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-function-params.cpp
  clang/test/SemaTemplate/instantiate-init.cpp

Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -108,7 +108,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaTemplate/instantiate-function-params.cpp
===
--- clang/test/SemaTemplate/instantiate-function-params.cpp
+++ clang/test/SemaTemplate/instantiate-function-params.cpp
@@ -3,32 +3,32 @@
 // PR6619
 template struct if_c { };
 template struct if_ {
-  typedef if_c< static_cast(T1::value)> almost_type_; // expected-note 5{{in instantiation}}
+  typedef if_c< static_cast(T1::value)> almost_type_; // expected-note 7{{in instantiation}}
 };
 template  struct wrap_constraints { };
 template  
 inline char has_constraints_(Model* , // expected-note 3{{candidate template ignored}}
-   wrap_constraints* = 0); // expected-note 2{{in instantiation}}
+   wrap_constraints* = 0); // expected-note 4{{in instantiation}}
 
 template  struct not_satisfied {
   static const bool value = sizeof( has_constraints_((Model*)0)  == 1); // expected-error 3{{no matching function}} \
-  // expected-note 2{{while substituting deduced template arguments into function template 'has_constraints_' [with }}
+  // expected-note 4{{while substituting deduced template arguments into function template 'has_constraints_' [with }}
 };
 template  struct requirement_;
 template  struct instantiate {
 };
-template  struct requirement_   : if_<   not_satisfied >::type { // expected-note 5{{in instantiation}}
+template  struct requirement_   : if_<   not_satisfied >::type { // expected-error 3{{no type named 'type' in}} expected-note 7{{in instantiation}}
 };
 template  struct usage_requirements {
 };
 template < typename TT > struct InputIterator{
-typedef  instantiate< & requirement_ x)>::failed> boost_concept_check1; // expected-note {{in instantiation}}
+typedef  instantiate< & requirement_ x)>::failed> boost_concept_check1; // expected-note 2{{in instantiation}}
 };
-template < typename TT > struct ForwardIterator  : InputIterator  { // expected-note {{in instantiation}}
-  typedef instantiate< & requirement_ x)>::failed> boost_concept_check2; // expected-note {{in instantiation}}
+template < typename TT > struct ForwardIterator  : InputIterator  { // expected-note 2{{in instantiation}}
+  typedef instantiate< & requirement_ x)>::failed> boost_concept_check2; // expected-note 2{{in instantiation}}
 
 };
-typedef instantiate< &requirement_ x)>::failed> boost_concept_checkX;// expected-note 3{{in instantiation}}
+typedef instantiate< &requirement_ x)>::failed> boost_concept_checkX;// ex

[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-05-13 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett marked an inline comment as done.
DavidSpickett added inline comments.



Comment at: clang/test/Driver/program-path-priority.c:72
+// -gcc has lowest priority
+// RUN: default_triple=$(%t/clang --version | grep -oP "(?<=Target:\s).*")
+// RUN: touch %t/${default_triple}-gcc

Pretty sure I'm stretching the limits here, probably not suitable for Windows. 
I hoped to be able to capture the default triple in a CHECK line, then use it 
in a following RUN line. (though thinking about how FileCheck works, that isn't 
possible)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79842



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


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-05-13 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett created this revision.
DavidSpickett added reviewers: rogfer01, ddunbar, chandlerc.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.
DavidSpickett marked an inline comment as done.
DavidSpickett added inline comments.



Comment at: clang/test/Driver/program-path-priority.c:72
+// -gcc has lowest priority
+// RUN: default_triple=$(%t/clang --version | grep -oP "(?<=Target:\s).*")
+// RUN: touch %t/${default_triple}-gcc

Pretty sure I'm stretching the limits here, probably not suitable for Windows. 
I hoped to be able to capture the default triple in a CHECK line, then use it 
in a following RUN line. (though thinking about how FileCheck works, that isn't 
possible)


As seen in:
https://bugs.llvm.org/show_bug.cgi?id=45693

When clang looks for a tool it has a set of
possible names for it, in priority order.
Previously it would look for these names in
the program path. Then look for all the names
in the PATH.

This means that aarch64-none-elf-gcc on the PATH
would lose to gcc in the program path.
(which was /usr/bin in the bug's case)

This changes that logic to search each name in both
possible locations, then move to the next name.
Which is more what you would expect to happen when
using a non default triple.

(-B prefixes maybe should follow this logic too,
but are not changed in this patch)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79842

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/program-path-priority.c

Index: clang/test/Driver/program-path-priority.c
===
--- /dev/null
+++ clang/test/Driver/program-path-priority.c
@@ -0,0 +1,113 @@
+// Check the priority used when searching for tools
+// Names and locations have a set priority. (highest to lowest)
+// -tool, tool, -tool
+// program path, PATH
+// Such that a more specific name found in the PATH
+// will win over a less specific name found in the program path
+// Prefix dirs (added with -B) overrride the location,
+// so only name priority is accounted for, unless we fail to find
+// anything at all in the prefix.
+
+// Copy clang to a new dir which will be its
+// "program path" for these tests
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: cp %clang %t
+
+// No gccs at all, nothing is found
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NO_NOTREAL_GCC %s
+// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc
+// NO_NOTREAL_GCC-NOT: /gcc
+
+// -gcc in program path is found
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=PROG_PATH_NOTREAL_GCC %s
+// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc
+
+// -gcc on the PATH is found
+// RUN: mkdir -p %t/env
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: touch %t/env/notreal-none-elf-gcc
+// RUN: chmod +x %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=ENV_PATH_NOTREAL_GCC %s
+// ENV_PATH_NOTREAL_GCC: env/notreal-none-elf-gcc
+
+// -gcc in program path is preferred to one on the PATH
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=BOTH_NOTREAL_GCC %s
+// BOTH_NOTREAL_GCC: notreal-none-elf-gcc
+// BOTH_NOTREAL_GCC-NOT: env/notreal-none-elf-gcc
+
+// On program path, -gcc is preferred to plain gcc
+// RUN: touch %t/gcc
+// RUN: chmod +x %t/gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_GCC_PREFERRED %s
+// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc
+// NOTREAL_GCC_PREFERRED-NOT: /gcc
+
+// -gcc on the PATH is preferred to gcc in program path
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PROG %s
+// NOTREAL_PATH_OVER_GCC_PROG: /env/notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PROG-NOT: /gcc
+
+// -gcc on the PATH is preferred to gcc on the PATH
+// RUN: rm %t/gcc
+// RUN: touch %t/env/gcc
+// RUN: chmod +x %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PATH %s
+// NOTREAL_PATH_OVER_GCC_PATH: /env/notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PATH-NOT: /gcc
+
+// -gcc has lowest priority
+// RUN: default_triple=$(%t/clang --version | grep -oP "(?<=Target:\s).*")
+// RUN: touch %t/${default_triple}-gcc
+// RUN: chmod +x %t/${default_triple}-gcc
+
+// -gcc on PATH beats default triple in program path
+// RUN: touch %t/${default_triple}-gcc
+// RUN: chmod +x %t/${default_triple}-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -

[PATCH] D79843: [analyzer] Fix crash for non-pointers annotated as nonnull

2020-05-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a project: clang.

Nonnull attribute can be applied to non-pointers.  This caused assertion
failures in NonNullParamChecker when we tried to *assume* such parameters
to be non-zero.

rdar://problem/63150074


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79843

Files:
  clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  clang/test/Analysis/UserNullabilityAnnotations.m


Index: clang/test/Analysis/UserNullabilityAnnotations.m
===
--- clang/test/Analysis/UserNullabilityAnnotations.m
+++ clang/test/Analysis/UserNullabilityAnnotations.m
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -verify -Wno-objc-root-class %s \
+// RUN:   -Wno-tautological-pointer-compare \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=nullability \
 // RUN:   -analyzer-checker=debug.ExprInspection
@@ -34,3 +35,15 @@
   clang_analyzer_eval(Grandson->Value != 0); // expected-warning{{TRUE}}
   clang_analyzer_eval(foo()->Child->Value != 0); // expected-warning{{TRUE}}
 }
+
+// Check that we correctly process situations when non-pointer parameters
+// get nonnul attributes.
+// Original problem: rdar://problem/63150074
+typedef struct {
+  long a;
+} B;
+__attribute__((nonnull)) void c(B x, int *y);
+
+void c(B x, int *y) {
+  clang_analyzer_eval(y != 0); // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -254,12 +254,18 @@
 if (!ParameterNonNullMarks.test(Parameter->getFunctionScopeIndex()))
   continue;
 
+// 2. Check that parameter is a pointer.
+//Nonnull attribute can be applied to non-pointers (by default
+//__attribute__(nonnull) implies "all parameters").
+if (!Parameter->getType()->isPointerType())
+  continue;
+
 Loc ParameterLoc = State->getLValue(Parameter, LocContext);
 // We never consider top-level function parameters undefined.
 auto StoredVal =
 State->getSVal(ParameterLoc).castAs();
 
-// 2. Assume that it is indeed non-null
+// 3. Assume that it is indeed non-null
 if (ProgramStateRef NewState = State->assume(StoredVal, true)) {
   State = NewState;
 }


Index: clang/test/Analysis/UserNullabilityAnnotations.m
===
--- clang/test/Analysis/UserNullabilityAnnotations.m
+++ clang/test/Analysis/UserNullabilityAnnotations.m
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -verify -Wno-objc-root-class %s \
+// RUN:   -Wno-tautological-pointer-compare \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=nullability \
 // RUN:   -analyzer-checker=debug.ExprInspection
@@ -34,3 +35,15 @@
   clang_analyzer_eval(Grandson->Value != 0); // expected-warning{{TRUE}}
   clang_analyzer_eval(foo()->Child->Value != 0); // expected-warning{{TRUE}}
 }
+
+// Check that we correctly process situations when non-pointer parameters
+// get nonnul attributes.
+// Original problem: rdar://problem/63150074
+typedef struct {
+  long a;
+} B;
+__attribute__((nonnull)) void c(B x, int *y);
+
+void c(B x, int *y) {
+  clang_analyzer_eval(y != 0); // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -254,12 +254,18 @@
 if (!ParameterNonNullMarks.test(Parameter->getFunctionScopeIndex()))
   continue;
 
+// 2. Check that parameter is a pointer.
+//Nonnull attribute can be applied to non-pointers (by default
+//__attribute__(nonnull) implies "all parameters").
+if (!Parameter->getType()->isPointerType())
+  continue;
+
 Loc ParameterLoc = State->getLValue(Parameter, LocContext);
 // We never consider top-level function parameters undefined.
 auto StoredVal =
 State->getSVal(ParameterLoc).castAs();
 
-// 2. Assume that it is indeed non-null
+// 3. Assume that it is indeed non-null
 if (ProgramStateRef NewState = State->assume(StoredVal, true)) {
   State = NewState;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 855f0ce - [analyzer] Fix crash for non-pointers annotated as nonnull

2020-05-13 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-05-13T13:36:49+03:00
New Revision: 855f0ce79bf3bdf34a390d1f5fd842a6aa79d5ef

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

LOG: [analyzer] Fix crash for non-pointers annotated as nonnull

Summary:
Nonnull attribute can be applied to non-pointers.  This caused assertion
failures in NonNullParamChecker when we tried to *assume* such parameters
to be non-zero.

rdar://problem/63150074

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
clang/test/Analysis/UserNullabilityAnnotations.m

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
index c3c6a69a222c..534b5d68434f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -254,12 +254,18 @@ void 
NonNullParamChecker::checkBeginFunction(CheckerContext &Context) const {
 if (!ParameterNonNullMarks.test(Parameter->getFunctionScopeIndex()))
   continue;
 
+// 2. Check that parameter is a pointer.
+//Nonnull attribute can be applied to non-pointers (by default
+//__attribute__(nonnull) implies "all parameters").
+if (!Parameter->getType()->isPointerType())
+  continue;
+
 Loc ParameterLoc = State->getLValue(Parameter, LocContext);
 // We never consider top-level function parameters undefined.
 auto StoredVal =
 State->getSVal(ParameterLoc).castAs();
 
-// 2. Assume that it is indeed non-null
+// 3. Assume that it is indeed non-null
 if (ProgramStateRef NewState = State->assume(StoredVal, true)) {
   State = NewState;
 }

diff  --git a/clang/test/Analysis/UserNullabilityAnnotations.m 
b/clang/test/Analysis/UserNullabilityAnnotations.m
index e3c2b6fb05d7..5e708c7aca58 100644
--- a/clang/test/Analysis/UserNullabilityAnnotations.m
+++ b/clang/test/Analysis/UserNullabilityAnnotations.m
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -verify -Wno-objc-root-class %s \
+// RUN:   -Wno-tautological-pointer-compare \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=nullability \
 // RUN:   -analyzer-checker=debug.ExprInspection
@@ -34,3 +35,15 @@ void f1(NestedNonnullMember *Root) {
   clang_analyzer_eval(Grandson->Value != 0); // expected-warning{{TRUE}}
   clang_analyzer_eval(foo()->Child->Value != 0); // expected-warning{{TRUE}}
 }
+
+// Check that we correctly process situations when non-pointer parameters
+// get nonnul attributes.
+// Original problem: rdar://problem/63150074
+typedef struct {
+  long a;
+} B;
+__attribute__((nonnull)) void c(B x, int *y);
+
+void c(B x, int *y) {
+  clang_analyzer_eval(y != 0); // expected-warning{{TRUE}}
+}



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


[PATCH] D79843: [analyzer] Fix crash for non-pointers annotated as nonnull

2020-05-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Perfect, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79843



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


[PATCH] D79843: [analyzer] Fix crash for non-pointers annotated as nonnull

2020-05-13 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG855f0ce79bf3: [analyzer] Fix crash for non-pointers 
annotated as nonnull (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79843

Files:
  clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  clang/test/Analysis/UserNullabilityAnnotations.m


Index: clang/test/Analysis/UserNullabilityAnnotations.m
===
--- clang/test/Analysis/UserNullabilityAnnotations.m
+++ clang/test/Analysis/UserNullabilityAnnotations.m
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -verify -Wno-objc-root-class %s \
+// RUN:   -Wno-tautological-pointer-compare \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=nullability \
 // RUN:   -analyzer-checker=debug.ExprInspection
@@ -34,3 +35,15 @@
   clang_analyzer_eval(Grandson->Value != 0); // expected-warning{{TRUE}}
   clang_analyzer_eval(foo()->Child->Value != 0); // expected-warning{{TRUE}}
 }
+
+// Check that we correctly process situations when non-pointer parameters
+// get nonnul attributes.
+// Original problem: rdar://problem/63150074
+typedef struct {
+  long a;
+} B;
+__attribute__((nonnull)) void c(B x, int *y);
+
+void c(B x, int *y) {
+  clang_analyzer_eval(y != 0); // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -254,12 +254,18 @@
 if (!ParameterNonNullMarks.test(Parameter->getFunctionScopeIndex()))
   continue;
 
+// 2. Check that parameter is a pointer.
+//Nonnull attribute can be applied to non-pointers (by default
+//__attribute__(nonnull) implies "all parameters").
+if (!Parameter->getType()->isPointerType())
+  continue;
+
 Loc ParameterLoc = State->getLValue(Parameter, LocContext);
 // We never consider top-level function parameters undefined.
 auto StoredVal =
 State->getSVal(ParameterLoc).castAs();
 
-// 2. Assume that it is indeed non-null
+// 3. Assume that it is indeed non-null
 if (ProgramStateRef NewState = State->assume(StoredVal, true)) {
   State = NewState;
 }


Index: clang/test/Analysis/UserNullabilityAnnotations.m
===
--- clang/test/Analysis/UserNullabilityAnnotations.m
+++ clang/test/Analysis/UserNullabilityAnnotations.m
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -verify -Wno-objc-root-class %s \
+// RUN:   -Wno-tautological-pointer-compare \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=nullability \
 // RUN:   -analyzer-checker=debug.ExprInspection
@@ -34,3 +35,15 @@
   clang_analyzer_eval(Grandson->Value != 0); // expected-warning{{TRUE}}
   clang_analyzer_eval(foo()->Child->Value != 0); // expected-warning{{TRUE}}
 }
+
+// Check that we correctly process situations when non-pointer parameters
+// get nonnul attributes.
+// Original problem: rdar://problem/63150074
+typedef struct {
+  long a;
+} B;
+__attribute__((nonnull)) void c(B x, int *y);
+
+void c(B x, int *y) {
+  clang_analyzer_eval(y != 0); // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -254,12 +254,18 @@
 if (!ParameterNonNullMarks.test(Parameter->getFunctionScopeIndex()))
   continue;
 
+// 2. Check that parameter is a pointer.
+//Nonnull attribute can be applied to non-pointers (by default
+//__attribute__(nonnull) implies "all parameters").
+if (!Parameter->getType()->isPointerType())
+  continue;
+
 Loc ParameterLoc = State->getLValue(Parameter, LocContext);
 // We never consider top-level function parameters undefined.
 auto StoredVal =
 State->getSVal(ParameterLoc).castAs();
 
-// 2. Assume that it is indeed non-null
+// 3. Assume that it is indeed non-null
 if (ProgramStateRef NewState = State->assume(StoredVal, true)) {
   State = NewState;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8cbd3f4 - [analyzer] SATestBuild.py: Be defensive against corrupt plist files.

2020-05-13 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-05-13T14:13:00+03:00
New Revision: 8cbd3f431a919e3398683bb5b72fdd781798bcc8

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

LOG: [analyzer] SATestBuild.py: Be defensive against corrupt plist files.

Added: 


Modified: 
clang/utils/analyzer/SATestBuild.py

Removed: 




diff  --git a/clang/utils/analyzer/SATestBuild.py 
b/clang/utils/analyzer/SATestBuild.py
index 347f1e2dd5e0..42b2658f5303 100755
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -58,6 +58,7 @@
 import sys
 import threading
 import time
+from xml.parsers.expat import ExpatError
 try:
 import queue
 except ImportError:
@@ -485,10 +486,14 @@ def CleanUpEmptyPlists(SBOutputDir):
 for F in glob.glob(SBOutputDir + "/*/*.plist"):
 P = os.path.join(SBOutputDir, F)
 
-Data = plistlib.readPlist(P)
-# Delete empty reports.
-if not Data['files']:
-os.remove(P)
+try:
+Data = plistlib.readPlist(P)
+# Delete empty reports.
+if not Data['files']:
+os.remove(P)
+continue
+except ExpatError as e:
+print('Error parsing plist file %s: %s' % (P, str(e)))
 continue
 
 



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


[PATCH] D78374: [Analyzer][StreamChecker] Added evaluation of fread and fwrite.

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

I'm sorry for the late review -- please know that this isn't the first time me 
taking a look, this is a complex issue. I find navigating your phabricator 
comments a bit difficult, it would help a lot if you would accompany them with 
a lot of code examples, and a lot more tests in the actual patch.

Error handling is super annoying with streams. Take a look at this:

  #include "stdio.h"
  
  int main() {
FILE *F = fopen("test.cpp", "r");
putc('c', F);
printf("error: %i\n", ferror(F));
char Buf[1024];
const int READ_COUNT = 5;
if (READ_COUNT != fread(Buf, sizeof(char), READ_COUNT, F))
  printf("eof: %i\n", ferror(F));
else
  printf("%s\n", Buf);
fclose(F);
  }

  $ clang++ test.cpp && ./a.out 
  error: 1
  #incl

Should we allow this? It seems like the error flag was set, but the actual 
problem is unrelated to the read, so the read still works fine.

I feel like we're constantly changing what we're shooting for, and that implies 
immediate code changes. Let's take a step back, draw a state machine (no error, 
feof, ferror, indeterminate state), and just define what is an error, what is a 
code smell, what is perfectly fine, because we don't seem to be on the clear on 
this. We need to follow and agree on the C standard in a very literal sense, 
and we're not there just yet. The amount and placement of the state splits seem 
to cause a lot of confusion and we're not ready for that discussion just yet.

D70470  is a great example for a patch with a 
state machine.

In D78374#2023195 , @balazske wrote:

> Pre-statement checks for `fread` and `fwrite` filter out the cases when the 
> position is "indeterminate", because in those states it is fatal error to 
> call the function. Otherwise if not only the **EOF** flag is set initially 
> (at start of `fread`) in `ErrorState` the `fread` should not generate state 
> when other errors are possible (or none) (this contains an execution where 
> initially EOF is set, after the function no **EOF** is set or **FERROR** is 
> set). So the **EOF** initial state must be handled separately, probably split 
> from the rest of the error state.


I read through this many times but I just don't understand what you mean, could 
you rephrase this please?

In D78374#2031694 , @balazske wrote:

> Added state split before fread to make warning for error state possible.


Is there a significant gain behind doing that instead of doing a state split 
immediately? It feels unnatural to delay the split. It doesn't accurately 
represent how the code would run. Are we supposed to do this at every precall? 
What about other checkers that may rely on this one?




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:37
+/// Note: A stream has either FEOF or FERROR set but not both at the same time.
+struct StreamErrorState {
+  /// There is an execution path with none of the error flags set.

balazske wrote:
> Szelethus wrote:
> > We're not describing the error state of a stream here, but rather 
> > //possible// error states, so the name should reflect that.
> I do not think that `StreamPossibleErrorState` is better, it is anyway a 
> //state// that can contain any information. It is an error related state even 
> if it defines not one exact error.
Alright, you convinced me.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:107
+  /// This value applies to all execution paths in ErrorState except the FEOF
+  /// case. In more detail, an EOF+indeterminate state is the same as EOF 
state.
+  bool FilePositionIndeterminate = false;

The standard suggests that this happens on FERROR, not FEOF.

> If an error occurs, the resulting value of the file position indicator for 
> the stream is indeterminate. If a partial element is read, its value is 
> indeterminate.

It would be wild if the stream wouldn't set the FEOF flag after reaching the 
end of the file. Also, I would imagine FEOF being usually implemented with the 
file position indicator.

```lang=bash
$ cat test.cpp`
```
```lang=cpp
#include "stdio.h"

int main() {
  FILE *F = fopen("test.cpp", "r");
  char Buf[1024];
  const int READ_COUNT = 9;
  if (READ_COUNT != fread(Buf, sizeof(char), READ_COUNT, F)) {
printf("%i\n", feof(F));
  }
}
```
```lang=bash
$ build/bin/clang++ test.cpp && ./a.out 
1

```

Operations on an EOF and indeterminate stream are very different.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78374



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

Yeah, this patch should definitely have unit tests. All similar patches should.


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

https://reviews.llvm.org/D79704



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


[PATCH] D79852: [libunwind] Fix wrong endianness check in Unwind-EHABI

2020-05-13 Thread Idan Freiberg via Phabricator via cfe-commits
speidy created this revision.
speidy added a reviewer: miyuki.
speidy added a project: libunwind.
Herald added subscribers: libcxx-commits, llvm-commits, kristof.beyls.
Herald added a project: LLVM.
Herald added a reviewer: libunwind.
speidy edited the summary of this revision.
speidy edited the summary of this revision.
speidy edited the summary of this revision.

The ARM specific code was trying to determine endianness using the
`__LITTLE_ENDIAN__` macro which is not guaranteed to be defined.
When not defined, it makes libunwind to build the big-endian code even
when the compiler builds for a little-endian target.

This issue leads libunwind to crash with SIGSEGV during stack unwinding when
it built for ARM by using musl-gcc toolchain (from http://musl.cc) and breaks 
exception
handling.

Switched into a more hermetic check which should also raise a
compile-time error in case endianness could not be determined.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79852

Files:
  libunwind/src/Unwind-EHABI.cpp


Index: libunwind/src/Unwind-EHABI.cpp
===
--- libunwind/src/Unwind-EHABI.cpp
+++ libunwind/src/Unwind-EHABI.cpp
@@ -31,10 +31,12 @@
 // signinficant byte.
 uint8_t getByte(const uint32_t* data, size_t offset) {
   const uint8_t* byteData = reinterpret_cast(data);
-#ifdef __LITTLE_ENDIAN__
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
   return byteData[(offset & ~(size_t)0x03) + (3 - (offset & (size_t)0x03))];
-#else
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
   return byteData[offset];
+#else
+#error "Unable to determine endianess"
 #endif
 }
 
@@ -943,10 +945,12 @@
 // SP is only 32-bit aligned so don't copy 64-bit at a time.
 uint64_t w0 = *sp++;
 uint64_t w1 = *sp++;
-#ifdef __LITTLE_ENDIAN__
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 uint64_t value = (w1 << 32) | w0;
-#else
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 uint64_t value = (w0 << 32) | w1;
+#else
+#error "Unable to determine endianess"
 #endif
 if (_Unwind_VRS_Set(context, regclass, i, representation, &value) !=
 _UVRSR_OK)


Index: libunwind/src/Unwind-EHABI.cpp
===
--- libunwind/src/Unwind-EHABI.cpp
+++ libunwind/src/Unwind-EHABI.cpp
@@ -31,10 +31,12 @@
 // signinficant byte.
 uint8_t getByte(const uint32_t* data, size_t offset) {
   const uint8_t* byteData = reinterpret_cast(data);
-#ifdef __LITTLE_ENDIAN__
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
   return byteData[(offset & ~(size_t)0x03) + (3 - (offset & (size_t)0x03))];
-#else
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
   return byteData[offset];
+#else
+#error "Unable to determine endianess"
 #endif
 }
 
@@ -943,10 +945,12 @@
 // SP is only 32-bit aligned so don't copy 64-bit at a time.
 uint64_t w0 = *sp++;
 uint64_t w1 = *sp++;
-#ifdef __LITTLE_ENDIAN__
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 uint64_t value = (w1 << 32) | w0;
-#else
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 uint64_t value = (w0 << 32) | w1;
+#else
+#error "Unable to determine endianess"
 #endif
 if (_Unwind_VRS_Set(context, regclass, i, representation, &value) !=
 _UVRSR_OK)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-05-13 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett updated this revision to Diff 263686.
DavidSpickett added a comment.

- Fix spelling
- Rework explanatory comments to be a bit clearer.


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

https://reviews.llvm.org/D79842

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/program-path-priority.c

Index: clang/test/Driver/program-path-priority.c
===
--- /dev/null
+++ clang/test/Driver/program-path-priority.c
@@ -0,0 +1,115 @@
+// Check the priority used when searching for tools
+// Names and locations are usually in this order:
+// -tool, tool, -tool
+// program path, PATH
+// (from highest to lowest priority)
+// A higher priority name found in a lower priority
+// location will win over a lower priority name in a
+// higher priority location.
+// Prefix dirs (added with -B) override the location,
+// so only name priority is accounted for, unless we fail to find
+// anything at all in the prefix.
+
+// Copy clang to a new dir which will be its
+// "program path" for these tests
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: cp %clang %t
+
+// No gccs at all, nothing is found
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NO_NOTREAL_GCC %s
+// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc
+// NO_NOTREAL_GCC-NOT: /gcc
+
+// -gcc in program path is found
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=PROG_PATH_NOTREAL_GCC %s
+// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc
+
+// -gcc on the PATH is found
+// RUN: mkdir -p %t/env
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: touch %t/env/notreal-none-elf-gcc
+// RUN: chmod +x %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=ENV_PATH_NOTREAL_GCC %s
+// ENV_PATH_NOTREAL_GCC: env/notreal-none-elf-gcc
+
+// -gcc in program path is preferred to one on the PATH
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=BOTH_NOTREAL_GCC %s
+// BOTH_NOTREAL_GCC: notreal-none-elf-gcc
+// BOTH_NOTREAL_GCC-NOT: env/notreal-none-elf-gcc
+
+// On program path, -gcc is preferred to plain gcc
+// RUN: touch %t/gcc
+// RUN: chmod +x %t/gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_GCC_PREFERRED %s
+// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc
+// NOTREAL_GCC_PREFERRED-NOT: /gcc
+
+// -gcc on the PATH is preferred to gcc in program path
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PROG %s
+// NOTREAL_PATH_OVER_GCC_PROG: /env/notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PROG-NOT: /gcc
+
+// -gcc on the PATH is preferred to gcc on the PATH
+// RUN: rm %t/gcc
+// RUN: touch %t/env/gcc
+// RUN: chmod +x %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PATH %s
+// NOTREAL_PATH_OVER_GCC_PATH: /env/notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PATH-NOT: /gcc
+
+// -gcc has lowest priority
+// RUN: default_triple=$(%t/clang --version | grep -oP "(?<=Target:\s).*")
+// RUN: touch %t/${default_triple}-gcc
+// RUN: chmod +x %t/${default_triple}-gcc
+
+// -gcc on PATH beats default triple in program path
+// RUN: touch %t/${default_triple}-gcc
+// RUN: chmod +x %t/${default_triple}-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s
+// DEFAULT_TRIPLE_GCC: env/notreal-none-elf-gcc
+
+// plain gcc on PATH beats default triple in program path
+// RUN: rm %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_NO_NOTREAL %s
+// DEFAULT_TRIPLE_NO_NOTREAL: env/gcc
+// DEFAULT_TRIPLE_NO_NOTREAL-NOT: -gcc
+
+// default triple only chosen when no others are present
+// RUN: rm %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_NO_OTHERS %s
+// DEFAULT_TRIPLE_NO_OTHERS: -gcc
+// DEFAULT_TRIPLE_NO_OTHERS-NOT: notreal-none-elf-gcc
+// DEFAULT_TRIPLE_NO_OTHERS-NOT: /gcc
+
+// -B paths are searched separately so default triple will win
+// if put in one of those even if other paths have higher priority names
+// RUN: mkdir -p %t/prefix
+// RUN: mv %t/${default_triple}-gcc %t/prefix
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s -B 

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:435-442
+  const VarDecl *VD;
+  if (const auto *VR =
+  dyn_cast(cast(Sym)->getRegion())) {
+VD = cast(VR->getDecl());
+  } else if (const auto *PR =
+ dyn_cast(cast(Sym)->getRegion())) 
{
+VD = cast(PR->getDecl());

baloghadamsoftware wrote:
> Szelethus wrote:
> > Hmm. So, the surrounding code definitely suggests that we're definitely 
> > finishing for a parameter here, but it isn't always a parameter region? I 
> > know you struggled with this, have you gained any insight as to why?
> Not all regions for `ParmVarDecl` are `ParamRegions`. Exceptions are 
> parameters captured by a lambda or a block as well as parameters of functions 
> analyzed top-level.
That would be a lovely unit test case! :)


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

https://reviews.llvm.org/D79704



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D79704#2033669 , @Szelethus wrote:

> Yeah, this patch should definitely have unit tests. All similar patches 
> should.


I wonder how I could make unit tests for this. I already looked up the unit 
tests and found no unit test for regions.


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

https://reviews.llvm.org/D79704



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-05-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Type checking/value checking for this should happen during Sema, not codegen.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2049
+ConstantFP *Confidence_f = dyn_cast(Confidence);
+if (!Confidence_f) {
+  CGM.Error(E->getArg(2)->getLocStart(),

This check should be able to be done during Sema.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2056
+  if (prob < 0.0 || prob > 1.0) {
+CGM.Error(E->getArg(2)->getLocStart(),
+  "probability of __builtin_expect_with_probability is "

Same as above, we shouldn't do this during Codegen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-05-13 Thread Ties Stuij via Phabricator via cfe-commits
stuij marked 2 inline comments as done.
stuij added a comment.

@asmith: Thanks for reviewing :) Fixed your suggestions in the coming revision.




Comment at: clang/include/clang/AST/ASTContext.h:965
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
+  CanQualType BFloat16Ty; // ARM NEON
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3

asmith wrote:
> Maybe the comment is unnecessary. I can imagine other targets besides ARM 
> NEON using BFloat
fair



Comment at: clang/include/clang/AST/Type.h:1982
   bool isFloat16Type() const;  // C11 extension ISO/IEC TS 18661
+  bool isBFloat16Type() const; // ARM BFloat
   bool isFloat128Type() const;

asmith wrote:
> don't think this comment adds anything
> 
fair


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-05-13 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 263689.
ASDenysPetrov added a comment.

Updated due to @xazax.hun comments.


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

https://reviews.llvm.org/D78933

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint_manager_conditions.cpp

Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- /dev/null
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -0,0 +1,213 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void comparison_lt(int x, int y) {
+  if (x < y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_gt(int x, int y) {
+  if (x > y) {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_le(int x, int y) {
+  if (x <= y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eva

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 9 inline comments as done.
baloghadamsoftware added a comment.

Than you for your reviews, @NoQ and @Szelethus.

In D79704#2032271 , @NoQ wrote:

> Blanket reply! `ParamRegion` is not a `DeclRegion` because it does not 
> necessarily have a corresponding `Decl`. For instance, when calling a 
> function through an unknown function pointer, you don't have the declaration 
> of a function, let alone its parameters. But for parameters of C++ object 
> type you still need your `ParamRegion` because arguments are constructed into 
> it.


Hmm, I removed the part that tries to retrieve the parameter from the arguments 
of the `CallExpr`-like `Expr` because it was never invoked (I used an 
`assert(false)` there and executed all the tests and they passed). This means 
that we always found a `Decl`. However, this `Decl` is //not stored// but 
retrieved always based on the actual stack frame: we get the `Decl` of the 
function/method/block/etc. from the stack frame and find its parameter using 
the `Index`. This is always successful, at least in all the analyzer tests.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1051
+
+  const Expr *OriginExpr;
+  unsigned Index;

NoQ wrote:
> baloghadamsoftware wrote:
> > We do not use this at all. However, if I remove it then tests begin to fail 
> > with strange reasons, some of them even crashes at strange points. It seems 
> > that we need this for profiling the subclass.
> `Profile` is completely essential. Without it different regions will be 
> treated as if it's the same region.
I know, that was not the question. It is the `OriginExpr` which I tried to 
remove because I do not use it at all, except for profiling. It seems that 
without this field the `Profile` does not work correctly.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1054-1055
+
+  ParamRegion(const Expr *OE, unsigned Idx, const MemRegion *SReg)
+  : TypedValueRegion(SReg, ParamRegionKind), OriginExpr(OE), Index(Idx) {}
+

NoQ wrote:
> It looks like you decided to keep `VarRegion` for the top frame.
> 
> I want that asserted here, in the constructor, so that never to make a 
> mistake on this front.
Yes, because in the top frame we neither have `CallExpr` nor `Decl`. So we 
should assert here that we are not in the top frame, right? How do we check 
this based on these parameters?



Comment at: clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp:197-198
+if (const ParamRegion *PR = R->getAs())
+  if (const StackArgumentsSpaceRegion *
+  stackReg = dyn_cast(PR->getMemorySpace()))
+if (stackReg->getStackFrame() == SFC)

NoQ wrote:
> Yes it is a `StackArgumentsSpaceRegion`! Because we're a parameter.
So I can remove the inner branch?



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:164
+  const auto *SSR = dyn_cast(getMemorySpace());
+  return SSR ? SSR->getStackFrame() : nullptr;
+}

NoQ wrote:
> `SSR` shouldn't ever be null. Any parameter must be on the stack.
OK, I will remove this check.



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1579-1584
+  std::tie(Call, Index) = ParamRegion::getExprAndIndexForParam(PVD, LC);
+
+  if (Call)
+OriginalVR = MemMgr.getParamRegion(Call, Index, LC);
+  else
+OriginalVR = MemMgr.getVarRegion(VD, LC);

NoQ wrote:
> I suggest making a function in `MemRegionManager` that takes a `Decl` and 
> returns a region. There should only be one place in the code that decides 
> when exactly do we produce a `ParamRegion` instead of a `VarRegion`.
Good idea!



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1732
+ const LocationContext *LC) {
+  unsigned Index = PVD->getFunctionScopeIndex();
+  const StackFrameContext *SFC = LC->getStackFrame();

NoQ wrote:
> Does this method also suffer from the parameter vs. argument off-by-one 
> problem with operators?
Actually I removed all usage of the expression thus I got rid of the problem.



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1735-1736
+  const Stmt *CallSite = SFC->getCallSite();
+  if (!CallSite)
+return std::make_pair(nullptr, UINT_MAX);
+

NoQ wrote:
> Does this actually ever happen?
I will check it.



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1740
+  if (const auto *FD = dyn_cast(D)) {
+if (Index >= FD->param_size() || FD->parameters()[Index] != PVD)
+  return std::make_pair(nullptr, UINT_MAX);

NoQ wrote:
> Why would that ever happen? If it's just a sanity check, it should be an 
> assertion.
This happens all the time a lambda or a block captures a parameter of the 
enclosing funct

[PATCH] D78129: Add Marvell ThunderX3T110 support

2020-05-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Forgot to ask/add: can you commit this, do you have commit rights?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78129



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


[PATCH] D79856: Perform ActOnConversionDeclarator after looking for any virtual functions it overrides

2020-05-13 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
rdwampler abandoned this revision.

This allows for suppressing warnings about the conversion function never being 
called if it overrides a virtual function in a base class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79856

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/conversion-function.cpp


Index: clang/test/SemaCXX/conversion-function.cpp
===
--- clang/test/SemaCXX/conversion-function.cpp
+++ clang/test/SemaCXX/conversion-function.cpp
@@ -62,6 +62,24 @@
   operator const B(); // expected-warning{{conversion function converting 'B' 
to itself will never be used}}
 };
 
+class BaseA {};
+class DerivedA;
+
+class BaseB {
+  virtual operator BaseA &() = 0;
+  virtual operator DerivedA &() = 0;
+};
+
+class DerivedA : public BaseA, BaseB {
+  virtual operator BaseA &();// OK. Overrides BaseB::operatorBaseA&()
+  virtual operator DerivedA &(); // OK. Overrides BaseB::operatorDerivedA&()
+};
+
+class DerivedB : public BaseA {
+  virtual operator DerivedB &(); // expected-warning{{conversion function 
converting 'DerivedB' to itself will never be used}}
+  virtual operator BaseA &();// expected-warning{{conversion function 
converting 'DerivedB' to its base class 'BaseA' will never be used}}
+};
+
 // This used to crash Clang.
 struct Flip;
 struct Flop {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -10486,15 +10486,12 @@
 
   // Make sure we aren't redeclaring the conversion function.
   QualType ConvType = 
Context.getCanonicalType(Conversion->getConversionType());
-
   // C++ [class.conv.fct]p1:
   //   [...] A conversion function is never used to convert a
   //   (possibly cv-qualified) object to the (possibly cv-qualified)
   //   same object type (or a reference to it), to a (possibly
   //   cv-qualified) base class of that type (or a reference to it),
   //   or to (possibly cv-qualified) void.
-  // FIXME: Suppress this warning if the conversion function ends up being a
-  // virtual function that overrides a virtual function in a base class.
   QualType ClassType
 = Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
   if (const ReferenceType *ConvTypeRef = ConvType->getAs())
@@ -10502,6 +10499,8 @@
   if (Conversion->getTemplateSpecializationKind() != TSK_Undeclared &&
   Conversion->getTemplateSpecializationKind() != 
TSK_ExplicitSpecialization)
 /* Suppress diagnostics for instantiations. */;
+  else if (Conversion->size_overridden_methods() != 0)
+/* Suppress diagnostics for overriding virtual function in a base class. 
*/;
   else if (ConvType->isRecordType()) {
 ConvType = Context.getCanonicalType(ConvType).getUnqualifiedType();
 if (ConvType == ClassType)
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10716,9 +10716,6 @@
   return Redeclaration;
 }
   }
-} else if (CXXConversionDecl *Conversion
-   = dyn_cast(NewFD)) {
-  ActOnConversionDeclarator(Conversion);
 } else if (auto *Guide = dyn_cast(NewFD)) {
   if (auto *TD = Guide->getDescribedFunctionTemplate())
 CheckDeductionGuideTemplate(TD);
@@ -10747,6 +10744,9 @@
 checkThisInStaticMemberFunctionType(Method);
 }
 
+if (CXXConversionDecl *Conversion = dyn_cast(NewFD))
+  ActOnConversionDeclarator(Conversion);
+
 // Extra checking for C++ overloaded operators (C++ [over.oper]).
 if (NewFD->isOverloadedOperator() &&
 CheckOverloadedOperatorDeclaration(NewFD)) {


Index: clang/test/SemaCXX/conversion-function.cpp
===
--- clang/test/SemaCXX/conversion-function.cpp
+++ clang/test/SemaCXX/conversion-function.cpp
@@ -62,6 +62,24 @@
   operator const B(); // expected-warning{{conversion function converting 'B' to itself will never be used}}
 };
 
+class BaseA {};
+class DerivedA;
+
+class BaseB {
+  virtual operator BaseA &() = 0;
+  virtual operator DerivedA &() = 0;
+};
+
+class DerivedA : public BaseA, BaseB {
+  virtual operator BaseA &();// OK. Overrides BaseB::operatorBaseA&()
+  virtual operator DerivedA &(); // OK. Overrides BaseB::operatorDerivedA&()
+};
+
+class DerivedB : public BaseA {
+  virtual operator DerivedB &(); // expected-warning{{conversion function converting 'DerivedB' to itself will never be used}}
+  virtual operator BaseA &();// expected-warning{{conversion function converting 'DerivedB' to its base class 'BaseA' will never be used}}
+};
+
 // This used to crash Clang.
 struct Flip;
 struct Flop {
Index: clang/lib/Sema/SemaDeclCXX.

[PATCH] D78129: Add Marvell ThunderX3T110 support

2020-05-13 Thread Wei Zhao via Phabricator via cfe-commits
wxz2020 added a comment.

Joel will help me to commit it. Thanks,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78129



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


[PATCH] D79842: [clang][Driver] Correct tool search path priority

2020-05-13 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett updated this revision to Diff 263696.
DavidSpickett added a comment.

- Updated test to look for forward or backslash in expected file paths.


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

https://reviews.llvm.org/D79842

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/program-path-priority.c

Index: clang/test/Driver/program-path-priority.c
===
--- /dev/null
+++ clang/test/Driver/program-path-priority.c
@@ -0,0 +1,115 @@
+// Check the priority used when searching for tools
+// Names and locations are usually in this order:
+// -tool, tool, -tool
+// program path, PATH
+// (from highest to lowest priority)
+// A higher priority name found in a lower priority
+// location will win over a lower priority name in a
+// higher priority location.
+// Prefix dirs (added with -B) override the location,
+// so only name priority is accounted for, unless we fail to find
+// anything at all in the prefix.
+
+// Copy clang to a new dir which will be its
+// "program path" for these tests
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: cp %clang %t
+
+// No gccs at all, nothing is found
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NO_NOTREAL_GCC %s
+// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc
+// NO_NOTREAL_GCC-NOT: {{/|}}gcc
+
+// -gcc in program path is found
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=PROG_PATH_NOTREAL_GCC %s
+// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc
+
+// -gcc on the PATH is found
+// RUN: mkdir -p %t/env
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: touch %t/env/notreal-none-elf-gcc
+// RUN: chmod +x %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=ENV_PATH_NOTREAL_GCC %s
+// ENV_PATH_NOTREAL_GCC: env{{/|}}notreal-none-elf-gcc
+
+// -gcc in program path is preferred to one on the PATH
+// RUN: touch %t/notreal-none-elf-gcc
+// RUN: chmod +x %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=BOTH_NOTREAL_GCC %s
+// BOTH_NOTREAL_GCC: notreal-none-elf-gcc
+// BOTH_NOTREAL_GCC-NOT: env{{/|}}notreal-none-elf-gcc
+
+// On program path, -gcc is preferred to plain gcc
+// RUN: touch %t/gcc
+// RUN: chmod +x %t/gcc
+// RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_GCC_PREFERRED %s
+// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc
+// NOTREAL_GCC_PREFERRED-NOT: {{/|}}gcc
+
+// -gcc on the PATH is preferred to gcc in program path
+// RUN: rm %t/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PROG %s
+// NOTREAL_PATH_OVER_GCC_PROG: env{{/|}}notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PROG-NOT: {{/|}}gcc
+
+// -gcc on the PATH is preferred to gcc on the PATH
+// RUN: rm %t/gcc
+// RUN: touch %t/env/gcc
+// RUN: chmod +x %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PATH %s
+// NOTREAL_PATH_OVER_GCC_PATH: env{{/|}}notreal-none-elf-gcc
+// NOTREAL_PATH_OVER_GCC_PATH-NOT: {{/|}}gcc
+
+// -gcc has lowest priority
+// RUN: default_triple=$(%t/clang --version | grep -oP "(?<=Target:\s).*")
+// RUN: touch %t/${default_triple}-gcc
+// RUN: chmod +x %t/${default_triple}-gcc
+
+// -gcc on PATH beats default triple in program path
+// RUN: touch %t/${default_triple}-gcc
+// RUN: chmod +x %t/${default_triple}-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s
+// DEFAULT_TRIPLE_GCC: env{{/|}}notreal-none-elf-gcc
+
+// plain gcc on PATH beats default triple in program path
+// RUN: rm %t/env/notreal-none-elf-gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_NO_NOTREAL %s
+// DEFAULT_TRIPLE_NO_NOTREAL: env{{/|}}gcc
+// DEFAULT_TRIPLE_NO_NOTREAL-NOT: -gcc
+
+// default triple only chosen when no others are present
+// RUN: rm %t/env/gcc
+// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 \
+// RUN: | FileCheck --check-prefix=DEFAULT_TRIPLE_NO_OTHERS %s
+// DEFAULT_TRIPLE_NO_OTHERS: -gcc
+// DEFAULT_TRIPLE_NO_OTHERS-NOT: notreal-none-elf-gcc
+// DEFAULT_TRIPLE_NO_OTHERS-NOT: {{/|}}gcc
+
+// -B paths are searched separately so default triple will win
+// if put in one of those even if other paths have higher priority names
+// RUN: mkdir -p %t/prefix
+// RUN: mv %t/${default_triple}-gcc %t/prefix
+// RUN: touch %t/notreal-none-elf-gcc
+// R

[PATCH] D78374: [Analyzer][StreamChecker] Added evaluation of fread and fwrite.

2020-05-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

I think this is a expected way of how it works, failure of a stream operation 
does not necessarily depend on result of a previous operation. So any operation 
can fail or not, independent of the previous error state (the "ferror" may 
happen because a temporary disk error and it is worth to retry the read, at 
least a non-`fread` function where the "indeterminate file position" problem 
does not happen). This would make things more simple. Only the EOF is probably 
exception, in EOF state any read operation fails with EOF. (But I do not know 
if it is possible that a stream in EOF state becomes non-EOF because new data 
appears at the end, if other program can write into it or it is some form of 
"pipe" or special file. If this is true even EOF needs no special handling.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78374



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


[PATCH] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/test/Analysis/vla-overflow.c:10
+// Size of this array should be the first to overflow.
+size_t s = sizeof(char[x][x][x][x]); // expected-warning{{Declared 
variable-length array (VLA) has too large size}}
+return s;

Let's not trim be checker name here.

Also, we could mention what the specific size is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330



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


[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-05-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:90
+
+  TriState GetCmpOpState(size_t CurrentOPIndex, size_t QueriedOPIndex) const {
+assert(CurrentOPIndex < CmpOpCount && QueriedOPIndex <= CmpOpCount);

I think this function should not work with indices. It should work with 
operators. So the caller of this function never need to invoke `IndexFromOp` or 
`OpFromIndex` making this function easier to use.


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

https://reviews.llvm.org/D78933



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


[PATCH] D67405: Make FormatToken::Type private.

2020-05-13 Thread Manuel Klimek via Phabricator via cfe-commits
klimek updated this revision to Diff 263707.
klimek added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67405

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp

Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -369,9 +369,9 @@
   bool SwitchLabelEncountered = false;
   do {
 tok::TokenKind kind = FormatTok->Tok.getKind();
-if (FormatTok->Type == TT_MacroBlockBegin) {
+if (FormatTok->getType() == TT_MacroBlockBegin) {
   kind = tok::l_brace;
-} else if (FormatTok->Type == TT_MacroBlockEnd) {
+} else if (FormatTok->getType() == TT_MacroBlockEnd) {
   kind = tok::r_brace;
 }
 
@@ -1033,11 +1033,11 @@
   case tok::kw_asm:
 nextToken();
 if (FormatTok->is(tok::l_brace)) {
-  FormatTok->Type = TT_InlineASMBrace;
+  FormatTok->setType(TT_InlineASMBrace);
   nextToken();
   while (FormatTok && FormatTok->isNot(tok::eof)) {
 if (FormatTok->is(tok::r_brace)) {
-  FormatTok->Type = TT_InlineASMBrace;
+  FormatTok->setType(TT_InlineASMBrace);
   nextToken();
   addUnwrappedLine();
   break;
@@ -1342,7 +1342,7 @@
 // for them (the one we know is missing are lambdas).
 if (Style.BraceWrapping.AfterFunction)
   addUnwrappedLine();
-FormatTok->Type = TT_FunctionLBrace;
+FormatTok->setType(TT_FunctionLBrace);
 parseBlock(/*MustBeDeclaration=*/false);
 addUnwrappedLine();
 return;
@@ -1658,7 +1658,7 @@
   // This might or might not actually be a lambda arrow (this could be an
   // ObjC method invocation followed by a dereferencing arrow). We might
   // reset this back to TT_Unknown in TokenAnnotator.
-  FormatTok->Type = TT_LambdaArrow;
+  FormatTok->setType(TT_LambdaArrow);
   SeenArrow = true;
   nextToken();
   break;
@@ -1666,8 +1666,8 @@
   return true;
 }
   }
-  FormatTok->Type = TT_LambdaLBrace;
-  LSquare.Type = TT_LambdaLSquare;
+  FormatTok->setType(TT_LambdaLBrace);
+  LSquare.setType(TT_LambdaLSquare);
   parseChildBlock();
   return true;
 }
@@ -1700,7 +1700,7 @@
 
   // Consume * (generator function). Treat it like C++'s overloaded operators.
   if (FormatTok->is(tok::star)) {
-FormatTok->Type = TT_OverloadedOperator;
+FormatTok->setType(TT_OverloadedOperator);
 nextToken();
   }
 
@@ -2684,8 +2684,8 @@
 E = Line.Tokens.end();
I != E; ++I) {
 llvm::dbgs() << I->Tok->Tok.getName() << "["
- << "T=" << I->Tok->Type << ", OC=" << I->Tok->OriginalColumn
- << "] ";
+ << "T=" << I->Tok->getType()
+ << ", OC=" << I->Tok->OriginalColumn << "] ";
   }
   for (std::list::const_iterator I = Line.Tokens.begin(),
 E = Line.Tokens.end();
@@ -2956,14 +2956,14 @@
   flushComments(isOnNewLine(*FormatTok));
   parsePPDirective();
 }
-while (FormatTok->Type == TT_ConflictStart ||
-   FormatTok->Type == TT_ConflictEnd ||
-   FormatTok->Type == TT_ConflictAlternative) {
-  if (FormatTok->Type == TT_ConflictStart) {
+while (FormatTok->getType() == TT_ConflictStart ||
+   FormatTok->getType() == TT_ConflictEnd ||
+   FormatTok->getType() == TT_ConflictAlternative) {
+  if (FormatTok->getType() == TT_ConflictStart) {
 conditionalCompilationStart(/*Unreachable=*/false);
-  } else if (FormatTok->Type == TT_ConflictAlternative) {
+  } else if (FormatTok->getType() == TT_ConflictAlternative) {
 conditionalCompilationAlternative();
-  } else if (FormatTok->Type == TT_ConflictEnd) {
+  } else if (FormatTok->getType() == TT_ConflictEnd) {
 conditionalCompilationEnd();
   }
   FormatTok = Tokens->getNextToken();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -118,9 +118,9 @@
 if (Style.Language == FormatStyle::LK_TextProto ||
 (Style.Language == FormatStyle::LK_Proto && Left->Previous &&
  Left->Previous->isOneOf(TT_SelectorName, TT_DictLiteral)))
-  CurrentToken->Type = TT_DictLiteral;
+  CurrentToken->setType(TT_DictLiteral);
 else
-  CurrentToken->Type = TT_TemplateCloser;
+  CurrentToken->setType(TT_TemplateCloser);
 next();
 return true;
   }
@@ -151,7 +151,7 @@

[PATCH] D67405: Make FormatToken::Type private.

2020-05-13 Thread Manuel Klimek via Phabricator via cfe-commits
klimek updated this revision to Diff 263712.
klimek added a comment.

Update docs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67405

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp

Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -369,9 +369,9 @@
   bool SwitchLabelEncountered = false;
   do {
 tok::TokenKind kind = FormatTok->Tok.getKind();
-if (FormatTok->Type == TT_MacroBlockBegin) {
+if (FormatTok->getType() == TT_MacroBlockBegin) {
   kind = tok::l_brace;
-} else if (FormatTok->Type == TT_MacroBlockEnd) {
+} else if (FormatTok->getType() == TT_MacroBlockEnd) {
   kind = tok::r_brace;
 }
 
@@ -1033,11 +1033,11 @@
   case tok::kw_asm:
 nextToken();
 if (FormatTok->is(tok::l_brace)) {
-  FormatTok->Type = TT_InlineASMBrace;
+  FormatTok->setType(TT_InlineASMBrace);
   nextToken();
   while (FormatTok && FormatTok->isNot(tok::eof)) {
 if (FormatTok->is(tok::r_brace)) {
-  FormatTok->Type = TT_InlineASMBrace;
+  FormatTok->setType(TT_InlineASMBrace);
   nextToken();
   addUnwrappedLine();
   break;
@@ -1342,7 +1342,7 @@
 // for them (the one we know is missing are lambdas).
 if (Style.BraceWrapping.AfterFunction)
   addUnwrappedLine();
-FormatTok->Type = TT_FunctionLBrace;
+FormatTok->setType(TT_FunctionLBrace);
 parseBlock(/*MustBeDeclaration=*/false);
 addUnwrappedLine();
 return;
@@ -1658,7 +1658,7 @@
   // This might or might not actually be a lambda arrow (this could be an
   // ObjC method invocation followed by a dereferencing arrow). We might
   // reset this back to TT_Unknown in TokenAnnotator.
-  FormatTok->Type = TT_LambdaArrow;
+  FormatTok->setType(TT_LambdaArrow);
   SeenArrow = true;
   nextToken();
   break;
@@ -1666,8 +1666,8 @@
   return true;
 }
   }
-  FormatTok->Type = TT_LambdaLBrace;
-  LSquare.Type = TT_LambdaLSquare;
+  FormatTok->setType(TT_LambdaLBrace);
+  LSquare.setType(TT_LambdaLSquare);
   parseChildBlock();
   return true;
 }
@@ -1700,7 +1700,7 @@
 
   // Consume * (generator function). Treat it like C++'s overloaded operators.
   if (FormatTok->is(tok::star)) {
-FormatTok->Type = TT_OverloadedOperator;
+FormatTok->setType(TT_OverloadedOperator);
 nextToken();
   }
 
@@ -2684,8 +2684,8 @@
 E = Line.Tokens.end();
I != E; ++I) {
 llvm::dbgs() << I->Tok->Tok.getName() << "["
- << "T=" << I->Tok->Type << ", OC=" << I->Tok->OriginalColumn
- << "] ";
+ << "T=" << I->Tok->getType()
+ << ", OC=" << I->Tok->OriginalColumn << "] ";
   }
   for (std::list::const_iterator I = Line.Tokens.begin(),
 E = Line.Tokens.end();
@@ -2956,14 +2956,14 @@
   flushComments(isOnNewLine(*FormatTok));
   parsePPDirective();
 }
-while (FormatTok->Type == TT_ConflictStart ||
-   FormatTok->Type == TT_ConflictEnd ||
-   FormatTok->Type == TT_ConflictAlternative) {
-  if (FormatTok->Type == TT_ConflictStart) {
+while (FormatTok->getType() == TT_ConflictStart ||
+   FormatTok->getType() == TT_ConflictEnd ||
+   FormatTok->getType() == TT_ConflictAlternative) {
+  if (FormatTok->getType() == TT_ConflictStart) {
 conditionalCompilationStart(/*Unreachable=*/false);
-  } else if (FormatTok->Type == TT_ConflictAlternative) {
+  } else if (FormatTok->getType() == TT_ConflictAlternative) {
 conditionalCompilationAlternative();
-  } else if (FormatTok->Type == TT_ConflictEnd) {
+  } else if (FormatTok->getType() == TT_ConflictEnd) {
 conditionalCompilationEnd();
   }
   FormatTok = Tokens->getNextToken();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -118,9 +118,9 @@
 if (Style.Language == FormatStyle::LK_TextProto ||
 (Style.Language == FormatStyle::LK_Proto && Left->Previous &&
  Left->Previous->isOneOf(TT_SelectorName, TT_DictLiteral)))
-  CurrentToken->Type = TT_DictLiteral;
+  CurrentToken->setType(TT_DictLiteral);
 else
-  CurrentToken->Type = TT_TemplateCloser;
+  CurrentToken->setType(TT_TemplateCloser);
 next();
 return true;
   }
@@ -151,7 +151,7 @@

[PATCH] D79072: [Analyzer][VLASizeChecker] Check VLA size in typedef and sizeof.

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

In D79072#2025120 , @martong wrote:

> I'd split this patch into two as well.
>
> 1. [NFC] Refactoring parts
> 2. The actual extra additions about sizeof and typedef. WDYT?
>
>   Other than that looks good.


I wouldn't change this now, but for the future, changes like splitting 
functions into `checkVLA` and `checkVLASize` should deserve their own revision, 
because the actual new logic would only take a few lines, and a few minutes to 
review. The biggest pain point is that both this, and the followup patch change 
the same code and it makes it difficult to know whats the new functionality and 
what is just reorganization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79072



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


[PATCH] D79708: [clang][BFloat] add NEON emitter for bfloat

2020-05-13 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

Hi @stuij ,

thank you for working on this.

Would it make sense to add a test that includes the header file you have 
created?

Regards,

Francesco




Comment at: clang/include/clang/Basic/arm_neon_incl.td:293
+
+  string CartesianProductWith = "";
 }

What is this for?



Comment at: clang/utils/TableGen/NeonEmitter.cpp:628
 S += "x" + utostr(getNumElements());
+
   if (NumVectors > 1)

Remove me.



Comment at: clang/utils/TableGen/NeonEmitter.cpp:2198
 
+static void emitNeonTypeDefs(const std::string& types, raw_ostream &OS) {
+  std::string TypedefTypes(types);

Is this related to the changes for bfloat? Or is it a just a refactoring that 
it is nice to have? If the latter, please consider submitting it as a separate 
patch. If both refactoring and BF16 related, at the moment it is not possible 
to see clearly which changes are BF16 specific, so please do submit the 
refactoring first.



Comment at: clang/utils/TableGen/NeonEmitter.cpp:2617
+
+  OS << "#endif";
 }

Missing `\n`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79708



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


[PATCH] D79862: [clangd-remote] Replace YAML serialization with proper Protobuf messages

2020-05-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

YAML serialization was used in the Proof of Concept for simplicity.
This patch replaces implements Protobuf (de) serialization of almost all
types that need to be transferred over the protocol.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79862

Files:
  clang-tools-extra/clangd/index/Serialization.h
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp

Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -7,13 +7,90 @@
 //===--===//
 
 #include "Marshalling.h"
+#include "Index.pb.h"
+#include "Protocol.h"
 #include "index/Serialization.h"
+#include "index/Symbol.h"
+#include "index/SymbolID.h"
+#include "index/SymbolLocation.h"
+#include "index/SymbolOrigin.h"
 #include "support/Logger.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/StringSaver.h"
 
 namespace clang {
 namespace clangd {
 namespace remote {
 
+namespace {
+
+clangd::SymbolLocation::Position fromProtobuf(const Position &Message) {
+  clangd::SymbolLocation::Position Result;
+  Result.setColumn(static_cast(Message.column()));
+  Result.setLine(static_cast(Message.line()));
+  return Result;
+}
+
+Position toProtobuf(const clangd::SymbolLocation::Position &Position) {
+  remote::Position Result;
+  Result.set_column(Position.column());
+  Result.set_line(Position.line());
+  return Result;
+}
+
+clang::index::SymbolInfo fromProtobuf(const SymbolInfo &Message) {
+  clang::index::SymbolInfo Result;
+  Result.Kind = static_cast(Message.kind());
+  Result.SubKind = static_cast(Message.subkind());
+  Result.Lang = static_cast(Message.language());
+  Result.Properties =
+  static_cast(Message.properties());
+  return Result;
+}
+
+SymbolInfo toProtobuf(const clang::index::SymbolInfo &Info) {
+  SymbolInfo Result;
+  Result.set_kind(static_cast(Info.Kind));
+  Result.set_subkind(static_cast(Info.SubKind));
+  Result.set_language(static_cast(Info.Lang));
+  Result.set_properties(static_cast(Info.Properties));
+  return Result;
+}
+
+clangd::SymbolLocation fromProtobuf(const SymbolLocation &Message,
+llvm::UniqueStringSaver *Strings) {
+  clangd::SymbolLocation Location;
+  Location.Start = fromProtobuf(Message.start());
+  Location.End = fromProtobuf(Message.end());
+  Location.FileURI = Strings->save(Message.file_uri()).begin();
+  return Location;
+}
+
+SymbolLocation toProtobuf(const clangd::SymbolLocation &Location) {
+  remote::SymbolLocation Result;
+  *Result.mutable_start() = toProtobuf(Location.Start);
+  *Result.mutable_end() = toProtobuf(Location.End);
+  *Result.mutable_file_uri() = Location.FileURI;
+  return Result;
+}
+
+HeaderWithReferences
+toProtobuf(const clangd::Symbol::IncludeHeaderWithReferences &IncludeHeader) {
+  HeaderWithReferences Result;
+  Result.set_header(IncludeHeader.IncludeHeader.str());
+  Result.set_references(IncludeHeader.References);
+  return Result;
+}
+
+clangd::Symbol::IncludeHeaderWithReferences
+fromProtobuf(const HeaderWithReferences &Message) {
+  return clangd::Symbol::IncludeHeaderWithReferences{Message.header(),
+ Message.references()};
+}
+
+} // namespace
+
 clangd::FuzzyFindRequest fromProtobuf(const FuzzyFindRequest *Request) {
   clangd::FuzzyFindRequest Result;
   Result.Query = Request->query();
@@ -22,7 +99,7 @@
   Result.AnyScope = Request->any_scope();
   if (Request->limit())
 Result.Limit = Request->limit();
-  Result.RestrictForCodeCompletion = Request->resricted_for_code_completion();
+  Result.RestrictForCodeCompletion = Request->restricted_for_code_completion();
   for (const auto &Path : Request->proximity_paths())
 Result.ProximityPaths.push_back(Path);
   for (const auto &Type : Request->preferred_types())
@@ -32,21 +109,50 @@
 
 llvm::Optional fromProtobuf(const Symbol &Message,
 llvm::UniqueStringSaver *Strings) {
-  auto Result = symbolFromYAML(Message.yaml_serialization(), Strings);
-  if (!Result) {
-elog("Cannot convert Symbol from Protobuf: {}", Result.takeError());
+  if (!Message.has_info() || !Message.has_definition() ||
+  !Message.has_canonical_declarattion()) {
+elog("Cannot convert Symbol from Protobuf: {}", Message.ShortDebugString());
 return llvm::None;
   }
-  return *

[clang] 4b53495 - Perform ActOnConversionDeclarator after looking for any virtual functions it overrides

2020-05-13 Thread Ronald Wampler via cfe-commits

Author: Ronald Wampler
Date: 2020-05-13T10:34:19-04:00
New Revision: 4b53495c4ba2ba410f6383f9c57593e838ec0d57

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

LOG: Perform ActOnConversionDeclarator after looking for any virtual functions 
it overrides

Summary: This allows for suppressing warnings about the conversion function 
never being called if it overrides a virtual function in a base class.

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/conversion-function.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index eba672d54cf8..74a4fd8a06de 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -10716,9 +10716,6 @@ bool Sema::CheckFunctionDeclaration(Scope *S, 
FunctionDecl *NewFD,
   return Redeclaration;
 }
   }
-} else if (CXXConversionDecl *Conversion
-   = dyn_cast(NewFD)) {
-  ActOnConversionDeclarator(Conversion);
 } else if (auto *Guide = dyn_cast(NewFD)) {
   if (auto *TD = Guide->getDescribedFunctionTemplate())
 CheckDeductionGuideTemplate(TD);
@@ -10747,6 +10744,9 @@ bool Sema::CheckFunctionDeclaration(Scope *S, 
FunctionDecl *NewFD,
 checkThisInStaticMemberFunctionType(Method);
 }
 
+if (CXXConversionDecl *Conversion = dyn_cast(NewFD))
+  ActOnConversionDeclarator(Conversion);
+
 // Extra checking for C++ overloaded operators (C++ [over.oper]).
 if (NewFD->isOverloadedOperator() &&
 CheckOverloadedOperatorDeclaration(NewFD)) {

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 935ac93e9922..3f1121c0e9b2 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -10486,15 +10486,12 @@ Decl 
*Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
 
   // Make sure we aren't redeclaring the conversion function.
   QualType ConvType = 
Context.getCanonicalType(Conversion->getConversionType());
-
   // C++ [class.conv.fct]p1:
   //   [...] A conversion function is never used to convert a
   //   (possibly cv-qualified) object to the (possibly cv-qualified)
   //   same object type (or a reference to it), to a (possibly
   //   cv-qualified) base class of that type (or a reference to it),
   //   or to (possibly cv-qualified) void.
-  // FIXME: Suppress this warning if the conversion function ends up being a
-  // virtual function that overrides a virtual function in a base class.
   QualType ClassType
 = Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
   if (const ReferenceType *ConvTypeRef = ConvType->getAs())
@@ -10502,6 +10499,8 @@ Decl *Sema::ActOnConversionDeclarator(CXXConversionDecl 
*Conversion) {
   if (Conversion->getTemplateSpecializationKind() != TSK_Undeclared &&
   Conversion->getTemplateSpecializationKind() != 
TSK_ExplicitSpecialization)
 /* Suppress diagnostics for instantiations. */;
+  else if (Conversion->size_overridden_methods() != 0)
+/* Suppress diagnostics for overriding virtual function in a base class. 
*/;
   else if (ConvType->isRecordType()) {
 ConvType = Context.getCanonicalType(ConvType).getUnqualifiedType();
 if (ConvType == ClassType)

diff  --git a/clang/test/SemaCXX/conversion-function.cpp 
b/clang/test/SemaCXX/conversion-function.cpp
index 1486abea8c60..fdd603c98f43 100644
--- a/clang/test/SemaCXX/conversion-function.cpp
+++ b/clang/test/SemaCXX/conversion-function.cpp
@@ -62,6 +62,24 @@ class B : public A {
   operator const B(); // expected-warning{{conversion function converting 'B' 
to itself will never be used}}
 };
 
+class BaseA {};
+class DerivedA;
+
+class BaseB {
+  virtual operator BaseA &() = 0;
+  virtual operator DerivedA &() = 0;
+};
+
+class DerivedA : public BaseA, BaseB {
+  virtual operator BaseA &();// OK. Overrides BaseB::operatorBaseA&()
+  virtual operator DerivedA &(); // OK. Overrides BaseB::operatorDerivedA&()
+};
+
+class DerivedB : public BaseA {
+  virtual operator DerivedB &(); // expected-warning{{conversion function 
converting 'DerivedB' to itself will never be used}}
+  virtual operator BaseA &();// expected-warning{{conversion function 
converting 'DerivedB' to its base class 'BaseA' will never be used}}
+};
+
 // This used to crash Clang.
 struct Flip;
 struct Flop {



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


[clang] 53cc90f - Make FormatToken::Type private.

2020-05-13 Thread Manuel Klimek via cfe-commits

Author: Manuel Klimek
Date: 2020-05-13T16:37:58+02:00
New Revision: 53cc90f789996d1e1edc6a9233a85ce8d658aadd

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

LOG: Make FormatToken::Type private.

This enables us to intercept changes to the token type via setType(), which
is a precondition for being able to use multi-pass formatting for macro
arguments.

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/lib/Format/FormatToken.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 655df7e45ba7..2e39b03563ae 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1914,7 +1914,7 @@ class ObjCHeaderStyleGuesser : public TokenAnalyzer {
  << FormatTok->Tok.getLocation().printToString(
 SourceManager)
  << " token: " << FormatTok->TokenText << " token type: "
- << getTokenTypeName(FormatTok->Type) << "\n");
+ << getTokenTypeName(FormatTok->getType()) << "\n");
   return true;
 }
 if (guessIsObjC(SourceManager, Line->Children, Keywords))

diff  --git a/clang/lib/Format/FormatToken.cpp 
b/clang/lib/Format/FormatToken.cpp
index 90d09064bb43..ee35f3afae37 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -84,8 +84,8 @@ unsigned CommaSeparatedList::formatAfterToken(LineState 
&State,
   const FormatToken *LBrace =
   State.NextToken->Previous->getPreviousNonComment();
   if (!LBrace || !LBrace->isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) ||
-  LBrace->BlockKind == BK_Block || LBrace->Type == TT_DictLiteral ||
-  LBrace->Next->Type == TT_DesignatedInitializerPeriod)
+  LBrace->BlockKind == BK_Block || LBrace->getType() == TT_DictLiteral ||
+  LBrace->Next->getType() == TT_DesignatedInitializerPeriod)
 return 0;
 
   // Calculate the number of code points we have to format this list. As the

diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index c67cf192ab1f..7b6b1e8ddce7 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -113,6 +113,8 @@ namespace format {
   TYPE(CSharpGenericTypeConstraintComma)   
\
   TYPE(Unknown)
 
+/// Determines the semantic type of a syntactic token, e.g. whether "<" is a
+/// template opener or binary operator.
 enum TokenType {
 #define TYPE(X) TT_##X,
   LIST_TOKEN_TYPES
@@ -192,7 +194,10 @@ struct FormatToken {
   /// Contains the kind of block if this token is a brace.
   BraceBlockKind BlockKind = BK_Unknown;
 
-  TokenType Type = TT_Unknown;
+  /// Returns the token's type, e.g. whether "<" is a template opener or
+  /// binary operator.
+  TokenType getType() const { return Type; }
+  void setType(TokenType T) { Type = T; }
 
   /// The number of spaces that should be inserted before this token.
   unsigned SpacesRequiredBefore = 0;
@@ -590,6 +595,8 @@ struct FormatToken {
   return Previous->endsSequenceInternal(K1, Tokens...);
 return is(K1) && Previous && Previous->endsSequenceInternal(Tokens...);
   }
+
+  TokenType Type = TT_Unknown;
 };
 
 class ContinuationIndenter;

diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index 9e081e1495d0..249d3ac39c3e 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -158,7 +158,7 @@ bool FormatTokenLexer::tryMergeNSStringLiteral() {
   At->TokenText = StringRef(At->TokenText.begin(),
 String->TokenText.end() - At->TokenText.begin());
   At->ColumnWidth += String->ColumnWidth;
-  At->Type = TT_ObjCStringLiteral;
+  At->setType(TT_ObjCStringLiteral);
   Tokens.erase(Tokens.end() - 1);
   return true;
 }
@@ -177,7 +177,7 @@ bool FormatTokenLexer::tryMergeJSPrivateIdentifier() {
   StringRef(Hash->TokenText.begin(),
 Identifier->TokenText.end() - Hash->TokenText.begin());
   Hash->ColumnWidth += Identifier->ColumnWidth;
-  Hash->Type = TT_JsPrivateIdentifier;
+  Hash->setType(TT_JsPrivateIdentifier);
   Tokens.erase(Tokens.end() - 1);
   return true;
 }
@@ -201,7 +201,7 @@ bool FormatTokenLexer::tryMergeCSharpStringLiteral() {
   // would require similar work as that done for JavaScript template strings
   // in `handleTemplateStrings()`.
   auto &CSharpInterpolatedString = *(Tokens.end() - 2);
-  if (CSharpInterpolatedString->Type == TT_CSharpStringLiteral &&
+  if (CSharpInterpolatedString->getTyp

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1735-1736
+  const Stmt *CallSite = SFC->getCallSite();
+  if (!CallSite)
+return std::make_pair(nullptr, UINT_MAX);
+

baloghadamsoftware wrote:
> NoQ wrote:
> > Does this actually ever happen?
> I will check it.
Oh yes. If we have no `CallSite`, then we are in the top frame. Should I check 
`LC->inTopFrame()` instead?


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

https://reviews.llvm.org/D79704



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


[PATCH] D79710: [clang][BFloat] add create/set/get/dup intrinsics

2020-05-13 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c:119-120
+// CHECK-LABEL: test_vduph_laneq_bf16
+// CHECK64: %vgetq_lane = extractelement <8 x bfloat> %v, i32 7
+// CHECK32: %vget_lane = extractelement <8 x bfloat> %v, i32 7

This seems to be the only place where you need to differentiate between check32 
and check64, and I am not 100% sure the extra `q` in the name of the variable 
is relevant in terms of codegen testing.

Maybe you can just test both aarch32 and aarch64 with the same `CHECK` prefix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79710



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


[PATCH] D79035: [clang][AIX] Implement ABIInfo and TargetCodeGenInfo for AIX

2020-05-13 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1300
   OPT_maix_struct_return, OPT_msvr4_struct_return)) {
+// TODO: We might want to consider enabling these options on AIX in the
+// future.

Since we disable them in FE, should we remove the one in driver?



Comment at: clang/test/Frontend/aix-unsupported.c:10
+// RUN:   -c %s 2>&1 | FileCheck %s
+// CHECK: unsupported option

One thing I am not so sure about is that for these two options 
`-maix-struct-return`,  `-msvr4-struct-return`, do we need to update the 
`ClangCommandLineReference.rst` since we emit diags `unsupported option 
'-maix-struct-return' for target 'powerpc-unknown-aix'`


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

https://reviews.llvm.org/D79035



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-05-13 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 263719.
stuij added a comment.

changes:

- addressed asmith's comments
- Bfloat doesn't depend on half cmdline options and correct code is generation 
for AArch32 hard and softfp CC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypeCache.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-mangle-16bit-float.cpp
  clang/test/Sema/arm-bf16-forbidden-ops.c
  clang/test/Sema/arm-bf16-forbidden-ops.cpp
  clang/test/Sema/arm-bfloat.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -608,6 +608,7 @@
 TKIND(Elaborated);
 TKIND(Pipe);
 TKIND(Attributed);
+TKIND(BFloat16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
 #undef IMAGE_TYPE
Index: clang/test/Sema/arm-bfloat.cpp
===
--- /dev/null
+++ clang/test/Sema/arm-bfloat.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple aarch64-arm-none-eabi -target-cpu cortex-a75 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple arm-arm-none-eabi -target-cpu cortex-a53 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+
+void test(bool b) {
+  __bf16 bf16;
+
+  bf16 + bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 - bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 * bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 / bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+
+  __fp16 fp16;
+
+  bf16 + fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 + bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 - fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 - bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 * fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 * bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 / fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 / bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 = fp16; // expected-error {{assigning to '__bf16' from incompatible type '__fp16'}}
+  fp16 = bf16; // expected-error {{assigning to '__fp16' from incompatible type '__bf16'}}
+  bf16 + (b ? fp16 : bf16); // expected-error {{incompatible operand types ('__fp16' and '__bf16')}}
+}
Index: clang/test/Sema/arm-bf16-forbidden-ops.cpp
===
--- /dev/null
+++ clang/test/Sema/arm-bf16-forbidden-ops.cpp
@@ -0,0 +1,71 @@
+// RU

[PATCH] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

> Variable-length array (VLA) should have a size that fits into a size_t value. 
> At least if the size is queried with sizeof, but it is better (and more 
> simple) to check it always

So it is creating VLA larger than `sizeof(size_t)` isn't a bug, bur rather a 
sign of code smell? Then we shouldn't create a fatal error node for it, 
**unless** we're trying to fit it in a variable that isn't sufficiently large. 
The fact that `sizeof` it is a bug wasn't immediately obvious to me either, so 
a quote from the standard as comments would be appreciated:

§6.5.3.4.4 , about 
operator sizeof: The value of the result is implementation-defined, and its 
type (an unsigned integer type) is `size_t`, defined in `` (and other 
headers).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 263720.
baloghadamsoftware added a comment.

Updated according to the comments from @NoQ.


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

https://reviews.llvm.org/D79704

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -440,6 +440,9 @@
   if (const auto *VR = dyn_cast(MR))
 return isLive(VR, true);
 
+  if (const auto *PR = dyn_cast(MR))
+return isLive(PR, true);
+
   // FIXME: This is a gross over-approximation. What we really need is a way to
   // tell if anything still refers to this region. Unlike SymbolicRegions,
   // AllocaRegions don't have associated symbols, though, so we don't actually
@@ -573,3 +576,53 @@
 
   return VarContext->isParentOf(CurrentContext);
 }
+
+bool SymbolReaper::isLive(const ParamRegion *PR,
+  bool includeStoreBindings) const{
+  const StackFrameContext *ParamContext = PR->getStackFrame();
+
+  if (!ParamContext)
+return true;
+
+  if (!LCtx)
+return false;
+  const StackFrameContext *CurrentContext = LCtx->getStackFrame();
+
+  if (ParamContext == CurrentContext) {
+// If no statement is provided, everything is live.
+if (!Loc)
+  return true;
+
+// Anonymous parameters of an inheriting constructor are live for the entire
+// duration of the constructor.
+if (isa(Loc))
+  return true;
+
+if (const ParmVarDecl *PVD = PR->getDecl()) {
+  if (LCtx->getAnalysis()->isLive(Loc, PVD))
+return true;
+}
+
+if (!includeStoreBindings)
+  return false;
+
+unsigned &cachedQuery =
+  const_cast(this)->includedRegionCache[PR];
+
+if (cachedQuery) {
+  return cachedQuery == 1;
+}
+
+// Query the store to see if the region occurs in any live bindings.
+if (Store store = reapedStore.getStore()) {
+  bool hasRegion =
+reapedStore.getStoreManager().includedInBindings(store, PR);
+  cachedQuery = hasRegion ? 1 : 2;
+  return hasRegion;
+}
+
+return false;
+  }
+
+  return ParamContext->isParentOf(CurrentContext);
+}
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -138,6 +138,7 @@
 case MemRegion::CXXTempObjectRegionKind:
 case MemRegion::CXXBaseObjectRegionKind:
 case MemRegion::CXXDerivedObjectRegionKind:
+case MemRegion::ParamRegionKind:
   return MakeElementRegion(cast(R), PointeeTy);
 
 case MemRegion::ElementRegionKind: {
@@ -435,6 +436,13 @@
   return svalBuilder.dispatchCast(V, castTy);
 }
 
+Loc StoreManager::getLValueVar(const VarDecl *VD, const LocationContext *LC) {
+  if (const auto *PVD = dyn_cast(VD))
+return svalBuilder.makeLoc(MRMgr.getRegionForParam(PVD, LC));
+
+  return svalBuilder.makeLoc(MRMgr.getVarRegion(VD, LC));
+}
+
 SVal StoreManager::getLValueFieldOrIvar(const Decl *D, SVal Base) {
   if (Base.isUnknownOrUndef())
 return Base;
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -569,6 +569,8 @@
 
   SVal getBindingForVar(RegionBindingsConstRef B, const VarRegion *R);
 
+  SVal getBindingForParam(RegionBindingsConstRef B, const ParamRegion *R);
+
   SVal getBindingForLazySymbol(const TypedValueRegion *R);
 
   SVal getBindingForFieldOrElementCommon(RegionBindingsConstRef B,
@@ -1510,6 +1512,16 @@
 return CastRetrievedVal(getBindingForVar(B

[PATCH] D78444: Perform ActOnConversionDeclarator after looking for any virtual functions it overrides

2020-05-13 Thread Ronald Wampler via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b53495c4ba2: Perform ActOnConversionDeclarator after 
looking for any virtual functions it… (authored by rdwampler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78444

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/conversion-function.cpp


Index: clang/test/SemaCXX/conversion-function.cpp
===
--- clang/test/SemaCXX/conversion-function.cpp
+++ clang/test/SemaCXX/conversion-function.cpp
@@ -62,6 +62,24 @@
   operator const B(); // expected-warning{{conversion function converting 'B' 
to itself will never be used}}
 };
 
+class BaseA {};
+class DerivedA;
+
+class BaseB {
+  virtual operator BaseA &() = 0;
+  virtual operator DerivedA &() = 0;
+};
+
+class DerivedA : public BaseA, BaseB {
+  virtual operator BaseA &();// OK. Overrides BaseB::operatorBaseA&()
+  virtual operator DerivedA &(); // OK. Overrides BaseB::operatorDerivedA&()
+};
+
+class DerivedB : public BaseA {
+  virtual operator DerivedB &(); // expected-warning{{conversion function 
converting 'DerivedB' to itself will never be used}}
+  virtual operator BaseA &();// expected-warning{{conversion function 
converting 'DerivedB' to its base class 'BaseA' will never be used}}
+};
+
 // This used to crash Clang.
 struct Flip;
 struct Flop {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -10486,15 +10486,12 @@
 
   // Make sure we aren't redeclaring the conversion function.
   QualType ConvType = 
Context.getCanonicalType(Conversion->getConversionType());
-
   // C++ [class.conv.fct]p1:
   //   [...] A conversion function is never used to convert a
   //   (possibly cv-qualified) object to the (possibly cv-qualified)
   //   same object type (or a reference to it), to a (possibly
   //   cv-qualified) base class of that type (or a reference to it),
   //   or to (possibly cv-qualified) void.
-  // FIXME: Suppress this warning if the conversion function ends up being a
-  // virtual function that overrides a virtual function in a base class.
   QualType ClassType
 = Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
   if (const ReferenceType *ConvTypeRef = ConvType->getAs())
@@ -10502,6 +10499,8 @@
   if (Conversion->getTemplateSpecializationKind() != TSK_Undeclared &&
   Conversion->getTemplateSpecializationKind() != 
TSK_ExplicitSpecialization)
 /* Suppress diagnostics for instantiations. */;
+  else if (Conversion->size_overridden_methods() != 0)
+/* Suppress diagnostics for overriding virtual function in a base class. 
*/;
   else if (ConvType->isRecordType()) {
 ConvType = Context.getCanonicalType(ConvType).getUnqualifiedType();
 if (ConvType == ClassType)
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10716,9 +10716,6 @@
   return Redeclaration;
 }
   }
-} else if (CXXConversionDecl *Conversion
-   = dyn_cast(NewFD)) {
-  ActOnConversionDeclarator(Conversion);
 } else if (auto *Guide = dyn_cast(NewFD)) {
   if (auto *TD = Guide->getDescribedFunctionTemplate())
 CheckDeductionGuideTemplate(TD);
@@ -10747,6 +10744,9 @@
 checkThisInStaticMemberFunctionType(Method);
 }
 
+if (CXXConversionDecl *Conversion = dyn_cast(NewFD))
+  ActOnConversionDeclarator(Conversion);
+
 // Extra checking for C++ overloaded operators (C++ [over.oper]).
 if (NewFD->isOverloadedOperator() &&
 CheckOverloadedOperatorDeclaration(NewFD)) {


Index: clang/test/SemaCXX/conversion-function.cpp
===
--- clang/test/SemaCXX/conversion-function.cpp
+++ clang/test/SemaCXX/conversion-function.cpp
@@ -62,6 +62,24 @@
   operator const B(); // expected-warning{{conversion function converting 'B' to itself will never be used}}
 };
 
+class BaseA {};
+class DerivedA;
+
+class BaseB {
+  virtual operator BaseA &() = 0;
+  virtual operator DerivedA &() = 0;
+};
+
+class DerivedA : public BaseA, BaseB {
+  virtual operator BaseA &();// OK. Overrides BaseB::operatorBaseA&()
+  virtual operator DerivedA &(); // OK. Overrides BaseB::operatorDerivedA&()
+};
+
+class DerivedB : public BaseA {
+  virtual operator DerivedB &(); // expected-warning{{conversion function converting 'DerivedB' to itself will never be used}}
+  virtual operator BaseA &();// expected-warning{{conversion function converting 'DerivedB' to its base class 'BaseA' will never be used}}
+};
+
 // This used to crash Clang.
 struct Flip;
 struct Flop {
Index: clang/lib/Sema/SemaDeclCXX.cpp

[clang] a1fd188 - [FileCheck] Support comment directives

2020-05-13 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-05-13T11:29:48-04:00
New Revision: a1fd188223d9c9b404dccd3511fe8b63ef022a13

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

LOG: [FileCheck] Support comment directives

Sometimes you want to disable a FileCheck directive without removing
it entirely, or you want to write comments that mention a directive by
name.  The `COM:` directive makes it easy to do this.  For example,
you might have:

```
; X32: pinsrd_1:
; X32:pinsrd $1, 4(%esp), %xmm0

; COM: FIXME: X64 isn't working correctly yet for this part of codegen, but
; COM: X64 will have something similar to X32:
; COM:
; COM:   X64: pinsrd_1:
; COM:   X64:pinsrd $1, %edi, %xmm0
```

Without this patch, you need to use some combination of rewording and
directive syntax mangling to prevent FileCheck from recognizing the
commented occurrences of `X32:` and `X64:` above as directives.
Moreover, FileCheck diagnostics have been proposed that might complain
about the occurrences of `X64` that don't have the trailing `:`
because they look like directive typos:

  

I think dodging all these problems can prove tedious for test authors,
and directive syntax mangling already makes the purpose of existing
test code unclear.  `COM:` can avoid all these problems.

This patch also updates the small set of existing tests that define
`COM` as a check prefix:

- clang/test/CodeGen/default-address-space.c
- clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
- clang/test/Driver/hip-device-libs.hip
- llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll

I think lit should support `COM:` as well.  Perhaps `clang -verify`
should too.

Reviewed By: jhenderson, thopre

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

Added: 
llvm/test/FileCheck/comment/after-words.txt
llvm/test/FileCheck/comment/bad-comment-prefix.txt
llvm/test/FileCheck/comment/blank-comments.txt
llvm/test/FileCheck/comment/suffixes.txt
llvm/test/FileCheck/comment/suppresses-checks.txt
llvm/test/FileCheck/comment/unused-check-prefixes.txt
llvm/test/FileCheck/comment/unused-comment-prefixes.txt
llvm/test/FileCheck/comment/within-checks.txt

Modified: 
clang/test/CodeGen/default-address-space.c
clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
clang/test/Driver/hip-device-libs.hip
llvm/docs/CommandGuide/FileCheck.rst
llvm/include/llvm/Support/FileCheck.h
llvm/lib/Support/FileCheck.cpp
llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
llvm/test/FileCheck/first-character-match.txt
llvm/test/FileCheck/validate-check-prefix.txt
llvm/utils/FileCheck/FileCheck.cpp

Removed: 




diff  --git a/clang/test/CodeGen/default-address-space.c 
b/clang/test/CodeGen/default-address-space.c
index 21ba2b3269c2..6b3d7bc2e32a 100644
--- a/clang/test/CodeGen/default-address-space.c
+++ b/clang/test/CodeGen/default-address-space.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK,COM %s
+// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck 
-check-prefixes=CHECK %s
 
 // CHECK-DAG: @foo = addrspace(1) global i32 0
 int foo;
@@ -11,17 +11,17 @@ int ban[10];
 int *A;
 int *B;
 
-// COM-LABEL: define i32 @test1()
+// CHECK-LABEL: define i32 @test1()
 // CHECK: load i32, i32* addrspacecast{{[^@]+}} @foo
 int test1() { return foo; }
 
-// COM-LABEL: define i32 @test2(i32 %i)
-// COM: %[[addr:.*]] = getelementptr
+// CHECK-LABEL: define i32 @test2(i32 %i)
+// CHECK: %[[addr:.*]] = getelementptr
 // CHECK: load i32, i32* %[[addr]]
 // CHECK-NEXT: ret i32
 int test2(int i) { return ban[i]; }
 
-// COM-LABEL: define void @test3()
+// CHECK-LABEL: define void @test3()
 // CHECK: load i32*, i32** addrspacecast{{.*}} @B
 // CHECK: load i32, i32*
 // CHECK: load i32*, i32** addrspacecast{{.*}} @A

diff  --git a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl 
b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
index 35cc54c50d6f..e1f3f6fe1419 100644
--- a/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
+++ b/clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=COM,X86 %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple amdgcn | FileCheck 
-enable-var-scope -check-prefixes=COM,AMDGCN %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL2.0 -O0 -triple amdgcn | 
FileCheck -enable-var-scope -check-prefixes=COM,AMDGCN,AMDGCN20 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -ffake-address-space-map -triple 
i686-pc-darwin | FileCheck -enable-var-scope -check-prefixes=ALL,X86 %s
+// RUN: %clang_cc1 %s -emit-llvm -o 

[clang] cf2fb13 - Add -print-targets to print the registered targets

2020-05-13 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-05-13T11:34:22-04:00
New Revision: cf2fb139321ca06b5200a88847fabec93ee92d80

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

LOG: Add -print-targets to print the registered targets

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 20d2240a6078..317b6c191628 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -130,6 +130,7 @@ Modified Compiler Flags
 - ``-fno-char8_t`` now disables the ``char8_t`` keyword, not just the use of
   ``char8_t`` as the character type of ``u8`` literals. This restores the
   Clang 8 behavior that regressed in Clang 9 and 10.
+- -print-targets has been added to print the registered targets.
 
 New Pragmas in Clang
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8bfdfcac687c..158c2ad29bf7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2804,6 +2804,8 @@ def print_resource_dir : Flag<["-", "--"], 
"print-resource-dir">,
   HelpText<"Print the resource directory pathname">;
 def print_search_dirs : Flag<["-", "--"], "print-search-dirs">,
   HelpText<"Print the paths used for finding libraries and programs">;
+def print_targets : Flag<["-", "--"], "print-targets">,
+  HelpText<"Print the registered targets">;
 def private__bundle : Flag<["-"], "private_bundle">;
 def pthreads : Flag<["-"], "pthreads">;
 def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7d82c8faa573..5c726b23148f 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1815,6 +1815,11 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
 return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_targets)) {
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
+return false;
+  }
+
   return true;
 }
 



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


[PATCH] D79866: [CUDA][HIP] Do not emit debug info for stub function

2020-05-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.
Herald added a subscriber: aprantl.
Herald added a reviewer: aaron.ballman.

The stub function is generated by compiler and its instructions have nothing
to do with the kernel source code.

Currently clang generates debug info for the stub function, which causes
confusion for the debugger. For example, when users set break point
on a line of a kernel, the debugger should break on that line when the kernel is
executed and reaches that line, but instead the debugger breaks in the stub 
function.

This patch disables debug info for stub function.


https://reviews.llvm.org/D79866

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenCUDA/kernel-dbg-info.cu


Index: clang/test/CodeGenCUDA/kernel-dbg-info.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/kernel-dbg-info.cu
@@ -0,0 +1,33 @@
+// RUN: echo "GPU binary would be here" > %t
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+extern "C" __global__ void ckernel(int *a) {
+  *a = 1;
+}
+
+// Device side kernel names
+// CHECK: @[[CKERN:[0-9]*]] = {{.*}} c"ckernel\00"
+
+// DEV: define {{.*}}@ckernel{{.*}}!dbg
+// DEV:  store {{.*}}!dbg
+// DEV:  ret {{.*}}!dbg
+
+// CHECK-NOT: define {{.*}}@__device_stub__ckernel{{.*}}!dbg
+// CHECK: define {{.*}}@[[CSTUB:__device_stub__ckernel]]
+// CHECK-NOT: call {{.*}}@hipLaunchByPtr{{.*}}!dbg
+// CHECK: call {{.*}}@hipLaunchByPtr{{.*}}@[[CSTUB]]
+// CHECK-NOT: ret {{.*}}!dbg
+
+// CHECK-LABEL: define {{.*}}@_Z8hostfuncPi{{.*}}!dbg
+// CHECK: call void @[[CSTUB]]{{.*}}!dbg
+void hostfunc(int *a) {
+  ckernel<<<1, 1>>>(a);
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4361,6 +4361,12 @@
 S.Diag(FD->getBeginLoc(), diag::warn_kern_is_inline) << FD;
 
   D->addAttr(::new (S.Context) CUDAGlobalAttr(S.Context, AL));
+  // In host compilation the kernel is emitted as a stub function, which is
+  // a helper function for launching the kernel. The instructions in the helper
+  // function has nothing to do with the source code of the kernel. Do not emit
+  // debug info for the stub function to avoid confusing the debugger.
+  if (!S.LangOpts.CUDAIsDevice)
+D->addAttr(NoDebugAttr::CreateImplicit(S.Context));
 }
 
 static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) {


Index: clang/test/CodeGenCUDA/kernel-dbg-info.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/kernel-dbg-info.cu
@@ -0,0 +1,33 @@
+// RUN: echo "GPU binary would be here" > %t
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+extern "C" __global__ void ckernel(int *a) {
+  *a = 1;
+}
+
+// Device side kernel names
+// CHECK: @[[CKERN:[0-9]*]] = {{.*}} c"ckernel\00"
+
+// DEV: define {{.*}}@ckernel{{.*}}!dbg
+// DEV:  store {{.*}}!dbg
+// DEV:  ret {{.*}}!dbg
+
+// CHECK-NOT: define {{.*}}@__device_stub__ckernel{{.*}}!dbg
+// CHECK: define {{.*}}@[[CSTUB:__device_stub__ckernel]]
+// CHECK-NOT: call {{.*}}@hipLaunchByPtr{{.*}}!dbg
+// CHECK: call {{.*}}@hipLaunchByPtr{{.*}}@[[CSTUB]]
+// CHECK-NOT: ret {{.*}}!dbg
+
+// CHECK-LABEL: define {{.*}}@_Z8hostfuncPi{{.*}}!dbg
+// CHECK: call void @[[CSTUB]]{{.*}}!dbg
+void hostfunc(int *a) {
+  ckernel<<<1, 1>>>(a);
+}
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4361,6 +4361,12 @@
 S.Diag(FD->getBeginLoc(), diag::warn_kern_is_inline) << FD;
 
   D->addAttr(::new (S.Context) CUDAGlobalAttr(S.Context, AL));
+  // In host compilation the kernel is emitted as a stub function, which is
+  // a helper function for launching the kernel. The instructions in the helper
+  // function has nothing to do with the source code of the kernel. Do not emit
+  // debug info for the stub function to avoid confusing the debugger.
+  if (!S.LangOpts.CUDAIsDevice)
+D->addAttr(NoDebugAttr::CreateImplicit(S.Context));
 }
 
 static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) {

[PATCH] D79869: [clangd][BFloat] Add reinterpret cast intrinsics

2020-05-13 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov, kristof.beyls.
Herald added a project: clang.

This patch is part of a series implementing the Bfloat16 extension of the
Armv8.6-a architecture, as detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties is specified in the Arm C language
extension specification:

https://developer.arm.com/docs/ihi0055/d/procedure-call-standard-for-the-arm-64-bit-architecture


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79869

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/test/CodeGen/aarch64-bf16-reinterpret-intrinsics.c
  clang/test/CodeGen/arm-bf16-reinterpret-intrinsics.c
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -313,7 +313,7 @@
   /// The unmangled name.
   std::string Name;
   /// The input and output typespecs. InTS == OutTS except when
-  /// CartesianProductOfTypes is 1 - this is the case for vreinterpret.
+  /// CartesianProductWith is non-empty - this is the case for vreinterpret.
   TypeSpec OutTS, InTS;
   /// The base class kind. Most intrinsics use ClassS, which has full type
   /// info for integers (s32/u32). Some use ClassI, which doesn't care about
@@ -346,7 +346,7 @@
   /// The set of intrinsics that this intrinsic uses/requires.
   std::set Dependencies;
   /// The "base type", which is Type('d', OutTS). InBaseType is only
-  /// different if CartesianProductOfTypes = 1 (for vreinterpret).
+  /// different if CartesianProductWith is non-empty (for vreinterpret).
   Type BaseType, InBaseType;
   /// The return variable.
   Variable RetVar;
@@ -1939,10 +1939,10 @@
   std::string Proto = std::string(R->getValueAsString("Prototype"));
   std::string Types = std::string(R->getValueAsString("Types"));
   Record *OperationRec = R->getValueAsDef("Operation");
-  bool CartesianProductOfTypes = R->getValueAsBit("CartesianProductOfTypes");
   bool BigEndianSafe  = R->getValueAsBit("BigEndianSafe");
   std::string Guard = std::string(R->getValueAsString("ArchGuard"));
   bool IsUnavailable = OperationRec->getValueAsBit("Unavailable");
+  std::string CartesianProductWith = std::string(R->getValueAsString("CartesianProductWith"));
 
   // Set the global current record. This allows assert_with_loc to produce
   // decent location information even when highly nested.
@@ -1957,17 +1957,20 @@
 CK = ClassMap[R->getSuperClasses()[1].first];
 
   std::vector> NewTypeSpecs;
-  for (auto TS : TypeSpecs) {
-if (CartesianProductOfTypes) {
+  if (!CartesianProductWith.empty()) {
+std::vector ProductTypeSpecs = TypeSpec::fromTypeSpecs(CartesianProductWith);
+for (auto TS : TypeSpecs) {
   Type DefaultT(TS, ".");
-  for (auto SrcTS : TypeSpecs) {
+  for (auto SrcTS : ProductTypeSpecs) {
 Type DefaultSrcT(SrcTS, ".");
 if (TS == SrcTS ||
 DefaultSrcT.getSizeInBits() != DefaultT.getSizeInBits())
   continue;
 NewTypeSpecs.push_back(std::make_pair(TS, SrcTS));
   }
-} else {
+}
+  } else {
+for (auto TS : TypeSpecs) {
   NewTypeSpecs.push_back(std::make_pair(TS, TS));
 }
   }
Index: clang/test/CodeGen/arm-bf16-reinterpret-intrinsics.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-bf16-reinterpret-intrinsics.c
@@ -0,0 +1,314 @@
+// RUN: %clang_cc1 -triple armv8.2a-arm-none-eabi -target-feature +neon -target-feature +bf16 \
+// RUN: -disable-O0-optnone -S -emit-llvm -o - %s \
+// RUN: | opt -S -instcombine \
+// RUN: | FileCheck %s
+
+// REQUIRES: arm-registered-target
+
+#include 
+
+// CHECK-LABEL: @test_vreinterpret_bf16_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x i8> [[A:%.*]] to <4 x bfloat>
+// CHECK-NEXT:ret <4 x bfloat> [[TMP0]]
+//
+bfloat16x4_t test_vreinterpret_bf16_s8(int8x8_t a)  { return vreinterpret_bf16_s8(a);}
+// CHECK-LABEL: @test_vreinterpret_bf16_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i16> [[A:%.*]] to <4 x bfloat>
+// CHECK-NEXT:ret <4 x bfloat> [[TMP0]]
+//
+bfloat16x4_t test_vreinterpret_bf16_s16(int16x4_t a){ return vreinterpret_bf16_s16(a);   }
+// CHECK-LABEL: @test_vreinterpret_bf16_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <2 x i32> [[A:%.*]] to <4 x bfloat>
+// CHECK-NEXT:ret <4 x bfloat> [[A:%.*]]
+//
+bfloat16x4_t test_vreinterpret_bf16_s32(int32x2_t a){ return vreinterpret_bf16_s32(a);   }
+// CHECK-LABEL: @test_vreinterpret_bf16_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <2 x f

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-13 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:7899
+if (FpPragmaCurrentLocation.isInvalid()) {
+  assert(*FpPragmaCurrentValue == SemaObj->FpPragmaStack.DefaultValue &&
+ "Expected a default pragma float_control value");

yaxunl wrote:
> This changes the behavior regarding AST reader and seems to be too hash 
> restriction. Essentially this requires a pch can only be used with the same 
> fp options with which the pch is generated. Since there are lots of fp 
> options, it is impractical to generate pch for all the combinations.
> 
> We have seen regressions due to this assertion.
> 
> Can this assertion be dropped or done under some options?
> 
> Thanks.
> 
@yaxunl Can you please send me a reproducer, I'd like to see what's going on, 
not sure if just getting rid of the assertion will give the desired outcome. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-05-13 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 263739.
ASDenysPetrov added a comment.

Updated. @xazax.hun  you were right. Now it looks more readable. Thanks.


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

https://reviews.llvm.org/D78933

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint_manager_conditions.cpp

Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- /dev/null
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -0,0 +1,213 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+void comparison_lt(int x, int y) {
+  if (x < y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_gt(int x, int y) {
+  if (x > y) {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+  }
+}
+
+void comparison_le(int x, int y) {
+  if (x <= y) {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-war

[PATCH] D79565: Add -print-targets to print the registered targets

2020-05-13 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf2fb139321c: Add -print-targets to print the registered 
targets (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79565

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1815,6 +1815,11 @@
 return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_targets)) {
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
+return false;
+  }
+
   return true;
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2804,6 +2804,8 @@
   HelpText<"Print the resource directory pathname">;
 def print_search_dirs : Flag<["-", "--"], "print-search-dirs">,
   HelpText<"Print the paths used for finding libraries and programs">;
+def print_targets : Flag<["-", "--"], "print-targets">,
+  HelpText<"Print the registered targets">;
 def private__bundle : Flag<["-"], "private_bundle">;
 def pthreads : Flag<["-"], "pthreads">;
 def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -130,6 +130,7 @@
 - ``-fno-char8_t`` now disables the ``char8_t`` keyword, not just the use of
   ``char8_t`` as the character type of ``u8`` literals. This restores the
   Clang 8 behavior that regressed in Clang 9 and 10.
+- -print-targets has been added to print the registered targets.
 
 New Pragmas in Clang
 


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1815,6 +1815,11 @@
 return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_targets)) {
+llvm::TargetRegistry::printRegisteredTargetsForVersion(llvm::outs());
+return false;
+  }
+
   return true;
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2804,6 +2804,8 @@
   HelpText<"Print the resource directory pathname">;
 def print_search_dirs : Flag<["-", "--"], "print-search-dirs">,
   HelpText<"Print the paths used for finding libraries and programs">;
+def print_targets : Flag<["-", "--"], "print-targets">,
+  HelpText<"Print the registered targets">;
 def private__bundle : Flag<["-"], "private_bundle">;
 def pthreads : Flag<["-"], "pthreads">;
 def pthread : Flag<["-"], "pthread">, Flags<[CC1Option]>,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -130,6 +130,7 @@
 - ``-fno-char8_t`` now disables the ``char8_t`` keyword, not just the use of
   ``char8_t`` as the character type of ``u8`` literals. This restores the
   Clang 8 behavior that regressed in Clang 9 and 10.
+- -print-targets has been added to print the registered targets.
 
 New Pragmas in Clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78374: [Analyzer][StreamChecker] Added evaluation of fread and fwrite.

2020-05-13 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 2 inline comments as done.
balazske added a comment.

The intent is to model the fread-fwrite function failure by returning the error 
value and set the stream into error state. The error state is a composite of 
**ferror** and **feof**. The questions are now, at what case do these functions 
fail and with what error type?




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:107
+  /// This value applies to all execution paths in ErrorState except the FEOF
+  /// case. In more detail, an EOF+indeterminate state is the same as EOF 
state.
+  bool FilePositionIndeterminate = false;

Szelethus wrote:
> The standard suggests that this happens on FERROR, not FEOF.
> 
> > If an error occurs, the resulting value of the file position indicator for 
> > the stream is indeterminate. If a partial element is read, its value is 
> > indeterminate.
> 
> It would be wild if the stream wouldn't set the FEOF flag after reaching the 
> end of the file. Also, I would imagine FEOF being usually implemented with 
> the file position indicator.
> 
> ```lang=bash
> $ cat test.cpp`
> ```
> ```lang=cpp
> #include "stdio.h"
> 
> int main() {
>   FILE *F = fopen("test.cpp", "r");
>   char Buf[1024];
>   const int READ_COUNT = 9;
>   if (READ_COUNT != fread(Buf, sizeof(char), READ_COUNT, F)) {
> printf("%i\n", feof(F));
>   }
> }
> ```
> ```lang=bash
> $ build/bin/clang++ test.cpp && ./a.out 
> 1
> 
> ```
> 
> Operations on an EOF and indeterminate stream are very different.
I wanted to say in that comment that `FilePositionIndeterminate` should be 
ignored if the `ErrorState` is `ErrorFEof`. In other words the file is never 
indeterminate if in EOF state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78374



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


[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2020-05-13 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/test/SemaCXX/deprecated-copy.cpp:7
+#ifdef NO_USER_PROVIDED
+// expected-no-diagnostics
+#endif

xbolva00 wrote:
> xbolva00 wrote:
> > Quuxplusone wrote:
> > > I'm fairly confident this should just be two different test files. Also, 
> > > if a test file has an un-ifdeffed `// expected-no-diagnostics` plus an 
> > > un-ifdeffed `// expected-note ...`, which one wins?
> > ifdef is here
> > 
> > and ifNdef is below :)
> and DEPRECATED_COPY_DTOR is in own "code block"
Ah, you're right, I had missed that line 18 was still controlled by the `#ifdef 
DEPRECATED_COPY_DTOR` condition.
I still think this should be three(!) different files. Line 2 doesn't even look 
right to me: shouldn't it be `-Wdeprecated-copy 
-Wno-deprecated-copy-user-provided`?

I just did a `git grep 'RUN:' | grep '[-]Wno-' | grep -v '[-]W[^n]'` and found 
a massive number of tests that put `-Wno-foo` on the command line without 
putting `-Wbar` anywhere on the same line; I suspect many of these are bugs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79714



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-05-13 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D75936#2032090 , @craig.topper 
wrote:

> In D75936#2032078 , @sconstab wrote:
>
> > In D75936#2032027 , @nikic wrote:
> >
> > > This change causes a 0.8% compile-time regression for unoptimized builds 
> > > .
> > >  Based on the pipeline test diffs, I expect this is because the new pass 
> > > requests a bunch of analyses, which it most likely (LVI load hardening 
> > > disabled) will not need. Would it be possible to compute the analyses 
> > > only if LVI load hardening is actually enabled?
> >
> >
> > @craig.topper Do you have any ideas on how this could be done?
>
>
> Unfortunately due to LTO the need for LVI hardening is carried as a function 
> attribute. The pass manager system doesn't allow for running different passes 
> per function. So I don't have any good ideas of how to do that.


Hm, I see. One possibility would be to make those analyses lazy, but that's a 
larger change.

Possibly a pragmatic choice would be to not support this feature at O0? It does 
not seem relevant for non-production binaries. The relative impact of a couple 
unnecessary analysis passes is much higher at `O0` than it is at `O3`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75936



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


[PATCH] D79035: [clang][AIX] Implement ABIInfo and TargetCodeGenInfo for AIX

2020-05-13 Thread Jason Liu via Phabricator via cfe-commits
jasonliu marked an inline comment as done.
jasonliu added inline comments.



Comment at: clang/test/Frontend/aix-unsupported.c:10
+// RUN:   -c %s 2>&1 | FileCheck %s
+// CHECK: unsupported option

Xiangling_L wrote:
> One thing I am not so sure about is that for these two options 
> `-maix-struct-return`,  `-msvr4-struct-return`, do we need to update the 
> `ClangCommandLineReference.rst` since we emit diags `unsupported option 
> '-maix-struct-return' for target 'powerpc-unknown-aix'`
I think the error message is clear enough in itself what user should expect. I 
don't think it's necessary to add to the doc.


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

https://reviews.llvm.org/D79035



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


[PATCH] D79877: [clang][SveEmitter] SVE builtins for `svusdot` and `svsudot` ACLE.

2020-05-13 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli created this revision.
fpetrogalli added reviewers: sdesmalen, efriedma, david-arm.
Herald added subscribers: cfe-commits, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
fpetrogalli added a parent revision: D79639: [SveEmitter] Builtins for SVE 
matrix multiply `mmla`..

Intrinsics, guarded by `__ARM_FEATURE_SVE_MATMUL_INT8`:

- svusdot[_s32]
- svusdot[_n_s32]
- svusdot_lane[_s32]
- svsudot[_s32]
- svsudot[_n_s32]
- svsudot_lane[_s32]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79877

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_sudot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_usdot.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -213,13 +213,13 @@
   /// Return true if the intrinsic takes a splat operand.
   bool hasSplat() const {
 // These prototype modifiers are described in arm_sve.td.
-return Proto.find_first_of("ajfrKLR") != std::string::npos;
+return Proto.find_first_of("ajfrKLR@") != std::string::npos;
   }
 
   /// Return the parameter index of the splat operand.
   unsigned getSplatIdx() const {
 // These prototype modifiers are described in arm_sve.td.
-auto Idx = Proto.find_first_of("ajfrKLR");
+auto Idx = Proto.find_first_of("ajfrKLR@");
 assert(Idx != std::string::npos && Idx > 0 &&
"Prototype has no splat operand");
 return Idx - 1;
@@ -541,6 +541,12 @@
 ElementBitwidth /= 4;
 NumVectors = 0;
 break;
+  case '@':
+Signed = false;
+Float = false;
+ElementBitwidth /= 4;
+NumVectors = 0;
+break;
   case 'K':
 Signed = true;
 Float = false;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_usdot.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_usdot.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_INT8 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_INT8 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+svint32_t test_svusdot_s32(svint32_t x, svuint8_t y, svint8_t z) {
+  // CHECK-LABEL: test_svusdot_s32
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.usdot.nxv4i32( %x,  %y,  %z)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svusdot, _s32, , )(x, y, z);
+}
+
+svint32_t test_svusdot_n_s32(svint32_t x, svuint8_t y, int8_t z) {
+  // CHECK-LABEL: test_svusdot_n_s32
+  // CHECK: %[[SPLAT:.*]] = call  @llvm.aarch64.sve.dup.x.nxv16i8(i8 %z)
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.usdot.nxv4i32( %x,  %y,  %[[SPLAT]])
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svusdot, _n_s32, , )(x, y, z);
+}
+
+svint32_t test_svusdot_lane_s32_0(svint32_t x, svuint8_t y, svint8_t z) {
+  // CHECK-LABEL: test_svusdot_lane_s32_0
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.usdot.lane.nxv4i32( %x,  %y,  %z, i32 0)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svusdot_lane, _s32, , )(x, y, z, 0);
+}
+
+svint32_t test_svusdot_lane_s32_1(svint32_t x, svuint8_t y, svint8_t z) {
+  // CHECK-LABEL: test_svusdot_lane_s32_1
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.usdot.lane.nxv4i32( %x,  %y,  %z, i32 1)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svusdot_lane, _s32, , )(x, y, z, 1);
+}
+
+svint32_t test_svusdot_lane_s32_2(svint32_t x, svuint8_t y, svint8_t z) {
+  // CHECK-LABEL: test_svusdot_lane_s32_2
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.usdot.lane.nxv4i32( %x,  %y,  %z, i32 2)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svusdot_lane, _s32, , )(x, y, z, 2);
+}
+
+svint32_t test_svusdot_lane_s32_3(svint32_t x, svuint8_t y, svint8_t z) {
+  // CHECK-LABEL: test_svusdot_lane_s32_3
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.usdot.lane.nxv4i32( %x,  %y,  %z, i32 3)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svusdot_lane, _s32, , )(x, y, z, 3);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_sudot.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_sudot.c
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -D__ARM_FEATUR

[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-13 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 263748.
baloghadamsoftware added a comment.
Herald added a subscriber: mgorny.

Unit test added.


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

https://reviews.llvm.org/D79704

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/ParamRegionTest.cpp

Index: clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
@@ -0,0 +1,83 @@
+//===- unittests/StaticAnalyzer/ParamRegionTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Reusables.h"
+
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+class ParamRegionTestConsumer : public ExprEngineConsumer {
+  void performTest(const Decl *D) {
+StoreManager &StMgr = Eng.getStoreManager();
+MemRegionManager &MRMgr = StMgr.getRegionManager();
+const StackFrameContext *SFC =
+Eng.getAnalysisDeclContextManager().getStackFrame(D);
+
+if (isa(D)) {
+  const auto *ParamN = findDeclByName(D, "n");
+  const auto *ParamM = findDeclByName(D, "m");
+  const TypedValueRegion *RegN = MRMgr.getRegionForParam(ParamN, SFC);
+  const TypedValueRegion *RegM = MRMgr.getRegionForParam(ParamM, SFC);
+  assert(isa(RegN));
+  if (SFC->inTopFrame())
+assert(isa(RegM));
+  else
+assert(isa(RegM));
+}
+
+if (const auto *FD = dyn_cast(D)) {
+  if (FD->getNameAsString() == "foo") {
+const auto *ParamN = findDeclByName(D, "n");
+const TypedValueRegion *RegN = MRMgr.getRegionForParam(ParamN, SFC);
+if (SFC->inTopFrame())
+  assert(isa(RegN));
+else
+  assert(isa(RegN));
+  } else if (FD->getNameAsString() == "bar") {
+const auto *ParamL = findDeclByName(D, "l");
+const TypedValueRegion *RegL = MRMgr.getRegionForParam(ParamL, SFC);
+assert(isa(RegL));
+  }
+}
+  }
+
+public:
+  ParamRegionTestConsumer(CompilerInstance &C) : ExprEngineConsumer(C) {}
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (const auto *D : DG) {
+  performTest(D);
+}
+return true;
+  }
+};
+
+class ParamRegionTestAction : public ASTFrontendAction {
+public:
+  std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef File) override {
+return std::make_unique(Compiler);
+  }
+};
+
+TEST(ParamRegion, ParamRegionTest) {
+  EXPECT_TRUE(tooling::runToolOnCode(
+  std::make_unique(),
+  "void foo(int n) { "
+  "auto lambda = [n](int m) { return n + m; }; "
+  "int k = lambda(2); } "
+  "void bar(int l) { foo(l); }"));
+}
+
+} // namespace
+} // namespace ento
+} // namespace clang
Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -6,6 +6,7 @@
   AnalyzerOptionsTest.cpp
   CallDescriptionTest.cpp
   StoreTest.cpp
+  ParamRegionTest.cpp
   RegisterCustomCheckersTest.cpp
   SymbolReaperTest.cpp
   )
Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++

[PATCH] D79879: [clangd] Change getSymbolID to accept macro location instead of macro info

2020-05-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.
kadircet added a child revision: D79881: [clangd] locateMacroAt returns 
definition range instead of MacroInfo.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79879

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CollectMacros.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp

Index: clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
===
--- clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
+++ clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
@@ -92,8 +92,9 @@
   const auto *Id = syntax::spelledIdentifierTouching(*Loc, AST.getTokens());
   ASSERT_TRUE(Id);
   auto Macro = locateMacroAt(*Id, PP);
-  assert(Macro);
-  auto SID = getSymbolID(Macro->Name, Macro->Info, SM);
+  assert(Macro && Macro->Info);
+  auto SID = getSymbolID(Macro->Name, Macro->Info->getDefinitionLoc(), SM);
+  assert(SID);
 
   EXPECT_THAT(ExpectedRefs,
   UnorderedElementsAreArray(ActualMacroRefs.MacroRefs[*SID]))
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -387,7 +387,7 @@
   if (SM.isWrittenInBuiltinFile(DefLoc))
 return true;
 
-  auto ID = getSymbolID(Name->getName(), MI, SM);
+  auto ID = getSymbolID(Name->getName(), DefLoc, SM);
   if (!ID)
 return true;
 
@@ -510,14 +510,16 @@
 // First, drop header guards. We can't identify these until EOF.
 for (const IdentifierInfo *II : IndexedMacros) {
   if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
-if (auto ID = getSymbolID(II->getName(), MI, PP->getSourceManager()))
+if (auto ID = getSymbolID(II->getName(), MI->getDefinitionLoc(),
+  PP->getSourceManager()))
   if (MI->isUsedForHeaderGuard())
 Symbols.erase(*ID);
 }
 // Now increment refcounts.
 for (const IdentifierInfo *II : ReferencedMacros) {
   if (const auto *MI = PP->getMacroDefinition(II).getMacroInfo())
-if (auto ID = getSymbolID(II->getName(), MI, PP->getSourceManager()))
+if (auto ID = getSymbolID(II->getName(), MI->getDefinitionLoc(),
+  PP->getSourceManager()))
   IncRef(*ID);
 }
   }
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -753,9 +753,10 @@
   }
 
   RefsRequest Req;
-  if (Macro) {
+  if (Macro && Macro->Info) {
 // Handle references to macro.
-if (auto MacroSID = getSymbolID(Macro->Name, Macro->Info, SM)) {
+if (auto MacroSID =
+getSymbolID(Macro->Name, Macro->Info->getDefinitionLoc(), SM)) {
   // Collect macro references from main file.
   const auto &IDToRefs = AST.getMacros().MacroRefs;
   auto Refs = IDToRefs.find(*MacroSID);
Index: clang-tools-extra/clangd/CollectMacros.cpp
===
--- clang-tools-extra/clangd/CollectMacros.cpp
+++ clang-tools-extra/clangd/CollectMacros.cpp
@@ -7,8 +7,10 @@
 //===--===//
 
 #include "CollectMacros.h"
+#include "index/SymbolID.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/Optional.h"
 
 namespace clang {
 namespace clangd {
@@ -25,7 +27,10 @@
   Out.Names.insert(Name);
   auto Range = halfOpenToRange(
   SM, CharSourceRange::getCharRange(Loc, MacroNameTok.getEndLoc()));
-  if (auto SID = getSymbolID(Name, MI, SM))
+  llvm::Optional SID;
+  if (MI)
+SID = getSymbolID(Name, MI->getDefinitionLoc(), SM);
+  if (SID)
 Out.MacroRefs[*SID].push_back(Range);
   else
 Out.UnknownMacros.push_back(Range);
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -503,9 +503,12 @@
 return clang::clangd::getSymbolID(R.Declaration);
   }
   case CodeCompletionResult::RK_Macro:
-return clang::clangd::getSymbolID(R.Macro->getName(), R.MacroDefInfo, SM);
+if (!R.MacroDefInfo)
+  return llvm::None;
+return clang::clangd::getSymbolID(R.Macro->getName(),
+  R.MacroDefInfo->getDefinitionLoc(), SM);
   case CodeCompletionResult::RK_Keyword:
-re

[PATCH] D79708: [clang][BFloat] add NEON emitter for bfloat

2020-05-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/include/clang/Basic/arm_bf16.td:1
+//===--- arm_fp16.td - ARM FP16 compiler interface 
===//
+//

typo: fp16 - > bf16?
Here, and a few more places, or is it intentional? If so, I guess that can be a 
bit confusing?




Comment at: clang/utils/TableGen/NeonEmitter.cpp:2411
+/// is comprised of type definitions and function declarations.
+void NeonEmitter::runFP16(raw_ostream &OS) {
+  OS << "/*=== arm_fp16.h - ARM FP16 intrinsics "

I am a bit confused here, we already have a runFP16, I am missing something?



Comment at: clang/utils/TableGen/NeonEmitter.cpp:2416
+" *\n"
+" * Permission is hereby granted, free of charge, to any person "
+"obtaining a copy\n"

I can't remember the outcome, but I had a discussion with @sdesmalen about this 
license, if this should be the new or old copyright notice. I believe, but am 
not certain, that this should be the new one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79708



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


[PATCH] D79881: [clangd] locateMacroAt returns definition range instead of MacroInfo

2020-05-13 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Depends on D79879 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79881

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp


Index: clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
===
--- clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
+++ clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
@@ -92,8 +92,8 @@
   const auto *Id = syntax::spelledIdentifierTouching(*Loc, 
AST.getTokens());
   ASSERT_TRUE(Id);
   auto Macro = locateMacroAt(*Id, PP);
-  assert(Macro && Macro->Info);
-  auto SID = getSymbolID(Macro->Name, Macro->Info->getDefinitionLoc(), SM);
+  assert(Macro);
+  auto SID = getSymbolID(Macro->Name, Macro->DefRange.getBegin(), SM);
   assert(SID);
 
   EXPECT_THAT(ExpectedRefs,
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -206,8 +206,8 @@
 locateMacroReferent(const syntax::Token &TouchedIdentifier, ParsedAST &AST,
 llvm::StringRef MainFilePath) {
   if (auto M = locateMacroAt(TouchedIdentifier, AST.getPreprocessor())) {
-if (auto Loc = makeLocation(AST.getASTContext(),
-M->Info->getDefinitionLoc(), MainFilePath)) {
+if (auto Loc = makeLocation(AST.getASTContext(), M->DefRange.getBegin(),
+MainFilePath)) {
   LocatedSymbol Macro;
   Macro.Name = std::string(M->Name);
   Macro.PreferredDeclaration = *Loc;
@@ -753,10 +753,10 @@
   }
 
   RefsRequest Req;
-  if (Macro && Macro->Info) {
+  if (Macro) {
 // Handle references to macro.
 if (auto MacroSID =
-getSymbolID(Macro->Name, Macro->Info->getDefinitionLoc(), SM)) {
+getSymbolID(Macro->Name, Macro->DefRange.getBegin(), SM)) {
   // Collect macro references from main file.
   const auto &IDToRefs = AST.getMacros().MacroRefs;
   auto Refs = IDToRefs.find(*MacroSID);
@@ -875,8 +875,8 @@
 SymbolDetails NewMacro;
 NewMacro.name = std::string(M->Name);
 llvm::SmallString<32> USR;
-if (!index::generateUSRForMacro(NewMacro.name, M->Info->getDefinitionLoc(),
-SM, USR)) {
+if (!index::generateUSRForMacro(NewMacro.name, M->DefRange.getBegin(), SM,
+USR)) {
   NewMacro.USR = std::string(USR.str());
   NewMacro.ID = SymbolID(NewMacro.USR);
 }
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -291,7 +291,7 @@
 
 struct DefinedMacro {
   llvm::StringRef Name;
-  const MacroInfo *Info;
+  CharSourceRange DefRange;
 };
 /// Gets the macro referenced by \p SpelledTok. It must be a spelled token
 /// aligned to the beginning of an identifier.
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -961,7 +961,11 @@
 Loc = Loc.getLocWithOffset(-1);
   MacroDefinition MacroDef = PP.getMacroDefinitionAtLoc(IdentifierInfo, Loc);
   if (auto *MI = MacroDef.getMacroInfo())
-return DefinedMacro{IdentifierInfo->getName(), MI};
+return DefinedMacro{
+IdentifierInfo->getName(),
+// MacroInfo::getDefinitionEndLoc returns the location for last token.
+CharSourceRange::getTokenRange(MI->getDefinitionLoc(),
+   MI->getDefinitionEndLoc())};
   return None;
 }
 
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -553,8 +553,8 @@
   // FIXME: Populate parameters
 
   // Try to get the full definition, not just the name
-  SourceLocation StartLoc = Macro.Info->getDefinitionLoc();
-  SourceLocation EndLoc = Macro.Info->getDefinitionEndLoc();
+  SourceLocation StartLoc = Macro.DefRange.getBegin();
+  SourceLocation EndLoc = Macro.DefRange.getEnd();
   if (EndLoc.isValid()) {
 EndLoc = Lexer::getLocForEndOfToken(EndLoc, 0, SM, AST.getLangOpts());
 bool Invalid;


Index: clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
===
--- clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
+++ clang-tools-extra/clangd/unit

[PATCH] D79869: [clang][BFloat] Add reinterpret cast intrinsics

2020-05-13 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson added a comment.

As I was an author of this patch (among others) please could you add a list of 
authors to the commit message. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79869



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


[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-13 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 263753.
ahatanak marked 6 inline comments as done.
ahatanak added a comment.

Address review comments. Handle derived-to-base cast expressions and array 
subscript expressions that don't have constant indices.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/warn-cast-align.cpp

Index: clang/test/SemaCXX/warn-cast-align.cpp
===
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -43,3 +43,97 @@
   typedef int *IntPtr;
   c = IntPtr(P);
 }
+
+struct __attribute__((aligned(16))) A {
+  char m0[16];
+  char m1[16];
+};
+
+struct B0 {
+  char m0[16];
+};
+
+struct B1 {
+  char m0[16];
+};
+
+struct C {
+  A &m0;
+  B0 &m1;
+  A m2;
+};
+
+struct __attribute__((aligned(16))) D0 : B0, B1 {
+};
+
+struct __attribute__((aligned(16))) D1 : virtual B0 {
+};
+
+struct B2 {
+  char m0[8];
+};
+
+struct B3 {
+  char m0[8];
+};
+
+struct B4 {
+  char m0[8];
+};
+
+struct D2 : B2, B3 {
+};
+
+struct __attribute__((aligned(16))) D3 : B4, D2 {
+};
+
+struct __attribute__((aligned(16))) D4 : virtual D2 {
+};
+
+void test2(int n, A *a2) {
+  __attribute__((aligned(16))) char m[sizeof(A) * 2];
+  char(&m_ref)[sizeof(A) * 2] = m;
+  extern char(&m_ref_noinit)[sizeof(A) * 2];
+  __attribute__((aligned(16))) char vararray[10][n];
+  A t0;
+  B0 t1;
+  C t2 = {.m0 = t0, .m1 = t1};
+  __attribute__((aligned(16))) char t3[5][5][5];
+  __attribute__((aligned(16))) char t4[4][16];
+  D0 t5;
+  D1 t6;
+  D3 t7;
+  D4 t8;
+
+  A *a;
+  a = (A *)&m;
+  a = (A *)(m + sizeof(A));
+  a = (A *)(sizeof(A) + m);
+  a = (A *)((sizeof(A) * 2 + m) - sizeof(A));
+  a = (A *)((sizeof(A) * 2 + m) - 1); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + 1);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(1 + m);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + n);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&m[sizeof(A)];
+  a = (A *)&m[n]; // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&m_ref;
+  a = (A *)&m_ref_noinit;// expected-warning {{cast from 'char (*)[64]' to 'A *'}}
+  a = (A *)(&vararray[4][0]);// expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(a2->m0 + sizeof(A)); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(&t2.m0);
+  a = (A *)(&t2.m1); // expected-warning {{cast from 'B0 *' to 'A *'}}
+  a = (A *)(&t2.m2);
+  a = (A *)(t2.m2.m1);
+  a = (A *)(&t3[3][3][0]); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(&t3[2][2][4]);
+  a = (A *)(&t3[0][n][0]); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&t4[n][0];
+  a = (A *)&t4[n][1]; // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(static_cast(&t5));
+  a = (A *)(&(static_cast(t5)));
+  a = (A *)(static_cast(&t6)); // expected-warning {{cast from 'B0 *' to 'A *'}}
+  a = (A *)(static_cast(&t7)); // expected-warning {{cast from 'B2 *' to 'A *'}}
+  a = (A *)(static_cast(&t7));
+  a = (A *)(static_cast(&t8)); // expected-warning {{cast from 'B2 *' to 'A *'}}
+  a = (A *)(static_cast(&t8)); // expected-warning {{cast from 'B3 *' to 'A *'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -30,6 +30,7 @@
 #include "clang/AST/NSAPI.h"
 #include "clang/AST/NonTrivialTypeVisitor.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
@@ -13105,17 +13106,192 @@
   return HasInvalidParm;
 }
 
-/// A helper function to get the alignment of a Decl referred to by DeclRefExpr
-/// or MemberExpr.
-static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign,
-  ASTContext &Context) {
-  if (const auto *DRE = dyn_cast(E))
-return Context.getDeclAlign(DRE->getDecl());
+Optional>
+static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext &Ctx);
+
+/// Compute the alignment and offset of the base class object given the
+/// derived-to-base cast expression and the alignment and offset of the derived
+/// class object.
+static std::pair getDerivedToBaseAlignmentAndOffset(
+const ImplicitCastExpr *ICE, QualType DerivedType, CharUnits BaseAlignment,
+CharUnits Offset, ASTContext &Ctx) {
+  for (auto PathI = ICE->path_begin(), PathE = ICE->path_end(); PathI != PathE;
+   ++PathI) {
+const CXXBaseSpecifier *Base = *PathI;
+if (Base->isVirtual()) {
+  BaseAlignment = Ctx.getTypeAlignInChars(Base->getType());
+  Offset = CharUnits::Zero();
+} else {
+  const ASTRecordLayo

[PATCH] D79710: [clang][BFloat] add create/set/get/dup intrinsics

2020-05-13 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson added a comment.

I was an author for part of this patch. Please add all authors as a list of 
authors to this commit message. Thanks!

As an aside, it would be worth doing this for all the patches in this series


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79710



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


[PATCH] D79800: [Sema] Remove default values for arguments prior to a parameter pack if the pack is used

2020-05-13 Thread Raul Tambre via Phabricator via cfe-commits
tambre updated this revision to Diff 263759.
tambre added a comment.

Simplify code, improve comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79800

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CXX/drs/dr7xx.cpp


Index: clang/test/CXX/drs/dr7xx.cpp
===
--- clang/test/CXX/drs/dr7xx.cpp
+++ clang/test/CXX/drs/dr7xx.cpp
@@ -230,5 +230,12 @@
 
 template 
 void h(int i = 0, T ...args, int j = 1) {}
+
+// PR23029
+// Ensure passing parameters using the parameter packs actually works.
+void use() {
+  f(0, 1);
+  h(0, 1);
+}
 #endif
 }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1974,6 +1974,47 @@
 TemplateArgumentList::CreateCopy(SemaRef.Context,
  Innermost),
 /*InsertPos=*/nullptr);
+
+// Parameter packs are allowed after parameters with default values.
+// If the specialized Function has more parameters than the TemplatedDecl
+// then the default values aren't used and the parameter pack is used and 
we
+// need to remove default values from non-pack parameters to prevent it
+// being diagnosed as invalid code due to the expanded parameters lacking
+// default values.
+FunctionDecl *TemplatedDecl = FunctionTemplate->getTemplatedDecl();
+unsigned NumTemplatedParams = TemplatedDecl->getNumParams();
+
+if (Function->getNumParams() >= NumTemplatedParams) {
+  unsigned FirstDefault = 0;
+  bool FoundDefault = false;
+
+  for (unsigned p = 0; p < NumTemplatedParams; ++p) {
+ParmVarDecl *Param = TemplatedDecl->getParamDecl(p);
+
+if (FoundDefault) {
+  if (Param->isParameterPack()) {
+// Found a parameter pack. Remove default arguments for all
+// parameters prior to this since we now know this is valid code
+// without them.
+for (unsigned d = FirstDefault; d < p; ++d) {
+  ParmVarDecl *Param = Function->getParamDecl(d);
+  Param->setDefaultArg(nullptr);
+}
+
+break;
+  }
+
+  // If we encounter a regular parameter with no default value after
+  // we've encountered any with a default, then this is invalid code 
and
+  // we bail out. This is diagnosed later in 
CheckCXXDefaultArguments().
+  if (!Param->hasDefaultArg())
+break;
+} else if (Param->hasDefaultArg()) {
+  FirstDefault = p;
+  FoundDefault = true;
+}
+  }
+}
   } else if (isFriend && D->isThisDeclarationADefinition()) {
 // Do not connect the friend to the template unless it's actually a
 // definition. We don't want non-template functions to be marked as being


Index: clang/test/CXX/drs/dr7xx.cpp
===
--- clang/test/CXX/drs/dr7xx.cpp
+++ clang/test/CXX/drs/dr7xx.cpp
@@ -230,5 +230,12 @@
 
 template 
 void h(int i = 0, T ...args, int j = 1) {}
+
+// PR23029
+// Ensure passing parameters using the parameter packs actually works.
+void use() {
+  f(0, 1);
+  h(0, 1);
+}
 #endif
 }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1974,6 +1974,47 @@
 TemplateArgumentList::CreateCopy(SemaRef.Context,
  Innermost),
 /*InsertPos=*/nullptr);
+
+// Parameter packs are allowed after parameters with default values.
+// If the specialized Function has more parameters than the TemplatedDecl
+// then the default values aren't used and the parameter pack is used and we
+// need to remove default values from non-pack parameters to prevent it
+// being diagnosed as invalid code due to the expanded parameters lacking
+// default values.
+FunctionDecl *TemplatedDecl = FunctionTemplate->getTemplatedDecl();
+unsigned NumTemplatedParams = TemplatedDecl->getNumParams();
+
+if (Function->getNumParams() >= NumTemplatedParams) {
+  unsigned FirstDefault = 0;
+  bool FoundDefault = false;
+
+  for (unsigned p = 0; p < NumTemplatedParams; ++p) {
+ParmVarDecl *Param = TemplatedDecl->getParamDecl(p);
+
+if (FoundDefault) {
+  if (Param->isParameterPack()) {
+// Found a parameter pack. Remove default arguments for all
+// parameters prior to this since we now k

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:7899
+if (FpPragmaCurrentLocation.isInvalid()) {
+  assert(*FpPragmaCurrentValue == SemaObj->FpPragmaStack.DefaultValue &&
+ "Expected a default pragma float_control value");

mibintc wrote:
> yaxunl wrote:
> > This changes the behavior regarding AST reader and seems to be too hash 
> > restriction. Essentially this requires a pch can only be used with the same 
> > fp options with which the pch is generated. Since there are lots of fp 
> > options, it is impractical to generate pch for all the combinations.
> > 
> > We have seen regressions due to this assertion.
> > 
> > Can this assertion be dropped or done under some options?
> > 
> > Thanks.
> > 
> @yaxunl Can you please send me a reproducer, I'd like to see what's going on, 
> not sure if just getting rid of the assertion will give the desired outcome. 
{F11915161}

Pls apply the patch.

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79072: [Analyzer][VLASizeChecker] Check VLA size in typedef and sizeof.

2020-05-13 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
Herald added a subscriber: rnkovacs.

In D79072#2026553 , @balazske wrote:

> This change is relatively small and the refactoring like part (introduction 
> of `checkVLA` if I think correct?) is connected to its use. The other change 
> is add of a new function (callback). This is probably small enough to go into 
> one change and we can see why the new function `checkVLA` is needed. So my 
> vote is to not split this change.


Okay, you convinced me. LGTM!




Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:577
+  if (isa(*DS->decl_begin())) {
+ExplodedNodeSet DstPre;
+getCheckerManager().runCheckersForPreStmt(DstPre, Pred, DS, *this);

balazske wrote:
> Should we not do something else with the VLA size expressions (not only call 
> the checker callbacks) because they should be evaluated, are these handled in 
> some other way automatically? (The CFG should contain these expressions 
> already so these should be evaluated by the engine, and this place is only to 
> make the checkers aware of `typedef` statements.)
Yeah, I agree with @balazske. This could be used for anything else in the 
future, not just for VLA. It is more generic than that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79072



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


[PATCH] D78374: [Analyzer][StreamChecker] Added evaluation of fread and fwrite.

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D78374#2033826 , @balazske wrote:

> I think this is a expected way of how it works, failure of a stream operation 
> does not necessarily depend on result of a previous operation. So any 
> operation can fail or not, independent of the previous error state (the 
> "ferror" may happen because a temporary disk error and it is worth to retry 
> the read, at least a non-`fread` function where the "indeterminate file 
> position" problem does not happen). This would make things more simple. Only 
> the EOF is probably exception, in EOF state any read operation fails with EOF.


Right. But, speaking about generality, would it be reasonably to assume that 
all (or almost all) operations may also result in an indeterminate file 
indicator? Because if so, we could, and totally should strip those changes from 
the fread/fwrite ones and make a new revision.

That is by the way true for a lot of other changes, such as the delayed state 
split or the new error state struct. I mean not to burden you by micromanaging 
a lot of small patches, but it makes reviewing far faster for me.

> (But I do not know if it is possible that a stream in EOF state becomes 
> non-EOF because new data appears at the end, if other program can write into 
> it or it is some form of "pipe" or special file. If this is true even EOF 
> needs no special handling.)

That is a great question, but I strongly believe that it cannot without 
`freopen`. I mean, if I were to create an io library, I would set a pointer to 
the beginning and the end of the file, and know we hit eof is the current 
pointer hits the end point. Besides, how could anyone change the `FILE *` 
object in a non-analyzable way?

In any case, its a reasonable to assume it won't change.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:937-939
+new BuiltinBug(this, "Stream is in error state",
+   "Function called when stream has already error state "
+   "flag (EOF or error) set."));

Since this isn't a bug but rather a code smell, a note would be a nice 
compliment.
"Use clearerr() to clear the error flag"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78374



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-05-13 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Add a description in our documentation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

2020-05-13 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D79330#2026564 , @balazske wrote:

> I do not know if it would me **much** cleaner.
>
> - First part: Move calculation of `ArraySize` into `checkVLA` and rename 
> `checkVLASize` to `checkVLAIndexSize`.
> - Second part: Add the check for total array size to `checkVLA`. The first 
> part in itself does not make sense necessarily until we see why this change 
> is needed (this is, because the total size is checked and that calculation 
> needs the same data and the total size should be checked both places where 
> `checkVLA` is used). The original code is not much better than after this 
> "part 1" refactoring, computation of `ArraySize` is needed only once not at 
> both places where `checkVLA`is called (but it is needed to implement "part 
> 2").


Alright, makes sense, so let's just disregard the refactoring comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-05-13 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson added a comment.

I authored some of the code for this patch, please update the commit message 
with my name on the list :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D79862: [clangd-remote] Replace YAML serialization with proper Protobuf messages

2020-05-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

It's tedious, but we really should have tests for this now.




Comment at: clang-tools-extra/clangd/index/remote/Index.proto:68
 
-// FIXME(kirillbobyrev): Properly serialize symbols and refs instead of passing
-// YAML.
-message Ref { string yaml_serialization = 1; }
-message Symbol { string yaml_serialization = 1; }
+message Symbol {
+  string id = 1;

somewhere in this file there should be a hint that semantics of all fields 
matches those in the structs in Index/



Comment at: clang-tools-extra/clangd/index/remote/Index.proto:70
+  string id = 1;
+  SymbolInfo info = 2;
+  string name = 3;

sigh, I wish we'd managed to get rid of this struct by now :-(
Maybe we can still do it before the 11 release


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79862



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-05-13 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

Is it possible to overload __builtin_expect(..)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

2020-05-13 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

In D79330#2033990 , @Szelethus wrote:

> > Variable-length array (VLA) should have a size that fits into a size_t 
> > value. At least if the size is queried with sizeof, but it is better (and 
> > more simple) to check it always
>
> So creating VLA larger than `sizeof(size_t)` isn't a bug, bur rather a sign 
> of code smell? Then we shouldn't create a fatal error node for it, **unless** 
> we're trying to fit it in a variable that isn't sufficiently large. The fact 
> that `sizeof`ing it is a bug wasn't immediately obvious to me either, so a 
> quote from the standard as comments would be appreciated:
>
> §6.5.3.4.4 , about 
> operator sizeof: The value of the result is implementation-defined, and its 
> type (an unsigned integer type) is `size_t`, defined in `` (and 
> other headers).


I am not sure if I can follow your concern here.
`sizeof(size_t)` is typically 8, so that is not a bug, neither a code smell to 
have `char VLA[sizeof(size_t)];`. The problem is when the size is bigger than 
the maximum value of `size_t`, that ix 0xff...ff, as we can see that in the new 
tests.
Besides, not having the size printed out in the warning is not a blocker for 
me, this looks good enough.




Comment at: clang/test/Analysis/vla-overflow.c:10
+// Size of this array should be the first to overflow.
+size_t s = sizeof(char[x][x][x][x]); // expected-warning{{Declared 
variable-length array (VLA) has too large size}}
+return s;

Szelethus wrote:
> Let's not trim be checker name here.
> 
> Also, we could mention what the specific size is.
Yes, that's a good idea to print the actual size of the VLA when we have that 
info. But I think we cannot just print that when it overflows! :D We can, 
however, print the maximum allowed value in case of the overflow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330



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


[PATCH] D78120: [analyzer][StreamChecker] Don't make StreamTestChecker depend on StreamChecker for the time being

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D78120#1983756 , @balazske wrote:

> LGTM
>  But a better approach can be to make a new kind of dependency. (Or split the 
> StreamChecker.)


Definitely the latter, I just didn't wanna mess with your project :) But I'd be 
happy to assist in splitting it up eventually!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78120



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


[clang] b2eb439 - [clang-format] Fix AlignConsecutive on PP blocks

2020-05-13 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-05-13T18:31:51+01:00
New Revision: b2eb439317576ce718193763c12bff9fccdfc166

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

LOG: [clang-format] Fix AlignConsecutive on PP blocks

Summary:
Currently the 'AlignConsecutive*' options incorrectly align across
elif and else statements, even if they are very far away and across
unrelated preprocessor macros.

This failed since on preprocessor run 2+, there is not enough context
about the #ifdefs to actually differentiate one block from another,
causing them to align across different blocks or even large sections of
the file.

Eg, with AlignConsecutiveAssignments:

```
\#if FOO  // Run 1
\#else// Run 1
int a   = 1;  // Run 2, wrong
\#endif   // Run 1

\#if FOO  // Run 1
\#else// Run 1
int bar = 1;  // Run 2
\#endif   // Run 1
```

is read as

```
int a   = 1;  // Run 2, wrong
int bar = 1;  // Run 2
```

The approach taken to fix this was to add a new flag to Token that
forces breaking alignment across groups of lines (MustBreakAlignBefore)
in a similar manner to the existing flag that forces a line break
(MustBreakBefore). This flag is set for the first Token after a
preprocessor statement or diff conflict marker.

Fixes #25167,#31281

Patch By: JakeMerdichAMD

Reviewed By: MyDeveloperDay

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestComments.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 7b6b1e8ddce7..2ad839a6a4f0 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -182,6 +182,12 @@ struct FormatToken {
   /// before the token.
   bool MustBreakBefore = false;
 
+  /// Whether to not align across this token
+  ///
+  /// This happens for example when a preprocessor directive ended directly
+  /// before the token, but very rarely otherwise.
+  bool MustBreakAlignBefore = false;
+
   /// The raw text of the token.
   ///
   /// Contains the raw token text without leading whitespace and without 
leading

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 084b4fbb0bcf..b303758f1cb8 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2968,6 +2968,7 @@ void UnwrappedLineParser::readToken(int LevelDifference) {
   }
   FormatTok = Tokens->getNextToken();
   FormatTok->MustBreakBefore = true;
+  FormatTok->MustBreakAlignBefore = true;
 }
 
 if (!PPStack.empty() && (PPStack.back().Kind == PP_Unreachable) &&
@@ -2992,6 +2993,7 @@ void UnwrappedLineParser::pushToken(FormatToken *Tok) {
   Line->Tokens.push_back(UnwrappedLineNode(Tok));
   if (MustBreakBeforeNextToken) {
 Line->Tokens.back().Tok->MustBreakBefore = true;
+Line->Tokens.back().Tok->MustBreakAlignBefore = true;
 MustBreakBeforeNextToken = false;
   }
 }

diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index bc71a89fc92b..e641f10ccead 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -377,9 +377,11 @@ static unsigned AlignTokens(const FormatStyle &Style, F 
&&Matches,
 if (Changes[i].NewlinesBefore != 0) {
   CommasBeforeMatch = 0;
   EndOfSequence = i;
-  // If there is a blank line, or if the last line didn't contain any
-  // matching token, the sequence ends here.
-  if (Changes[i].NewlinesBefore > 1 || !FoundMatchOnLine)
+  // If there is a blank line, there is a forced-align-break (eg,
+  // preprocessor), or if the last line didn't contain any matching token,
+  // the sequence ends here.
+  if (Changes[i].NewlinesBefore > 1 ||
+  Changes[i].Tok->MustBreakAlignBefore || !FoundMatchOnLine)
 AlignCurrentSequence();
 
   FoundMatchOnLine = false;
@@ -618,6 +620,8 @@ void WhitespaceManager::alignTrailingComments() {
 if (Changes[i].StartOfBlockComment)
   continue;
 Newlines += Changes[i].NewlinesBefore;
+if (Changes[i].Tok->MustBreakAlignBefore)
+  BreakBeforeNext = true;
 if (!Changes[i].IsTrailingComment)
   continue;
 

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 227e12dfaf73..430423fbf941 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -11457,6 +11457,29 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) {
   verifyFormat("int oneTwoThree = 123

[clang] c82243d - [clang-format] : Fix additional pointer alignment for overloaded operators

2020-05-13 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-05-13T18:33:57+01:00
New Revision: c82243d0675bad130d22a9301d3dc1e7cfb05c2f

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

LOG: [clang-format] : Fix additional pointer alignment for overloaded operators

Summary:
Follow on from {D78879} to handle the more obscure to prevent spaces between 
operators

```
operator void *&();
operator void *&&();
operator void &*();
operator void &&*();
```

Reviewers: sylvestre.ledru, sammccall, krasimir, Abpostelnicu

Reviewed By: sammccall, Abpostelnicu

Subscribers: cfe-commits

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 76d1d4b60202..043859a2f5c0 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2818,7 +2818,7 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine &Line,
 tok::l_square));
   if (Right.is(tok::star) && Left.is(tok::l_paren))
 return false;
-  if (Right.is(tok::star) && Left.is(tok::star))
+  if (Left.is(tok::star) && Right.isOneOf(tok::star, tok::amp, tok::ampamp))
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) {
 const FormatToken *Previous = &Left;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 430423fbf941..1308487bb9f1 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -15760,6 +15760,8 @@ TEST_F(FormatTest, OperatorSpacing) {
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void *();", Style);
   verifyFormat("Foo::operator void **();", Style);
+  verifyFormat("Foo::operator void *&();", Style);
+  verifyFormat("Foo::operator void *&&();", Style);
   verifyFormat("Foo::operator()(void *);", Style);
   verifyFormat("Foo::operator*(void *);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15773,6 +15775,10 @@ TEST_F(FormatTest, OperatorSpacing) {
   verifyFormat("Foo::operator &();", Style);
   verifyFormat("Foo::operator &&();", Style);
   verifyFormat("Foo::operator &&();", Style);
+  verifyFormat("Foo::operator *&();", Style);
+  verifyFormat("Foo::operator *&();", Style);
+  verifyFormat("Foo::operator *&&();", Style);
+  verifyFormat("Foo::operator *&&();", Style);
   verifyFormat("operator*(int (*)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&();", Style);
@@ -15796,12 +15802,15 @@ TEST_F(FormatTest, OperatorSpacing) {
   verifyFormat("operator const FooRight &()", Style);
   verifyFormat("operator const FooRight *()", Style);
   verifyFormat("operator const FooRight **()", Style);
+  verifyFormat("operator const FooRight *&()", Style);
+  verifyFormat("operator const FooRight *&&()", Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator**();", Style);
   verifyFormat("Foo::operator void*();", Style);
   verifyFormat("Foo::operator void**();", Style);
+  verifyFormat("Foo::operator void*&();", Style);
   verifyFormat("Foo::operator/*comment*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
@@ -15812,10 +15821,13 @@ TEST_F(FormatTest, OperatorSpacing) {
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator**();", Style);
   verifyFormat("Foo::operator**();", Style);
+  verifyFormat("Foo::operator*&();", Style);
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator*&();", Style);
+  verifyFormat("Foo::operator*&();", Style);
   verifyFormat("operator*(int (*)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&();", Style);
@@ -15844,6 +15856,8 @@ TEST_F(FormatTest, OperatorSpacing) {
   verifyFormat("operator const FooLeft&()", Style);
   verifyFormat("operator const FooLeft*()", Style);
   verifyFormat("operator const FooLeft**()", Style);
+  verifyFormat("operator const FooLeft*&()", Style);
+  verifyFormat("operator const FooLeft*&&()", Style);
 
   // PR45107
   verifyFormat("operator Vector&();", Style);



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-05-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D79830#2034400 , @davidxl wrote:

> Is it possible to overload __builtin_expect(..)?


No OP, but...
First, Overloading builtins is a bit of a pain.  You end up having to do custom 
type checking.
Second, GCC already made the decision to do a separate name.  I'd want us to 
match them unless we have a really good reason not to.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[PATCH] D79866: [CUDA][HIP] Do not emit debug info for stub function

2020-05-13 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

I do not see the behavior the patch is supposed to fix in CUDA.
If I compile a simple program, host-side debugger does not see the `kernel`, 
sees `__device_stub_kernel` and, if the breakpoint is set on `kernel`, it 
treats it as a yet-to-be-loaded one and does end up breaking on intry into the 
kernel on the GPU side.

E.g.:

  (cuda-gdb) info symbol kernel
  No symbol "kernel" in current context.
  (cuda-gdb) info symbol __device_stub__kernel
  __device_stub__kernel() in section .text
  (cuda-gdb) b kernel
  Function "kernel" not defined.
  Make breakpoint pending on future shared library load? (y or [n]) y
  Breakpoint 1 (kernel) pending.
  (cuda-gdb) r
  Starting program: /usr/local/google/home/tra/work/llvm/build/debug/print
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
  Hello from host
  [New Thread 0x7fffd700 (LWP 227347)]
  [New Thread 0x7fffdf7fe700 (LWP 227348)]
  [New Thread 0x7fffdeffd700 (LWP 227349)]
  [Switching focus to CUDA kernel 0, grid 1, block (0,0,0), thread (0,0,0), 
device 0, sm 0, warp 0, lane 0]
  
  Thread 1 "print" hit Breakpoint 1, kernel<<<(1,1,1),(1,1,1)>>> () at 
print.cu:3
  3 printf("Hello\n");

Perhaps it's HIP-specific behavior that needs this tweak. 
For CUDA, I would rather that we continue to emit debug info for the stub (in 
it's __device_stub form). It is useful for debugging some issues.


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

https://reviews.llvm.org/D79866



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


[PATCH] D78120: [analyzer][StreamChecker] Don't make StreamTestChecker depend on StreamChecker for the time being

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D78120#2034455 , @Szelethus wrote:

> In D78120#1983756 , @balazske wrote:
>
> > LGTM
> >  But a better approach can be to make a new kind of dependency. (Or split 
> > the StreamChecker.)
>
>
> Definitely the latter, I just didn't wanna mess with your project :) But I'd 
> be happy to assist in splitting it up eventually!


Just to clarify, I don't mean to push the implementation of the correct 
solution to somebody else, but StreamChecker is a moving target and splitting 
checkers up, as this project demonstrates, is about a few lines worth of work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78120



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


[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:13122
+if (Base->isVirtual()) {
+  BaseAlignment = Ctx.getTypeAlignInChars(Base->getType());
+  Offset = CharUnits::Zero();

Oh, this — and all the other places that do presumed alignment based on a 
pointee type — needs a special case for C++ records with virtual bases, because 
you need to get its presumed alignment as a base sub-object, not its presumed 
alignment as a complete object, which is what `getTypeAlignInChars` will 
return.  The right way to merge that information is to get the normal alignment 
— which may be lower than expected if there's a typedef in play — and then 
`min` that with the base sub-object alignment.



Comment at: clang/lib/Sema/SemaChecking.cpp:13140
+  E = E->IgnoreParens();
+  switch (E->getStmtClass()) {
+  default:

You should add a case for unary `*`.



Comment at: clang/lib/Sema/SemaChecking.cpp:13211
+  }
+  return Optional>();
+}

There's an `llvm::None` which has this effect.



Comment at: clang/lib/Sema/SemaChecking.cpp:13225
+return getBaseAlignmentAndOffsetFromPtr(cast(E)->getSubExpr(),
+Ctx);
+  case Stmt::UnaryOperatorClass: {

I don't think we guarantee that these will be no-op casts; all the explicit 
cast nodes should be handled the same as ImplicitCastExpr, in both of these 
functions.



Comment at: clang/lib/Sema/SemaChecking.cpp:13254
+   BinaryOperatorKind Kind) {
+  auto LHSRes = getBaseAlignmentAndOffsetFromPtr(LHS, Ctx);
+  if (!LHSRes) {

Can you do this with just a type analysis on the operands instead of eagerly 
doing these calls?



Comment at: clang/lib/Sema/SemaChecking.cpp:13266
+  if (!RHS->isIntegerConstantExpr(RHSRes, Ctx))
+return Optional>();
+  CharUnits Offset = LHSRes->second;

This should be handled the same as array subscripting.  Maybe you can extract a 
helper for that that's given a pointer expression, an integer expression, and a 
flag indicating whether it's a subtraction?



Comment at: clang/lib/Sema/SemaChecking.cpp:13279
+  return HandleBinOp(BO->getLHS(), BO->getRHS(), Opcode);
+break;
+  }

You should look through comma expressions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767



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


[PATCH] D79852: [libunwind] Fix wrong endianness check in Unwind-EHABI

2020-05-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo 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/D79852/new/

https://reviews.llvm.org/D79852



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-13 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D79704#2032947 , @Szelethus wrote:

> In D79704#2032271 , @NoQ wrote:
>
> > Blanket reply! `ParamRegion` is not a `DeclRegion` because it does not 
> > necessarily have a corresponding `Decl`. For instance, when calling a 
> > function through an unknown function pointer, you don't have the 
> > declaration of a function, let alone its parameters.
>
>
> Well hold on for a second then -- how is this, if it is, different for member 
> pointers? Aren't they represented with a `VarRegion`?


They aren't even `Loc`!

We currently don't have a representation for an unknown pointer-to-member. A 
known pointer-to-member is represented by a `FieldDecl` (not sure about static 
members) but it's still a `NonLoc` and as such isn't a region at all. Because, 
well, you can't dereference a pointer-to-member; you can only apply it to a 
base pointer like an offset. The mental model is "an offset". Therefore it's 
`NonLoc`.

Pointers to member functions are a different thing; they're function pointers 
so they're kinda regions.

>> But for parameters of C++ object type you still need your `ParamRegion` 
>> because arguments are constructed into it.
> 
> Could you give a specific code example?



  struct S {
S() {
  this; // What region does 'this' point to...
}
  };
  
  void foo(void (*bar)(S)) {
bar(S()); // ...in this invocation?
  }


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

https://reviews.llvm.org/D79704



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


[PATCH] D70351: [clang][WIP][clang-scan-deps] Add an experimental C API.

2020-05-13 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

I mostly just need to rebase this patch now. I'll try to get to that soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70351



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


[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-05-13 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D79830#2034380 , @RKSimon wrote:

> Add a description in our documentation?


And Ideally add a note to release notes too..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79830



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


[clang] 7a8edcb - [Clang] Restore replace_path_prefix instead of startswith

2020-05-13 Thread Sylvain Audi via cfe-commits

Author: Sylvain Audi
Date: 2020-05-13T13:49:14-04:00
New Revision: 7a8edcb2124b60941ef6ea4bb4b38a9eb0d70137

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

LOG: [Clang] Restore replace_path_prefix instead of startswith

In D49466, sys::path::replace_path_prefix was used instead startswith for 
-f[macro/debug/file]-prefix-map options.
However those were reverted later (commit 
rG3bb24bf25767ef5bbcef958b484e7a06d8689204) due to broken Windows tests.

This patch restores those replace_path_prefix calls.
It also modifies the prefix matching to be case-insensitive under Windows.

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

Added: 
clang/test/Preprocessor/Inputs/include-file-test/file_test.h
clang/test/Preprocessor/file_test_windows.c

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/Preprocessor/file_test.c
llvm/include/llvm/Support/Path.h
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/Support/Path.cpp
llvm/unittests/Support/Path.cpp

Removed: 
clang/test/Preprocessor/file_test.h



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 0c23b16a78d8..f92b21d5e636 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -470,10 +470,14 @@ CGDebugInfo::createFile(StringRef FileName,
 }
 
 std::string CGDebugInfo::remapDIPath(StringRef Path) const {
+  if (DebugPrefixMap.empty())
+return Path.str();
+
+  SmallString<256> P = Path;
   for (const auto &Entry : DebugPrefixMap)
-if (Path.startswith(Entry.first))
-  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
-  return Path.str();
+if (llvm::sys::path::replace_path_prefix(P, Entry.first, Entry.second))
+  break;
+  return P.str().str();
 }
 
 unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index cf8bb2fbab99..4908594d6081 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1456,10 +1456,8 @@ static void remapMacroPath(
 const std::map>
 &MacroPrefixMap) {
   for (const auto &Entry : MacroPrefixMap)
-if (Path.startswith(Entry.first)) {
-  Path = (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
+if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
   break;
-}
 }
 
 /// ExpandBuiltinMacro - If an identifier token is read that is to be expanded
@@ -1543,8 +1541,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
   } else {
 FN += PLoc.getFilename();
   }
-  Lexer::Stringify(FN);
   remapMacroPath(FN, PPOpts->MacroPrefixMap);
+  Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
 Tok.setKind(tok::string_literal);

diff  --git a/clang/test/Preprocessor/file_test.h 
b/clang/test/Preprocessor/Inputs/include-file-test/file_test.h
similarity index 100%
rename from clang/test/Preprocessor/file_test.h
rename to clang/test/Preprocessor/Inputs/include-file-test/file_test.h

diff  --git a/clang/test/Preprocessor/file_test.c 
b/clang/test/Preprocessor/file_test.c
index 3788db6eb090..890fa2cfcaa9 100644
--- a/clang/test/Preprocessor/file_test.c
+++ b/clang/test/Preprocessor/file_test.c
@@ -1,23 +1,23 @@
-// XFAIL: system-windows
+// UNSUPPORTED: system-windows
 // RUN: %clang -E -ffile-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | 
FileCheck %s
 // RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH/empty -c -o - %s | 
FileCheck %s
 // RUN: %clang -E -fmacro-prefix-map=%p=/UNLIKELY_PATH=empty -c -o - %s | 
FileCheck %s -check-prefix CHECK-EVIL
 // RUN: %clang -E -fmacro-prefix-map=%p/= -c -o - %s | FileCheck %s 
--check-prefix CHECK-REMOVE
 
 filename: __FILE__
-#include "file_test.h"
+#include "Inputs/include-file-test/file_test.h"
 
-// CHECK: filename: "/UNLIKELY_PATH/empty{{/|}}file_test.c"
-// CHECK: filename: "/UNLIKELY_PATH/empty{{/|}}file_test.h"
-// CHECK: basefile: "/UNLIKELY_PATH/empty{{/|}}file_test.c"
+// CHECK: filename: "/UNLIKELY_PATH/empty/file_test.c"
+// CHECK: filename: "/UNLIKELY_PATH/empty/Inputs/include-file-test/file_test.h"
+// CHECK: basefile: "/UNLIKELY_PATH/empty/file_test.c"
 // CHECK-NOT: filename:
 
-// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{/|}}file_test.c"
-// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{/|}}file_test.h"
-// CHECK-EVIL: basefile: "/UNLIKELY_PATH=empty{{/|}}file_test.c"
+// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty/file_test.c"
+// CHECK-EVIL: filename: 
"/UNLIKELY_PATH=empty/Inputs/include-file-test/file_test.h"
+// CHECK-EVIL: basefile: "/UNLIKELY_PATH=empty/file_test.c"
 // CHECK-EVIL-NOT: filename

[PATCH] D79834: Speed up preamble building by replacing the slow translateFile call by a new, faster isMainFile check

2020-05-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 263781.
arphaman added a comment.

fix assertion in the unit test.


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

https://reviews.llvm.org/D79834

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2054,8 +2054,7 @@
   // some directives (e.g. #endif of a header guard) will never be seen.
   // Since this will lead to confusing errors, avoid the inclusion.
   if (Action == Enter && File && PreambleConditionalStack.isRecording() &&
-  SourceMgr.translateFile(&File->getFileEntry()) ==
-  SourceMgr.getMainFileID()) {
+  SourceMgr.isMainFile(*File)) {
 Diag(FilenameTok.getLocation(),
  diag::err_pp_including_mainfile_in_preamble);
 return {ImportAction::None};
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -373,6 +373,7 @@
 
 void SourceManager::clearIDTables() {
   MainFileID = FileID();
+  CachedMainFileEntry = Optional>();
   LocalSLocEntryTable.clear();
   LoadedSLocEntryTable.clear();
   SLocEntryLoaded.clear();
@@ -389,6 +390,15 @@
   createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
 }
 
+bool SourceManager::isMainFile(FileEntryRef SourceFile) {
+  assert(MainFileID.isValid() && "expected initialized SourceManager");
+  if (!CachedMainFileEntry)
+*CachedMainFileEntry = getFileEntryRefForID(MainFileID);
+  if (!*CachedMainFileEntry)
+return false;
+  return (*CachedMainFileEntry)->getUID() == SourceFile.getUID();
+}
+
 void SourceManager::initializeForReplay(const SourceManager &Old) {
   assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
 
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -35,6 +35,7 @@
 #define LLVM_CLANG_BASIC_SOURCEMANAGER_H
 
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/BitVector.h"
@@ -59,9 +60,6 @@
 
 class ASTReader;
 class ASTWriter;
-class FileManager;
-class FileEntry;
-class FileEntryRef;
 class LineTableInfo;
 class SourceManager;
 
@@ -706,6 +704,9 @@
   /// The file ID for the main source file of the translation unit.
   FileID MainFileID;
 
+  /// The file entry for the main source file.
+  Optional> CachedMainFileEntry;
+
   /// The file ID for the precompiled preamble there is one.
   FileID PreambleFileID;
 
@@ -813,6 +814,9 @@
 MainFileID = FID;
   }
 
+  /// Returns true when the given FileEntry corresponds to the main file.
+  bool isMainFile(FileEntryRef SourceFile);
+
   /// Set the file ID for the precompiled preamble.
   void setPreambleFileID(FileID Preamble) {
 assert(PreambleFileID.isInvalid() && "PreambleFileID already set!");


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2054,8 +2054,7 @@
   // some directives (e.g. #endif of a header guard) will never be seen.
   // Since this will lead to confusing errors, avoid the inclusion.
   if (Action == Enter && File && PreambleConditionalStack.isRecording() &&
-  SourceMgr.translateFile(&File->getFileEntry()) ==
-  SourceMgr.getMainFileID()) {
+  SourceMgr.isMainFile(*File)) {
 Diag(FilenameTok.getLocation(),
  diag::err_pp_including_mainfile_in_preamble);
 return {ImportAction::None};
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -373,6 +373,7 @@
 
 void SourceManager::clearIDTables() {
   MainFileID = FileID();
+  CachedMainFileEntry = Optional>();
   LocalSLocEntryTable.clear();
   LoadedSLocEntryTable.clear();
   SLocEntryLoaded.clear();
@@ -389,6 +390,15 @@
   createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
 }
 
+bool SourceManager::isMainFile(FileEntryRef SourceFile) {
+  assert(MainFileID.isValid() && "expected initialized SourceManager");
+  if (!CachedMainFileEntry)
+*CachedMainFileEntry = getFileEntryRefForID(MainFileID);
+  if (!*CachedMainFileEntry)
+return false;
+  return (*CachedMainFileEntry)->getUID() == SourceFile.getUID();
+}
+
 void SourceManager::initializeForReplay(const SourceManager &Old) {
   assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
 
Index: clang/include/clang/Basic/SourceManager.h
===

[PATCH] D79388: [clang-format] Fix AlignConsecutive on PP blocks

2020-05-13 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2eb43931757: [clang-format] Fix AlignConsecutive on PP 
blocks (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79388

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestComments.cpp

Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -2780,6 +2780,27 @@
"   // line 2 about b\n"
"   long b;",
getLLVMStyleWithColumns(80)));
+
+  // Checks an edge case in preprocessor handling.
+  // These comments should *not* be aligned
+  EXPECT_EQ(
+  "#if FOO\n"
+  "#else\n"
+  "long a; // Line about a\n"
+  "#endif\n"
+  "#if BAR\n"
+  "#else\n"
+  "long b_long_name; // Line about b\n"
+  "#endif\n",
+  format("#if FOO\n"
+ "#else\n"
+ "long a;   // Line about a\n" // Previous (bad) behavior
+ "#endif\n"
+ "#if BAR\n"
+ "#else\n"
+ "long b_long_name; // Line about b\n"
+ "#endif\n",
+ getLLVMStyleWithColumns(80)));
 }
 
 TEST_F(FormatTestComments, AlignsBlockCommentDecorations) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11457,6 +11457,29 @@
   verifyFormat("int oneTwoThree = 123; // comment\n"
"int oneTwo  = 12;  // comment",
Alignment);
+
+  // Bug 25167
+  verifyFormat("#if A\n"
+   "#else\n"
+   "int  = 12;\n"
+   "#endif\n"
+   "#if B\n"
+   "#else\n"
+   "int a = 12;\n"
+   "#endif\n",
+   Alignment);
+  verifyFormat("enum foo {\n"
+   "#if A\n"
+   "#else\n"
+   "   = 12;\n"
+   "#endif\n"
+   "#if B\n"
+   "#else\n"
+   "  a = 12;\n"
+   "#endif\n"
+   "};\n",
+   Alignment);
+
   EXPECT_EQ("int a = 5;\n"
 "\n"
 "int oneTwoThree = 123;",
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -377,9 +377,11 @@
 if (Changes[i].NewlinesBefore != 0) {
   CommasBeforeMatch = 0;
   EndOfSequence = i;
-  // If there is a blank line, or if the last line didn't contain any
-  // matching token, the sequence ends here.
-  if (Changes[i].NewlinesBefore > 1 || !FoundMatchOnLine)
+  // If there is a blank line, there is a forced-align-break (eg,
+  // preprocessor), or if the last line didn't contain any matching token,
+  // the sequence ends here.
+  if (Changes[i].NewlinesBefore > 1 ||
+  Changes[i].Tok->MustBreakAlignBefore || !FoundMatchOnLine)
 AlignCurrentSequence();
 
   FoundMatchOnLine = false;
@@ -618,6 +620,8 @@
 if (Changes[i].StartOfBlockComment)
   continue;
 Newlines += Changes[i].NewlinesBefore;
+if (Changes[i].Tok->MustBreakAlignBefore)
+  BreakBeforeNext = true;
 if (!Changes[i].IsTrailingComment)
   continue;
 
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2968,6 +2968,7 @@
   }
   FormatTok = Tokens->getNextToken();
   FormatTok->MustBreakBefore = true;
+  FormatTok->MustBreakAlignBefore = true;
 }
 
 if (!PPStack.empty() && (PPStack.back().Kind == PP_Unreachable) &&
@@ -2992,6 +2993,7 @@
   Line->Tokens.push_back(UnwrappedLineNode(Tok));
   if (MustBreakBeforeNextToken) {
 Line->Tokens.back().Tok->MustBreakBefore = true;
+Line->Tokens.back().Tok->MustBreakAlignBefore = true;
 MustBreakBeforeNextToken = false;
   }
 }
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -182,6 +182,12 @@
   /// before the token.
   bool MustBreakBefore = false;
 
+  /// Whether to not align across this token
+  ///
+  /// This happens for example when a preprocessor directive ended directly
+  /// before the token, but very rarely otherwise.
+  bool MustBreakAlignBefore = false;
+
   /// The raw text of t

[PATCH] D79201: [clang-format] : Fix additional pointer alignment for overloaded operators

2020-05-13 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc82243d0675b: [clang-format] : Fix additional pointer 
alignment for overloaded operators (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79201

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15760,6 +15760,8 @@
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void *();", Style);
   verifyFormat("Foo::operator void **();", Style);
+  verifyFormat("Foo::operator void *&();", Style);
+  verifyFormat("Foo::operator void *&&();", Style);
   verifyFormat("Foo::operator()(void *);", Style);
   verifyFormat("Foo::operator*(void *);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15773,6 +15775,10 @@
   verifyFormat("Foo::operator &();", Style);
   verifyFormat("Foo::operator &&();", Style);
   verifyFormat("Foo::operator &&();", Style);
+  verifyFormat("Foo::operator *&();", Style);
+  verifyFormat("Foo::operator *&();", Style);
+  verifyFormat("Foo::operator *&&();", Style);
+  verifyFormat("Foo::operator *&&();", Style);
   verifyFormat("operator*(int (*)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&();", Style);
@@ -15796,12 +15802,15 @@
   verifyFormat("operator const FooRight &()", Style);
   verifyFormat("operator const FooRight *()", Style);
   verifyFormat("operator const FooRight **()", Style);
+  verifyFormat("operator const FooRight *&()", Style);
+  verifyFormat("operator const FooRight *&&()", Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator**();", Style);
   verifyFormat("Foo::operator void*();", Style);
   verifyFormat("Foo::operator void**();", Style);
+  verifyFormat("Foo::operator void*&();", Style);
   verifyFormat("Foo::operator/*comment*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
@@ -15812,10 +15821,13 @@
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator**();", Style);
   verifyFormat("Foo::operator**();", Style);
+  verifyFormat("Foo::operator*&();", Style);
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator&();", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator*&();", Style);
+  verifyFormat("Foo::operator*&();", Style);
   verifyFormat("operator*(int (*)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&();", Style);
@@ -15844,6 +15856,8 @@
   verifyFormat("operator const FooLeft&()", Style);
   verifyFormat("operator const FooLeft*()", Style);
   verifyFormat("operator const FooLeft**()", Style);
+  verifyFormat("operator const FooLeft*&()", Style);
+  verifyFormat("operator const FooLeft*&&()", Style);
 
   // PR45107
   verifyFormat("operator Vector&();", Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2818,7 +2818,7 @@
 tok::l_square));
   if (Right.is(tok::star) && Left.is(tok::l_paren))
 return false;
-  if (Right.is(tok::star) && Left.is(tok::star))
+  if (Left.is(tok::star) && Right.isOneOf(tok::star, tok::amp, tok::ampamp))
 return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) {
 const FormatToken *Previous = &Left;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15760,6 +15760,8 @@
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void *();", Style);
   verifyFormat("Foo::operator void **();", Style);
+  verifyFormat("Foo::operator void *&();", Style);
+  verifyFormat("Foo::operator void *&&();", Style);
   verifyFormat("Foo::operator()(void *);", Style);
   verifyFormat("Foo::operator*(void *);", Style);
   verifyFormat("Foo::operator*();", Style);
@@ -15773,6 +15775,10 @@
   verifyFormat("Foo::operator &();", Style);
   verifyFormat("Foo::operator &&();", Style);
   verifyFormat("Foo::operator &&();", Style);
+  verifyFormat("Foo::operator *&();", Style);
+  verifyFormat("Foo::operator *&();", Style);
+  verifyFormat("Foo::operator *&&();", Style);
+  verifyFormat("Foo::operator *&&();", Style);
   verifyFormat("operator*(int (*)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&();", Style);
@@ -15796,12 +15802,15 @@
   verifyFormat("operator const F

[clang] 2a12acd - [analyzer][StreamChecker] Don't make StreamTestChecker depend on StreamChecker for the time being

2020-05-13 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-05-13T20:05:11+02:00
New Revision: 2a12acda4c9fad4d69dce7a43e99690df357648c

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

LOG: [analyzer][StreamChecker] Don't make StreamTestChecker depend on 
StreamChecker for the time being

The comment in Checkers.td explains whats going on. As StreamChecker grows,
expect a need to have smaller checkers out of it, but let that be a worry for
later.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/test/Analysis/stream-error.c

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 4315b0984abc..c35f8b115f16 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1430,9 +1430,14 @@ def TaintTesterChecker : Checker<"TaintTest">,
   HelpText<"Mark tainted symbols as such.">,
   Documentation;
 
+// This checker *technically* depends on SteamChecker, but we don't allow
+// dependency checkers to emit diagnostics, and a debug checker isn't worth
+// the chore needed to create a modeling portion on its own. Since this checker
+// is for development purposes only anyways, make sure that StreamChecker is
+// also enabled, at least for the time being.
 def StreamTesterChecker : Checker<"StreamTester">,
-  HelpText<"Add test functions to StreamChecker for test and debugging 
purposes.">,
-  Dependencies<[StreamChecker]>,
+  HelpText<"Add test functions to StreamChecker for test and debugging "
+   "purposes.">,
   Documentation;
 
 def ExprInspectionChecker : Checker<"ExprInspection">,

diff  --git a/clang/test/Analysis/stream-error.c 
b/clang/test/Analysis/stream-error.c
index 2bd25ca30fa3..2302f3efc2f1 100644
--- a/clang/test/Analysis/stream-error.c
+++ b/clang/test/Analysis/stream-error.c
@@ -1,4 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core 
-analyzer-checker=debug.StreamTester,debug.ExprInspection -analyzer-store 
region -verify %s
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-checker=alpha.unix.Stream \
+// RUN: -analyzer-checker=debug.StreamTester \
+// RUN: -analyzer-checker=debug.ExprInspection
 
 #include "Inputs/system-header-simulator.h"
 



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


[PATCH] D78190: Add Bfloat IR type

2020-05-13 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.

Nothing much has changed here: there was already broad consensus on this change 
and direction, and the last few weeks we have only seen a few rounds of minor 
comments and nits, so still LGTM.
Please wait a day with committing to provide the opportunity for a last-minute 
objection to this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78190



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


[PATCH] D79388: [clang-format] Fix AlignConsecutive on PP blocks

2020-05-13 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD added a comment.

Thanks for the commit and review @MyDeveloperDay!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79388



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


[PATCH] D79274: Fix template class debug info for Visual Studio visualizers

2020-05-13 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth marked 2 inline comments as done.
amccarth added a comment.

Made the requested changes after an in-person conversation to clear up my 
earlier confusion.


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

https://reviews.llvm.org/D79274



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


[PATCH] D79274: Fix template class debug info for Visual Studio visualizers

2020-05-13 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth updated this revision to Diff 263790.
amccarth added a comment.

Addressed feedback, specifically:

- Distinction is now on CodeView generation rather than -fms-compatibility.
- Tests two --std= levels plus the default one.


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

https://reviews.llvm.org/D79274

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp


Index: clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -1,11 +1,19 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
-// RUN:   -o - -triple=x86_64-pc-win32 -std=c++98 | \
+// RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
 // RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview 
-emit-llvm %s \
-// RUN:   -o - -triple=x86_64-pc-win32 -std=c++98 | \
+// RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
 // RUN:FileCheck %s --check-prefix=CHECK --check-prefix=QUAL
+// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
+// RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++11 | \
+// RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
+// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
+// RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null | \
+// RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
+// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
 
 void freefunc() { }
 // CHECK-DAG: "freefunc"
@@ -94,5 +102,7 @@
 
 template  struct ClassTemplate { A a; B b; 
C c; };
 ClassTemplate > f;
-// This will only show up in normal debug builds.
+// This will only show up in normal debug builds.  The space in `> >` is
+// important for compatibility with Windows debuggers, so it should always be
+// there when generating CodeView.
 // UNQUAL-DAG: "ClassTemplate >"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -231,9 +231,12 @@
   // If we're emitting codeview, it's important to try to match MSVC's naming 
so
   // that visualizers written for MSVC will trigger for our class names. In
   // particular, we can't have spaces between arguments of standard templates
-  // like basic_string and vector.
-  if (CGM.getCodeGenOpts().EmitCodeView)
+  // like basic_string and vector, but we must have spaces between consecutive
+  // angle brackets that close nested template argument lists.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
 PP.MSVCFormatting = true;
+PP.SplitTemplateClosers = true;
+  }
 
   // Apply -fdebug-prefix-map.
   PP.Callbacks = &PrintCB;


Index: clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -1,11 +1,19 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
-// RUN:   -o - -triple=x86_64-pc-win32 -std=c++98 | \
+// RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
 // RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview -emit-llvm %s \
-// RUN:   -o - -triple=x86_64-pc-win32 -std=c++98 | \
+// RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
 // RUN:FileCheck %s --check-prefix=CHECK --check-prefix=QUAL
+// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
+// RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++11 | \
+// RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
+// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
+// RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null | \
+// RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
+// 

[PATCH] D79330: [Analyzer][VLASizeChecker] Check for VLA size overflow.

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

In D79330#2034414 , @martong wrote:

> I am not sure if I can follow your concern here.
>  `sizeof(size_t)` is typically 8, so that is not a bug, neither a code smell 
> to have `char VLA[sizeof(size_t)];`. The problem is when the size is bigger 
> than the maximum value of `size_t`, that ix 0xff...ff, as we can see that in 
> the new tests.
>  Besides, not having the size printed out in the warning is not a blocker for 
> me, this looks good enough.


Silly me. The size would be nice, but if we don't explain how we calculated 
that size, it wouldn't make the bug report much better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79330



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


[PATCH] D79834: Speed up preamble building by replacing the slow translateFile call by a new, faster isMainFile check

2020-05-13 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

IIUC the issue is that `SourceManager::translateFile()` basically consists of 
two blocks of code:

  // First, check the main file ID, since it is common to look for a
  // location in the main file.
  if (MainFileID.isValid()) {
bool Invalid = false;
const SLocEntry &MainSLoc = getSLocEntry(MainFileID, &Invalid);
if (Invalid)
  return FileID();
  
if (MainSLoc.isFile()) {
  const ContentCache *MainContentCache =
  MainSLoc.getFile().getContentCache();
  if (MainContentCache && MainContentCache->OrigEntry == SourceFile)
return MainFileID;
}
  }

and

// The location we're looking for isn't in the main file; look
// through all of the local source locations.
  ...

The comments suggest that the first block is a heuristic related to our case 
and the second block I would assume being the expensive part. 
`SourceManager::getFileEntryRefForID` implementation seems similar to the first 
block.

It makes sense to me to avoid the expensive search. I'm just wondering - how 
much speedup do we get with caching the value?


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

https://reviews.llvm.org/D79834



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


[PATCH] D79796: [DO NOT REVIEW] Sketch support for generating CC1 command line from CompilerInvocation

2020-05-13 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 263795.
dang added a comment.

Rebase on top of llvm/master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CompilerInvocationTest.cpp


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -24,7 +24,15 @@
   CompilerInvocation CInvok;
   CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
 
-  ASSERT_EQ(CInvok.getCC1CommandLine(), " -fmodules-strict-context-hash");
+  SmallVector GeneratedArgs;
+  SmallVector GeneratedArgsStorage;
+  auto StringAlloc = [&GeneratedArgsStorage](const Twine &Arg) {
+return GeneratedArgsStorage.emplace_back(Arg.str()).c_str();
+  };
+
+  CInvok.generateCC1CommandLine(GeneratedArgs, StringAlloc);
+
+  ASSERT_STREQ(GeneratedArgs[0], "-fmodules-strict-context-hash");
 }
 
 } // anonymous namespace
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -51,6 +51,7 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
@@ -3831,9 +3832,9 @@
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }
 
-std::string CompilerInvocation::getCC1CommandLine() const {
-  std::string CMDLine;
-  llvm::raw_string_ostream CMDStream(CMDLine);
+void CompilerInvocation::generateCC1CommandLine(
+SmallVectorImpl &Args,
+llvm::function_ref StringAllocator) const {
 #define PREFIX(PREFIX_TYPE, BRACED_INIT)   
\
   const char *PREFIX_TYPE[4] = BRACED_INIT;
 #define OPTION_WITH_MARSHALLING(PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, 
\
@@ -3841,11 +3842,10 @@
 VALUES, KEYPATH, IS_POSITIVE, DEFAULT_VALUE)   
\
   if (Option::KIND##Class == Option::FlagClass &&  
\
   IS_POSITIVE != DEFAULT_VALUE && this->KEYPATH != DEFAULT_VALUE)  
\
-CMDStream << " " << PREFIX_TYPE[0] << NAME;
+Args.push_back(StringAllocator(Twine(PREFIX_TYPE[0]) + NAME));
 #include "clang/Driver/Options.inc"
 #undef OPTION_WITH_MARSHALLING
 #undef PREFIX
-  return CMDStream.str();
 }
 
 namespace clang {
Index: clang/include/clang/Frontend/CompilerInvocation.h
===
--- clang/include/clang/Frontend/CompilerInvocation.h
+++ clang/include/clang/Frontend/CompilerInvocation.h
@@ -185,7 +185,19 @@
   /// identifying the conditions under which the module was built.
   std::string getModuleHash() const;
 
-  std::string getCC1CommandLine() const;
+  /// Generate a cc1-compatible command line arguments from this instance.
+  ///
+  /// \param [out] Args - The generated arguments. Note that the caller is
+  /// responsible for insersting the path to the clang executable and "-cc1" if
+  /// desired.
+  /// \param StringAllocator - A function that given a Twine can allocate
+  /// storage for a given command line argument and return a pointer to the
+  /// newly allocated string. The returned pointer is what gets appended to
+  /// Args.
+  void
+  generateCC1CommandLine(llvm::SmallVectorImpl &Args,
+ llvm::function_ref
+ StringAllocator) const;
 
   /// @}
   /// @name Option Subgroups


Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -24,7 +24,15 @@
   CompilerInvocation CInvok;
   CompilerInvocation::CreateFromArgs(CInvok, Args, *Diags);
 
-  ASSERT_EQ(CInvok.getCC1CommandLine(), " -fmodules-strict-context-hash");
+  SmallVector GeneratedArgs;
+  SmallVector GeneratedArgsStorage;
+  auto StringAlloc = [&GeneratedArgsStorage](const Twine &Arg) {
+return GeneratedArgsStorage.emplace_back(Arg.str()).c_str();
+  };
+
+  CInvok.generateCC1CommandLine(GeneratedArgs, StringAlloc);
+
+  ASSERT_STREQ(GeneratedArgs[0], "-fmodules-strict-context-hash");
 }
 
 } // anonymous namespace
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -51,6 +51,7 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "

[PATCH] D79877: [clang][SveEmitter] SVE builtins for `svusdot` and `svsudot` ACLE.

2020-05-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM with one small comment.




Comment at: clang/include/clang/Basic/arm_sve.td:1249
+def SVSUDOT_S: SInst<"svsudot[_s32]","ddqb", "i",   MergeNone, 
"aarch64_sve_usdot", [ReverseUSDOT]>;
+def SVSUDOT_N_S  : SInst<"svsudot[_n_s32]",  "ddq@", "i",   MergeNone, 
"aarch64_sve_usdot", [ReverseUSDOT]>;
+

These intrinsics aren't overloaded; maybe consider writing the actual type 
int8_t/uint8_t, instead of introducing "unsigned scalar of 1/4 width element 
type"?  If there's some reason the current form is better, that's fine, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79877



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


[PATCH] D79796: [DO NOT REVIEW] Sketch support for generating CC1 command line from CompilerInvocation

2020-05-13 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 263796.
dang added a comment.

Upload the right patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -33,6 +33,20 @@
   return OS;
 }
 
+static void EmitMarshallingInfo(raw_ostream &OS, const Record &R) {
+  OS << R.getValueAsString("KeyPath");
+  OS << ", ";
+  if (!isa(R.getValueInit("IsPositive")))
+OS << R.getValueAsBit("IsPositive");
+  else
+OS << "INVALID";
+  OS << ", ";
+  if (!isa(R.getValueInit("DefaultValue")))
+OS << R.getValueAsString("DefaultValue");
+  else
+OS << "INVALID";
+}
+
 /// OptParserEmitter - This tablegen backend takes an input .td file
 /// describing a list of options and emits a data structure for parsing and
 /// working with those options when given an input command line.
@@ -135,12 +149,8 @@
 
   OS << "//\n";
   OS << "// Options\n\n";
-  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
-const Record &R = *Opts[i];
-
-// Start a single option entry.
-OS << "OPTION(";
 
+  auto WriteOptRecordFields = [&](raw_ostream &OS, const Record &R) {
 // The option prefix;
 std::vector prf = R.getValueAsListOfStrings("Prefixes");
 OS << Prefixes[PrefixKeyT(prf.begin(), prf.end())] << ", ";
@@ -149,7 +159,7 @@
 write_cstring(OS, R.getValueAsString("Name"));
 
 // The option identifier name.
-OS  << ", "<< getOptionName(R);
+OS << ", " << getOptionName(R);
 
 // The option kind.
 OS << ", " << R.getValueAsDef("Kind")->getValueAsString("Name");
@@ -190,8 +200,7 @@
 int NumFlags = 0;
 const ListInit *LI = R.getValueAsListInit("Flags");
 for (Init *I : *LI)
-  OS << (NumFlags++ ? " | " : "")
- << cast(I)->getDef()->getName();
+  OS << (NumFlags++ ? " | " : "") << cast(I)->getDef()->getName();
 if (GroupFlags) {
   for (Init *I : *GroupFlags)
 OS << (NumFlags++ ? " | " : "")
@@ -224,11 +233,33 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+  };
+
+  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
+const Record &R = *Opts[i];
 
+// Start a single option entry.
+OS << "OPTION(";
+WriteOptRecordFields(OS, R);
 OS << ")\n";
   }
   OS << "#endif // OPTION\n";
 
+  OS << "#ifdef OPTION_WITH_MARSHALLING\n";
+  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
+const Record &R = *Opts[i];
+
+if (!isa(R.getValueInit("MarshallingInfo"))) {
+  OS << "OPTION_WITH_MARSHALLING(";
+  WriteOptRecordFields(OS, R);
+  OS << ", ";
+  EmitMarshallingInfo(
+  OS, *cast(R.getValueInit("MarshallingInfo"))->getDef());
+  OS << ")\n";
+}
+  }
+  OS << "#endif // OPTION_WITH_MARSHALLING\n";
+
   OS << "\n";
   OS << "#ifdef OPTTABLE_ARG_INIT\n";
   OS << "//\n";
@@ -252,8 +283,8 @@
 "OptTable!\");\n";
 }
 OS << "}\n";
+}
+OS << "\n";
+OS << "#endif // OPTTABLE_ARG_INIT\n";
   }
-  OS << "\n";
-  OS << "#endif // OPTTABLE_ARG_INIT\n";
-}
 } // end namespace llvm
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -80,6 +80,16 @@
   list Flags = [];
 }
 
+// Add support for generating marshalling code
+
+class OptionMarshallingInfo {
+  code KeyPath = keypath;
+  // Used by the Flag option kind.
+  bit IsPositive = ?;
+  code DefaultValue = ?;
+  list EnumValues = ?;
+}
+
 // Define the option class.
 
 class Option prefixes, string name, OptionKind kind> {
@@ -97,6 +107,7 @@
   OptionGroup Group = ?;
   Option Alias = ?;
   list AliasArgs = [];
+  OptionMarshallingInfo MarshallingInfo = ?;
 }
 
 // Helpers for defining options.
@@ -130,6 +141,22 @@
 class Values { string Values = value; }
 class ValuesCode { code ValuesCode = valuecode; }
 
+class MarshallingInfo { OptionMarshallingInfo MarshallingInfo = info; }
+class MarshallingFlag
+  : OptionMarshallingInfo {
+  bit IsPositive = ispositive;
+  code DefaultValue = defaultvalue;
+}
+class MarshallingString
+  : OptionMarshallingInfo {
+  code DefaultValue = defaultvalue;
+}
+class MarshallingEnum enumvalues>
+  : OptionMarshallingInfo {
+  code DefaultValue = defaultvalue;
+  listEnumValues = enumvalues;
+}
+
 // Predefined options.
 
 // FIXME: Have generator validate that these appear in correct 

[PATCH] D78134: [Sema] Don't apply an lvalue-to-rvalue conversion to a discarded-value expression if it has an array type

2020-05-13 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 263792.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Check function types in `DefaultLvalueConversion`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78134

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/expr/p10-0x.cpp
  clang/test/SemaCXX/warn-unused-value-cxx11.cpp


Index: clang/test/SemaCXX/warn-unused-value-cxx11.cpp
===
--- clang/test/SemaCXX/warn-unused-value-cxx11.cpp
+++ clang/test/SemaCXX/warn-unused-value-cxx11.cpp
@@ -41,4 +41,13 @@
   (void)noexcept(s.g() = 5); // Ok
 }
 
-}
\ No newline at end of file
+}
+
+namespace volatile_array {
+void test() {
+  char a[10];
+  volatile char b[10];
+  a; // expected-warning-re {{expression result unused{{$
+  b; // expected-warning-re {{expression result unused{{$
+}
+}
Index: clang/test/CXX/expr/p10-0x.cpp
===
--- clang/test/CXX/expr/p10-0x.cpp
+++ clang/test/CXX/expr/p10-0x.cpp
@@ -44,3 +44,12 @@
   refcall();
   1 ? refcall() : *x;
 }
+
+// CHECK: define void @_Z2f3v()
+// CHECK-NOT: load
+// CHECK-NOT: memcpy
+
+void f3(void) {
+  volatile char a[10];
+  a;
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -370,7 +370,10 @@
 }
   }
 
-  if (E->isGLValue() && E->getType().isVolatileQualified()) {
+  // Tell the user to assign it into a variable to force a volatile load if 
this
+  // isn't an array.
+  if (E->isGLValue() && E->getType().isVolatileQualified() &&
+  !E->getType()->isArrayType()) {
 Diag(Loc, diag::warn_unused_volatile) << R1 << R2;
 return;
   }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -606,6 +606,10 @@
   QualType T = E->getType();
   assert(!T.isNull() && "r-value conversion on typeless expression?");
 
+  // lvalue-to-rvalue conversion cannot be applied to function or array types.
+  if (T->isFunctionType() || T->isArrayType())
+return E;
+
   // We don't want to throw lvalue-to-rvalue casts on top of
   // expressions of certain types in C++.
   if (getLangOpts().CPlusPlus &&
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -10855,9 +10855,8 @@
   bool Diagnose = true);
 
   // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
-  // the operand.  This is DefaultFunctionArrayLvalueConversion,
-  // except that it assumes the operand isn't of function or array
-  // type.
+  // the operand. This function is a no-op if the operand has a function type
+  // or an array type.
   ExprResult DefaultLvalueConversion(Expr *E);
 
   // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that


Index: clang/test/SemaCXX/warn-unused-value-cxx11.cpp
===
--- clang/test/SemaCXX/warn-unused-value-cxx11.cpp
+++ clang/test/SemaCXX/warn-unused-value-cxx11.cpp
@@ -41,4 +41,13 @@
   (void)noexcept(s.g() = 5); // Ok
 }
 
-}
\ No newline at end of file
+}
+
+namespace volatile_array {
+void test() {
+  char a[10];
+  volatile char b[10];
+  a; // expected-warning-re {{expression result unused{{$
+  b; // expected-warning-re {{expression result unused{{$
+}
+}
Index: clang/test/CXX/expr/p10-0x.cpp
===
--- clang/test/CXX/expr/p10-0x.cpp
+++ clang/test/CXX/expr/p10-0x.cpp
@@ -44,3 +44,12 @@
   refcall();
   1 ? refcall() : *x;
 }
+
+// CHECK: define void @_Z2f3v()
+// CHECK-NOT: load
+// CHECK-NOT: memcpy
+
+void f3(void) {
+  volatile char a[10];
+  a;
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -370,7 +370,10 @@
 }
   }
 
-  if (E->isGLValue() && E->getType().isVolatileQualified()) {
+  // Tell the user to assign it into a variable to force a volatile load if this
+  // isn't an array.
+  if (E->isGLValue() && E->getType().isVolatileQualified() &&
+  !E->getType()->isArrayType()) {
 Diag(Loc, diag::warn_unused_volatile) << R1 << R2;
 return;
   }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -606,6 +606,10 @@
   QualType T = E->getType();
   assert(!T.isNull() && "r-value conversion on typeless expression?");
 
+  // lvalue-to-rvalue

[PATCH] D78120: [analyzer][StreamChecker] Don't make StreamTestChecker depend on StreamChecker for the time being

2020-05-13 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a12acda4c9f: [analyzer][StreamChecker] Don't make 
StreamTestChecker depend on StreamChecker… (authored by Szelethus).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78120

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/test/Analysis/stream-error.c


Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -1,4 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core 
-analyzer-checker=debug.StreamTester,debug.ExprInspection -analyzer-store 
region -verify %s
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-checker=alpha.unix.Stream \
+// RUN: -analyzer-checker=debug.StreamTester \
+// RUN: -analyzer-checker=debug.ExprInspection
 
 #include "Inputs/system-header-simulator.h"
 
Index: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1430,9 +1430,14 @@
   HelpText<"Mark tainted symbols as such.">,
   Documentation;
 
+// This checker *technically* depends on SteamChecker, but we don't allow
+// dependency checkers to emit diagnostics, and a debug checker isn't worth
+// the chore needed to create a modeling portion on its own. Since this checker
+// is for development purposes only anyways, make sure that StreamChecker is
+// also enabled, at least for the time being.
 def StreamTesterChecker : Checker<"StreamTester">,
-  HelpText<"Add test functions to StreamChecker for test and debugging 
purposes.">,
-  Dependencies<[StreamChecker]>,
+  HelpText<"Add test functions to StreamChecker for test and debugging "
+   "purposes.">,
   Documentation;
 
 def ExprInspectionChecker : Checker<"ExprInspection">,


Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -1,4 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-checker=debug.StreamTester,debug.ExprInspection -analyzer-store region -verify %s
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-checker=alpha.unix.Stream \
+// RUN: -analyzer-checker=debug.StreamTester \
+// RUN: -analyzer-checker=debug.ExprInspection
 
 #include "Inputs/system-header-simulator.h"
 
Index: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1430,9 +1430,14 @@
   HelpText<"Mark tainted symbols as such.">,
   Documentation;
 
+// This checker *technically* depends on SteamChecker, but we don't allow
+// dependency checkers to emit diagnostics, and a debug checker isn't worth
+// the chore needed to create a modeling portion on its own. Since this checker
+// is for development purposes only anyways, make sure that StreamChecker is
+// also enabled, at least for the time being.
 def StreamTesterChecker : Checker<"StreamTester">,
-  HelpText<"Add test functions to StreamChecker for test and debugging purposes.">,
-  Dependencies<[StreamChecker]>,
+  HelpText<"Add test functions to StreamChecker for test and debugging "
+   "purposes.">,
   Documentation;
 
 def ExprInspectionChecker : Checker<"ExprInspection">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79866: [CUDA][HIP] Do not emit debug info for stub function

2020-05-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D79866#2034460 , @tra wrote:

> I do not see the behavior the patch is supposed to fix in CUDA.
>  If I compile a simple program, host-side debugger does not see the `kernel`, 
> sees `__device_stub_kernel` and, if the breakpoint is set on `kernel`, it 
> treats it as a yet-to-be-loaded one and does end up breaking on intry into 
> the kernel on the GPU side.
>
> E.g.:
>
>   (cuda-gdb) info symbol kernel
>   No symbol "kernel" in current context.
>   (cuda-gdb) info symbol __device_stub__kernel
>   __device_stub__kernel() in section .text
>   (cuda-gdb) b kernel
>   Function "kernel" not defined.
>   Make breakpoint pending on future shared library load? (y or [n]) y
>   Breakpoint 1 (kernel) pending.
>   (cuda-gdb) r
>   Starting program: /usr/local/google/home/tra/work/llvm/build/debug/print
>   [Thread debugging using libthread_db enabled]
>   Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
>   Hello from host
>   [New Thread 0x7fffd700 (LWP 227347)]
>   [New Thread 0x7fffdf7fe700 (LWP 227348)]
>   [New Thread 0x7fffdeffd700 (LWP 227349)]
>   [Switching focus to CUDA kernel 0, grid 1, block (0,0,0), thread (0,0,0), 
> device 0, sm 0, warp 0, lane 0]
>  
>   Thread 1 "print" hit Breakpoint 1, kernel<<<(1,1,1),(1,1,1)>>> () at 
> print.cu:3
>   3 printf("Hello\n");
>
>
> Perhaps it's HIP-specific behavior that needs this tweak. 
>  For CUDA, I would rather that we continue to emit debug info for the stub 
> (in it's __device_stub form). It is useful for debugging some issues.


can you try set bp by using file name and line number on the kernel?


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

https://reviews.llvm.org/D79866



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


[PATCH] D79796: [DO NOT REVIEW] Sketch support for generating CC1 command line from CompilerInvocation

2020-05-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: llvm/utils/TableGen/OptParserEmitter.cpp:162
 // The option identifier name.
-OS  << ", "<< getOptionName(R);
+OS << ", " << getOptionName(R);
 

This whitespace fixup LGTM, but you should commit it separately as an NFC 
commit.  I suggest doing that now-ish; no need to wait for the RFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796



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


  1   2   >