r366159 - Allow for vendor prefixes in a list test

2019-07-15 Thread Nathan Lanza via cfe-commits
Author: lanza
Date: Mon Jul 15 17:57:50 2019
New Revision: 366159

URL: http://llvm.org/viewvc/llvm-project?rev=366159=rev
Log:
Allow for vendor prefixes in a list test

Summary:
Preprocessor/init.c contains a line that explicitly checks for the
string

__VERSION__ "Clang{{.*}}

It's valid to have a toolchain configured to emit a vendor prefix
before the word Clang. e.g.

__VERSION__ "Vendor Clang{{.*}}

Subscribers: fedor.sergeev, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=366159=366158=366159=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Jul 15 17:57:50 2019
@@ -8169,7 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "Clang{{.*}}
+// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32


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


r366166 - Change a lit test to permit vendor specific clang version

2019-07-15 Thread Nathan Lanza via cfe-commits
Author: lanza
Date: Mon Jul 15 19:05:52 2019
New Revision: 366166

URL: http://llvm.org/viewvc/llvm-project?rev=366166=rev
Log:
Change a lit test to permit vendor specific clang version

A test manually checks for the string `__VERSION__ "Clang`. This needs
to permit vendor specific variants.

Modified:
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=366166=366165=366166=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Jul 15 19:05:52 2019
@@ -9041,7 +9041,7 @@
 // X86_64-CLOUDABI:#define __UINT_LEAST8_MAX__ 255
 // X86_64-CLOUDABI:#define __UINT_LEAST8_TYPE__ unsigned char
 // X86_64-CLOUDABI:#define __USER_LABEL_PREFIX__
-// X86_64-CLOUDABI:#define __VERSION__ "Clang{{.*}}
+// X86_64-CLOUDABI:#define __VERSION__ "{{.*}}Clang{{.*}}
 // X86_64-CLOUDABI:#define __WCHAR_MAX__ 2147483647
 // X86_64-CLOUDABI:#define __WCHAR_TYPE__ int
 // X86_64-CLOUDABI:#define __WCHAR_WIDTH__ 32


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


[PATCH] D64680: [analyzer] MallocChecker: Prevent Integer Set Library false positives

2019-07-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2547-2548
+  StringRef FunctionStr = "";
+  if (const Decl *D = C.getStackFrame()->getDecl())
+if (const FunctionDecl *FD = D->getAsFunction())
+  FunctionStr = Lexer::getSourceText(

`const auto *FD = dyn_cast(C.getStackFrame()->getDecl())`.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2549-2552
+  FunctionStr = Lexer::getSourceText(
+  CharSourceRange::getTokenRange(
+  {FD->getBeginLoc(), FD->getBody()->getBeginLoc()}),
+  C.getSourceManager(), C.getLangOpts());

I'm slightly worried that it'll crash when `free()` is being called from within 
a body farm.

For now it probably cannot happen because none of the bodyfarmed functions can 
call `free()` directly, but i'd anyway rather add a check that the source 
locations we're taking are valid.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2554-2559
+  if (FunctionStr.equals(""))
+return false;
+
+  // We do not model the Integer Set Library's retain-count based allocation.
+  if (!FunctionStr.contains("__isl_"))
+return false;

If the string is empty, it clearly cannot contain `__isl_`, so the first check 
is redundant.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2564-2566
+if (const auto *DRE = dyn_cast(Arg->IgnoreImpCasts())) {
+  if (const auto *VD = dyn_cast(DRE->getDecl())) {
+SVal V = State->getSVal(State->getLValue(VD, C.getLocationContext()));

`C.getSVal(Arg)`.



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:2569
+  if (const RefState *RS = State->get(Sym)) {
+State = State->remove(Sym);
+State = State->set(Sym, RefState::getEscaped(RS));

`remove` is unnecessary, we overwrite it anyway.


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

https://reviews.llvm.org/D64680



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


[PATCH] D63954: Add lifetime categories attributes

2019-07-15 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4164
+  let Content = [{
+When annotating a class ``O`` with ``[[gsl::Owner(T)]]``, then each function
+that returns cv-qualified ``T&`` or ``T*`` is assumed to return a

mgehre wrote:
> gribozavr wrote:
> > Slightly better: "In a class annotated with ..., each function that returns 
> > ... is assumed to ..."
> > 
> > However, the "is assumed" part throws me off. There's no assumption here -- 
> > this is what this attribute means, intentionally, by design, no guessing 
> > involved.
> > 
> > So how about this?
> > 
> > The attribute `[[gsl::Owner(T)]]` applies to structs and classes that own 
> > an object of type `T`:
> > 
> > ```
> > [[gsl::Owner(int)]] class IntOwner {
> > private:
> >   int value;
> > public:
> >   int *getInt() { return  }
> >   long *getLong();
> > };
> > ```
> > 
> > In a class annotated like this each member function that returns `T&` or 
> > `T*` returns a pointer/reference to the data owned by the class instance:
> > 
> > ```
> > IntOwner int_owner;
> > int *x = int_owner.getInt();
> > // `x` points to memory owned by `int_owner`.
> > ```
> > 
> > Therefore, that the lifetime of that data ends when ... For example:
> > 
> > ```
> > int *x = IntOwner().getInt();
> > // `x` points to memory owned by the temporary `IntOwner()`, which has been 
> > destroyed now.
> > 
> > long *y = IntOwner().getLong();
> > // Can't make any conclusion about validity of `y`.
> > ```
> > 
> What I meant to express by "is assumed to" is that this attribute does not 
> change what member functions do. E.g. if I had `int* f() { static int i; 
> return  }`, then `f` would not return data owned by the class instance, 
> even when annotating the class with `[[gsl::Owner(T)]]`. The point is that 
> when member functions with return type `T*`/`T&` don't return data owned by 
> the class instance, one should not add the `[[gsl::Owner(T)]]` attribute - or 
> the analysis will produce wrong results. Here, we would warn if code uses the 
> returned value of `f` after the class instances has been destroyed even 
> though it would be safe.
> 
> There is a chicken and egg problem here. With this PR, we don't get any 
> analysis yet, so providing examples of analysis results like "`x` points to 
> memory owned by the temporary `IntOwner()`, which has been destroyed now." 
> can be misleading. On the other hand, if we would just document the current 
> meaning of the attribute, it would be nothing.
> The implication "member function that returns `T&` or ` T*` returns a 
> pointer/reference to the data owned by the class instance" is just one part 
> of being an Owner. Herb's paper
> uses this in more ways (e.g. output arguments, handling of move semantics, 
> etc.), which we would implement incrementally together with the respective 
> documentation update.
> 
> So I propose to keep the documentation basic for this PR and update the 
> documentation with the upcoming PRs that add to the analysis. Would that be 
> acceptable?
> I added a note that the attribute is currently experimental and subject to 
> change.
> What I meant to express by "is assumed to" is that this attribute does not 
> change what member functions do.

I don't think we should be making allowances for code that uses an attribute to 
promise something and then does some other thing. In that model, there's 
alignment between what code does and what attribute says.

And I mean of course the attribute does not change what the code does... that 
must be obvious but you can mention it explicitly if you want.

> With this PR, we don't get any analysis yet

I don't think the analysis must be automatic in order to show what analysis can 
be done. Attribute documentation needs enough examples to give people a flavor 
of what the attribute does, and what possible benefits it can bring.

Documentation for the specific analysis that is actually done should go 
elsewhere into Clang's documentation (if necessary).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63954



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


Re: r366123 - ARM MTE stack sanitizer.

2019-07-15 Thread Amara Emerson via cfe-commits
Hi Evgeniy,

This commit looks like it broke the lldb bot: 
http://green.lab.llvm.org/green/job/lldb-cmake/31011/ 


Can you take a look?

Amara

> On Jul 15, 2019, at 1:02 PM, Evgeniy Stepanov via cfe-commits 
>  wrote:
> 
> Author: eugenis
> Date: Mon Jul 15 13:02:23 2019
> New Revision: 366123
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=366123=rev
> Log:
> ARM MTE stack sanitizer.
> 
> Add "memtag" sanitizer that detects and mitigates stack memory issues
> using armv8.5 Memory Tagging Extension.
> 
> It is similar in principle to HWASan, which is a software implementation
> of the same idea, but there are enough differencies to warrant a new
> sanitizer type IMHO. It is also expected to have very different
> performance properties.
> 
> The new sanitizer does not have a runtime library (it may grow one
> later, along with a "debugging" mode). Similar to SafeStack and
> StackProtector, the instrumentation pass (in a follow up change) will be
> inserted in all cases, but will only affect functions marked with the
> new sanitize_memtag attribute.
> 
> Reviewers: pcc, hctim, vitalybuka, ostannard
> 
> Subscribers: srhines, mehdi_amini, javed.absar, kristof.beyls, hiraditya, 
> cryptoad, steven_wu, dexonsmith, cfe-commits, llvm-commits
> 
> Tags: #clang, #llvm
> 
> Differential Revision: https://reviews.llvm.org/D64169
> 
> Added:
>cfe/trunk/test/CodeGen/memtag-attr.cpp
>cfe/trunk/test/Lexer/has_feature_memtag_sanitizer.cpp
> Modified:
>cfe/trunk/include/clang/Basic/Features.def
>cfe/trunk/include/clang/Basic/Sanitizers.def
>cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
>cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
>cfe/trunk/lib/Driver/SanitizerArgs.cpp
>cfe/trunk/lib/Driver/ToolChains/Linux.cpp
>cfe/trunk/test/Driver/fsanitize.c
>cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp
> 
> Modified: cfe/trunk/include/clang/Basic/Features.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=366123=366122=366123=diff
> ==
> --- cfe/trunk/include/clang/Basic/Features.def (original)
> +++ cfe/trunk/include/clang/Basic/Features.def Mon Jul 15 13:02:23 2019
> @@ -42,6 +42,7 @@ FEATURE(address_sanitizer,
> FEATURE(hwaddress_sanitizer,
> LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
>SanitizerKind::KernelHWAddress))
> +FEATURE(memtag_sanitizer, LangOpts.Sanitize.has(SanitizerKind::MemTag))
> FEATURE(xray_instrument, LangOpts.XRayInstrument)
> FEATURE(undefined_behavior_sanitizer,
> LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
> 
> Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=366123=366122=366123=diff
> ==
> --- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
> +++ cfe/trunk/include/clang/Basic/Sanitizers.def Mon Jul 15 13:02:23 2019
> @@ -55,6 +55,9 @@ SANITIZER("hwaddress", HWAddress)
> // Kernel Hardware-assisted AddressSanitizer (KHWASan)
> SANITIZER("kernel-hwaddress", KernelHWAddress)
> 
> +// A variant of AddressSanitizer using AArch64 MTE extension.
> +SANITIZER("memtag", MemTag)
> +
> // MemorySanitizer
> SANITIZER("memory", Memory)
> 
> 
> Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=366123=366122=366123=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Mon Jul 15 13:02:23 2019
> @@ -369,6 +369,10 @@ llvm::Function *CodeGenModule::CreateGlo
>   !isInSanitizerBlacklist(SanitizerKind::KernelHWAddress, Fn, Loc))
> Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
> 
> +  if (getLangOpts().Sanitize.has(SanitizerKind::MemTag) &&
> +  !isInSanitizerBlacklist(SanitizerKind::MemTag, Fn, Loc))
> +Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
> +
>   if (getLangOpts().Sanitize.has(SanitizerKind::Thread) &&
>   !isInSanitizerBlacklist(SanitizerKind::Thread, Fn, Loc))
> Fn->addFnAttr(llvm::Attribute::SanitizeThread);
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=366123=366122=366123=diff
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Jul 15 13:02:23 2019
> @@ -696,6 +696,8 @@ void CodeGenFunction::StartFunction(Glob
> Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
>   if 

r366169 - Revert "[OPENMP]Add support for analysis of if clauses."

2019-07-15 Thread Ali Tamur via cfe-commits
Author: tamur
Date: Mon Jul 15 20:20:15 2019
New Revision: 366169

URL: http://llvm.org/viewvc/llvm-project?rev=366169=rev
Log:
Revert "[OPENMP]Add support for analysis of if clauses."

This reverts commit rL366068.
The patch broke 86 tests under clang/test/OpenMP/ when run with address 
sanitizer.

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/test/Analysis/cfg-openmp.cpp
cfe/trunk/test/OpenMP/cancel_if_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_if_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_if_messages.cpp
cfe/trunk/test/OpenMP/target_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_enter_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_exit_data_if_messages.cpp
cfe/trunk/test/OpenMP/target_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_if_messages.cpp
cfe/trunk/test/OpenMP/target_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_if_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_if_messages.cpp
cfe/trunk/test/OpenMP/target_teams_if_messages.cpp
cfe/trunk/test/OpenMP/target_update_if_messages.cpp
cfe/trunk/test/OpenMP/task_if_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_if_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=366169=366168=366169=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Jul 15 20:20:15 2019
@@ -501,10 +501,11 @@ public:
 return const_child_range(,  + 1);
   }
 
-  child_range used_children();
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
   const_child_range used_children() const {
-auto Children = const_cast(this)->used_children();
-return const_child_range(Children.begin(), Children.end());
+return const_child_range(const_child_iterator(), const_child_iterator());
   }
 
   static bool classof(const OMPClause *T) {

Modified: cfe/trunk/lib/AST/OpenMPClause.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/OpenMPClause.cpp?rev=366169=366168=366169=diff
==
--- cfe/trunk/lib/AST/OpenMPClause.cpp (original)
+++ cfe/trunk/lib/AST/OpenMPClause.cpp Mon Jul 15 20:20:15 2019
@@ -209,25 +209,6 @@ const OMPClauseWithPostUpdate *OMPClause
   return nullptr;
 }
 
-/// Gets the address of the original, non-captured, expression used in the
-/// clause as the preinitializer.
-static Stmt **getAddrOfExprAsWritten(Stmt *S) {
-  if (!S)
-return nullptr;
-  if (auto *DS = dyn_cast(S)) {
-assert(DS->isSingleDecl() && "Only single expression must be captured.");
-if (auto *OED = dyn_cast(DS->getSingleDecl()))
-  return OED->getInitAddress();
-  }
-  return nullptr;
-}
-
-OMPClause::child_range OMPIfClause::used_children() {
-  if (Stmt **C = getAddrOfExprAsWritten(getPreInitStmt()))
-return child_range(C, C + 1);
-  return child_range(,  + 1);
-}
-
 OMPOrderedClause *OMPOrderedClause::Create(const ASTContext , Expr *Num,
unsigned NumLoops,
SourceLocation StartLoc,

Modified: cfe/trunk/test/Analysis/cfg-openmp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-openmp.cpp?rev=366169=366168=366169=diff
==
--- cfe/trunk/test/Analysis/cfg-openmp.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-openmp.cpp Mon Jul 15 20:20:15 2019
@@ -1,402 +1,340 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s 2>&1 -fopenmp 
-fopenmp-version=45 | FileCheck %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG %s 2>&1 -fopenmp | 
FileCheck %s
 
 // CHECK-LABEL:  void xxx(int argc)
 void xxx(int argc) {
 // CHECK:[B1]
 // CHECK-NEXT:   1: int x;
-// CHECK-NEXT:   2: int cond;
-  int x, cond;
-// CHECK-NEXT:   [[#ATOM:]]: x
-// CHECK-NEXT:   [[#ATOM+1]]: [B1.[[#ATOM]]] (ImplicitCastExpr, 
LValueToRValue, int)
-// CHECK-NEXT:   [[#ATOM+2]]: argc
-// CHECK-NEXT:   [[#ATOM+3]]: 

[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with '-mframe-pointer'

2019-07-15 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 210014.
ychen marked an inline comment as done.
ychen added a comment.

- update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56353

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/msp430-fp-elim.c
  clang/test/CodeGen/x86_64-profiling-keep-fp.c
  clang/test/CodeGen/xcore-abi.c
  clang/test/CodeGen/xcore-abi.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenObjCXX/msabi-stret.mm
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang-translation.c
  clang/test/Driver/frame-pointer-elim.c
  clang/test/Driver/frame-pointer.c
  clang/test/Driver/woa-fp.c
  clang/test/Driver/xcore-opts.c

Index: clang/test/Driver/xcore-opts.c
===
--- clang/test/Driver/xcore-opts.c
+++ clang/test/Driver/xcore-opts.c
@@ -3,9 +3,8 @@
 // RUN: %clang -target xcore -x c++ %s -fexceptions -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-EXCEP %s
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
+// CHECK: "-mframe-pointer=none"
 // CHECK: "-nostdsysteminc"
-// CHECK-NOT: "-mdisable-fp-elim"
-// CHECK-NOT: "-momit-leaf-frame-pointer"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: clang/test/Driver/woa-fp.c
===
--- clang/test/Driver/woa-fp.c
+++ clang/test/Driver/woa-fp.c
@@ -34,7 +34,7 @@
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -O3 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -Os -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 
-// CHECK-DEFAULT: "-mdisable-fp-elim"
-// CHECK-FPO-NOT: "-mdisable-fp-elim"
-// CHECK-NO-FPO: "-mdisable-fp-elim"
+// CHECK-DEFAULT: "-mframe-pointer=all"
+// CHECK-FPO-NOT: "-mframe-pointer=all"
+// CHECK-NO-FPO: "-mframe-pointer=all"
 
Index: clang/test/Driver/frame-pointer.c
===
--- clang/test/Driver/frame-pointer.c
+++ clang/test/Driver/frame-pointer.c
@@ -57,15 +57,15 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
 
-// CHECK0-32: -mdisable-fp-elim
-// CHECK1-32-NOT: -mdisable-fp-elim
-// CHECK2-32-NOT: -mdisable-fp-elim
-// CHECK3-32-NOT: -mdisable-fp-elim
-// CHECKs-32-NOT: -mdisable-fp-elim
+// CHECK0-32: -mframe-pointer=all
+// CHECK1-32-NOT: -mframe-pointer=all
+// CHECK2-32-NOT: -mframe-pointer=all
+// CHECK3-32-NOT: -mframe-pointer=all
+// CHECKs-32-NOT: -mframe-pointer=all
 
-// CHECK0-64: -mdisable-fp-elim
-// CHECK1-64-NOT: -mdisable-fp-elim
-// CHECK2-64-NOT: -mdisable-fp-elim
-// CHECK3-64-NOT: -mdisable-fp-elim
-// CHECKs-64-NOT: -mdisable-fp-elim
-// CHECK-MACHO-64: -mdisable-fp-elim
+// CHECK0-64: -mframe-pointer=all
+// CHECK1-64-NOT: -mframe-pointer=all
+// CHECK2-64-NOT: -mframe-pointer=all
+// CHECK3-64-NOT: -mframe-pointer=all
+// CHECKs-64-NOT: -mframe-pointer=all
+// CHECK-MACHO-64: -mframe-pointer=all
Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -1,11 +1,6 @@
-// KEEP-ALL: "-mdisable-fp-elim"
-// KEEP-ALL-NOT: "-momit-leaf-frame-pointer"
-
-// KEEP-NON-LEAF: "-mdisable-fp-elim"
-// KEEP-NON-LEAF: "-momit-leaf-frame-pointer"
-
-// KEEP-NONE-NOT: "-mdisable-fp-elim"
-// KEEP-NONE-NOT: "-momit-leaf-frame-pointer"
+// KEEP-ALL:  "-mframe-pointer=all"
+// KEEP-NON-LEAF: "-mframe-pointer=non-leaf"
+// KEEP-NONE: "-mframe-pointer=none"
 
 // On Linux x86, omit frame pointer when optimization is enabled.
 // RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
@@ -73,20 +68,17 @@
 // RUN: %clang -### -target armv7s-apple-ios -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-7S %s
 // WARN-OMIT-7S: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s'
-// WARN-OMIT-7S: "-mdisable-fp-elim"
-// WARN-OMIT-7S-NOT: "-momit-leaf-frame-pointer"
+// WARN-OMIT-7S: "-mframe-pointer=all"
 
 // RUN: %clang -### -target armv7k-apple-watchos -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-7K %s
 // WARN-OMIT-7K: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7k'
-// 

[PATCH] D64089: [Driver] Introduce -stdlib++-isystem

2019-07-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64089



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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with '-mframe-pointer'

2019-07-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1728
 }
+assert(!FpKind.empty() && "unknown frame-pointer");
+FuncAttrs.addAttribute("frame-pointer", FpKind);

The `assert` here is not very necessary.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3955
+  const char *FPKeepKindStr = nullptr;
+  switch(FPKeepKind) {
+  case CodeGenOptions::FramePointerKind::None:

Add a space after `switch`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56353



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


r366165 - reland "add -fthinlto-index= option to clang-cl"

2019-07-15 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Jul 15 18:35:49 2019
New Revision: 366165

URL: http://llvm.org/viewvc/llvm-project?rev=366165=rev
Log:
reland "add -fthinlto-index= option to clang-cl"

Summary:
This is a reland of r366146, adding in the previously missing '--'
flag that prevents filenames from being interpreted as flags.

Original description:
This adds a -fthinlto-index= option to clang-cl, which allows it to
be used to drive ThinLTO backend passes. This allows clang-cl to be
used for distributed ThinLTO.

Tags: #clang

Added:
cfe/trunk/test/Driver/cl-thinlto-backend.c
Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=366165=366164=366165=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jul 15 18:35:49 2019
@@ -1270,7 +1270,7 @@ def flto_jobs_EQ : Joined<["-"], "flto-j
"of 0 means the number of threads will be derived from "
"the number of CPUs detected)">;
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
-  Flags<[CC1Option]>, Group,
+  Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;

Added: cfe/trunk/test/Driver/cl-thinlto-backend.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-thinlto-backend.c?rev=366165=auto
==
--- cfe/trunk/test/Driver/cl-thinlto-backend.c (added)
+++ cfe/trunk/test/Driver/cl-thinlto-backend.c Mon Jul 15 18:35:49 2019
@@ -0,0 +1,9 @@
+// RUN: %clang_cl -c -flto=thin -Fo%t.obj -- %s
+// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
+
+// -fthinlto_index should be passed to cc1
+// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
+// RUN: -- %t.obj 2>&1 | FileCheck %s
+
+// CHECK: -fthinlto-index=
+// CHECK: "-x" "ir"


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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-15 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum added a comment.

In D64537#1586809 , @aheejin wrote:

> Where should we call `__wasm_init_tls`, in case within a library?


Dynamic libraries are not supported by the local-exec TLS model. Support will 
be implemented later. The idea is that we'll have an `__ensure_tls_initialized` 
function that will `malloc` and `__wasm_init_tls` if `__tls_base == 0`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64537



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


[PATCH] D61838: [Sema] Suppress additional warnings for C's zero initializer

2019-07-15 Thread Peter Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366163: [Sema] Suppress additional warnings for Cs 
zero initializer (authored by Lekensteyn, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D61838?vs=209994=210009#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61838

Files:
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/test/Sema/zero-initializer.c


Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -2303,11 +2303,11 @@
 bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions ) 
const {
   assert(isSyntacticForm() && "only test syntactic form as zero initializer");
 
-  if (LangOpts.CPlusPlus || getNumInits() != 1) {
+  if (LangOpts.CPlusPlus || getNumInits() != 1 || !getInit(0)) {
 return false;
   }
 
-  const IntegerLiteral *Lit = dyn_cast(getInit(0));
+  const IntegerLiteral *Lit = 
dyn_cast(getInit(0)->IgnoreImplicit());
   return Lit && Lit->getValue() == 0;
 }
 
Index: cfe/trunk/test/Sema/zero-initializer.c
===
--- cfe/trunk/test/Sema/zero-initializer.c
+++ cfe/trunk/test/Sema/zero-initializer.c
@@ -7,6 +7,8 @@
 struct B { struct A a; };
 struct C { struct B b; };
 struct D { struct C c; int n; };
+struct E { short e; };
+struct F { struct E e; int n; };
 
 int main(void)
 {
@@ -23,6 +25,9 @@
   struct C p = { 0 }; // no-warning
   struct C q = { 9 }; // warning suppressed for struct with single element
   struct D r = { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  struct F s = { 0 }; // no-warning
+  struct F t = { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+
   f = (struct foo ) { 0 }; // no-warning
   g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' 
initializer}}
   h = (struct foo ) { 9, 9 }; // no-warning
@@ -36,6 +41,8 @@
   p = (struct C) { 0 }; // no-warning
   q = (struct C) { 9 }; // warning suppressed for struct with single element
   r = (struct D) { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  s = (struct F) { 0 }; // no-warning
+  t = (struct F) { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
 
   return 0;
 }


Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -2303,11 +2303,11 @@
 bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions ) const {
   assert(isSyntacticForm() && "only test syntactic form as zero initializer");
 
-  if (LangOpts.CPlusPlus || getNumInits() != 1) {
+  if (LangOpts.CPlusPlus || getNumInits() != 1 || !getInit(0)) {
 return false;
   }
 
-  const IntegerLiteral *Lit = dyn_cast(getInit(0));
+  const IntegerLiteral *Lit = dyn_cast(getInit(0)->IgnoreImplicit());
   return Lit && Lit->getValue() == 0;
 }
 
Index: cfe/trunk/test/Sema/zero-initializer.c
===
--- cfe/trunk/test/Sema/zero-initializer.c
+++ cfe/trunk/test/Sema/zero-initializer.c
@@ -7,6 +7,8 @@
 struct B { struct A a; };
 struct C { struct B b; };
 struct D { struct C c; int n; };
+struct E { short e; };
+struct F { struct E e; int n; };
 
 int main(void)
 {
@@ -23,6 +25,9 @@
   struct C p = { 0 }; // no-warning
   struct C q = { 9 }; // warning suppressed for struct with single element
   struct D r = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  struct F s = { 0 }; // no-warning
+  struct F t = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+
   f = (struct foo ) { 0 }; // no-warning
   g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' initializer}}
   h = (struct foo ) { 9, 9 }; // no-warning
@@ -36,6 +41,8 @@
   p = (struct C) { 0 }; // no-warning
   q = (struct C) { 9 }; // warning suppressed for struct with single element
   r = (struct D) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  s = (struct F) { 0 }; // no-warning
+  t = (struct F) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
 
   return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r366163 - [Sema] Suppress additional warnings for C's zero initializer

2019-07-15 Thread Peter Wu via cfe-commits
Author: lekensteyn
Date: Mon Jul 15 18:13:36 2019
New Revision: 366163

URL: http://llvm.org/viewvc/llvm-project?rev=366163=rev
Log:
[Sema] Suppress additional warnings for C's zero initializer

Summary:
D28148 relaxed some checks for assigning { 0 } to a structure for all C
standards, but it failed to handle structures with non-integer
subobjects. Relax -Wmissing-braces checks for such structures, and add
some additional tests.

This fixes PR39931.

Patch By: al3xtjames

Reviewed By: Lekensteyn

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

Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/Sema/zero-initializer.c

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=366163=366162=366163=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Jul 15 18:13:36 2019
@@ -2303,11 +2303,11 @@ bool InitListExpr::isTransparent() const
 bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions ) 
const {
   assert(isSyntacticForm() && "only test syntactic form as zero initializer");
 
-  if (LangOpts.CPlusPlus || getNumInits() != 1) {
+  if (LangOpts.CPlusPlus || getNumInits() != 1 || !getInit(0)) {
 return false;
   }
 
-  const IntegerLiteral *Lit = dyn_cast(getInit(0));
+  const IntegerLiteral *Lit = 
dyn_cast(getInit(0)->IgnoreImplicit());
   return Lit && Lit->getValue() == 0;
 }
 

Modified: cfe/trunk/test/Sema/zero-initializer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/zero-initializer.c?rev=366163=366162=366163=diff
==
--- cfe/trunk/test/Sema/zero-initializer.c (original)
+++ cfe/trunk/test/Sema/zero-initializer.c Mon Jul 15 18:13:36 2019
@@ -7,6 +7,8 @@ struct A { int a; };
 struct B { struct A a; };
 struct C { struct B b; };
 struct D { struct C c; int n; };
+struct E { short e; };
+struct F { struct E e; int n; };
 
 int main(void)
 {
@@ -23,6 +25,9 @@ int main(void)
   struct C p = { 0 }; // no-warning
   struct C q = { 9 }; // warning suppressed for struct with single element
   struct D r = { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  struct F s = { 0 }; // no-warning
+  struct F t = { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+
   f = (struct foo ) { 0 }; // no-warning
   g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' 
initializer}}
   h = (struct foo ) { 9, 9 }; // no-warning
@@ -36,6 +41,8 @@ int main(void)
   p = (struct C) { 0 }; // no-warning
   q = (struct C) { 9 }; // warning suppressed for struct with single element
   r = (struct D) { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  s = (struct F) { 0 }; // no-warning
+  t = (struct F) { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
 
   return 0;
 }


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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-15 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

Where should we call `__wasm_init_tls`, in case within a library?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64537



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


[PATCH] D64772: Allow for vendor prefixes in a list test

2019-07-15 Thread Nathan Lanza via Phabricator via cfe-commits
lanza updated this revision to Diff 210004.
lanza added a comment.

rebase


Repository:
  rC Clang

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

https://reviews.llvm.org/D64772

Files:
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8169,7 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "Clang{{.*}}
+// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8169,7 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "Clang{{.*}}
+// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64772: Allow for vendor prefixes in a list test

2019-07-15 Thread Nathan Lanza via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366159: Allow for vendor prefixes in a list test (authored 
by lanza, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64772

Files:
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8169,7 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "Clang{{.*}}
+// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8169,7 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "Clang{{.*}}
+// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64780: Disallow most calling convention attributes on PS4.

2019-07-15 Thread Paul Robinson via Phabricator via cfe-commits
probinson added reviewers: rnk, rjmccall.
probinson added a comment.

This has my blessing as PS4 code owner, but I'd like other eyes on it with 
respect to how we've gone about it.
+ rnk, rjmccall as the most likely suspects.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64780



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


Re: r366076 - fix unnamed fiefield issue and add tests for __builtin_preserve_access_index intrinsic

2019-07-15 Thread Eric Christopher via cfe-commits
I'm going to cheat and make Nick do it :)

-eric

On Mon, Jul 15, 2019 at 5:12 PM Yonghong Song  wrote:
>
> HI, Eric,
>
> No problem!
>
> I just tried the following cmake (removing -DLLVM_ENABLE_ASSERTIONS=ON which 
> is used in my previous build)
>
> cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
> -DCMAKE_C_COMPILER=/llvm8/bin/clang \
> -DCMAKE_CXX_COMPILER=/llvm8/bin/clang++ \
> -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON
> -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ..
>
> and cannot reproduce the issue. If you could send me the cmake
> command line which caused failure in your environment. That will
> be great!
>
> Thanks,
>
> Yonghong
>
> On 7/15/19, 4:50 PM, "Eric Christopher"  wrote:
>
> Just wanted to let you know I've temporarily reverted this here:
>
> echristo@jhereg ~/s/llvm-project> git llvm push
> Pushing 1 commit:
>   ba7decf8c91 Temporarily Revert "fix unnamed fiefield issue and add
> tests for __builtin_preserve_access_index intrinsic"
> Sendingcfe/trunk/lib/CodeGen/CGExpr.cpp
> Sendingcfe/trunk/lib/CodeGen/CodeGenFunction.h
> Deleting   cfe/trunk/test/CodeGen/builtin-preserve-access-index.c
> Deleting   cfe/trunk/test/Sema/builtin-preserve-access-index.c
> Transmitting file data ..done
> Committing transaction...
> Committed revision 366155.
> Committed ba7decf8c91 to svn.
>
> Since the testcase was causing problems in non-assert builds. Feel
> free to recommit when you fix that :)
>
> Thanks!
>
> -eric
>
> On Mon, Jul 15, 2019 at 8:42 AM Yonghong Song via cfe-commits
>  wrote:
> >
> > Author: yhs
> > Date: Mon Jul 15 08:42:41 2019
> > New Revision: 366076
> >
> > URL: 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D366076-26view-3Drev=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=DA8e1B5r073vIqRrFz7MRA=dtjPkUWyM2j7LOCdes9xK0tSCe4BrvYtJpmJu_el7xE=LyV9cu6egVjs0MILQtMXrDRw1r2afyEdzsh_tKDRsQE=
> > Log:
> > fix unnamed fiefield issue and add tests for 
> __builtin_preserve_access_index intrinsic
> >
> > This is a followup patch for 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D61809=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=DA8e1B5r073vIqRrFz7MRA=dtjPkUWyM2j7LOCdes9xK0tSCe4BrvYtJpmJu_el7xE=zdwdBj89w175wBRDiJ8ts1YTR7VrNyt4IHp-29y6b8E=
>  .
> > Handle unnamed bitfield properly and add more test cases.
> >
> > Fixed the unnamed bitfield issue. The unnamed bitfield is ignored
> > by debug info, so we need to ignore such a struct/union member
> > when we try to get the member index in the debug info.
> >
> > D61809 contains two test cases but not enough as it does
> > not checking generated IRs in the fine grain level, and also
> > it does not have semantics checking tests.
> > This patch added unit tests for both code gen and semantics checking for
> > the new intrinsic.
> >
> > Signed-off-by: Yonghong Song 
> >
> > Added:
> > cfe/trunk/test/CodeGen/builtin-preserve-access-index.c
> > cfe/trunk/test/Sema/builtin-preserve-access-index.c
> > Modified:
> > cfe/trunk/lib/CodeGen/CGExpr.cpp
> > cfe/trunk/lib/CodeGen/CodeGenFunction.h
> >
> > Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> > URL: 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CGExpr.cpp-3Frev-3D366076-26r1-3D366075-26r2-3D366076-26view-3Ddiff=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=DA8e1B5r073vIqRrFz7MRA=dtjPkUWyM2j7LOCdes9xK0tSCe4BrvYtJpmJu_el7xE=wNn-0ZBP1UL0gaIGHoTeMMTdnpNcjwneAK5I8Y8AaJY=
> > 
> ==
> > --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Jul 15 08:42:41 2019
> > @@ -3892,6 +3892,23 @@ LValue CodeGenFunction::EmitLValueForLam
> >return EmitLValueForField(LambdaLV, Field);
> >  }
> >
> > +/// Get the field index in the debug info. The debug info 
> structure/union
> > +/// will ignore the unnamed bitfields.
> > +unsigned CodeGenFunction::getDebugInfoFIndex(const RecordDecl *Rec,
> > + unsigned FieldIndex) {
> > +  unsigned I = 0, Skipped = 0;
> > +
> > +  for (auto F : Rec->getDefinition()->fields()) {
> > +if (I == FieldIndex)
> > +  break;
> > +if (F->isUnnamedBitfield())
> > +  Skipped++;
> > +I++;
> > +  }
> > +
> > +  return FieldIndex - Skipped;
> > +}
> > +
> >  /// Get the address of a zero-sized field within a record. The 
> resulting
> >  /// address doesn't necessarily have the right type.
> >  static Address emitAddrOfZeroSizeField(CodeGenFunction , Address 
> Base,
> > @@ -3931,7 +3948,7 @@ static Address 

Re: r366076 - fix unnamed fiefield issue and add tests for __builtin_preserve_access_index intrinsic

2019-07-15 Thread Yonghong Song via cfe-commits
HI, Eric,

No problem!

I just tried the following cmake (removing -DLLVM_ENABLE_ASSERTIONS=ON which is 
used in my previous build)

cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \
-DCMAKE_C_COMPILER=/llvm8/bin/clang \
-DCMAKE_CXX_COMPILER=/llvm8/bin/clang++ \
-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON 
-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install ..

and cannot reproduce the issue. If you could send me the cmake
command line which caused failure in your environment. That will
be great!

Thanks,

Yonghong

On 7/15/19, 4:50 PM, "Eric Christopher"  wrote:

Just wanted to let you know I've temporarily reverted this here:

echristo@jhereg ~/s/llvm-project> git llvm push
Pushing 1 commit:
  ba7decf8c91 Temporarily Revert "fix unnamed fiefield issue and add
tests for __builtin_preserve_access_index intrinsic"
Sendingcfe/trunk/lib/CodeGen/CGExpr.cpp
Sendingcfe/trunk/lib/CodeGen/CodeGenFunction.h
Deleting   cfe/trunk/test/CodeGen/builtin-preserve-access-index.c
Deleting   cfe/trunk/test/Sema/builtin-preserve-access-index.c
Transmitting file data ..done
Committing transaction...
Committed revision 366155.
Committed ba7decf8c91 to svn.

Since the testcase was causing problems in non-assert builds. Feel
free to recommit when you fix that :)

Thanks!

-eric

On Mon, Jul 15, 2019 at 8:42 AM Yonghong Song via cfe-commits
 wrote:
>
> Author: yhs
> Date: Mon Jul 15 08:42:41 2019
> New Revision: 366076
>
> URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D366076-26view-3Drev=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=DA8e1B5r073vIqRrFz7MRA=dtjPkUWyM2j7LOCdes9xK0tSCe4BrvYtJpmJu_el7xE=LyV9cu6egVjs0MILQtMXrDRw1r2afyEdzsh_tKDRsQE=
 
> Log:
> fix unnamed fiefield issue and add tests for 
__builtin_preserve_access_index intrinsic
>
> This is a followup patch for 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D61809=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=DA8e1B5r073vIqRrFz7MRA=dtjPkUWyM2j7LOCdes9xK0tSCe4BrvYtJpmJu_el7xE=zdwdBj89w175wBRDiJ8ts1YTR7VrNyt4IHp-29y6b8E=
 .
> Handle unnamed bitfield properly and add more test cases.
>
> Fixed the unnamed bitfield issue. The unnamed bitfield is ignored
> by debug info, so we need to ignore such a struct/union member
> when we try to get the member index in the debug info.
>
> D61809 contains two test cases but not enough as it does
> not checking generated IRs in the fine grain level, and also
> it does not have semantics checking tests.
> This patch added unit tests for both code gen and semantics checking for
> the new intrinsic.
>
> Signed-off-by: Yonghong Song 
>
> Added:
> cfe/trunk/test/CodeGen/builtin-preserve-access-index.c
> cfe/trunk/test/Sema/builtin-preserve-access-index.c
> Modified:
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_CodeGen_CGExpr.cpp-3Frev-3D366076-26r1-3D366075-26r2-3D366076-26view-3Ddiff=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=DA8e1B5r073vIqRrFz7MRA=dtjPkUWyM2j7LOCdes9xK0tSCe4BrvYtJpmJu_el7xE=wNn-0ZBP1UL0gaIGHoTeMMTdnpNcjwneAK5I8Y8AaJY=
 
> 
==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Jul 15 08:42:41 2019
> @@ -3892,6 +3892,23 @@ LValue CodeGenFunction::EmitLValueForLam
>return EmitLValueForField(LambdaLV, Field);
>  }
>
> +/// Get the field index in the debug info. The debug info structure/union
> +/// will ignore the unnamed bitfields.
> +unsigned CodeGenFunction::getDebugInfoFIndex(const RecordDecl *Rec,
> + unsigned FieldIndex) {
> +  unsigned I = 0, Skipped = 0;
> +
> +  for (auto F : Rec->getDefinition()->fields()) {
> +if (I == FieldIndex)
> +  break;
> +if (F->isUnnamedBitfield())
> +  Skipped++;
> +I++;
> +  }
> +
> +  return FieldIndex - Skipped;
> +}
> +
>  /// Get the address of a zero-sized field within a record. The resulting
>  /// address doesn't necessarily have the right type.
>  static Address emitAddrOfZeroSizeField(CodeGenFunction , Address 
Base,
> @@ -3931,7 +3948,7 @@ static Address emitPreserveStructAccess(
>CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
>
>return CGF.Builder.CreatePreserveStructAccessIndex(
> -  base, idx, field->getFieldIndex(), DbgInfo);
> +  base, idx, CGF.getDebugInfoFIndex(rec, field->getFieldIndex()), 
DbgInfo);
>  }
   

[PATCH] D61838: [Sema] Suppress additional warnings for C's zero initializer

2019-07-15 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn accepted this revision.
Lekensteyn added a comment.

Thanks, I'll push once the build and test pass.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61838



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


Re: r366146 - add -fthinlto-index= option to clang-cl

2019-07-15 Thread Eric Christopher via cfe-commits
Hi Bob,

I've temporarily reverted this here:

echristo@jhereg ~/s/llvm-project> git llvm push
Pushing 1 commit:
  1dbd2f85903 Temporarily revert "add -fthinlto-index= option to clang-cl"
Sendingcfe/trunk/include/clang/Driver/Options.td
Deleting   cfe/trunk/test/Driver/cl-thinlto-backend.c
Transmitting file data .done
Committing transaction...
Committed revision 366157.
Committed 1dbd2f85903 to svn.

as I was seeing testsuite failures on darwin release+asserts with the
patch. Let's follow up offline if you can't duplicate.

Thanks!

-eric

On Mon, Jul 15, 2019 at 3:49 PM Bob Haarman via cfe-commits
 wrote:
>
> Author: inglorion
> Date: Mon Jul 15 15:50:04 2019
> New Revision: 366146
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366146=rev
> Log:
> add -fthinlto-index= option to clang-cl
>
> Summary:
> This adds a -fthinlto-index= option to clang-cl, which allows it to
> be used to drive ThinLTO backend passes. This allows clang-cl to be
> used for distributed ThinLTO.
>
> Reviewers: tejohnson, pcc, rnk
>
> Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D64458
>
> Added:
> cfe/trunk/test/Driver/cl-thinlto-backend.c
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=366146=366145=366146=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Mon Jul 15 15:50:04 2019
> @@ -1270,7 +1270,7 @@ def flto_jobs_EQ : Joined<["-"], "flto-j
> "of 0 means the number of threads will be derived from "
> "the number of CPUs detected)">;
>  def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
> -  Flags<[CC1Option]>, Group,
> +  Flags<[CoreOption, CC1Option]>, Group,
>HelpText<"Perform ThinLTO importing using provided function summary 
> index">;
>  def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
>  Group, Flags<[DriverOption, 
> CoreOption]>;
>
> Added: cfe/trunk/test/Driver/cl-thinlto-backend.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-thinlto-backend.c?rev=366146=auto
> ==
> --- cfe/trunk/test/Driver/cl-thinlto-backend.c (added)
> +++ cfe/trunk/test/Driver/cl-thinlto-backend.c Mon Jul 15 15:50:04 2019
> @@ -0,0 +1,9 @@
> +// RUN: %clang_cl -c -flto=thin -Fo%t.obj %s
> +// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
> +
> +// -fthinlto_index should be passed to cc1
> +// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
> +// RUN: %t.obj 2>&1 | FileCheck %s
> +
> +// CHECK: -fthinlto-index=
> +// CHECK: "-x" "ir"
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366157 - Temporarily revert "add -fthinlto-index= option to clang-cl"

2019-07-15 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Mon Jul 15 17:02:40 2019
New Revision: 366157

URL: http://llvm.org/viewvc/llvm-project?rev=366157=rev
Log:
Temporarily revert "add -fthinlto-index= option to clang-cl"

This is causing testsuite failures on (at least) darwin release+asserts.

This reverts commit r366146.

Removed:
cfe/trunk/test/Driver/cl-thinlto-backend.c
Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=366157=366156=366157=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jul 15 17:02:40 2019
@@ -1270,7 +1270,7 @@ def flto_jobs_EQ : Joined<["-"], "flto-j
"of 0 means the number of threads will be derived from "
"the number of CPUs detected)">;
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
-  Flags<[CoreOption, CC1Option]>, Group,
+  Flags<[CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;

Removed: cfe/trunk/test/Driver/cl-thinlto-backend.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-thinlto-backend.c?rev=366156=auto
==
--- cfe/trunk/test/Driver/cl-thinlto-backend.c (original)
+++ cfe/trunk/test/Driver/cl-thinlto-backend.c (removed)
@@ -1,9 +0,0 @@
-// RUN: %clang_cl -c -flto=thin -Fo%t.obj %s
-// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
-
-// -fthinlto_index should be passed to cc1
-// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
-// RUN: %t.obj 2>&1 | FileCheck %s
-
-// CHECK: -fthinlto-index=
-// CHECK: "-x" "ir"


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


LLVM buildmaster will be updated and restarted tonight

2019-07-15 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 8PM Pacific time today.

Thanks

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


[PATCH] D64780: Disallow most calling convention attributes on PS4.

2019-07-15 Thread Sunil Srivastava via Phabricator via cfe-commits
Sunil_Srivastava created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We wish to disable most calling convention attributes for PS4, allowing just 
cdecl (and the equivalent sysv_abi on PS4), which are default.


Repository:
  rC Clang

https://reviews.llvm.org/D64780

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/X86.h
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/no_callconv.cpp
  unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp

Index: unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp
===
--- unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp
+++ unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp
@@ -86,6 +86,8 @@
 }
 
 TEST(RecursiveASTVisitor, VisitsAttributedLambdaExpr) {
+  if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).isPS4())
+return; // PS4 does not support fastcall.
   LambdaExprVisitor Visitor;
   Visitor.ExpectMatch("", 1, 12);
   EXPECT_TRUE(Visitor.runOver(
Index: test/Sema/no_callconv.cpp
===
--- test/Sema/no_callconv.cpp
+++ test/Sema/no_callconv.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -DPS4 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fsyntax-only -verify
+
+#ifdef PS4
+
+// PS4 does not support these.
+void __vectorcall func_vc() {} // expected-error {{'__vectorcall' calling convention not supported for this target}}
+void __regcall func_rc() {} // expected-error {{'__regcall' calling convention not supported for this target}}
+void __attribute__((vectorcall)) funcA() {} // expected-error {{'vectorcall' calling convention not supported for this target}}
+void __attribute__((regcall)) funcB() {} // expected-error {{'regcall' calling convention not supported for this target}}
+void __attribute__((ms_abi)) funcH() {} // expected-error {{'ms_abi' calling convention not supported for this target}}
+void __attribute__((intel_ocl_bicc)) funcJ() {} // expected-error {{'intel_ocl_bicc' calling convention not supported for this target}}
+void __attribute__((swiftcall)) funcK() {} // expected-error {{'swiftcall' calling convention not supported for this target}}
+void __attribute__((pascal)) funcG() {} // expected-error {{'pascal' calling convention not supported for this target}}
+void __attribute__((preserve_most)) funcL() {} // expected-error {{'preserve_most' calling convention not supported for this target}}
+void __attribute__((preserve_all)) funcM() {} // expected-error {{'preserve_all' calling convention not supported for this target}}
+void __attribute__((stdcall)) funcD() {} // expected-error {{'stdcall' calling convention not supported for this target}}
+void __attribute__((fastcall)) funcE() {} // expected-error {{'fastcall' calling convention not supported for this target}}
+void __attribute__((thiscall)) funcF() {} // expected-error {{'thiscall' calling convention not supported for this target}}
+#else
+
+void __vectorcall func_vc() {}
+void __regcall func_rc() {}
+void __attribute__((vectorcall)) funcA() {}
+void __attribute__((regcall)) funcB() {}
+void __attribute__((ms_abi)) funcH() {}
+void __attribute__((intel_ocl_bicc)) funcJ() {}
+void __attribute__((swiftcall)) funcK() {}
+void __attribute__((preserve_most)) funcL() {}
+void __attribute__((preserve_all)) funcM() {}
+
+// Same function with different calling conventions. Error with a note pointing to the last decl.
+void __attribute__((preserve_all)) funcR(); // expected-note {{previous declaration is here}}
+void __attribute__((preserve_most)) funcR(); // expected-error {{function declared 'preserve_most' here was previously declared 'preserve_all'}}
+
+void __attribute__((pascal)) funcG() {} // expected-warning {{'pascal' calling convention ignored for this target}}
+
+void __attribute__((stdcall)) funcD() {} // expected-warning {{'stdcall' calling convention ignored for this target}}
+void __attribute__((fastcall)) funcE() {} // expected-warning {{'fastcall' calling convention ignored for this target}}
+void __attribute__((thiscall)) funcF() {} // expected-warning {{'thiscall' calling convention ignored for this target}}
+#endif
+
+void __attribute__((sysv_abi)) funcI() {}
+void __attribute__((cdecl)) funcC() {}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4668,6 +4668,11 @@
 CC = CC_C;
 break;
 
+  case TargetInfo::CCCR_Error:
+Diag(Attrs.getLoc(), diag::error_cconv_unsupported)
+<< Attrs << (int)CallingConventionIgnoredReason::ForThisTarget;
+break;
+
   case TargetInfo::CCCR_Warning: {
 Diag(Attrs.getLoc(), diag::warn_cconv_ignored)
 << Attrs << (int)CallingConventionIgnoredReason::ForThisTarget;
Index: lib/Basic/Targets/X86.h

[PATCH] D64776: [WebAssembly] Compile all TLS on Emscripten as local-exec

2019-07-15 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209996.
quantum added a comment.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

Change to use TODO instead of XXX


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64776

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  lld/test/wasm/data-segments.ll
  lld/test/wasm/tls.ll
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/include/llvm/MC/MCSectionWasm.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/atomic-fence.ll
  llvm/test/CodeGen/WebAssembly/atomic-mem-consistency.ll
  llvm/test/CodeGen/WebAssembly/atomic-rmw.ll
  llvm/test/CodeGen/WebAssembly/i32-load-store-alignment.ll
  llvm/test/CodeGen/WebAssembly/i64-load-store-alignment.ll
  llvm/test/CodeGen/WebAssembly/load-ext-atomic.ll
  llvm/test/CodeGen/WebAssembly/offset-atomics.ll
  llvm/test/CodeGen/WebAssembly/store-trunc-atomic.ll
  llvm/test/CodeGen/WebAssembly/target-features-tls.ll
  llvm/test/CodeGen/WebAssembly/target-features.ll
  llvm/test/CodeGen/WebAssembly/tls.ll

Index: llvm/test/CodeGen/WebAssembly/tls.ll
===
--- llvm/test/CodeGen/WebAssembly/tls.ll
+++ llvm/test/CodeGen/WebAssembly/tls.ll
@@ -1,17 +1,82 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck --check-prefix=SINGLE %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+atomics,+bulk-memory | FileCheck %s --check-prefixes=CHECK,TLS
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+atomics,+bulk-memory -fast-isel | FileCheck %s --check-prefixes=CHECK,TLS
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+atomics,-bulk-memory | FileCheck %s --check-prefixes=CHECK,NO-TLS
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
+; CHECK-NEXT: .functype  address_of_tls () -> (i32)
 define i32 @address_of_tls() {
-  ; SINGLE: i32.const $push0=, tls
-  ; SINGLE-NEXT: return $pop0
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const tls
+  ; NO-TLS-NEXT: return
   ret i32 ptrtoint(i32* @tls to i32)
 }
 
-; SINGLE: .type	tls,@object
-; SINGLE-NEXT: .section	.bss.tls,"",@
-; SINGLE-NEXT: .p2align 2
-; SINGLE-NEXT: tls:
-; SINGLE-NEXT: .int32 0
-@tls = internal thread_local global i32 0
+; CHECK-LABEL: ptr_to_tls:
+; CHECK-NEXT: .functype ptr_to_tls () -> (i32)
+define i32* @ptr_to_tls() {
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const tls
+  ; NO-TLS-NEXT: return
+  ret i32* @tls
+}
+
+; CHECK-LABEL: tls_load:
+; CHECK-NEXT: .functype tls_load () -> (i32)
+define i32 @tls_load() {
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: i32.load 0
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const 0
+  ; NO-TLS-NEXT: i32.load tls
+  ; NO-TLS-NEXT: return
+  %tmp = load i32, i32* @tls, align 4
+  ret i32 %tmp
+}
+
+; CHECK-LABEL: tls_store:
+; CHECK-NEXT: .functype tls_store (i32) -> ()
+define void @tls_store(i32 %x) {
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: i32.store 0
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const 0
+  ; NO-TLS-NEXT: i32.store tls
+  ; NO-TLS-NEXT: return
+  store i32 %x, i32* @tls, align 4
+  ret void
+}
+
+; CHECK-LABEL: tls_size:
+; CHECK-NEXT: .functype tls_size () -> (i32)
+define i32 @tls_size() {
+; CHECK-NEXT: global.get __tls_size
+; CHECK-NEXT: return
+  %1 = call i32 @llvm.wasm.tls.size.i32()
+  ret i32 %1
+}
+
+; CHECK: .type tls,@object
+; TLS-NEXT: .section .tbss.tls,"",@
+; NO-TLS-NEXT: .section .bss.tls,"",@
+; CHECK-NEXT: .p2align 2
+; CHECK-NEXT: tls:
+; CHECK-NEXT: .int32 0
+@tls = internal thread_local(localexec) global i32 0
+
+declare i32 @llvm.wasm.tls.size.i32()
Index: llvm/test/CodeGen/WebAssembly/target-features.ll
===
--- llvm/test/CodeGen/WebAssembly/target-features.ll
+++ llvm/test/CodeGen/WebAssembly/target-features.ll
@@ -23,7 +23,7 @@
   ret void
 }
 
-attributes #0 = { 

Re: r366076 - fix unnamed fiefield issue and add tests for __builtin_preserve_access_index intrinsic

2019-07-15 Thread Eric Christopher via cfe-commits
Just wanted to let you know I've temporarily reverted this here:

echristo@jhereg ~/s/llvm-project> git llvm push
Pushing 1 commit:
  ba7decf8c91 Temporarily Revert "fix unnamed fiefield issue and add
tests for __builtin_preserve_access_index intrinsic"
Sendingcfe/trunk/lib/CodeGen/CGExpr.cpp
Sendingcfe/trunk/lib/CodeGen/CodeGenFunction.h
Deleting   cfe/trunk/test/CodeGen/builtin-preserve-access-index.c
Deleting   cfe/trunk/test/Sema/builtin-preserve-access-index.c
Transmitting file data ..done
Committing transaction...
Committed revision 366155.
Committed ba7decf8c91 to svn.

Since the testcase was causing problems in non-assert builds. Feel
free to recommit when you fix that :)

Thanks!

-eric

On Mon, Jul 15, 2019 at 8:42 AM Yonghong Song via cfe-commits
 wrote:
>
> Author: yhs
> Date: Mon Jul 15 08:42:41 2019
> New Revision: 366076
>
> URL: http://llvm.org/viewvc/llvm-project?rev=366076=rev
> Log:
> fix unnamed fiefield issue and add tests for __builtin_preserve_access_index 
> intrinsic
>
> This is a followup patch for https://reviews.llvm.org/D61809.
> Handle unnamed bitfield properly and add more test cases.
>
> Fixed the unnamed bitfield issue. The unnamed bitfield is ignored
> by debug info, so we need to ignore such a struct/union member
> when we try to get the member index in the debug info.
>
> D61809 contains two test cases but not enough as it does
> not checking generated IRs in the fine grain level, and also
> it does not have semantics checking tests.
> This patch added unit tests for both code gen and semantics checking for
> the new intrinsic.
>
> Signed-off-by: Yonghong Song 
>
> Added:
> cfe/trunk/test/CodeGen/builtin-preserve-access-index.c
> cfe/trunk/test/Sema/builtin-preserve-access-index.c
> Modified:
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=366076=366075=366076=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Jul 15 08:42:41 2019
> @@ -3892,6 +3892,23 @@ LValue CodeGenFunction::EmitLValueForLam
>return EmitLValueForField(LambdaLV, Field);
>  }
>
> +/// Get the field index in the debug info. The debug info structure/union
> +/// will ignore the unnamed bitfields.
> +unsigned CodeGenFunction::getDebugInfoFIndex(const RecordDecl *Rec,
> + unsigned FieldIndex) {
> +  unsigned I = 0, Skipped = 0;
> +
> +  for (auto F : Rec->getDefinition()->fields()) {
> +if (I == FieldIndex)
> +  break;
> +if (F->isUnnamedBitfield())
> +  Skipped++;
> +I++;
> +  }
> +
> +  return FieldIndex - Skipped;
> +}
> +
>  /// Get the address of a zero-sized field within a record. The resulting
>  /// address doesn't necessarily have the right type.
>  static Address emitAddrOfZeroSizeField(CodeGenFunction , Address Base,
> @@ -3931,7 +3948,7 @@ static Address emitPreserveStructAccess(
>CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
>
>return CGF.Builder.CreatePreserveStructAccessIndex(
> -  base, idx, field->getFieldIndex(), DbgInfo);
> +  base, idx, CGF.getDebugInfoFIndex(rec, field->getFieldIndex()), 
> DbgInfo);
>  }
>
>  static bool hasAnyVptr(const QualType Type, const ASTContext ) {
> @@ -4048,7 +4065,7 @@ LValue CodeGenFunction::EmitLValueForFie
>getContext().getRecordType(rec), rec->getLocation());
>addr = Address(
>Builder.CreatePreserveUnionAccessIndex(
> -  addr.getPointer(), field->getFieldIndex(), DbgInfo),
> +  addr.getPointer(), getDebugInfoFIndex(rec, 
> field->getFieldIndex()), DbgInfo),
>addr.getAlignment());
>  }
>} else {
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=366076=366075=366076=diff
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Jul 15 08:42:41 2019
> @@ -2652,6 +2652,9 @@ public:
>/// Converts Location to a DebugLoc, if debug information is enabled.
>llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location);
>
> +  /// Get the record field index as represented in debug info.
> +  unsigned getDebugInfoFIndex(const RecordDecl *Rec, unsigned FieldIndex);
> +
>
>
> //======//
>//Declaration Emission
>
> Added: cfe/trunk/test/CodeGen/builtin-preserve-access-index.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-preserve-access-index.c?rev=366076=auto
> 

[PATCH] D64776: [WebAssembly] Compile all TLS on Emscripten as local-exec

2019-07-15 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209997.
quantum added a comment.

Undo compressing the previous diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64776

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp


Index: llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
@@ -179,8 +179,14 @@
   report_fatal_error("cannot use thread-local storage without bulk memory",
  false);
 
+// Currently Emscripten does not support dynamic linking with threads.
+// Therefore, if we have thread-local storage, only the local-exec model
+// is possible.
+// TODO: remove this and implement proper TLS models once Emscripten
+// supports dynamic linking with threads.
 if (GA->getGlobal()->getThreadLocalMode() !=
-GlobalValue::LocalExecTLSModel) {
+GlobalValue::LocalExecTLSModel &&
+!Subtarget->getTargetTriple().isOSEmscripten()) {
   report_fatal_error("only -ftls-model=local-exec is supported for now",
  false);
 }


Index: llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
@@ -179,8 +179,14 @@
   report_fatal_error("cannot use thread-local storage without bulk memory",
  false);
 
+// Currently Emscripten does not support dynamic linking with threads.
+// Therefore, if we have thread-local storage, only the local-exec model
+// is possible.
+// TODO: remove this and implement proper TLS models once Emscripten
+// supports dynamic linking with threads.
 if (GA->getGlobal()->getThreadLocalMode() !=
-GlobalValue::LocalExecTLSModel) {
+GlobalValue::LocalExecTLSModel &&
+!Subtarget->getTargetTriple().isOSEmscripten()) {
   report_fatal_error("only -ftls-model=local-exec is supported for now",
  false);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366155 - Temporarily Revert "fix unnamed fiefield issue and add tests for __builtin_preserve_access_index intrinsic"

2019-07-15 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Mon Jul 15 16:49:31 2019
New Revision: 366155

URL: http://llvm.org/viewvc/llvm-project?rev=366155=rev
Log:
Temporarily Revert "fix unnamed fiefield issue and add tests for 
__builtin_preserve_access_index intrinsic"

The commit had tests that would only work with names in the IR.

This reverts commit r366076.

Removed:
cfe/trunk/test/CodeGen/builtin-preserve-access-index.c
cfe/trunk/test/Sema/builtin-preserve-access-index.c
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=366155=366154=366155=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Jul 15 16:49:31 2019
@@ -3892,23 +3892,6 @@ LValue CodeGenFunction::EmitLValueForLam
   return EmitLValueForField(LambdaLV, Field);
 }
 
-/// Get the field index in the debug info. The debug info structure/union
-/// will ignore the unnamed bitfields.
-unsigned CodeGenFunction::getDebugInfoFIndex(const RecordDecl *Rec,
- unsigned FieldIndex) {
-  unsigned I = 0, Skipped = 0;
-
-  for (auto F : Rec->getDefinition()->fields()) {
-if (I == FieldIndex)
-  break;
-if (F->isUnnamedBitfield())
-  Skipped++;
-I++;
-  }
-
-  return FieldIndex - Skipped;
-}
-
 /// Get the address of a zero-sized field within a record. The resulting
 /// address doesn't necessarily have the right type.
 static Address emitAddrOfZeroSizeField(CodeGenFunction , Address Base,
@@ -3948,7 +3931,7 @@ static Address emitPreserveStructAccess(
   CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
 
   return CGF.Builder.CreatePreserveStructAccessIndex(
-  base, idx, CGF.getDebugInfoFIndex(rec, field->getFieldIndex()), DbgInfo);
+  base, idx, field->getFieldIndex(), DbgInfo);
 }
 
 static bool hasAnyVptr(const QualType Type, const ASTContext ) {
@@ -4065,7 +4048,7 @@ LValue CodeGenFunction::EmitLValueForFie
   getContext().getRecordType(rec), rec->getLocation());
   addr = Address(
   Builder.CreatePreserveUnionAccessIndex(
-  addr.getPointer(), getDebugInfoFIndex(rec, 
field->getFieldIndex()), DbgInfo),
+  addr.getPointer(), field->getFieldIndex(), DbgInfo),
   addr.getAlignment());
 }
   } else {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=366155=366154=366155=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Jul 15 16:49:31 2019
@@ -2652,9 +2652,6 @@ public:
   /// Converts Location to a DebugLoc, if debug information is enabled.
   llvm::DebugLoc SourceLocToDebugLoc(SourceLocation Location);
 
-  /// Get the record field index as represented in debug info.
-  unsigned getDebugInfoFIndex(const RecordDecl *Rec, unsigned FieldIndex);
-
 
   
//======//
   //Declaration Emission

Removed: cfe/trunk/test/CodeGen/builtin-preserve-access-index.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-preserve-access-index.c?rev=366154=auto
==
--- cfe/trunk/test/CodeGen/builtin-preserve-access-index.c (original)
+++ cfe/trunk/test/CodeGen/builtin-preserve-access-index.c (removed)
@@ -1,177 +0,0 @@
-// RUN: %clang -target x86_64 -emit-llvm -S -g %s -o - | FileCheck %s
-
-#define _(x) (__builtin_preserve_access_index(x))
-
-const void *unit1(const void *arg) {
-  return _(arg);
-}
-// CHECK: define dso_local i8* @unit1(i8* %arg)
-// CHECK-NOT: llvm.preserve.array.access.index
-// CHECK-NOT: llvm.preserve.struct.access.index
-// CHECK-NOT: llvm.preserve.union.access.index
-
-const void *unit2(void) {
-  return _((const void *)0xULL);
-}
-// CHECK: define dso_local i8* @unit2()
-// CHECK-NOT: llvm.preserve.array.access.index
-// CHECK-NOT: llvm.preserve.struct.access.index
-// CHECK-NOT: llvm.preserve.union.access.index
-
-const void *unit3(const int *arg) {
-  return _(arg + 1);
-}
-// CHECK: define dso_local i8* @unit3(i32* %arg)
-// CHECK-NOT: llvm.preserve.array.access.index
-// CHECK-NOT: llvm.preserve.struct.access.index
-// CHECK-NOT: llvm.preserve.union.access.index
-
-const void *unit4(const int *arg) {
-  return _([1]);
-}
-// CHECK: define dso_local i8* @unit4(i32* %arg)
-// CHECK-NOT: getelementptr
-// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0i32(i32* %0, i32 
0, i32 1)
-
-const void *unit5(const int *arg[5]) {
-  return _([1][2]);
-}
-// CHECK: define dso_local i8* @unit5(i32** %arg)
-// CHECK-NOT: 

[PATCH] D61838: [Sema] Suppress additional warnings for C's zero initializer

2019-07-15 Thread Alex James via Phabricator via cfe-commits
al3xtjames updated this revision to Diff 209994.
al3xtjames marked an inline comment as done.
al3xtjames added a comment.

Added null check for `getInit(0)`


Repository:
  rC Clang

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

https://reviews.llvm.org/D61838

Files:
  clang/lib/AST/Expr.cpp
  clang/test/Sema/zero-initializer.c


Index: clang/test/Sema/zero-initializer.c
===
--- clang/test/Sema/zero-initializer.c
+++ clang/test/Sema/zero-initializer.c
@@ -7,6 +7,8 @@
 struct B { struct A a; };
 struct C { struct B b; };
 struct D { struct C c; int n; };
+struct E { short e; };
+struct F { struct E e; int n; };
 
 int main(void)
 {
@@ -23,6 +25,9 @@
   struct C p = { 0 }; // no-warning
   struct C q = { 9 }; // warning suppressed for struct with single element
   struct D r = { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  struct F s = { 0 }; // no-warning
+  struct F t = { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+
   f = (struct foo ) { 0 }; // no-warning
   g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' 
initializer}}
   h = (struct foo ) { 9, 9 }; // no-warning
@@ -36,6 +41,8 @@
   p = (struct C) { 0 }; // no-warning
   q = (struct C) { 9 }; // warning suppressed for struct with single element
   r = (struct D) { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  s = (struct F) { 0 }; // no-warning
+  t = (struct F) { 9 }; // expected-warning {{suggest braces around 
initialization of subobject}} expected-warning {{missing field 'n' initializer}}
 
   return 0;
 }
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2303,11 +2303,11 @@
 bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions ) 
const {
   assert(isSyntacticForm() && "only test syntactic form as zero initializer");
 
-  if (LangOpts.CPlusPlus || getNumInits() != 1) {
+  if (LangOpts.CPlusPlus || getNumInits() != 1 || !getInit(0)) {
 return false;
   }
 
-  const IntegerLiteral *Lit = dyn_cast(getInit(0));
+  const IntegerLiteral *Lit = 
dyn_cast(getInit(0)->IgnoreImplicit());
   return Lit && Lit->getValue() == 0;
 }
 


Index: clang/test/Sema/zero-initializer.c
===
--- clang/test/Sema/zero-initializer.c
+++ clang/test/Sema/zero-initializer.c
@@ -7,6 +7,8 @@
 struct B { struct A a; };
 struct C { struct B b; };
 struct D { struct C c; int n; };
+struct E { short e; };
+struct F { struct E e; int n; };
 
 int main(void)
 {
@@ -23,6 +25,9 @@
   struct C p = { 0 }; // no-warning
   struct C q = { 9 }; // warning suppressed for struct with single element
   struct D r = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  struct F s = { 0 }; // no-warning
+  struct F t = { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+
   f = (struct foo ) { 0 }; // no-warning
   g = (struct foo ) { 9 }; // expected-warning {{missing field 'y' initializer}}
   h = (struct foo ) { 9, 9 }; // no-warning
@@ -36,6 +41,8 @@
   p = (struct C) { 0 }; // no-warning
   q = (struct C) { 9 }; // warning suppressed for struct with single element
   r = (struct D) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
+  s = (struct F) { 0 }; // no-warning
+  t = (struct F) { 9 }; // expected-warning {{suggest braces around initialization of subobject}} expected-warning {{missing field 'n' initializer}}
 
   return 0;
 }
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2303,11 +2303,11 @@
 bool InitListExpr::isIdiomaticZeroInitializer(const LangOptions ) const {
   assert(isSyntacticForm() && "only test syntactic form as zero initializer");
 
-  if (LangOpts.CPlusPlus || getNumInits() != 1) {
+  if (LangOpts.CPlusPlus || getNumInits() != 1 || !getInit(0)) {
 return false;
   }
 
-  const IntegerLiteral *Lit = dyn_cast(getInit(0));
+  const IntegerLiteral *Lit = dyn_cast(getInit(0)->IgnoreImplicit());
   return Lit && Lit->getValue() == 0;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64772: Allow for vendor prefixes in a list test

2019-07-15 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

Yeah, that makes sense, the common path uses `{{.*}}` as the value itself is 
uninteresting.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64772



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


[PATCH] D63961: [clangd][xpc] pass the LSP value using data instead of string

2019-07-15 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

I'd add a test with non-empty non-LSP dictionary to specifically test that 
we're ignoring the content. I like const-correctness but that's up to you. 
Otherwise LGTM.




Comment at: clang-tools-extra/clangd/unittests/xpc/ConversionTests.cpp:34
+TEST(JsonXpcConversionTest, IgnoreNonLSPDictionary) {
+  xpc_object_t EmptyDict = xpc_dictionary_create(nullptr, nullptr, 0);
+  json::Value Val = xpcToJson(EmptyDict);

We should also test something like

```
const char* key = "NotAnLSP";
const char* value = "Foo";
xpc_object_t EmptyDict = xpc_dictionary_create(, , 1);
```



Comment at: clang-tools-extra/clangd/xpc/Conversion.cpp:22
   const char *const Key = "LSP";
-  xpc_object_t PayloadObj = xpc_string_create(llvm::to_string(JSON).c_str());
+  std::string Str = llvm::to_string(JSON);
+  xpc_object_t PayloadObj = xpc_data_create(Str.data(), Str.size());

Nit - `const std::string`?



Comment at: clang-tools-extra/clangd/xpc/Conversion.cpp:29
   if (xpc_get_type(XPCObject) == XPC_TYPE_DICTIONARY) {
-const char *const LSP = xpc_dictionary_get_string(XPCObject, "LSP");
-auto Json = json::parse(llvm::StringRef(LSP));
+size_t Length;
+const char *LSP =

Nit -`const size_t` and `const char * const`?


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

https://reviews.llvm.org/D63961



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


[PATCH] D64762: [AST] Treat semantic form of InitListExpr as implicit code in traversals

2019-07-15 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Please add tests to 
`llvm/tools/clang/unittests/Tooling/RecursiveASTVisitorTests/`.




Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:2332
   S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
   TRY_TO(TraverseSynOrSemInitListExpr(
   S->isSemanticForm() ? S : S->getSemanticForm(), Queue));

Instead of adding a whole new if statement, could you wrap the second existing 
TRY_TO in `if(shouldVisitImplicitCode())` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64762



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


r366153 - Revert "[NewPM] Port Sancov"

2019-07-15 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Mon Jul 15 16:18:31 2019
New Revision: 366153

URL: http://llvm.org/viewvc/llvm-project?rev=366153=rev
Log:
Revert "[NewPM] Port Sancov"

This reverts commit 5652f35817f07b16f8b3856d594cc42f4d7ee29c.

Removed:
cfe/trunk/test/CodeGen/sancov-new-pm.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=366153=366152=366153=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jul 15 16:18:31 2019
@@ -60,7 +60,6 @@
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
-#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -196,8 +195,11 @@ static void addBoundsCheckingPass(const
   PM.add(createBoundsCheckingLegacyPass());
 }
 
-static SanitizerCoverageOptions
-getSancovOptsFromCGOpts(const CodeGenOptions ) {
+static void addSanitizerCoveragePass(const PassManagerBuilder ,
+ legacy::PassManagerBase ) {
+  const PassManagerBuilderWrapper  =
+  static_cast(Builder);
+  const CodeGenOptions  = BuilderWrapper.getCGOpts();
   SanitizerCoverageOptions Opts;
   Opts.CoverageType =
   static_cast(CGOpts.SanitizeCoverageType);
@@ -213,17 +215,7 @@ getSancovOptsFromCGOpts(const CodeGenOpt
   Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   Opts.PCTable = CGOpts.SanitizeCoveragePCTable;
   Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth;
-  return Opts;
-}
-
-static void addSanitizerCoveragePass(const PassManagerBuilder ,
- legacy::PassManagerBase ) {
-  const PassManagerBuilderWrapper  =
-  static_cast(Builder);
-  const CodeGenOptions  = BuilderWrapper.getCGOpts();
-  auto Opts = getSancovOptsFromCGOpts(CGOpts);
-  PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts));
-  PM.add(createSanitizerCoverageLegacyPassPass(Opts));
+  PM.add(createSanitizerCoverageModulePass(Opts));
 }
 
 // Check if ASan should use GC-friendly instrumentation for globals.
@@ -1143,21 +1135,6 @@ void EmitAssemblyHelper::EmitAssemblyWit
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-PB.registerPipelineStartEPCallback(
-[SancovOpts](ModulePassManager ) {
-  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
-});
-PB.registerOptimizerLastEPCallback(
-[SancovOpts](FunctionPassManager ,
- PassBuilder::OptimizationLevel Level) {
-  FPM.addPass(SanitizerCoveragePass(SancovOpts));
-});
-  }
-
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1242,18 +1219,8 @@ void EmitAssemblyHelper::EmitAssemblyWit
   }
 }
 
-if (CodeGenOpts.OptimizationLevel == 0) {
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
-MPM.addPass(createModuleToFunctionPassAdaptor(
-SanitizerCoveragePass(SancovOpts)));
-  }
-
+if (CodeGenOpts.OptimizationLevel == 0)
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
-}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Removed: cfe/trunk/test/CodeGen/sancov-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sancov-new-pm.c?rev=366152=auto
==
--- cfe/trunk/test/CodeGen/sancov-new-pm.c (original)
+++ cfe/trunk/test/CodeGen/sancov-new-pm.c (removed)
@@ -1,41 +0,0 @@
-// Test that SanitizerCoverage works under the new pass manager.
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s 
-fexperimental-new-pass-manager -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-O0
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s 
-fexperimental-new-pass-manager -O2 -S -emit-llvm -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-O2
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=fuzzer %s 

r366152 - [DirectoryWatcher][linux] Fix for older kernels

2019-07-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Jul 15 16:14:00 2019
New Revision: 366152

URL: http://llvm.org/viewvc/llvm-project?rev=366152=rev
Log:
[DirectoryWatcher][linux] Fix for older kernels

IN_EXCL_UNLINK exists since Linux 2.6.36

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

Modified:
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp?rev=366152=366151=366152=diff
==
--- cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp Mon Jul 15 
16:14:00 2019
@@ -24,6 +24,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -332,8 +333,12 @@ std::unique_ptr clang:
 
   const int InotifyWD = inotify_add_watch(
   InotifyFD, Path.str().c_str(),
-  IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_EXCL_UNLINK | IN_MODIFY |
-  IN_MOVED_FROM | IN_MOVE_SELF | IN_MOVED_TO | IN_ONLYDIR | 
IN_IGNORED);
+  IN_CREATE | IN_DELETE | IN_DELETE_SELF | IN_MODIFY |
+  IN_MOVED_FROM | IN_MOVE_SELF | IN_MOVED_TO | IN_ONLYDIR | IN_IGNORED
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+  | IN_EXCL_UNLINK
+#endif
+  );
   if (InotifyWD == -1)
 return nullptr;
 


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


[PATCH] D61838: [Sema] Suppress additional warnings for C's zero initializer

2019-07-15 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added a comment.

@al3xtjames I was about to commit this but noticed that some others check 
whether `getInit(0)` is NULL or not before proceeding. Should that be done here 
as well? If not, why?

See for example "Harden InitListExpr::isStringLiteralInit() against getInit() 
returning null." in
https://github.com/llvm/llvm-project/commit/256bd96d1c2464b0f0ecb482ca52075a3158f6a1#diff-dac09655ff6a54658c320a28a6ea297c
and InitListExpr::isTransparent in
https://github.com/llvm/llvm-project/commit/122f88d481971b68d05ba12395c3b73ab4b31ab3#diff-dac09655ff6a54658c320a28a6ea297c


Repository:
  rC Clang

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

https://reviews.llvm.org/D61838



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


[PATCH] D62584: [OpenCL][PR42033] Deducing addr space with template parameter types

2019-07-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D62584#1585091 , @Anastasia wrote:

> In D62584#1583340 , @rjmccall wrote:
>
> > Oh, yes, it definitely can't be done to class types.  I suppose we should 
> > just forget about it.
>
>
> Ok, regarding address space qualifiers in template instantiation - is it 
> still ok that we ignore them here in this patch?


I think ignoring them in templates rather than diagnosing is the right thing to 
do, since it means that reasonable things, e.g. template functions returning 
`T`, won't be erroneous if you instantiate `T = __global int` just like they 
wouldn't be with `T = const int`.


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

https://reviews.llvm.org/D62584



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


[PATCH] D64083: [OpenCL][Sema] Improve address space support for blocks

2019-07-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Sounds good.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64083



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


[PATCH] D64458: add -fthinlto-index= option to clang-cl

2019-07-15 Thread Bob Haarman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366146: add -fthinlto-index= option to clang-cl (authored by 
inglorion, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64458?vs=209954=209980#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64458

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/test/Driver/cl-thinlto-backend.c


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1270,7 +1270,7 @@
"of 0 means the number of threads will be derived from "
"the number of CPUs detected)">;
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
-  Flags<[CC1Option]>, Group,
+  Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;
Index: cfe/trunk/test/Driver/cl-thinlto-backend.c
===
--- cfe/trunk/test/Driver/cl-thinlto-backend.c
+++ cfe/trunk/test/Driver/cl-thinlto-backend.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cl -c -flto=thin -Fo%t.obj %s
+// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
+
+// -fthinlto_index should be passed to cc1
+// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
+// RUN: %t.obj 2>&1 | FileCheck %s
+
+// CHECK: -fthinlto-index=
+// CHECK: "-x" "ir"


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1270,7 +1270,7 @@
"of 0 means the number of threads will be derived from "
"the number of CPUs detected)">;
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
-  Flags<[CC1Option]>, Group,
+  Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, CoreOption]>;
Index: cfe/trunk/test/Driver/cl-thinlto-backend.c
===
--- cfe/trunk/test/Driver/cl-thinlto-backend.c
+++ cfe/trunk/test/Driver/cl-thinlto-backend.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cl -c -flto=thin -Fo%t.obj %s
+// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
+
+// -fthinlto_index should be passed to cc1
+// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
+// RUN: %t.obj 2>&1 | FileCheck %s
+
+// CHECK: -fthinlto-index=
+// CHECK: "-x" "ir"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366146 - add -fthinlto-index= option to clang-cl

2019-07-15 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Jul 15 15:50:04 2019
New Revision: 366146

URL: http://llvm.org/viewvc/llvm-project?rev=366146=rev
Log:
add -fthinlto-index= option to clang-cl

Summary:
This adds a -fthinlto-index= option to clang-cl, which allows it to
be used to drive ThinLTO backend passes. This allows clang-cl to be
used for distributed ThinLTO.

Reviewers: tejohnson, pcc, rnk

Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Driver/cl-thinlto-backend.c
Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=366146=366145=366146=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jul 15 15:50:04 2019
@@ -1270,7 +1270,7 @@ def flto_jobs_EQ : Joined<["-"], "flto-j
"of 0 means the number of threads will be derived from "
"the number of CPUs detected)">;
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
-  Flags<[CC1Option]>, Group,
+  Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;

Added: cfe/trunk/test/Driver/cl-thinlto-backend.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-thinlto-backend.c?rev=366146=auto
==
--- cfe/trunk/test/Driver/cl-thinlto-backend.c (added)
+++ cfe/trunk/test/Driver/cl-thinlto-backend.c Mon Jul 15 15:50:04 2019
@@ -0,0 +1,9 @@
+// RUN: %clang_cl -c -flto=thin -Fo%t.obj %s
+// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
+
+// -fthinlto_index should be passed to cc1
+// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
+// RUN: %t.obj 2>&1 | FileCheck %s
+
+// CHECK: -fthinlto-index=
+// CHECK: "-x" "ir"


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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-15 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum added a comment.

In D64537#1586577 , @dschuff wrote:

> Another high-level question (based just on reading the CL description): The 
> TLS-size intrinsic is per-function, does that mean that the tls-init function 
> is called for every function? are there just multiple TLS sections per object 
> file?


The TLS-size intrinsic returns the total size of TLS for the module it's called 
from. The initialization function initializes the TLS for the entire module.

In D64537#1586556 , @dschuff wrote:

> The `offset` field of a segment can be a constant expression 
> 
>  which can be a `global.get` of an imported global. So we could have an 
> imported global `__tls_base` which is different for each thread, and have an 
> active segment with that as its segment offset?


I didn't know that it could have been a constant expression. I don't think this 
would have worked very well on the main thread though, since we need to run 
`malloc` before we can compute `__tls_base`. I think this requires the global 
to be mutable, if only because we need to be able to initialize it on the main 
thread.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64537



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


[PATCH] D64608: [OpenCL] Make TableGen'd builtin tables and helper functions static

2019-07-15 Thread Tom Stellard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366143: [OpenCL] Make TableGend builtin tables and 
helper functions static (authored by tstellar, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64608?vs=209383=209975#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64608

Files:
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp


Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -688,7 +688,7 @@
  unsigned Len) {
 
   for (unsigned i = 0; i < Len; ++i) {
-OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
+const OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
 ASTContext  = S.Context;
 
 // Ignore this BIF if the version is incorrect.
Index: cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -207,7 +207,7 @@
 }
 
 void BuiltinNameEmitter::EmitSignatureTable() {
-  OS << "OpenCLType OpenCLSignature[] = {\n";
+  OS << "static const OpenCLType OpenCLSignature[] = {\n";
   for (auto  : SignatureSet) {
 OS << "// " << P.second << "\n";
 for (Record *R : P.first) {
@@ -222,7 +222,7 @@
 }
 
 void BuiltinNameEmitter::EmitBuiltinTable() {
-  OS << "OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
+  OS << "static const OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
   for (auto  : OverloadInfo) {
 StringRef Name = i.first;
 OS << "// " << Name << "\n";
@@ -255,7 +255,7 @@
   OS << R"(
 // Return 0 if name is not a recognized OpenCL builtin, or an index
 // into a table of declarations if it is an OpenCL builtin.
-std::pair isOpenCLBuiltin(llvm::StringRef name) {
+static std::pair isOpenCLBuiltin(llvm::StringRef name) {
 
 )";
 


Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -688,7 +688,7 @@
  unsigned Len) {
 
   for (unsigned i = 0; i < Len; ++i) {
-OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
+const OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
 ASTContext  = S.Context;
 
 // Ignore this BIF if the version is incorrect.
Index: cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -207,7 +207,7 @@
 }
 
 void BuiltinNameEmitter::EmitSignatureTable() {
-  OS << "OpenCLType OpenCLSignature[] = {\n";
+  OS << "static const OpenCLType OpenCLSignature[] = {\n";
   for (auto  : SignatureSet) {
 OS << "// " << P.second << "\n";
 for (Record *R : P.first) {
@@ -222,7 +222,7 @@
 }
 
 void BuiltinNameEmitter::EmitBuiltinTable() {
-  OS << "OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
+  OS << "static const OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
   for (auto  : OverloadInfo) {
 StringRef Name = i.first;
 OS << "// " << Name << "\n";
@@ -255,7 +255,7 @@
   OS << R"(
 // Return 0 if name is not a recognized OpenCL builtin, or an index
 // into a table of declarations if it is an OpenCL builtin.
-std::pair isOpenCLBuiltin(llvm::StringRef name) {
+static std::pair isOpenCLBuiltin(llvm::StringRef name) {
 
 )";
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366143 - [OpenCL] Make TableGen'd builtin tables and helper functions static

2019-07-15 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Mon Jul 15 15:34:19 2019
New Revision: 366143

URL: http://llvm.org/viewvc/llvm-project?rev=366143=rev
Log:
[OpenCL] Make TableGen'd builtin tables and helper functions static

Reviewers: Pierre, Anastasia

Reviewed By: Anastasia

Subscribers: yaxunl, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=366143=366142=366143=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Jul 15 15:34:19 2019
@@ -688,7 +688,7 @@ static void InsertOCLBuiltinDeclarations
  unsigned Len) {
 
   for (unsigned i = 0; i < Len; ++i) {
-OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
+const OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
 ASTContext  = S.Context;
 
 // Ignore this BIF if the version is incorrect.

Modified: cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp?rev=366143=366142=366143=diff
==
--- cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp Mon Jul 15 15:34:19 
2019
@@ -207,7 +207,7 @@ void BuiltinNameEmitter::GetOverloads()
 }
 
 void BuiltinNameEmitter::EmitSignatureTable() {
-  OS << "OpenCLType OpenCLSignature[] = {\n";
+  OS << "static const OpenCLType OpenCLSignature[] = {\n";
   for (auto  : SignatureSet) {
 OS << "// " << P.second << "\n";
 for (Record *R : P.first) {
@@ -222,7 +222,7 @@ void BuiltinNameEmitter::EmitSignatureTa
 }
 
 void BuiltinNameEmitter::EmitBuiltinTable() {
-  OS << "OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
+  OS << "static const OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
   for (auto  : OverloadInfo) {
 StringRef Name = i.first;
 OS << "// " << Name << "\n";
@@ -255,7 +255,7 @@ void BuiltinNameEmitter::EmitStringMatch
   OS << R"(
 // Return 0 if name is not a recognized OpenCL builtin, or an index
 // into a table of declarations if it is an OpenCL builtin.
-std::pair isOpenCLBuiltin(llvm::StringRef name) {
+static std::pair isOpenCLBuiltin(llvm::StringRef name) {
 
 )";
 


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


r366141 - [clang-fuzzer] Remove 'setUseOrcMCJITReplacement(false)' call.

2019-07-15 Thread Lang Hames via cfe-commits
Author: lhames
Date: Mon Jul 15 15:27:57 2019
New Revision: 366141

URL: http://llvm.org/viewvc/llvm-project?rev=366141=rev
Log:
[clang-fuzzer] Remove 'setUseOrcMCJITReplacement(false)' call.

The default value for this option (UseMCJITReplacement) is already false, and
OrcMCJITReplacement is going to have deprecation warnings attached in LLVM 9.0.
Removing this call removes a spurious warning.

Modified:
cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp

Modified: cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp?rev=366141=366140=366141=diff
==
--- cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp Mon Jul 15 
15:27:57 2019
@@ -159,7 +159,6 @@ static void CreateAndRunJITFunc(const st
   builder.setMAttrs(getFeatureList());
   builder.setErrorStr();
   builder.setEngineKind(EngineKind::JIT);
-  builder.setUseOrcMCJITReplacement(false);
   builder.setMCJITMemoryManager(make_unique());
   builder.setOptLevel(OLvl);
   builder.setTargetOptions(InitTargetOptionsFromCodeGenFlags());


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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with '-mframe-pointer'

2019-07-15 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 209973.
ychen marked an inline comment as not done.
ychen edited the summary of this revision.
ychen added a comment.

- Make `FramePointerKind` enum class.
- Replace two if-else-if blocks to switch statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56353

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/msp430-fp-elim.c
  clang/test/CodeGen/x86_64-profiling-keep-fp.c
  clang/test/CodeGen/xcore-abi.c
  clang/test/CodeGen/xcore-abi.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenObjCXX/msabi-stret.mm
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang-translation.c
  clang/test/Driver/frame-pointer-elim.c
  clang/test/Driver/frame-pointer.c
  clang/test/Driver/woa-fp.c
  clang/test/Driver/xcore-opts.c

Index: clang/test/Driver/xcore-opts.c
===
--- clang/test/Driver/xcore-opts.c
+++ clang/test/Driver/xcore-opts.c
@@ -3,9 +3,8 @@
 // RUN: %clang -target xcore -x c++ %s -fexceptions -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-EXCEP %s
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
+// CHECK: "-mframe-pointer=none"
 // CHECK: "-nostdsysteminc"
-// CHECK-NOT: "-mdisable-fp-elim"
-// CHECK-NOT: "-momit-leaf-frame-pointer"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: clang/test/Driver/woa-fp.c
===
--- clang/test/Driver/woa-fp.c
+++ clang/test/Driver/woa-fp.c
@@ -34,7 +34,7 @@
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -O3 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 // RUN: %clang -target armv7-windows-itanium -fno-omit-frame-pointer -### -S %s -Os -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-NO-FPO
 
-// CHECK-DEFAULT: "-mdisable-fp-elim"
-// CHECK-FPO-NOT: "-mdisable-fp-elim"
-// CHECK-NO-FPO: "-mdisable-fp-elim"
+// CHECK-DEFAULT: "-mframe-pointer=all"
+// CHECK-FPO-NOT: "-mframe-pointer=all"
+// CHECK-NO-FPO: "-mframe-pointer=all"
 
Index: clang/test/Driver/frame-pointer.c
===
--- clang/test/Driver/frame-pointer.c
+++ clang/test/Driver/frame-pointer.c
@@ -57,15 +57,15 @@
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -O3 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -### -S -Os %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
 
-// CHECK0-32: -mdisable-fp-elim
-// CHECK1-32-NOT: -mdisable-fp-elim
-// CHECK2-32-NOT: -mdisable-fp-elim
-// CHECK3-32-NOT: -mdisable-fp-elim
-// CHECKs-32-NOT: -mdisable-fp-elim
+// CHECK0-32: -mframe-pointer=all
+// CHECK1-32-NOT: -mframe-pointer=all
+// CHECK2-32-NOT: -mframe-pointer=all
+// CHECK3-32-NOT: -mframe-pointer=all
+// CHECKs-32-NOT: -mframe-pointer=all
 
-// CHECK0-64: -mdisable-fp-elim
-// CHECK1-64-NOT: -mdisable-fp-elim
-// CHECK2-64-NOT: -mdisable-fp-elim
-// CHECK3-64-NOT: -mdisable-fp-elim
-// CHECKs-64-NOT: -mdisable-fp-elim
-// CHECK-MACHO-64: -mdisable-fp-elim
+// CHECK0-64: -mframe-pointer=all
+// CHECK1-64-NOT: -mframe-pointer=all
+// CHECK2-64-NOT: -mframe-pointer=all
+// CHECK3-64-NOT: -mframe-pointer=all
+// CHECKs-64-NOT: -mframe-pointer=all
+// CHECK-MACHO-64: -mframe-pointer=all
Index: clang/test/Driver/frame-pointer-elim.c
===
--- clang/test/Driver/frame-pointer-elim.c
+++ clang/test/Driver/frame-pointer-elim.c
@@ -1,11 +1,6 @@
-// KEEP-ALL: "-mdisable-fp-elim"
-// KEEP-ALL-NOT: "-momit-leaf-frame-pointer"
-
-// KEEP-NON-LEAF: "-mdisable-fp-elim"
-// KEEP-NON-LEAF: "-momit-leaf-frame-pointer"
-
-// KEEP-NONE-NOT: "-mdisable-fp-elim"
-// KEEP-NONE-NOT: "-momit-leaf-frame-pointer"
+// KEEP-ALL:  "-mframe-pointer=all"
+// KEEP-NON-LEAF: "-mframe-pointer=non-leaf"
+// KEEP-NONE: "-mframe-pointer=none"
 
 // On Linux x86, omit frame pointer when optimization is enabled.
 // RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
@@ -73,20 +68,17 @@
 // RUN: %clang -### -target armv7s-apple-ios -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=WARN-OMIT-7S %s
 // WARN-OMIT-7S: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s'
-// WARN-OMIT-7S: "-mdisable-fp-elim"
-// WARN-OMIT-7S-NOT: "-momit-leaf-frame-pointer"
+// WARN-OMIT-7S: "-mframe-pointer=all"
 
 // RUN: %clang -### -target armv7k-apple-watchos -fomit-frame-pointer %s 2>&1 | \
 // RUN:   FileCheck 

[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-15 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Another high-level question (based just on reading the CL description): The 
TLS-size intrinsic is per-function, does that mean that the tls-init function 
is called for every function? are there just multiple TLS sections per object 
file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64537



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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with '-mframe-pointer'

2019-07-15 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen marked an inline comment as done and an inline comment as not done.
ychen added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:845
+  if (Args.hasArg(OPT_pg))
+Opts.setFramePointer(CodeGenOptions::FP_All);
+

MaskRay wrote:
> I guess this can be deleted now.
> 
> `-pg` + FramePointerKind::None is rejected by the driver.
> 
> ```
>   if (Arg *A = Args.getLastArg(options::OPT_pg))
> if (FPKeepKind == FramePointerKind::None)
>   D.Diag(diag::err_drv_argument_not_allowed_with) << 
> "-fomit-frame-pointer"
>   << A->getAsString(Args);
> ```
This is still needed for `clang/test/CodeGen/x86_64-profiling-keep-fp.c` to 
pass.

We could have another patch to address this and update the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56353



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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-15 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

The `offset` field of a segment can be a constant expression 

 which can be a `global.get` of an imported global. So we could have an 
imported global `__tls_base` which is different for each thread, and have an 
active segment with that as its segment offset?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64537



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


[PATCH] D64458: add -fthinlto-index= option to clang-cl

2019-07-15 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

I think it's a little unfortunate that we're continuing to go down the road of 
letting users pass more flags to the ThinLTO backend action, but I won't stand 
in the way here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64458



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


[PATCH] D64775: [Format/ObjC] Avoid breaking between unary operators and ObjC method invocations

2019-07-15 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: krasimir, djasper, sammccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Test Plan:

  New tests added. Ran tests with:
  % ninja FormatTests && ./tools/clang/unittests/Format/FormatTests
  Confirmed tests failed before change and passed after change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64775

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


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -886,6 +886,18 @@
" bb:42\n"
" cc:42];");
 
+  // Avoid breaking between unary operators and ObjC method expressions.
+  Style.ColumnLimit = 45;
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "![foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "+[foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "-[foo bar]) {\n"
+   "}");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2425,6 +2425,8 @@
   if (Left.is(TT_JavaAnnotation))
 return 50;
 
+  if (Left.is(TT_UnaryOperator) && Right.is(TT_ObjCMethodExpr))
+return 60;
   if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
   Left.Previous->isLabelString() &&
   (Left.NextOperator || Left.OperatorIndex != 0))


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -886,6 +886,18 @@
" bb:42\n"
" cc:42];");
 
+  // Avoid breaking between unary operators and ObjC method expressions.
+  Style.ColumnLimit = 45;
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "![foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "+[foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "-[foo bar]) {\n"
+   "}");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2425,6 +2425,8 @@
   if (Left.is(TT_JavaAnnotation))
 return 50;
 
+  if (Left.is(TT_UnaryOperator) && Right.is(TT_ObjCMethodExpr))
+return 60;
   if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
   Left.Previous->isLabelString() &&
   (Left.NextOperator || Left.OperatorIndex != 0))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366137 - [DirectoryWatcher][NFC][test] Add typedef for enum

2019-07-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Jul 15 15:11:28 2019
New Revision: 366137

URL: http://llvm.org/viewvc/llvm-project?rev=366137=rev
Log:
[DirectoryWatcher][NFC][test] Add typedef for enum

Modified:
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=366137=366136=366137=diff
==
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Mon Jul 15 
15:11:28 2019
@@ -32,6 +32,8 @@ static bool operator==(const DirectoryWa
 
 namespace {
 
+typedef DirectoryWatcher::Event::EventKind EventKind;
+
 struct DirectoryWatcherTestFixture {
   std::string TestRootDir;
   std::string TestWatchedDir;
@@ -81,15 +83,15 @@ struct DirectoryWatcherTestFixture {
   }
 };
 
-std::string eventKindToString(const DirectoryWatcher::Event::EventKind K) {
+std::string eventKindToString(const EventKind K) {
   switch (K) {
-  case DirectoryWatcher::Event::EventKind::Removed:
+  case EventKind::Removed:
 return "Removed";
-  case DirectoryWatcher::Event::EventKind::Modified:
+  case EventKind::Modified:
 return "Modified";
-  case DirectoryWatcher::Event::EventKind::WatchedDirRemoved:
+  case EventKind::WatchedDirRemoved:
 return "WatchedDirRemoved";
-  case DirectoryWatcher::Event::EventKind::WatcherGotInvalidated:
+  case EventKind::WatcherGotInvalidated:
 return "WatcherGotInvalidated";
   }
   llvm_unreachable("unknown event kind");
@@ -249,7 +251,6 @@ void checkEventualResultWithTimeout(Veri
   !TestConsumer.result().hasValue())
 TestConsumer.printUnmetExpectations(llvm::outs());
 }
-
 } // namespace
 
 TEST(DirectoryWatcherTest, InitialScanSync) {
@@ -260,9 +261,9 @@ TEST(DirectoryWatcherTest, InitialScanSy
   fixture.addFile("c");
 
   VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"},
-   {DirectoryWatcher::Event::EventKind::Modified, "b"},
-   {DirectoryWatcher::Event::EventKind::Modified, "c"}},
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}},
   {}};
 
   auto DW = DirectoryWatcher::create(
@@ -284,9 +285,9 @@ TEST(DirectoryWatcherTest, InitialScanAs
   fixture.addFile("c");
 
   VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"},
-   {DirectoryWatcher::Event::EventKind::Modified, "b"},
-   {DirectoryWatcher::Event::EventKind::Modified, "c"}},
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}},
   {}};
 
   auto DW = DirectoryWatcher::create(
@@ -305,9 +306,9 @@ TEST(DirectoryWatcherTest, AddFiles) {
 
   VerifyingConsumer TestConsumer{
   {},
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"},
-   {DirectoryWatcher::Event::EventKind::Modified, "b"},
-   {DirectoryWatcher::Event::EventKind::Modified, "c"}}};
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -330,8 +331,8 @@ TEST(DirectoryWatcherTest, ModifyFile) {
   fixture.addFile("a");
 
   VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}},
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}}};
+  {{EventKind::Modified, "a"}},
+  {{EventKind::Modified, "a"}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -359,8 +360,8 @@ TEST(DirectoryWatcherTest, DeleteFile) {
   fixture.addFile("a");
 
   VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}},
-  {{DirectoryWatcher::Event::EventKind::Removed, "a"}}};
+  {{EventKind::Modified, "a"}},
+  {{EventKind::Removed, "a"}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -380,8 +381,8 @@ TEST(DirectoryWatcherTest, DeleteWatched
 
   VerifyingConsumer TestConsumer{
   {},
-  {{DirectoryWatcher::Event::EventKind::WatchedDirRemoved, ""},
-   {DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""}}};
+  {{EventKind::WatchedDirRemoved, ""},
+   {EventKind::WatcherGotInvalidated, ""}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -400,7 +401,7 @@ TEST(DirectoryWatcherTest, InvalidatedWa
   DirectoryWatcherTestFixture fixture;
 
   VerifyingConsumer TestConsumer{
-  {}, {{DirectoryWatcher::Event::EventKind::WatcherGotInvalidated, ""}}};
+  {}, {{EventKind::WatcherGotInvalidated, ""}}};
 
   {
 auto DW = DirectoryWatcher::create(


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r366138 - [DirectoryWatcher][test] Relax test assumptions

2019-07-15 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Jul 15 15:11:51 2019
New Revision: 366138

URL: http://llvm.org/viewvc/llvm-project?rev=366138=rev
Log:
[DirectoryWatcher][test] Relax test assumptions

Workaround for FSEvents sometimes sending notifications for events that happened
before DirectoryWatcher was created.

This caused tests to be flaky on green dragon.

Modified:
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=366138=366137=366138=diff
==
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Mon Jul 15 
15:11:51 2019
@@ -264,7 +264,14 @@ TEST(DirectoryWatcherTest, InitialScanSy
   {{EventKind::Modified, "a"},
{EventKind::Modified, "b"},
{EventKind::Modified, "c"}},
-  {}};
+  {},
+  // We have to ignore these as it's a race between the test process
+  // which is scanning the directory and kernel which is sending
+  // notification.
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}}
+  };
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -288,7 +295,14 @@ TEST(DirectoryWatcherTest, InitialScanAs
   {{EventKind::Modified, "a"},
{EventKind::Modified, "b"},
{EventKind::Modified, "c"}},
-  {}};
+  {},
+  // We have to ignore these as it's a race between the test process
+  // which is scanning the directory and kernel which is sending
+  // notification.
+  {{EventKind::Modified, "a"},
+   {EventKind::Modified, "b"},
+   {EventKind::Modified, "c"}}
+   };
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -332,6 +346,7 @@ TEST(DirectoryWatcherTest, ModifyFile) {
 
   VerifyingConsumer TestConsumer{
   {{EventKind::Modified, "a"}},
+  {{EventKind::Modified, "a"}},
   {{EventKind::Modified, "a"}}};
 
   auto DW = DirectoryWatcher::create(
@@ -361,7 +376,8 @@ TEST(DirectoryWatcherTest, DeleteFile) {
 
   VerifyingConsumer TestConsumer{
   {{EventKind::Modified, "a"}},
-  {{EventKind::Removed, "a"}}};
+  {{EventKind::Removed, "a"}},
+  {{EventKind::Modified, "a"}}};
 
   auto DW = DirectoryWatcher::create(
   fixture.TestWatchedDir,
@@ -414,44 +430,4 @@ TEST(DirectoryWatcherTest, InvalidatedWa
   } // DW is destructed here.
 
   checkEventualResultWithTimeout(TestConsumer);
-}
-
-TEST(DirectoryWatcherTest, ChangeMetadata) {
-  DirectoryWatcherTestFixture fixture;
-  fixture.addFile("a");
-
-  VerifyingConsumer TestConsumer{
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}},
-  // We don't expect any notification for file having access file changed.
-  {},
-  // Given the timing we are ok with receiving the duplicate event.
-  {{DirectoryWatcher::Event::EventKind::Modified, "a"}}};
-
-  auto DW = DirectoryWatcher::create(
-  fixture.TestWatchedDir,
-  [](llvm::ArrayRef Events,
-  bool IsInitial) {
-TestConsumer.consume(Events, IsInitial);
-  },
-  /*waitForInitialSync=*/true);
-
-  { // Change access and modification time of file a.
-Expected HopefullyTheFD = llvm::sys::fs::openNativeFileForWrite(
-fixture.getPathInWatched("a"), CD_OpenExisting, OF_None);
-if (!HopefullyTheFD) {
-  llvm::outs() << HopefullyTheFD.takeError();
-}
-
-const int FD = HopefullyTheFD.get();
-const TimePoint<> NewTimePt =
-std::chrono::system_clock::now() - std::chrono::minutes(1);
-#ifndef NDEBUG
-std::error_code setTimeRes =
-#endif
-llvm::sys::fs::setLastAccessAndModificationTime(FD, NewTimePt,
-NewTimePt);
-assert(!setTimeRes);
-  }
-
-  checkEventualResultWithTimeout(TestConsumer);
-}
+}
\ No newline at end of file


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


[PATCH] D64458: add -fthinlto-index= option to clang-cl

2019-07-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm too, since now this is just whitelisting a clang flag for clang-cl.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64458



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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-15 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209966.
quantum added a comment.

Fix duplicate end function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64537

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  lld/test/wasm/data-segments.ll
  lld/test/wasm/tls.ll
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/include/llvm/MC/MCSectionWasm.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/atomic-fence.ll
  llvm/test/CodeGen/WebAssembly/atomic-mem-consistency.ll
  llvm/test/CodeGen/WebAssembly/atomic-rmw.ll
  llvm/test/CodeGen/WebAssembly/i32-load-store-alignment.ll
  llvm/test/CodeGen/WebAssembly/i64-load-store-alignment.ll
  llvm/test/CodeGen/WebAssembly/load-ext-atomic.ll
  llvm/test/CodeGen/WebAssembly/offset-atomics.ll
  llvm/test/CodeGen/WebAssembly/store-trunc-atomic.ll
  llvm/test/CodeGen/WebAssembly/target-features-tls.ll
  llvm/test/CodeGen/WebAssembly/target-features.ll
  llvm/test/CodeGen/WebAssembly/tls.ll

Index: llvm/test/CodeGen/WebAssembly/tls.ll
===
--- llvm/test/CodeGen/WebAssembly/tls.ll
+++ llvm/test/CodeGen/WebAssembly/tls.ll
@@ -1,17 +1,82 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck --check-prefix=SINGLE %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+atomics,+bulk-memory | FileCheck %s --check-prefixes=CHECK,TLS
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+atomics,+bulk-memory -fast-isel | FileCheck %s --check-prefixes=CHECK,TLS
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+atomics,-bulk-memory | FileCheck %s --check-prefixes=CHECK,NO-TLS
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
+; CHECK-NEXT: .functype  address_of_tls () -> (i32)
 define i32 @address_of_tls() {
-  ; SINGLE: i32.const $push0=, tls
-  ; SINGLE-NEXT: return $pop0
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const tls
+  ; NO-TLS-NEXT: return
   ret i32 ptrtoint(i32* @tls to i32)
 }
 
-; SINGLE: .type	tls,@object
-; SINGLE-NEXT: .section	.bss.tls,"",@
-; SINGLE-NEXT: .p2align 2
-; SINGLE-NEXT: tls:
-; SINGLE-NEXT: .int32 0
-@tls = internal thread_local global i32 0
+; CHECK-LABEL: ptr_to_tls:
+; CHECK-NEXT: .functype ptr_to_tls () -> (i32)
+define i32* @ptr_to_tls() {
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const tls
+  ; NO-TLS-NEXT: return
+  ret i32* @tls
+}
+
+; CHECK-LABEL: tls_load:
+; CHECK-NEXT: .functype tls_load () -> (i32)
+define i32 @tls_load() {
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: i32.load 0
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const 0
+  ; NO-TLS-NEXT: i32.load tls
+  ; NO-TLS-NEXT: return
+  %tmp = load i32, i32* @tls, align 4
+  ret i32 %tmp
+}
+
+; CHECK-LABEL: tls_store:
+; CHECK-NEXT: .functype tls_store (i32) -> ()
+define void @tls_store(i32 %x) {
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: i32.store 0
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const 0
+  ; NO-TLS-NEXT: i32.store tls
+  ; NO-TLS-NEXT: return
+  store i32 %x, i32* @tls, align 4
+  ret void
+}
+
+; CHECK-LABEL: tls_size:
+; CHECK-NEXT: .functype tls_size () -> (i32)
+define i32 @tls_size() {
+; CHECK-NEXT: global.get __tls_size
+; CHECK-NEXT: return
+  %1 = call i32 @llvm.wasm.tls.size.i32()
+  ret i32 %1
+}
+
+; CHECK: .type tls,@object
+; TLS-NEXT: .section .tbss.tls,"",@
+; NO-TLS-NEXT: .section .bss.tls,"",@
+; CHECK-NEXT: .p2align 2
+; CHECK-NEXT: tls:
+; CHECK-NEXT: .int32 0
+@tls = internal thread_local(localexec) global i32 0
+
+declare i32 @llvm.wasm.tls.size.i32()
Index: llvm/test/CodeGen/WebAssembly/target-features.ll
===
--- llvm/test/CodeGen/WebAssembly/target-features.ll
+++ llvm/test/CodeGen/WebAssembly/target-features.ll
@@ -23,7 +23,7 @@
   ret void
 }
 
-attributes #0 = { "target-features"="+atomics" }
+attributes #0 = { "target-features"="+atomics,+bulk-memory" }
 

[PATCH] D64772: Allow for vendor prefixes in a list test

2019-07-15 Thread Nathan Lanza via Phabricator via cfe-commits
lanza created this revision.
Herald added subscribers: cfe-commits, fedor.sergeev.
Herald added a project: clang.

Preprocessor/init.c contains a line that explicitly checks for the
string

__VERSION__ "Clang{{.*}}

It's valid to have a toolchain configured to emit a vendor prefix
before the word Clang. e.g.

__VERSION__ "Vendor Clang{{.*}}


Repository:
  rC Clang

https://reviews.llvm.org/D64772

Files:
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8169,7 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "Clang{{.*}}
+// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -8169,7 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "Clang{{.*}}
+// SPARC:#define __VERSION__ "{{.*}}Clang{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64458: add -fthinlto-index= option to clang-cl

2019-07-15 Thread Bob Haarman via Phabricator via cfe-commits
inglorion updated this revision to Diff 209954.
inglorion added a comment.

Simplified after rebasing on top of r366127.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64458

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-thinlto-backend.c


Index: clang/test/Driver/cl-thinlto-backend.c
===
--- /dev/null
+++ clang/test/Driver/cl-thinlto-backend.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cl -c -flto=thin -Fo%t.obj %s
+// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
+
+// -fthinlto_index should be passed to cc1
+// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
+// RUN: %t.obj 2>&1 | FileCheck %s
+
+// CHECK: -fthinlto-index=
+// CHECK: "-x" "ir"
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1270,7 +1270,7 @@
"of 0 means the number of threads will be derived from "
"the number of CPUs detected)">;
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
-  Flags<[CC1Option]>, Group,
+  Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;


Index: clang/test/Driver/cl-thinlto-backend.c
===
--- /dev/null
+++ clang/test/Driver/cl-thinlto-backend.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cl -c -flto=thin -Fo%t.obj %s
+// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
+
+// -fthinlto_index should be passed to cc1
+// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
+// RUN: %t.obj 2>&1 | FileCheck %s
+
+// CHECK: -fthinlto-index=
+// CHECK: "-x" "ir"
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1270,7 +1270,7 @@
"of 0 means the number of threads will be derived from "
"the number of CPUs detected)">;
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
-  Flags<[CC1Option]>, Group,
+  Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, CoreOption]>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-07-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Also, shouldn't we add this to the release notes? In general, it's be around 
time to sort it out (might do that myself before the new branch).


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

https://reviews.llvm.org/D64274



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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-15 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum added inline comments.



Comment at: lld/test/wasm/data-segments.ll:7
 ; RUN: wasm-ld -no-gc-sections --no-entry --shared-memory --max-memory=131072 
%t.atomics.o -o %t.atomics.wasm
-; RUN: obj2yaml %t.atomics.wasm | FileCheck %s --check-prefix ACTIVE
+; RUN: obj2yaml %t.atomics.wasm | FileCheck %s --check-prefixes 
ACTIVE,ACTIVE-TLS
 

aheejin wrote:
> quantum wrote:
> > aheejin wrote:
> > > What is the difference between `ACTIVE` and `ACTIVE-TLS`? It looks we 
> > > don't have different build processes for them. And as what @sbc100 said, 
> > > can we exclude TLS from build?
> > `ACTIVE-TLS` is for builds with TLS enabled. Currently, we use 
> > `--shared-memory` to determine that, per @tlively's recommendation. The 
> > rationale is that we don't want even more flags that need to be passed in a 
> > proper threaded build.
> Then if we don't enable `--shared-memory`, we don't generate those globals? 
> Do we have a test for that?
Yes. In this file, the cases with `--check-prefix ACTIVE` will ensure that the 
fields are not generated.



Comment at: lld/wasm/Driver.cpp:543
+  "__wasm_init_tls", WASM_SYMBOL_VISIBILITY_HIDDEN,
+  make(I32ArgSignature, "__wasm_init_tls"));
+

tlively wrote:
> quantum wrote:
> > aheejin wrote:
> > > Does this TLS thing work when `Config->Shared == true`, i.e., do we 
> > > create TLS globals even when this is a library?
> > Since TLS is module specific (we can't allocate memory for other modules), 
> > we must in fact generate this symbol for every module. Shared library 
> > support will not be implemented in this diff, however.
> Until we do implement TLS for shared modules, would it make sense to omit 
> these globals and function from shared modules, since we can't use them in 
> that context anyway?
That would make sense for now.



Comment at: lld/wasm/Writer.cpp:638
+  if (Name.startswith(".tbss."))
+return ".tdata";
   return Name;

tlively wrote:
> quantum wrote:
> > tlively wrote:
> > > Does this mean we can't control whether .tdata or .tbss comes first? Is 
> > > that important for anything?
> > Yes, it does mean that. The only reason why .tbss is supposed to be 
> > separate is so that its memory can just be zeroed whereas .tdata has to 
> > have the bytes stored in the program image. Currently, we just explicitly 
> > store the zero bytes, so this won't be a problem.
> It would be really great if we could find a way to elide the .bss 0 bytes as 
> a code size optimization. Since we can't assume that the memory is already 
> zeroed the way we can with passive segments, perhaps we can use a memory.fill 
> instruction to zero the memory? Pursuing this in a follow-on CL should be 
> fine.
Yes, this is a good idea for a follow-on CL.



Comment at: lld/wasm/Writer.cpp:805
+  writeUleb128(os, 0, "num locals");
+  writeU8(os, WASM_OPCODE_END, "end function");
+}

tlively wrote:
> You could avoid duplicating these lines by making them unconditional.
Right.



Comment at: lld/wasm/Writer.cpp:905
+  if (config->sharedMemory)
+createInitTLSFunction();
+

tlively wrote:
> Can you remind me how the InitTLSFunction interacts with relocatable code? 
> I'm wondering if this should be called up in the condition with the other 
> synthetic functions.
I don't think it should. `__wasm_init_tls` initializes the TLS block for the 
current module only, so every shared library needs to have its own 
`__wasm_init_tls`.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp:193
+
+if (!Features[WebAssembly::FeatureBulkMemory])
   Stripped |= stripThreadLocals(M);

tlively wrote:
> I just realized that if we have atomics but not bulk memory and TLS is 
> stripped, then we will be in the awkward situation of both using atomics and 
> disallowing atomics because the module is not thread safe. I think the best 
> solution would be to go back and forcibly strip both atomics and TLS if 
> either of them would be stripped.
Done.



Comment at: llvm/test/CodeGen/WebAssembly/tls.ll:2
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt 
-wasm-disable-explicit-locals -mattr=+bulk-memory | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt 
-wasm-disable-explicit-locals -mattr=+bulk-memory -fast-isel | FileCheck %s
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"

tlively wrote:
> It would be good to check the negative case, too, i.e with bulk-memory 
> disabled.
Done.



Comment at: llvm/test/CodeGen/WebAssembly/tls.ll:6
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
 define i32 @address_of_tls() {

tlively wrote:
> Is `CHECK` still used as a prefix if it not listed in the invocation of 
> FileCheck?
Yes, 

[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-15 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209953.
quantum marked 16 inline comments as done.
quantum added a comment.

Deal with review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64537

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  lld/test/wasm/data-segments.ll
  lld/test/wasm/tls.ll
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/include/llvm/MC/MCSectionWasm.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/atomic-fence.ll
  llvm/test/CodeGen/WebAssembly/atomic-mem-consistency.ll
  llvm/test/CodeGen/WebAssembly/atomic-rmw.ll
  llvm/test/CodeGen/WebAssembly/i32-load-store-alignment.ll
  llvm/test/CodeGen/WebAssembly/i64-load-store-alignment.ll
  llvm/test/CodeGen/WebAssembly/load-ext-atomic.ll
  llvm/test/CodeGen/WebAssembly/offset-atomics.ll
  llvm/test/CodeGen/WebAssembly/store-trunc-atomic.ll
  llvm/test/CodeGen/WebAssembly/target-features-tls.ll
  llvm/test/CodeGen/WebAssembly/target-features.ll
  llvm/test/CodeGen/WebAssembly/tls.ll

Index: llvm/test/CodeGen/WebAssembly/tls.ll
===
--- llvm/test/CodeGen/WebAssembly/tls.ll
+++ llvm/test/CodeGen/WebAssembly/tls.ll
@@ -1,17 +1,82 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck --check-prefix=SINGLE %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+atomics,+bulk-memory | FileCheck %s --check-prefixes=CHECK,TLS
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+atomics,+bulk-memory -fast-isel | FileCheck %s --check-prefixes=CHECK,TLS
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+atomics,-bulk-memory | FileCheck %s --check-prefixes=CHECK,NO-TLS
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
+; CHECK-NEXT: .functype  address_of_tls () -> (i32)
 define i32 @address_of_tls() {
-  ; SINGLE: i32.const $push0=, tls
-  ; SINGLE-NEXT: return $pop0
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const tls
+  ; NO-TLS-NEXT: return
   ret i32 ptrtoint(i32* @tls to i32)
 }
 
-; SINGLE: .type	tls,@object
-; SINGLE-NEXT: .section	.bss.tls,"",@
-; SINGLE-NEXT: .p2align 2
-; SINGLE-NEXT: tls:
-; SINGLE-NEXT: .int32 0
-@tls = internal thread_local global i32 0
+; CHECK-LABEL: ptr_to_tls:
+; CHECK-NEXT: .functype ptr_to_tls () -> (i32)
+define i32* @ptr_to_tls() {
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const tls
+  ; NO-TLS-NEXT: return
+  ret i32* @tls
+}
+
+; CHECK-LABEL: tls_load:
+; CHECK-NEXT: .functype tls_load () -> (i32)
+define i32 @tls_load() {
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: i32.load 0
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const 0
+  ; NO-TLS-NEXT: i32.load tls
+  ; NO-TLS-NEXT: return
+  %tmp = load i32, i32* @tls, align 4
+  ret i32 %tmp
+}
+
+; CHECK-LABEL: tls_store:
+; CHECK-NEXT: .functype tls_store (i32) -> ()
+define void @tls_store(i32 %x) {
+  ; TLS-DAG: global.get __tls_base
+  ; TLS-DAG: i32.const tls
+  ; TLS-NEXT: i32.add
+  ; TLS-NEXT: i32.store 0
+  ; TLS-NEXT: return
+
+  ; NO-TLS-NEXT: i32.const 0
+  ; NO-TLS-NEXT: i32.store tls
+  ; NO-TLS-NEXT: return
+  store i32 %x, i32* @tls, align 4
+  ret void
+}
+
+; CHECK-LABEL: tls_size:
+; CHECK-NEXT: .functype tls_size () -> (i32)
+define i32 @tls_size() {
+; CHECK-NEXT: global.get __tls_size
+; CHECK-NEXT: return
+  %1 = call i32 @llvm.wasm.tls.size.i32()
+  ret i32 %1
+}
+
+; CHECK: .type tls,@object
+; TLS-NEXT: .section .tbss.tls,"",@
+; NO-TLS-NEXT: .section .bss.tls,"",@
+; CHECK-NEXT: .p2align 2
+; CHECK-NEXT: tls:
+; CHECK-NEXT: .int32 0
+@tls = internal thread_local(localexec) global i32 0
+
+declare i32 @llvm.wasm.tls.size.i32()
Index: llvm/test/CodeGen/WebAssembly/target-features.ll
===
--- llvm/test/CodeGen/WebAssembly/target-features.ll
+++ llvm/test/CodeGen/WebAssembly/target-features.ll
@@ -23,7 +23,7 @@
   ret void
 }
 
-attributes #0 = { "target-features"="+atomics" }
+attributes #0 = { 

[PATCH] D64610: [clang] allow -fthinlto-index= without -x ir

2019-07-15 Thread Bob Haarman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
inglorion marked an inline comment as done.
Closed by commit rL366127: [clang] allow -fthinlto-index= without -x ir 
(authored by inglorion, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64610?vs=209948=209952#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64610

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/thinlto_backend.c


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2119,6 +2119,12 @@
   Diag(clang::diag::warn_drv_treating_input_as_cxx)
   << getTypeName(OldTy) << getTypeName(Ty);
   }
+
+  // If running with -fthinlto-index=, extensions that normally 
identify
+  // native object files actually identify LLVM bitcode files.
+  if (Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ) &&
+  Ty == types::TY_Object)
+Ty = types::TY_LLVM_BC;
 }
 
 // -ObjC and -ObjC++ override the default language, but only for 
"source
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3647,8 +3647,7 @@
 
   if (const Arg *A = Args.getLastArg(options::OPT_fthinlto_index_EQ)) {
 if (!types::isLLVMIR(Input.getType()))
-  D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
-   << "-x ir";
+  D.Diag(diag::err_drv_arg_requires_bitcode_input) << A->getAsString(Args);
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -159,6 +159,8 @@
   "cannot read configuration file '%0'">;
 def err_drv_nested_config_file: Error<
   "option '--config' is not allowed inside configuration file">;
+def err_drv_arg_requires_bitcode_input: Error<
+  "option '%0' requires input to be LLVM bitcode">;
 
 def err_target_unsupported_arch
   : Error<"the target architecture '%0' is not supported by the target '%1'">;
Index: cfe/trunk/test/Driver/thinlto_backend.c
===
--- cfe/trunk/test/Driver/thinlto_backend.c
+++ cfe/trunk/test/Driver/thinlto_backend.c
@@ -2,8 +2,14 @@
 // RUN: llvm-lto -thinlto -o %t %t.o
 
 // -fthinlto_index should be passed to cc1
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### 
2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
+// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### \
+// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 // CHECK-THINLTOBE-ACTION: -fthinlto-index=
+// CHECK-THINLTOBE-ACTION-SAME: {{"?-x"? "?ir"?}}
+
+// Check that this also works without -x ir.
+// RUN: %clang -O2 -o %t1.o %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 
 // -save-temps should be passed to cc1
 // RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc 
-save-temps -### 2>&1 | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS 
-check-prefix=CHECK-SAVE-TEMPS-CWD
@@ -15,5 +21,6 @@
 // CHECK-SAVE-TEMPS-NOT: -emit-llvm-bc
 
 // Ensure clang driver gives the expected error for incorrect input type
-// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
-// CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only 
allowed with '-x ir'
+// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-WARNING
+// CHECK-WARNING: error: option '-fthinlto-index={{.*}}' requires input to be 
LLVM bitcode


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -2119,6 +2119,12 @@
   Diag(clang::diag::warn_drv_treating_input_as_cxx)
   << getTypeName(OldTy) << getTypeName(Ty);
   }
+
+  // If running with -fthinlto-index=, extensions that normally identify
+  // native object files actually identify LLVM bitcode files.
+  if (Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ) &&
+  Ty == types::TY_Object)
+

r366127 - [clang] allow -fthinlto-index= without -x ir

2019-07-15 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Jul 15 13:51:44 2019
New Revision: 366127

URL: http://llvm.org/viewvc/llvm-project?rev=366127=rev
Log:
[clang] allow -fthinlto-index= without -x ir

Summary:
Previously, passing -fthinlto-index= to clang required that bitcode
files be explicitly marked by -x ir. This change makes us detect files
with object file extensions as bitcode files when -fthinlto-index= is
present, so that explicitly marking them is no longer necessary.
Explicitly specifying -x ir is still accepted and continues to be part
of the test case to ensure we continue to support it.

Reviewers: tejohnson, rnk, pcc

Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/thinlto_backend.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=366127=366126=366127=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jul 15 13:51:44 
2019
@@ -159,6 +159,8 @@ def err_drv_cannot_read_config_file : Er
   "cannot read configuration file '%0'">;
 def err_drv_nested_config_file: Error<
   "option '--config' is not allowed inside configuration file">;
+def err_drv_arg_requires_bitcode_input: Error<
+  "option '%0' requires input to be LLVM bitcode">;
 
 def err_target_unsupported_arch
   : Error<"the target architecture '%0' is not supported by the target '%1'">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=366127=366126=366127=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jul 15 13:51:44 2019
@@ -2119,6 +2119,12 @@ void Driver::BuildInputs(const ToolChain
   Diag(clang::diag::warn_drv_treating_input_as_cxx)
   << getTypeName(OldTy) << getTypeName(Ty);
   }
+
+  // If running with -fthinlto-index=, extensions that normally 
identify
+  // native object files actually identify LLVM bitcode files.
+  if (Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ) &&
+  Ty == types::TY_Object)
+Ty = types::TY_LLVM_BC;
 }
 
 // -ObjC and -ObjC++ override the default language, but only for 
"source

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=366127=366126=366127=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Jul 15 13:51:44 2019
@@ -3647,8 +3647,7 @@ void Clang::ConstructJob(Compilation ,
 
   if (const Arg *A = Args.getLastArg(options::OPT_fthinlto_index_EQ)) {
 if (!types::isLLVMIR(Input.getType()))
-  D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
-   << "-x ir";
+  D.Diag(diag::err_drv_arg_requires_bitcode_input) << A->getAsString(Args);
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 

Modified: cfe/trunk/test/Driver/thinlto_backend.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/thinlto_backend.c?rev=366127=366126=366127=diff
==
--- cfe/trunk/test/Driver/thinlto_backend.c (original)
+++ cfe/trunk/test/Driver/thinlto_backend.c Mon Jul 15 13:51:44 2019
@@ -2,8 +2,14 @@
 // RUN: llvm-lto -thinlto -o %t %t.o
 
 // -fthinlto_index should be passed to cc1
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### 
2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
+// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### \
+// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 // CHECK-THINLTOBE-ACTION: -fthinlto-index=
+// CHECK-THINLTOBE-ACTION-SAME: {{"?-x"? "?ir"?}}
+
+// Check that this also works without -x ir.
+// RUN: %clang -O2 -o %t1.o %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 
 // -save-temps should be passed to cc1
 // RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc 
-save-temps -### 2>&1 | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS 
-check-prefix=CHECK-SAVE-TEMPS-CWD
@@ -15,5 +21,6 @@
 // CHECK-SAVE-TEMPS-NOT: -emit-llvm-bc
 
 // Ensure clang driver gives the expected error for incorrect input type
-// 

[PATCH] D64610: [clang] allow -fthinlto-index= without -x ir

2019-07-15 Thread Bob Haarman via Phabricator via cfe-commits
inglorion updated this revision to Diff 209948.
inglorion added a comment.

Fix typo pointed out by MaskRay (thanks!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64610

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/thinlto_backend.c


Index: clang/test/Driver/thinlto_backend.c
===
--- clang/test/Driver/thinlto_backend.c
+++ clang/test/Driver/thinlto_backend.c
@@ -2,8 +2,14 @@
 // RUN: llvm-lto -thinlto -o %t %t.o
 
 // -fthinlto_index should be passed to cc1
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### 
2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
+// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### \
+// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 // CHECK-THINLTOBE-ACTION: -fthinlto-index=
+// CHECK-THINLTOBE-ACTION-SAME: {{"?-x"? "?ir"?}}
+
+// Check that this also works without -x ir.
+// RUN: %clang -O2 -o %t1.o %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 
 // -save-temps should be passed to cc1
 // RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc 
-save-temps -### 2>&1 | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS 
-check-prefix=CHECK-SAVE-TEMPS-CWD
@@ -15,5 +21,6 @@
 // CHECK-SAVE-TEMPS-NOT: -emit-llvm-bc
 
 // Ensure clang driver gives the expected error for incorrect input type
-// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
-// CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only 
allowed with '-x ir'
+// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-WARNING
+// CHECK-WARNING: error: option '-fthinlto-index={{.*}}' requires input to be 
LLVM bitcode
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3647,8 +3647,7 @@
 
   if (const Arg *A = Args.getLastArg(options::OPT_fthinlto_index_EQ)) {
 if (!types::isLLVMIR(Input.getType()))
-  D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
-   << "-x ir";
+  D.Diag(diag::err_drv_arg_requires_bitcode_input) << A->getAsString(Args);
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2119,6 +2119,12 @@
   Diag(clang::diag::warn_drv_treating_input_as_cxx)
   << getTypeName(OldTy) << getTypeName(Ty);
   }
+
+  // If running with -fthinlto-index=, extensions that normally 
identify
+  // native object files actually identify LLVM bitcode files.
+  if (Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ) &&
+  Ty == types::TY_Object)
+Ty = types::TY_LLVM_BC;
 }
 
 // -ObjC and -ObjC++ override the default language, but only for 
"source
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -159,6 +159,8 @@
   "cannot read configuration file '%0'">;
 def err_drv_nested_config_file: Error<
   "option '--config' is not allowed inside configuration file">;
+def err_drv_arg_requires_bitcode_input: Error<
+  "option '%0' requires input to be LLVM bitcode">;
 
 def err_target_unsupported_arch
   : Error<"the target architecture '%0' is not supported by the target '%1'">;


Index: clang/test/Driver/thinlto_backend.c
===
--- clang/test/Driver/thinlto_backend.c
+++ clang/test/Driver/thinlto_backend.c
@@ -2,8 +2,14 @@
 // RUN: llvm-lto -thinlto -o %t %t.o
 
 // -fthinlto_index should be passed to cc1
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
+// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### \
+// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 // CHECK-THINLTOBE-ACTION: -fthinlto-index=
+// CHECK-THINLTOBE-ACTION-SAME: {{"?-x"? "?ir"?}}
+
+// Check that this also works without -x ir.
+// RUN: %clang -O2 -o %t1.o %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 
 // -save-temps should be passed to cc1
 // RUN: %clang 

[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-07-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

This LGTM now but I will wait for @teemperor to take a look at it.




Comment at: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp:620
 
 if (predicate(decl->getKind())) {
   if (log) {

I think a comment on the `predicate` would be helpful as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333



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


[PATCH] D62525: [Analyzer] Add new visitor to the iterator checkers

2019-07-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1099
 reportOutOfRangeBug("Iterator decremented ahead of its valid range.", LHS,
-C, N);
+C, N, Pos, false);
   }

`/*PastTheEnd=*/ false`



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:1277-1292
+State = setContainerData(State, ContReg, CData->newEnd(OldEndSym));
   } else {
 State = setContainerData(State, ContReg,
- ContainerData::fromEnd(NewEndSym));
+ ContainerData::fromEnd(OldEndSym));
   }
+  // Then generate and assign a new "end" symbol for the old container.
+  auto NewEndSym =

I'm confused, are these changes related to this patch? It doesn't seem to be.


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

https://reviews.llvm.org/D62525



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


[PATCH] D61879: WIP: Prototype of DSE optimizations for -ftrivial-auto-var-init

2019-07-15 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 209942.
vitalybuka added a comment.

Rebase only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61879

Files:
  clang/test/CodeGenCXX/union-tbaa2.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Transforms/Scalar.h
  llvm/include/llvm/Transforms/Scalar/DeadStoreEliminationExp.h
  llvm/lib/Analysis/Analysis.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Scalar/CMakeLists.txt
  llvm/lib/Transforms/Scalar/DeadStoreEliminationExp.cpp
  llvm/lib/Transforms/Scalar/DeadStoreEliminationExpGlobal.cpp
  llvm/lib/Transforms/Scalar/DeadStoreEliminationExpGlobal.h
  llvm/lib/Transforms/Scalar/DeadStoreEliminationExpGlobalArgInfoGen.h
  llvm/lib/Transforms/Scalar/DeadStoreEliminationExpGlobalGUIDListGen.h
  llvm/lib/Transforms/Scalar/Scalar.cpp
  llvm/test/ObjectYAML/MachO/DWARF-debug_line.yaml
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/Other/pass-pipelines.ll
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/coro-split-01.ll
  llvm/test/Transforms/Coroutines/ex0.ll
  llvm/test/Transforms/Coroutines/ex1.ll
  llvm/test/Transforms/Coroutines/ex2.ll
  llvm/test/Transforms/Coroutines/ex3.ll
  llvm/test/Transforms/Coroutines/ex4.ll
  llvm/test/Transforms/Coroutines/ex5.ll
  llvm/test/Transforms/Coroutines/phi-coro-end.ll
  llvm/test/Transforms/Coroutines/restart-trigger.ll
  llvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Transforms/Scalar/BUILD.gn
@@ -19,6 +19,8 @@
 "CorrelatedValuePropagation.cpp",
 "DCE.cpp",
 "DeadStoreElimination.cpp",
+"DeadStoreEliminationExp.cpp",
+"DeadStoreEliminationExpGlobal.cpp",
 "DivRemPairs.cpp",
 "EarlyCSE.cpp",
 "FlattenCFGPass.cpp",
Index: llvm/test/Transforms/Coroutines/restart-trigger.ll
===
--- llvm/test/Transforms/Coroutines/restart-trigger.ll
+++ llvm/test/Transforms/Coroutines/restart-trigger.ll
@@ -7,6 +7,8 @@
 ; CHECK:  CoroSplit: Processing coroutine 'f' state: 0
 ; CHECK-NEXT: CoroSplit: Processing coroutine 'f' state: 1
 
+; REQUIRES: abcd
+
 define void @f() {
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
   %size = call i32 @llvm.coro.size.i32()
Index: llvm/test/Transforms/Coroutines/phi-coro-end.ll
===
--- llvm/test/Transforms/Coroutines/phi-coro-end.ll
+++ llvm/test/Transforms/Coroutines/phi-coro-end.ll
@@ -1,6 +1,8 @@
 ; Verify that we correctly handle suspend when the coro.end block contains phi
 ; RUN: opt < %s -O2 -enable-coroutines -S | FileCheck %s
 
+; REQUIRES: abcd
+
 define i8* @f(i32 %n) {
 entry:
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
Index: llvm/test/Transforms/Coroutines/ex5.ll
===
--- llvm/test/Transforms/Coroutines/ex5.ll
+++ llvm/test/Transforms/Coroutines/ex5.ll
@@ -1,6 +1,8 @@
 ; Fifth example from Doc/Coroutines.rst (final suspend)
 ; RUN: opt < %s -O2 -enable-coroutines -S | FileCheck %s
 
+; REQUIRES: abcd
+
 define i8* @f(i32 %n) {
 entry:
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
Index: llvm/test/Transforms/Coroutines/ex4.ll
===
--- llvm/test/Transforms/Coroutines/ex4.ll
+++ llvm/test/Transforms/Coroutines/ex4.ll
@@ -1,6 +1,8 @@
 ; Fourth example from Doc/Coroutines.rst (coroutine promise)
 ; RUN: opt < %s -O2 -enable-coroutines -S | FileCheck %s
 
+; REQUIRES: abcd
+
 define i8* @f(i32 %n) {
 entry:
   %promise = alloca i32
Index: llvm/test/Transforms/Coroutines/ex3.ll
===
--- llvm/test/Transforms/Coroutines/ex3.ll
+++ llvm/test/Transforms/Coroutines/ex3.ll
@@ -1,6 +1,8 @@
 ; Third example from Doc/Coroutines.rst (two suspend points)
 ; RUN: opt < %s -O2 -enable-coroutines -S | FileCheck %s
 
+; REQUIRES: abcd
+
 define i8* @f(i32 %n) {
 entry:
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
Index: llvm/test/Transforms/Coroutines/ex2.ll
===
--- llvm/test/Transforms/Coroutines/ex2.ll
+++ llvm/test/Transforms/Coroutines/ex2.ll
@@ -1,6 +1,8 @@
 ; Second example from Doc/Coroutines.rst (custom alloc and 

[PATCH] D63279: [Analyzer] Unroll for-loops where the upper boundary is a variable with know value

2019-07-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added inline comments.
This revision now requires changes to proceed.



Comment at: lib/StaticAnalyzer/Core/LoopUnrolling.cpp:214-216
+  const Expr *BoundExpr = CondOp->getLHS()->IgnoreParenImpCasts();
+  if (BoundExpr == Matches[0].getNodeAs("boundVarOperand"))
+BoundExpr = CondOp->getRHS()->IgnoreParenImpCasts();

NoQ wrote:
> Szelethus wrote:
> > Alright, I stood on top of this for longer than I'd like to admit, what's 
> > happening here? Like, `CondExpr`, with the given testfile, should be `i < 
> > n`, right? Then `BoundExpr` is supposed to be `i`, and if that is equal to 
> > `Matches[0].getNodeAs("boundVarOperand")` (which I guess is supposed 
> > to `n`), which I'm not sure how it could ever happen, we assign the RHS of 
> > the assignment to `BoundExpr`?
> > 
> > What does this do? Why is it needed? Which 2 test cases cover these lines?
> I think this is about `i < n` vs. `n > i`.
If that is the case, I'd be more comfortable seeing a test for it (there 
doesn't seem to be any) before landing this.



Comment at: lib/StaticAnalyzer/Core/LoopUnrolling.cpp:221-230
+  if (BoundNumVal.isUnknown()) {
+if (const auto *BoundDeclRefExpr = dyn_cast(BoundExpr)) {
+  // FIXME: Add other declarations such as Objective-C fields
+  if (const auto *BoundVarDecl =
+  dyn_cast(BoundDeclRefExpr->getDecl())) {
+BoundNumVal = State->getSVal(
+State->getLValue(BoundVarDecl, Pred->getLocationContext()));

NoQ wrote:
> Szelethus wrote:
> > I don't see obvious test case for which `BoundNumVal` would be unknown, am 
> > I wrong?
> We need an `ExprInspection` method that reliably produces an `UnknownVal`, 
> because there's no truly valid reason to produce `UnknownVal` apart from 
> "something is unimplemented".
For this too.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63279



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


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I don't see obvious red flags strictly regarding the analyzer!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-07-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:562
+  HelpText<"Check virtual function calls during construction/destruction">,
   Documentation;
 

Szelethus wrote:
> Szelethus wrote:
> > `Dependencies<[PureVirtualCallChecker]>,`
> //Ackchyually//, we should have this the other way around for backward 
> compatibility reasons :^) Sorry, oversight on my end.
Forgot this inline here, woops.


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

https://reviews.llvm.org/D64274



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


[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-07-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D64274#1574086 , @NoQ wrote:

> Hmm, wait, i don't really break backwards compatibility. Fridays...


//Ackchyually//,  it doesn't per se break anything, but will result in 
CodeChecker no longer enabling `optin.cplusplus.VirtualCall` :^) Sorry, 
oversight on my end. Observe the following monster of a clang invocation by

  CodeChecker check -b "g++ -c 
clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp" --verbose 
debug_analyzer

(I put arrows at the important lines, this is with your patch applied)

  clang --analyze -Qunused-arguments --analyzer-no-default-checks
-Xclang analyzer-opt-analyze-headers
-Xclang analyzer-output=plist-multi-file -o 
/tmp/tmpxmqqTL/cxx-uninitialized-object-ptr-ref.cpp_e4f3d9e72b29ea0cba420ce947ee.plist
-Xclang analyzer-config -Xclang expand-macros=true
-Xclang analyzer-checker=core.CallAndMessage
-Xclang analyzer-checker=core.DivideZero
-Xclang analyzer-checker=core.DynamicTypePropagation
-Xclang analyzer-checker=core.NonNullParamChecker
-Xclang analyzer-checker=core.NullDereference
-Xclang analyzer-checker=core.StackAddressEscape
-Xclang analyzer-checker=core.UndefinedBinaryOperatorResult
-Xclang analyzer-checker=core.VLASize
-Xclang analyzer-checker=core.uninitialized.ArraySubscript
-Xclang analyzer-checker=core.uninitialized.Assign
-Xclang analyzer-checker=core.uninitialized.Branch
-Xclang analyzer-checker=core.uninitialized.CapturedBlockVariable
-Xclang analyzer-checker=core.uninitialized.UndefReturn
-Xclang analyzer-checker=cplusplus.InnerPointer
-Xclang analyzer-checker=cplusplus.Move
-Xclang analyzer-checker=cplusplus.NewDelete
-Xclang analyzer-checker=cplusplus.NewDeleteLeaks
-Xclang analyzer-disable-checker=cplusplus.PureVirtualCall 
<-- problem right here
-Xclang analyzer-checker=deadcode.DeadStores
-Xclang analyzer-checker=nullability.NullPassedToNonnull
-Xclang analyzer-checker=nullability.NullReturnedFromNonnull
-Xclang analyzer-disable-checker=nullability.NullableDereferenced
-Xclang analyzer-disable-checker=nullability.NullablePassedToNonnull
-Xclang analyzer-disable-checker=nullability.NullableReturnedFromNonnull
-Xclang analyzer-disable-checker=optin.cplusplus.UninitializedObject
-Xclang analyzer-checker=optin.cplusplus.VirtualCall 
<-- problem right here
-Xclang analyzer-disable-checker=optin.mpi.MPI-Checker
-Xclang analyzer-disable-checker=optin.osx.OSObjectCStyleCast
-Xclang 
analyzer-disable-checker=optin.osx.cocoa.localizability.EmptyLocalizationContextChecker
-Xclang 
analyzer-disable-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker
-Xclang analyzer-disable-checker=optin.performance.GCDAntipattern
-Xclang analyzer-disable-checker=optin.performance.Padding
-Xclang analyzer-checker=optin.portability.UnixAPI
-Xclang analyzer-disable-checker=osx.API
-Xclang analyzer-disable-checker=osx.MIG
-Xclang analyzer-disable-checker=osx.NumberObjectConversion
-Xclang analyzer-disable-checker=osx.OSObjectRetainCount
-Xclang analyzer-disable-checker=osx.ObjCProperty
-Xclang analyzer-disable-checker=osx.SecKeychainAPI
-Xclang analyzer-disable-checker=osx.cocoa.AtSync
-Xclang analyzer-disable-checker=osx.cocoa.AutoreleaseWrite
-Xclang analyzer-disable-checker=osx.cocoa.ClassRelease
-Xclang analyzer-disable-checker=osx.cocoa.Dealloc
-Xclang analyzer-disable-checker=osx.cocoa.IncompatibleMethodTypes
-Xclang analyzer-disable-checker=osx.cocoa.Loops
-Xclang analyzer-disable-checker=osx.cocoa.MissingSuperCall
-Xclang analyzer-disable-checker=osx.cocoa.NSAutoreleasePool
-Xclang analyzer-disable-checker=osx.cocoa.NSError
-Xclang analyzer-disable-checker=osx.cocoa.NilArg
-Xclang analyzer-disable-checker=osx.cocoa.NonNilReturnValue
-Xclang analyzer-disable-checker=osx.cocoa.ObjCGenerics
-Xclang analyzer-disable-checker=osx.cocoa.RetainCount
-Xclang analyzer-disable-checker=osx.cocoa.RunLoopAutoreleaseLeak
-Xclang analyzer-disable-checker=osx.cocoa.SelfInit
-Xclang analyzer-disable-checker=osx.cocoa.SuperDealloc
-Xclang analyzer-disable-checker=osx.cocoa.UnusedIvars
-Xclang analyzer-disable-checker=osx.cocoa.VariadicMethodTypes
-Xclang analyzer-disable-checker=osx.coreFoundation.CFError
-Xclang analyzer-disable-checker=osx.coreFoundation.CFNumber
-Xclang analyzer-disable-checker=osx.coreFoundation.CFRetainRelease
-Xclang analyzer-disable-checker=osx.coreFoundation.containers.OutOfBounds
-Xclang 
analyzer-disable-checker=osx.coreFoundation.containers.PointerSizedValues
-Xclang analyzer-checker=security.FloatLoopCounter
-Xclang 
analyzer-disable-checker=security.insecureAPI.DeprecatedOrUnsafeBufferHandling
-Xclang 

[PATCH] D64169: ARM MTE stack sanitizer.

2019-07-15 Thread Evgenii Stepanov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366123: ARM MTE stack sanitizer. (authored by eugenis, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D64169?vs=209578=209936#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64169

Files:
  cfe/trunk/include/clang/Basic/Features.def
  cfe/trunk/include/clang/Basic/Sanitizers.def
  cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
  cfe/trunk/lib/Driver/SanitizerArgs.cpp
  cfe/trunk/lib/Driver/ToolChains/Linux.cpp
  cfe/trunk/test/CodeGen/memtag-attr.cpp
  cfe/trunk/test/Driver/fsanitize.c
  cfe/trunk/test/Lexer/has_feature_memtag_sanitizer.cpp
  cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp
  llvm/trunk/docs/BitCodeFormat.rst
  llvm/trunk/docs/LangRef.rst
  llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/trunk/include/llvm/IR/Attributes.td
  llvm/trunk/lib/AsmParser/LLLexer.cpp
  llvm/trunk/lib/AsmParser/LLParser.cpp
  llvm/trunk/lib/AsmParser/LLToken.h
  llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/trunk/lib/IR/Attributes.cpp
  llvm/trunk/lib/IR/Verifier.cpp
  llvm/trunk/lib/Transforms/IPO/ForceFunctionAttrs.cpp
  llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/trunk/test/Bitcode/attributes.ll
  llvm/trunk/test/Transforms/Inline/attributes.ll
  llvm/trunk/utils/emacs/llvm-mode.el

Index: llvm/trunk/lib/AsmParser/LLLexer.cpp
===
--- llvm/trunk/lib/AsmParser/LLLexer.cpp
+++ llvm/trunk/lib/AsmParser/LLLexer.cpp
@@ -679,6 +679,7 @@
   KEYWORD(shadowcallstack);
   KEYWORD(sanitize_address);
   KEYWORD(sanitize_hwaddress);
+  KEYWORD(sanitize_memtag);
   KEYWORD(sanitize_thread);
   KEYWORD(sanitize_memory);
   KEYWORD(speculative_load_hardening);
Index: llvm/trunk/lib/AsmParser/LLParser.cpp
===
--- llvm/trunk/lib/AsmParser/LLParser.cpp
+++ llvm/trunk/lib/AsmParser/LLParser.cpp
@@ -1311,6 +1311,8 @@
   B.addAttribute(Attribute::SanitizeAddress); break;
 case lltok::kw_sanitize_hwaddress:
   B.addAttribute(Attribute::SanitizeHWAddress); break;
+case lltok::kw_sanitize_memtag:
+  B.addAttribute(Attribute::SanitizeMemTag); break;
 case lltok::kw_sanitize_thread:
   B.addAttribute(Attribute::SanitizeThread); break;
 case lltok::kw_sanitize_memory:
@@ -1668,6 +1670,7 @@
 case lltok::kw_returns_twice:
 case lltok::kw_sanitize_address:
 case lltok::kw_sanitize_hwaddress:
+case lltok::kw_sanitize_memtag:
 case lltok::kw_sanitize_memory:
 case lltok::kw_sanitize_thread:
 case lltok::kw_speculative_load_hardening:
@@ -1766,6 +1769,7 @@
 case lltok::kw_returns_twice:
 case lltok::kw_sanitize_address:
 case lltok::kw_sanitize_hwaddress:
+case lltok::kw_sanitize_memtag:
 case lltok::kw_sanitize_memory:
 case lltok::kw_sanitize_thread:
 case lltok::kw_speculative_load_hardening:
Index: llvm/trunk/lib/AsmParser/LLToken.h
===
--- llvm/trunk/lib/AsmParser/LLToken.h
+++ llvm/trunk/lib/AsmParser/LLToken.h
@@ -176,6 +176,7 @@
   kw_argmemonly,
   kw_sanitize_address,
   kw_sanitize_hwaddress,
+  kw_sanitize_memtag,
   kw_builtin,
   kw_byval,
   kw_inalloca,
Index: llvm/trunk/lib/IR/Attributes.cpp
===
--- llvm/trunk/lib/IR/Attributes.cpp
+++ llvm/trunk/lib/IR/Attributes.cpp
@@ -283,6 +283,8 @@
 return "sanitize_address";
   if (hasAttribute(Attribute::SanitizeHWAddress))
 return "sanitize_hwaddress";
+  if (hasAttribute(Attribute::SanitizeMemTag))
+return "sanitize_memtag";
   if (hasAttribute(Attribute::AlwaysInline))
 return "alwaysinline";
   if (hasAttribute(Attribute::ArgMemOnly))
Index: llvm/trunk/lib/IR/Verifier.cpp
===
--- llvm/trunk/lib/IR/Verifier.cpp
+++ llvm/trunk/lib/IR/Verifier.cpp
@@ -1516,6 +1516,7 @@
   case Attribute::ReturnsTwice:
   case Attribute::SanitizeAddress:
   case Attribute::SanitizeHWAddress:
+  case Attribute::SanitizeMemTag:
   case Attribute::SanitizeThread:
   case Attribute::SanitizeMemory:
   case Attribute::MinSize:
Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1296,6 +1296,9 @@
   case Attribute::AllocSize:
 llvm_unreachable("allocsize not supported in raw format");
 break;
+  case Attribute::SanitizeMemTag:
+llvm_unreachable("sanitize_memtag attribute not supported in raw format");
+break;
   }
   

r366123 - ARM MTE stack sanitizer.

2019-07-15 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Mon Jul 15 13:02:23 2019
New Revision: 366123

URL: http://llvm.org/viewvc/llvm-project?rev=366123=rev
Log:
ARM MTE stack sanitizer.

Add "memtag" sanitizer that detects and mitigates stack memory issues
using armv8.5 Memory Tagging Extension.

It is similar in principle to HWASan, which is a software implementation
of the same idea, but there are enough differencies to warrant a new
sanitizer type IMHO. It is also expected to have very different
performance properties.

The new sanitizer does not have a runtime library (it may grow one
later, along with a "debugging" mode). Similar to SafeStack and
StackProtector, the instrumentation pass (in a follow up change) will be
inserted in all cases, but will only affect functions marked with the
new sanitize_memtag attribute.

Reviewers: pcc, hctim, vitalybuka, ostannard

Subscribers: srhines, mehdi_amini, javed.absar, kristof.beyls, hiraditya, 
cryptoad, steven_wu, dexonsmith, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added:
cfe/trunk/test/CodeGen/memtag-attr.cpp
cfe/trunk/test/Lexer/has_feature_memtag_sanitizer.cpp
Modified:
cfe/trunk/include/clang/Basic/Features.def
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp

Modified: cfe/trunk/include/clang/Basic/Features.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Features.def?rev=366123=366122=366123=diff
==
--- cfe/trunk/include/clang/Basic/Features.def (original)
+++ cfe/trunk/include/clang/Basic/Features.def Mon Jul 15 13:02:23 2019
@@ -42,6 +42,7 @@ FEATURE(address_sanitizer,
 FEATURE(hwaddress_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
SanitizerKind::KernelHWAddress))
+FEATURE(memtag_sanitizer, LangOpts.Sanitize.has(SanitizerKind::MemTag))
 FEATURE(xray_instrument, LangOpts.XRayInstrument)
 FEATURE(undefined_behavior_sanitizer,
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=366123=366122=366123=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Mon Jul 15 13:02:23 2019
@@ -55,6 +55,9 @@ SANITIZER("hwaddress", HWAddress)
 // Kernel Hardware-assisted AddressSanitizer (KHWASan)
 SANITIZER("kernel-hwaddress", KernelHWAddress)
 
+// A variant of AddressSanitizer using AArch64 MTE extension.
+SANITIZER("memtag", MemTag)
+
 // MemorySanitizer
 SANITIZER("memory", Memory)
 

Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=366123=366122=366123=diff
==
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Mon Jul 15 13:02:23 2019
@@ -369,6 +369,10 @@ llvm::Function *CodeGenModule::CreateGlo
   !isInSanitizerBlacklist(SanitizerKind::KernelHWAddress, Fn, Loc))
 Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
 
+  if (getLangOpts().Sanitize.has(SanitizerKind::MemTag) &&
+  !isInSanitizerBlacklist(SanitizerKind::MemTag, Fn, Loc))
+Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
+
   if (getLangOpts().Sanitize.has(SanitizerKind::Thread) &&
   !isInSanitizerBlacklist(SanitizerKind::Thread, Fn, Loc))
 Fn->addFnAttr(llvm::Attribute::SanitizeThread);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=366123=366122=366123=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Jul 15 13:02:23 2019
@@ -696,6 +696,8 @@ void CodeGenFunction::StartFunction(Glob
 Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
   if (SanOpts.hasOneOf(SanitizerKind::HWAddress | 
SanitizerKind::KernelHWAddress))
 Fn->addFnAttr(llvm::Attribute::SanitizeHWAddress);
+  if (SanOpts.has(SanitizerKind::MemTag))
+Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
   if (SanOpts.has(SanitizerKind::Thread))
 Fn->addFnAttr(llvm::Attribute::SanitizeThread);
   if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 

[PATCH] D64765: [OPENMP]Add support for analysis of firstprivate variables.

2019-07-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked 2 inline comments as done.
ABataev added inline comments.



Comment at: lib/Analysis/CFG.cpp:4749
   // bidirectional, so we need to create temp vector.
-  for (Stmt *S : llvm::reverse(llvm::to_vector<8>(
-   OMPExecutableDirective::used_clauses_children(D->clauses() {
+  SmallVector Used(
+  OMPExecutableDirective::used_clauses_children(D->clauses()));

Had to create temp vector explicitly as the implicit one causes use-after-free 
effect.



Comment at: test/Analysis/cfg-openmp.cpp:188
 // CHECK-NEXT:  [[#TARGET+6]]: [B1.[[#TARGET+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
-// CHECK-NEXT:  [[#TARGET+7]]: #pragma omp target depend(in : argc) if(cond)
+// CHECK-NEXT:  [[#TARGET+7]]: fp
+// CHECK-NEXT:  [[#TARGET+8]]: argc

In `task` and `target` regions some of the variables might be implicit 
firstprivate just like in this case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64765



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


[PATCH] D61479: Finish "Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO"

2019-07-15 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM, but please update the summary:

  An alternative would be to disallow -fsanitize=function ...


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

https://reviews.llvm.org/D61479



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


[PATCH] D64765: [OPENMP]Add support for analysis of firstprivate variables.

2019-07-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: NoQ.
Herald added subscribers: jdoerfert, guansong.
Herald added a project: clang.

Firstprivate variables are the variables, for which the private copies
must be created in the OpenMP regions and must be initialized with the
original values. Thus, we must report if the uninitialized variable is
used as firstprivate.


Repository:
  rC Clang

https://reviews.llvm.org/D64765

Files:
  include/clang/AST/OpenMPClause.h
  lib/Analysis/CFG.cpp
  test/Analysis/cfg-openmp.cpp
  test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
  test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
  test/OpenMP/parallel_firstprivate_messages.cpp
  test/OpenMP/parallel_for_firstprivate_messages.cpp
  test/OpenMP/parallel_for_simd_firstprivate_messages.cpp
  test/OpenMP/parallel_sections_firstprivate_messages.cpp
  test/OpenMP/target_firstprivate_messages.cpp
  test/OpenMP/target_parallel_firstprivate_messages.cpp
  test/OpenMP/target_parallel_for_firstprivate_messages.cpp
  test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
  test/OpenMP/target_simd_firstprivate_messages.cpp
  test/OpenMP/target_teams_distribute_firstprivate_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_firstprivate_messages.cpp
  
test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_messages.cpp
  test/OpenMP/target_teams_distribute_simd_firstprivate_messages.cpp
  test/OpenMP/target_teams_firstprivate_messages.cpp
  test/OpenMP/task_firstprivate_messages.cpp
  test/OpenMP/taskloop_firstprivate_messages.cpp
  test/OpenMP/taskloop_simd_firstprivate_messages.cpp
  test/OpenMP/teams_distribute_firstprivate_messages.cpp
  test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
  test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
  test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
  test/OpenMP/teams_firstprivate_messages.cpp

Index: test/OpenMP/teams_firstprivate_messages.cpp
===
--- test/OpenMP/teams_firstprivate_messages.cpp
+++ test/OpenMP/teams_firstprivate_messages.cpp
@@ -10,6 +10,14 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp target
+#pragma omp teams firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
===
--- test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
+++ test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
@@ -10,6 +10,14 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
===
--- test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
+++ test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
@@ -10,6 +10,14 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute parallel for simd firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
===
--- test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
+++ test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
@@ -10,6 +10,14 @@
   return argc;
 }
 
+void xxx(int argc) {
+  int fp; // expected-note {{initialize the variable 'fp' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute parallel for firstprivate(fp) // expected-warning {{variable 'fp' is uninitialized when used here}}
+  for (int i = 0; i < 10; ++i)
+;
+}
+
 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {
Index: test/OpenMP/teams_distribute_firstprivate_messages.cpp
===
--- 

[PATCH] D64695: [clang-format] Added new style rule: SortNetBSDIncludes

2019-07-15 Thread Manikishan Ghantasala via Phabricator via cfe-commits
Manikishan added a comment.

In D64695#1586157 , @MyDeveloperDay 
wrote:

> I appreciate what you've done to make this patch less duplicated code..but 
> now you've almost got to the point where being able to control it all via 
> configuration.
>
> I'm with @rdwampler I think you should be able to extend the include 
> categories...and then this becomes a very powerful capability. There are many 
> people who use clang-format for a "non" standard style source trees, and they 
> might like to use such a capability themselves without having to inherit from 
> NetBSD type.
>
> I agree it will be complex, but that is a good justification for adding hard 
> coded a NetBSD style.


Thanks, I will try to implement it as suggested. 
This is my proposal algorithm:

1. Modify Include.Categories by adding one more field for grouping priority.
2. Add support for this third field in sortIncludes.

Am I missing anything?


Repository:
  rC Clang

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

https://reviews.llvm.org/D64695



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


[PATCH] D61479: Finish "Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO"

2019-07-15 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Looks reasonable to me -- mind waiting for another +1 on this to be safe? 
@eugenis, any thoughts?


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

https://reviews.llvm.org/D61479



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


[PATCH] D64695: [clang-format] Added new style rule: SortNetBSDIncludes

2019-07-15 Thread Manikishan Ghantasala via Phabricator via cfe-commits
Manikishan updated this revision to Diff 209933.

Repository:
  rC Clang

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

https://reviews.llvm.org/D64695

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  unittests/Format/SortIncludesTest.cpp

Index: unittests/Format/SortIncludesTest.cpp
===
--- unittests/Format/SortIncludesTest.cpp
+++ unittests/Format/SortIncludesTest.cpp
@@ -665,6 +665,67 @@
  "#include \"a.h\""));
 }
 
+TEST_F(SortIncludesTest, ParamAndTypesCheck) {
+  FmtStyle = getNetBSDStyle();
+  EXPECT_EQ("#include \n"
+			"#include \n"
+			"#include \n"
+			"#include \n"
+			"#include \n"
+			"#include \n",
+			sort("#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"
+ "#include \n"));
+	
+}
+
+TEST_F(SortIncludesTest, SortedIncludesInSingleBlockReGroupWithNetBSDSpecifications) {
+  FmtStyle = getNetBSDStyle();
+  EXPECT_EQ("#include \n"  
+  "#include \n"  
+  "#include \n"  
+  "#include \n" 
+  "#include \n"
+  "#include \n"
+  "\n"
+  "#include \n"
+  "#include \n"
+  "#include \n"
+  "#include \n"
+  "#include \n"
+  "\n"
+  "#include \n"
+  "#include \n"
+  "#include \n"
+  "#include \n"
+  "#include \n"
+  "\n"
+  "#include \n"
+  "\n"
+  "#include \"pathnames.h\"\n",
+  sort("#include \n"		
+   "#include \n"		
+   "#include \n"		
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"	
+   "#include \n"
+   "#include \n"		
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \"pathnames.h\"\n"		
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -278,8 +278,15 @@
   }
 };
 
-template <>
-struct ScalarEnumerationTraits {
+template <> struct ScalarEnumerationTraits {
+  static void enumeration(IO ,
+  FormatStyle::IncludeHeadersStyle ) {
+IO.enumCase(Value, "None", FormatStyle::SIS_None);
+IO.enumCase(Value, "NetBSD", FormatStyle::SIS_NetBSD);
+  }
+};
+
+template <> struct ScalarEnumerationTraits {
   static void enumeration(IO ,
   FormatStyle::SpaceBeforeParensOptions ) {
 IO.enumCase(Value, "Never", FormatStyle::SBPO_Never);
@@ -479,6 +486,7 @@
 IO.mapOptional("RawStringFormats", Style.RawStringFormats);
 IO.mapOptional("ReflowComments", Style.ReflowComments);
 IO.mapOptional("SortIncludes", Style.SortIncludes);
+IO.mapOptional("SortIncludesStyle", Style.SortIncludesStyle);
 IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);
 IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast);
 IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
@@ -609,7 +617,7 @@
 return Style;
   FormatStyle Expanded = Style;
   Expanded.BraceWrapping = {false, false, false, false, false, false,
-false, false, false, false, false,
+false, false, false, false, false, 
 false, false, true,  true,  true};
   switch (Style.BreakBeforeBraces) {
   case FormatStyle::BS_Linux:
@@ -759,6 +767,7 @@
 
   LLVMStyle.DisableFormat = false;
   LLVMStyle.SortIncludes = true;
+  LLVMStyle.SortIncludesStyle = FormatStyle::SIS_None;
   LLVMStyle.SortUsingDeclarations = true;
   LLVMStyle.StatementMacros.push_back("Q_UNUSED");
   LLVMStyle.StatementMacros.push_back("QT_REQUIRE_VERSION");
@@ -919,6 +928,7 @@
 "javax",
 };
 ChromiumStyle.SortIncludes = true;
+ChromiumStyle.SortIncludesStyle = FormatStyle::SIS_None;
   } else if (Language == FormatStyle::LK_JavaScript) {
 ChromiumStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
 ChromiumStyle.AllowShortLoopsOnASingleLine = false;
@@ -1023,6 +1033,30 @@
   return Style;
 }
 
+FormatStyle getNetBSDStyle() {
+  FormatStyle NetBSDStyle = getLLVMStyle();
+  NetBSDStyle.AlignTrailingComments = true;
+  NetBSDStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
+  NetBSDStyle.AlignConsecutiveMacros = true;
+  NetBSDStyle.BreakBeforeBraces = FormatStyle::BS_Mozilla;
+  NetBSDStyle.ColumnLimit = 80;
+  NetBSDStyle.ContinuationIndentWidth = 4;
+  NetBSDStyle.Cpp11BracedListStyle = false;
+  NetBSDStyle.FixNamespaceComments = true;
+  NetBSDStyle.IndentCaseLabels = false;
+  NetBSDStyle.IndentWidth = 8;
+  NetBSDStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
+  

[PATCH] D63062: [clang-format] Added New Style Rule: BitFieldDeclarationsOnePerLine

2019-07-15 Thread Manikishan Ghantasala via Phabricator via cfe-commits
Manikishan marked an inline comment as done.
Manikishan added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:2921
+  Right.is(tok::identifier) && (Right.Next->is(tok::colon)))
+  return true;
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0)

MyDeveloperDay wrote:
> mgorny wrote:
> > Misindent.
> This code appears 3 times (does it need to appear 3 times?), do we need some 
> sort of 
> 
> ```
> bool isBitField(FormatToken)
> {
> ...
> }
> ```
> 
> Should a bit field check for the existence of a number after the colon? I 
> can't think of other C++ constructs that appear as
> 
> ```
> comma identifier colon
> ```
> 
> but given that clang-format is used for ObjC,ProtoBuf,Java,JavaScript,C# I'm 
> pretty sure something odd is going to happen with JavaScript named 
> parameters, to be honest I think this is going to cause the following to get 
> reformatted 
> 
> MyFunctionCall({ xPosition: 20**, yPosition: 50,** width: 100, height: 5, 
> drawingNow: true });
> 
> 
> ```
> MyFunctionCall({ xPosition: 20**, yPosition: 50,**
> width: 100, 
> height: 5, 
> drawingNow: true });
> ```
> 
> or something like that
Yes,  you are correct this patch is failing many Javascript Tests. Will 
refactor the implementation.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63062



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


[PATCH] D63062: [clang-format] Added New Style Rule: BitFieldDeclarationsOnePerLine

2019-07-15 Thread Manikishan Ghantasala via Phabricator via cfe-commits
Manikishan marked 5 inline comments as done.
Manikishan added inline comments.



Comment at: unittests/Format/FormatTest.cpp:3671
+  );
+} 
 

MyDeveloperDay wrote:
> MyDeveloperDay wrote:
> > please add a test with comments (it will get logged)
> > 
> > 
> > ```
> > unsigned int baz : 11, /*motor control flags*/
> >  add: 2/* control code for turning the lights on */ 
> > ,
> >  foo: 3 /* (unused */
> > ```
> > 
> any thoughts on these comments?
Sorry, I totally have to keep this aside because of some reasons, will update 
within a day.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63062



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-15 Thread Ziang Wan via Phabricator via cfe-commits
ziangwan updated this revision to Diff 209928.
ziangwan marked an inline comment as done.
ziangwan edited the summary of this revision.
ziangwan added a comment.

Update diff.

1. Adopt


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

https://reviews.llvm.org/D64666

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/conversion.c
  clang/test/Sema/ext_vector_casts.c
  clang/test/Sema/implicit-float-conversion.c

Index: clang/test/Sema/implicit-float-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-float-conversion.c
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-float-conversion
+
+
+long testReturn(long a, float b) {
+  return a + b; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
+}
+
+
+void testAssignment() {
+  float f = 22;
+  double b = L;
+  
+  float ff = L; // expected-warning {{implicit conversion from 'long' to 'float' changes value from  to 1312}}
+  float  = UL; // expected-warning {{implicit conversion from 'unsigned long' to 'float' changes value from  to 1312}}
+
+  long l = L;
+  float fff = l; // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
+}
+
+
+void testExpression() {
+  float a = 0.0f;
+  float b = L + a; // expected-warning {{implicit conversion from 'long' to 'float' changes value from  to 1312}}
+
+  float g =  + ;
+  float c =  + 2223; // expected-warning {{implicit conversion from 'int' to 'float' changes value from 4445 to }}
+
+  int i = 0;
+  float d = i + a; // expected-warning {{implicit conversion from 'int' to 'float' may lose precision}}
+  
+  double e = 0.0;
+  double f = i + e;
+}
Index: clang/test/Sema/ext_vector_casts.c
===
--- clang/test/Sema/ext_vector_casts.c
+++ clang/test/Sema/ext_vector_casts.c
@@ -115,12 +115,12 @@
   vl = vl + t; // expected-warning {{implicit conversion loses integer precision}}
   
   vf = 1 + vf;
-  vf = l + vf;
+  vf = l + vf; // expected-warning {{implicit conversion from 'long' to 'float2' (vector of 2 'float' values) may lose precision}}
   vf = 2.0 + vf;
   vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
-  vf = vf + 0x;
+  vf = vf + 0x; // expected-warning {{implicit conversion from 'unsigned int' to 'float2' (vector of 2 'float' values) changes value from 4294967295 to 4294967296}}
   vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
   
-  vd = l + vd;
-  vd = vd + t;
+  vd = l + vd; // expected-warning {{implicit conversion from 'long' to 'double2' (vector of 2 'double' values) may lose precision}}
+  vd = vd + t; // expected-warning {{implicit conversion from '__uint128_t' (aka 'unsigned __int128') to 'double2' (vector of 2 'double' values) may lose precision}}
 }
Index: clang/test/Sema/conversion.c
===
--- clang/test/Sema/conversion.c
+++ clang/test/Sema/conversion.c
@@ -233,7 +233,7 @@
   takes_int(v);
   takes_long(v);
   takes_longlong(v);
-  takes_float(v);
+  takes_float(v); // expected-warning {{implicit conversion from 'int' to 'float' may lose precision}}
   takes_double(v);
   takes_longdouble(v);
 }
@@ -244,8 +244,8 @@
   takes_int(v); // expected-warning {{implicit conversion loses integer precision}}
   takes_long(v);
   takes_longlong(v);
-  takes_float(v);
-  takes_double(v);
+  takes_float(v); // expected-warning {{implicit conversion from 'long' to 'float' may lose precision}}
+  takes_double(v); // expected-warning {{implicit conversion from 'long' to 'double' may lose precision}}
   takes_longdouble(v);
 }
 
@@ -255,8 +255,8 @@
   takes_int(v); // expected-warning {{implicit conversion loses integer precision}}
   takes_long(v);
   takes_longlong(v);
-  takes_float(v);
-  takes_double(v);
+  takes_float(v); // expected-warning {{implicit conversion from 'long long' to 'float' may lose precision}}
+  takes_double(v); // expected-warning {{implicit conversion from 'long long' to 'double' may lose precision}}
   takes_longdouble(v);
 }
 
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11400,6 +11400,55 @@
 }
   }
 
+  // If we are casting an integer type to a floating point type, we might
+  // lose accuracy if the floating point type has a narrower significand
+  // than the integer type. Issue warnings for that accuracy loss. 
+  if (SourceBT && TargetBT && SourceBT->isIntegerType() &&
+

[PATCH] D63062: [clang-format] Added New Style Rule: BitFieldDeclarationsOnePerLine

2019-07-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: unittests/Format/FormatTest.cpp:3671
+  );
+} 
 

MyDeveloperDay wrote:
> please add a test with comments (it will get logged)
> 
> 
> ```
> unsigned int baz : 11, /*motor control flags*/
>  add: 2/* control code for turning the lights on */ ,
>  foo: 3 /* (unused */
> ```
> 
any thoughts on these comments?


Repository:
  rC Clang

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

https://reviews.llvm.org/D63062



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


[PATCH] D64742: Allow using -ftrivial-auto-var-init=zero in C mode without extra flags

2019-07-15 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

A lots of folks from the original discussion insisted on this as a compromise. 
I'd like to make sure they see and approve of this, they might have requests 
for e.g. specific performance numbers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64742



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


[PATCH] D64695: [clang-format] Added new style rule: SortNetBSDIncludes

2019-07-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I appreciate what you've done to make this patch less duplicated code..but now 
you've almost got to the point where being able to control it all via 
configuration.

I'm with @rdwampler I think you should be able to extend the include 
categories...and then this becomes a very powerful capability. There are many 
people who use clang-format for a "non" standard style source trees, and they 
might like to use such a capability themselves without having to inherit from 
NetBSD type.

I agree it will be complex, but that is a good justification for adding hard 
coded a NetBSD style.




Comment at: lib/Format/Format.cpp:1905
+  }
+  ///!!
   llvm::stable_sort(Indices, [&](unsigned LHSI, unsigned RHSI) {

remove


Repository:
  rC Clang

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

https://reviews.llvm.org/D64695



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


[PATCH] D64232: [analyzer] Prune calls to functions with linear CFGs that return a non-zero constrained value

2019-07-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked 2 inline comments as done.
Szelethus added inline comments.



Comment at: clang/test/Analysis/track-control-dependency-conditions.cpp:185
 return true;
   return coin(); // tracking-note{{Returning value}}
 }

NoQ wrote:
> Szelethus wrote:
> > This note is meaningful, the bug would not have occurred if `coin()` wasn't 
> > assumed to be false.
> M. M. Dunno, this is getting complicated very quickly. Say, if you 
> replace `return true` with `return false` on the previous line, the note 
> becomes meaningless again. I don't see a direct connection between 
> meaningfulness and linearness.
> 
> The note in this example is relatively meaningful indeed, but i'm not sure 
> it's so much meaningful that it's worth the noise. It's still not surprising 
> for me that `flipCoin()` occasionally returns false. I do believe that it may 
> be sometimes surprising that `flipCoin()` may return false on the *current 
> path*, which would make the note meaningful. However, note that we don't 
> prove that it may return false, we only push the assumption one step deeper, 
> i.e. put the blame on `coin()` instead of `flipCoin()`, but we still fully 
> trust our assumption about `coin()` which may have the same problem. And if 
> we had an actual proof that it may return false, we would have had a 
> concrete-false return value, so the patch wouldn't apply.
> 
> I guess some experimental data would be great to have. 
Oh yea, I see where you are going. As I understand correctly, these are two 
separate problems: trying to somehow argue about other execution paths and 
whether dropping all constraints on a symbol is a good approach.

I should have all the results by tomorrow if all goes according to plan.



Comment at: clang/test/Analysis/uninit-vals.c:181
 void testUseHalfPoint() {
-  struct Point p = getHalfPoint(); // expected-note{{Calling 'getHalfPoint'}}
-   // expected-note@-1{{Returning from 
'getHalfPoint'}}
-   // expected-note@-2{{'p' initialized here}}
+  struct Point p = getHalfPoint(); // expected-note{{'p' initialized here}}
   use(p); // expected-warning{{uninitialized}}

NoQ wrote:
> Szelethus wrote:
> > Szelethus wrote:
> > > NoQ wrote:
> > > > Huh, so there's not even a note in `getHalfPoint()`, just 
> > > > calling..returning? This definitely needs some attention from 
> > > > `NoStoreFuncVisitor`.
> > > > 
> > > > Generally, i think this is probably the single place where we do really 
> > > > want some info about what happens in `getHalfPoint()`. The report that 
> > > > consists only of "p is initialized..." and "...p is uninitialized" is 
> > > > pretty weird. Btw, could you write down the full warning text in this 
> > > > test? How bad this actually is?
> > > Wild idea: `UninitializedObjectChecker` exposes it's main logic through a 
> > > header file, how about we use it when we find a read of an uninitialized 
> > > region?
> > Passed-by-value struct argument contains uninitialized data (e.g., field: 
> > 'y')
> > 
> > Quite good imo.
> What specific logic are you talking about? You mean it'd scan the structure 
> for uninitialized fields and present the results of the scan to the user in a 
> note?
>What specific logic are you talking about? You mean it'd scan the structure 
>for uninitialized fields and present the results of the scan to the user in a 
>note?
Nvm, looked at the code, realized that what I said made no sense. What we are 
really missing here is a `trackRegionValue()` function :^)

Btw, I wasted s much time on figuring out that you don't get ANY notes 
whatsoever if you make this a cpp file rather than a c file, only the 
warning... Is this intended?


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

https://reviews.llvm.org/D64232



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


[PATCH] D64744: Loop #pragma tail_predicate

2019-07-15 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

IMHO, this loops like an option of a particular transformation, not an 
independent pragma. E.g.

  #pragma clang loop vectorize(enable) vectorize_remainder(predicated)

There could be multiple choices for how to execute remainder iterations, e.g. 
instead of an epilogue, the first iterations could be executed in an prologue. 
Or an option where the compiler may assume that the iteration-count is always a 
multiple of the vector width, etc.

Also consider interactions with other transformations: What would happen with 
the `llvm.loop.tailpredicate` metadata after, e.g. loop fusion/distribution? 
How does the user know whether the pragma had an effect?


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

https://reviews.llvm.org/D64744



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-07-15 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

@dankm are you still working on this patch?


Repository:
  rC Clang

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

https://reviews.llvm.org/D49466



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


[PATCH] D64717: [Clangd] Fixed ExtractVariable for MemberExprs and Assignment Exprs

2019-07-15 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah updated this revision to Diff 209922.
SureYeaah added a comment.

Added fix for selecting the callExpr of a MemberExpr/Function DeclRefExpr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64717

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -291,6 +291,7 @@
   const char *Input = "struct ^X { int x; int y; }";
   EXPECT_THAT(getMessage(ID, Input), ::testing::HasSubstr("0 |   int x"));
 }
+
 TEST(TweakTest, ExtractVariable) {
   llvm::StringLiteral ID = "ExtractVariable";
   checkAvailable(ID, R"cpp(
@@ -302,7 +303,7 @@
   int a = 5 + [[4 ^* ^xyz^()]];
   // multivariable initialization
   if(1)
-int x = ^1, y = ^a + 1, a = ^1, z = a + 1;
+int x = ^1, y = [[a + 1]], a = ^1, z = a + 1;
   // if without else
   if(^1) {}
   // if with else
@@ -315,13 +316,13 @@
 a = ^4;
   else
 a = ^5;
-  // for loop 
+  // for loop
   for(a = ^1; a > ^3^+^4; a++)
 a = ^2;
-  // while 
+  // while
   while(a < ^1)
-^a++;
-  // do while 
+[[a++]];
+  // do while
   do
 a = ^1;
   while(a < ^3);
@@ -343,22 +344,28 @@
 int xyz = ^1;
   };
 }
+void v() { return; }
 // function default argument
 void f(int b = ^1) {
   // void expressions
   auto i = new int, j = new int;
   de^lete i^, del^ete j;
+  [[g]]();
   // if
   if(1)
 int x = 1, y = a + 1, a = 1, z = ^a + 1;
   if(int a = 1)
 if(^a == 4)
   a = ^a ^+ 1;
-  // for loop 
+  // for loop
   for(int a = 1, b = 2, c = 3; ^a > ^b ^+ ^c; ^a++)
 a = ^a ^+ 1;
-  // lambda 
+  // lambda
   auto lamb = [&^a, &^b](int r = ^1) {return 1;}
+  // assigment
+  [[a ^= 5]];
+  // Variable DeclRefExpr
+  a = [[b]];
 }
   )cpp");
   // vector of pairs of input and output strings
@@ -412,6 +419,24 @@
R"cpp(void f(int a) {
 auto dummy = 1; label: [ [gsl::suppress("type")] ] for (;;) a = dummy;
  })cpp"},
+  // MemberExpr
+  {R"cpp(class T {
+   T f() {
+ return [[T().f().f]]();
+   }
+ };)cpp",
+   R"cpp(class T {
+   T f() {
+ auto dummy = T().f().f(); return dummy;
+   }
+ };)cpp"},
+  // Function DeclRefExpr
+  {R"cpp(int f() {
+   return [[f]]();
+ })cpp",
+   R"cpp(int f() {
+   auto dummy = f(); return dummy;
+ })cpp"},
   // FIXME: Doesn't work because bug in selection tree
   /*{R"cpp(#define PLUS(x) x++
  void f(int a) {
@@ -421,8 +446,8 @@
  void f(int a) {
auto dummy = a; PLUS(dummy);
  })cpp"},*/
-  // FIXME: Doesn't work correctly for \[\[clang::uninitialized\]\] int b
-  // = 1; since the attr is inside the DeclStmt and the bounds of
+  // FIXME: Wrong result for \[\[clang::uninitialized\]\] int b = 1;
+  // since the attr is inside the DeclStmt and the bounds of
   // DeclStmt don't cover the attribute
   };
   for (const auto  : InputOutputs) {
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -13,6 +13,7 @@
 #include "refactor/Tweak.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/OperationKinds.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
@@ -37,18 +38,16 @@
 const ASTContext );
   const clang::Expr *getExpr() const { return Expr; }
   const SelectionTree::Node *getExprNode() const { return ExprNode; }
-  bool isExtractable() const { return Extractable; }
   // Generate Replacement for replacing selected expression with given VarName
   tooling::Replacement replaceWithVar(llvm::StringRef VarName) const;
   // Generate Replacement for declaring the selected Expr as a new variable
   tooling::Replacement insertDeclaration(llvm::StringRef VarName) const;
+  const clang::Stmt *InsertionPoint = nullptr;
 
 private:
-  bool Extractable = false;
   const clang::Expr *Expr;
   const SelectionTree::Node *ExprNode;
   // Stmt before which we will extract
-  const clang::Stmt 

[PATCH] D64672: [X86] Prevent passing vectors of __int128 as in llvm IR

2019-07-15 Thread Warren Ristow via Phabricator via cfe-commits
wristow added a comment.

> Do we need to keep the old behavior on platforms where clang is the de facto 
> compiler?

I know we (PlayStation) will want to keep the old behavior.


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

https://reviews.llvm.org/D64672



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


[PATCH] D64762: [AST] Treat semantic form of InitListExpr as implicit code in traversals

2019-07-15 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: gribozavr.
Herald added a subscriber: kadircet.
Herald added a project: clang.

In particular, do not traverse the semantic form shouldVisitImplicitCode()
returns false.

This simplifies the common case of traversals, avoiding the need to
worry about some expressions being traversed twice.

No tests break after the change, the change would allow to simplify at
least one of the usages, i.e. r366070 which had to handle this in
clangd.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64762

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h


Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2308,15 +2308,25 @@
   return true;
 }
 
-// This method is called once for each pair of syntactic and semantic
-// InitListExpr, and it traverses the subtrees defined by the two forms. This
-// may cause some of the children to be visited twice, if they appear both in
-// the syntactic and the semantic form.
+// If shouldVisitImplicitCode() returns false, this method traverses only the
+// syntactic form of InitListExpr.
+// If shouldVisitImplicitCode() return true, this method is called once for
+// each pair of syntactic and semantic InitListExpr, and it traverses the
+// subtrees defined by the two forms. This may cause some of the children to be
+// visited twice, if they appear both in the syntactic and the semantic form.
 //
 // There is no guarantee about which form \p S takes when this method is 
called.
 template 
 bool RecursiveASTVisitor::TraverseInitListExpr(
 InitListExpr *S, DataRecursionQueue *Queue) {
+  if (!getDerived().shouldVisitImplicitCode()) {
+// Visit only the syntactic form if the clients are not interested in
+// implicit compiler-generated semantic form.
+TRY_TO(TraverseSynOrSemInitListExpr(
+S->isSyntacticForm() ? S : S->getSyntacticForm(), Queue));
+return true;
+  }
+
   TRY_TO(TraverseSynOrSemInitListExpr(
   S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
   TRY_TO(TraverseSynOrSemInitListExpr(


Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2308,15 +2308,25 @@
   return true;
 }
 
-// This method is called once for each pair of syntactic and semantic
-// InitListExpr, and it traverses the subtrees defined by the two forms. This
-// may cause some of the children to be visited twice, if they appear both in
-// the syntactic and the semantic form.
+// If shouldVisitImplicitCode() returns false, this method traverses only the
+// syntactic form of InitListExpr.
+// If shouldVisitImplicitCode() return true, this method is called once for
+// each pair of syntactic and semantic InitListExpr, and it traverses the
+// subtrees defined by the two forms. This may cause some of the children to be
+// visited twice, if they appear both in the syntactic and the semantic form.
 //
 // There is no guarantee about which form \p S takes when this method is called.
 template 
 bool RecursiveASTVisitor::TraverseInitListExpr(
 InitListExpr *S, DataRecursionQueue *Queue) {
+  if (!getDerived().shouldVisitImplicitCode()) {
+// Visit only the syntactic form if the clients are not interested in
+// implicit compiler-generated semantic form.
+TRY_TO(TraverseSynOrSemInitListExpr(
+S->isSyntacticForm() ? S : S->getSyntacticForm(), Queue));
+return true;
+  }
+
   TRY_TO(TraverseSynOrSemInitListExpr(
   S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
   TRY_TO(TraverseSynOrSemInitListExpr(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-15 Thread Steve Canon via Phabricator via cfe-commits
scanon requested changes to this revision.
scanon added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Sema/SemaChecking.cpp:11429
+  S.Context.getFloatTypeSemantics(QualType(TargetBT, 0)));
+TargetFloatValue.convertFromAPInt(SourceInt,
+  SourceBT->isSignedInteger(), llvm::APFloat::rmNearestTiesToEven);

Why don't we just check that the result of the first conversion is opOK? I 
don't think doing a round-trip check is required here.


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

https://reviews.llvm.org/D64666



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


[PATCH] D63048: Update __VERSION__ to remove the hardcoded 4.2.1 version

2019-07-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366091: Update __VERSION__ to remove the hardcoded 4.2.1 
version (authored by sylvestre, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63048

Files:
  cfe/trunk/docs/LanguageExtensions.rst
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -604,10 +604,9 @@
   // Support for #pragma redefine_extname (Sun compatibility)
   Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");
 
-  // As sad as it is, enough software depends on the __VERSION__ for version
-  // checks that it is necessary to report 4.2.1 (the base GCC version we claim
-  // compatibility with) first.
-  Builder.defineMacro("__VERSION__", "\"4.2.1 Compatible " +
+  // Previously this macro was set to a string aiming to achieve compatibility
+  // with GCC 4.2.1. Now, just return the full Clang version
+  Builder.defineMacro("__VERSION__", "\"" +
   Twine(getClangFullCPPVersion()) + "\"");
 
   // Initialize language-specific preprocessor defines.
Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -324,6 +324,8 @@
   ...
   #endif
 
+.. _languageextensions-builtin-macros:
+
 Builtin Macros
 ==
 
Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -56,6 +56,12 @@
 Non-comprehensive list of changes in this release
 -
 
+- The ``__VERSION__`` macro has been updated.
+  Previously this macro contained the string '4.2.1 Compatible' to achieve
+  compatibility with GCC 4.2.1, but that should no longer be necessary.
+  However, to retrieve Clang's version, please favor the one of the macro
+  defined in :ref:`clang namespaced version macros 
`.
+
 - ...
 
 
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -8169,7 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "4.2.1 Compatible{{.*}}
+// SPARC:#define __VERSION__ "Clang{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32
@@ -9041,7 +9041,7 @@
 // X86_64-CLOUDABI:#define __UINT_LEAST8_MAX__ 255
 // X86_64-CLOUDABI:#define __UINT_LEAST8_TYPE__ unsigned char
 // X86_64-CLOUDABI:#define __USER_LABEL_PREFIX__
-// X86_64-CLOUDABI:#define __VERSION__ "4.2.1 Compatible{{.*}}
+// X86_64-CLOUDABI:#define __VERSION__ "Clang{{.*}}
 // X86_64-CLOUDABI:#define __WCHAR_MAX__ 2147483647
 // X86_64-CLOUDABI:#define __WCHAR_TYPE__ int
 // X86_64-CLOUDABI:#define __WCHAR_WIDTH__ 32


Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -604,10 +604,9 @@
   // Support for #pragma redefine_extname (Sun compatibility)
   Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");
 
-  // As sad as it is, enough software depends on the __VERSION__ for version
-  // checks that it is necessary to report 4.2.1 (the base GCC version we claim
-  // compatibility with) first.
-  Builder.defineMacro("__VERSION__", "\"4.2.1 Compatible " +
+  // Previously this macro was set to a string aiming to achieve compatibility
+  // with GCC 4.2.1. Now, just return the full Clang version
+  Builder.defineMacro("__VERSION__", "\"" +
   Twine(getClangFullCPPVersion()) + "\"");
 
   // Initialize language-specific preprocessor defines.
Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -324,6 +324,8 @@
   ...
   #endif
 
+.. _languageextensions-builtin-macros:
+
 Builtin Macros
 ==
 
Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -56,6 +56,12 @@
 Non-comprehensive list of changes in this release
 -
 
+- The 

r366091 - Update __VERSION__ to remove the hardcoded 4.2.1 version

2019-07-15 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Mon Jul 15 10:47:22 2019
New Revision: 366091

URL: http://llvm.org/viewvc/llvm-project?rev=366091=rev
Log:
Update __VERSION__ to remove the hardcoded 4.2.1 version

Summary:
Just like in https://reviews.llvm.org/D56803
for -dumpversion

Reviewers: rnk

Reviewed By: rnk

Subscribers: dexonsmith, lebedev.ri, hubert.reinterpretcast, xbolva00, 
fedor.sergeev, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=366091=366090=366091=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Mon Jul 15 10:47:22 2019
@@ -324,6 +324,8 @@ option for a warning and returns true if
   ...
   #endif
 
+.. _languageextensions-builtin-macros:
+
 Builtin Macros
 ==
 

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=366091=366090=366091=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Jul 15 10:47:22 2019
@@ -56,6 +56,12 @@ Improvements to Clang's diagnostics
 Non-comprehensive list of changes in this release
 -
 
+- The ``__VERSION__`` macro has been updated.
+  Previously this macro contained the string '4.2.1 Compatible' to achieve
+  compatibility with GCC 4.2.1, but that should no longer be necessary.
+  However, to retrieve Clang's version, please favor the one of the macro
+  defined in :ref:`clang namespaced version macros 
`.
+
 - ...
 
 

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=366091=366090=366091=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Jul 15 10:47:22 2019
@@ -604,10 +604,9 @@ static void InitializePredefinedMacros(c
   // Support for #pragma redefine_extname (Sun compatibility)
   Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");
 
-  // As sad as it is, enough software depends on the __VERSION__ for version
-  // checks that it is necessary to report 4.2.1 (the base GCC version we claim
-  // compatibility with) first.
-  Builder.defineMacro("__VERSION__", "\"4.2.1 Compatible " +
+  // Previously this macro was set to a string aiming to achieve compatibility
+  // with GCC 4.2.1. Now, just return the full Clang version
+  Builder.defineMacro("__VERSION__", "\"" +
   Twine(getClangFullCPPVersion()) + "\"");
 
   // Initialize language-specific preprocessor defines.

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=366091=366090=366091=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Jul 15 10:47:22 2019
@@ -8169,7 +8169,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "4.2.1 Compatible{{.*}}
+// SPARC:#define __VERSION__ "Clang{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32
@@ -9041,7 +9041,7 @@
 // X86_64-CLOUDABI:#define __UINT_LEAST8_MAX__ 255
 // X86_64-CLOUDABI:#define __UINT_LEAST8_TYPE__ unsigned char
 // X86_64-CLOUDABI:#define __USER_LABEL_PREFIX__
-// X86_64-CLOUDABI:#define __VERSION__ "4.2.1 Compatible{{.*}}
+// X86_64-CLOUDABI:#define __VERSION__ "Clang{{.*}}
 // X86_64-CLOUDABI:#define __WCHAR_MAX__ 2147483647
 // X86_64-CLOUDABI:#define __WCHAR_TYPE__ int
 // X86_64-CLOUDABI:#define __WCHAR_WIDTH__ 32


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


[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-07-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D61634#1515176 , @tejohnson wrote:

> In D61634#1512020 , @gchatelet wrote:
>
> > AFAIU here is a coarse plan of what needs to happen
> >
> > 1. Add a `no-builtin` clang function attribute that has the same semantic 
> > as the `no-builtin` cmd line argument 
> > 
> > 2. Propagate it to the IR.
> >   - In the light of recent discussions and as @theraven suggested it seems 
> > more appropriate to encode them as individual IR attributes (e.g. 
> > `"no-builtin-memcpy"`, `"no-builtin-sqrt"`, etc..)
> > 3. Propagate/merge the `no-builtin` IR attribute for LTO by "updating 
> > `AttributeFuncs::areInlineCompatible` and/or 
> > `AttributeFuncs::mergeAttributesForInlining` and adding a new MergeRule in 
> > `include/llvm/IR/Attributes.td` and writing a function like 
> > `adjustCallerStackProbeSize`."
>
>
> This one isn't about LTO, but rather the inliner. You could have different 
> functions in the same module even without LTO that have incompatible 
> no-builtin attributes. There isn't any propagation required for LTO.
>
> > 4. Get inspiration from `TargetTransformInfo` to get `TargetLibraryInfo` on 
> > a per function basis for all passes and respect the IR attribute.
> > 
> >   I'm not familiar with 3 and 4 but I can definitely have a look. I'll 
> > update this patch to do 1 and 2 in the meantime. @tejohnson let me know how 
> > you want to proceed for your related patch 
> > . I'm happy to help if I can.
>
> I will mark that one obsolete. I can work on 4, it may just take some time to 
> get it all plumbed.


Checking in to see where we are on this issue. I haven't had any time to work 
on 4 but hopefully can start on that soon. But it needs the first part done to 
be effective.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-15 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a subscriber: aaron.ballman.
xbolva00 added a comment.

Probably @aaron.ballman would like to review this too..


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

https://reviews.llvm.org/D64666



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


[PATCH] D64695: [clang-format] Added new style rule: SortNetBSDIncludes

2019-07-15 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler added a comment.

> Sorry,  my mistake I meant that I have added Regex for priorities while 
> sorting and If I am not wrong I think IncludeCategories are used while 
> Regrouping after sorting the Includes. In addition to that in my case I have 
> to sort the includes In a particular order then grouping them in different
>  For example:
> 
>   #include   /*  first, */
>   #include   /*next, */
>   #include   /*   and then the rest, */
>   #include 
>   #include 
>   
>   #include 
>   #include 
>   #include 
>   #include 
>   #include 
>   
> 
> 
> As shown in the above example  should follow  then  but while 
> regrouping they should be in the same group.

OK. I think I understand. Since  and  have to come 
first we would need to set the regex and priorities for those individually. But 
then those will be treated as separate block and  grouped like:

#include 

#include 

#include   
more  includes

I wonder if a better approach would be to extend `IncludeCatalog` to allow the 
grouping to specified independent of the regex?

E.g.,  { "{", 0, 1 },  // priority 1, group 1

  {, 1, 1, }, // different priority, but same group
 {, 2, 1}  // more general headers with lower priority, but will 
still be grouped in group 1.
  }


Repository:
  rC Clang

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

https://reviews.llvm.org/D64695



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


[PATCH] D64678: [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

2019-07-15 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry marked 3 inline comments as done.
Nathan-Huckleberry added inline comments.



Comment at: clang/test/Sema/warn-uninitialized-statement-expression.c:21
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is 
uninitialized when used within its own initialization}}
+int x = my_widget.x;
+init2(_widget);

nickdesaulniers wrote:
> This needs a trailing comment like:
> ```
> int x = my_widget.x; // fixme: we should probably warn about this case
> ```
> and file a bug about it.  Doesn't need to be solved here.
https://bugs.llvm.org/show_bug.cgi?id=42625


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64678



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


[PATCH] D64062: Remove __VERSION__

2019-07-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D64062#1584219 , @saugustine wrote:

> This revision breaks python 2.7.16 builds, which are still supported by 
> upstream python for a few more months. I'm preparing a revert.
>
> The file is getcompiler.c:


I just want to point out that this code was already doing the wrong thing. It 
will report that the compiler is some incorrect version of GCC. After we add 
__VERSION__ back it will keep doing the wrong thing, which was sort of the 
point of removing it in the first place: to find such broken code and fix it. 
In any case, it sounds like it's not worth the effort, so let's just change the 
value of __VERSION__ instead of removing it.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64062



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-15 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

I verified the conversion values are correct in the precise warnings in the 
test cases.  From that perspective, and the rest of the code LGTM.  Please wait 
for review from another reviewer.  Thanks for the patch.




Comment at: clang/lib/Sema/SemaChecking.cpp:11426
+// during the whole conversion.
+// TODO: This operation is costly.
+llvm::APFloat TargetFloatValue(

This TODO doesn't add information about what to fix in the future.  I think 
it's ok to remove, as its understood that additional levels of semantic 
analysis is costlier and costlier.


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

https://reviews.llvm.org/D64666



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


[PATCH] D64678: [Sema] Fix -Wuninitialized for struct assignment from GNU C statement expression

2019-07-15 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 209905.
Nathan-Huckleberry marked 3 inline comments as done.
Nathan-Huckleberry added a comment.

- Change cast type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64678

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/warn-uninitialized-statement-expression.c


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int *);
+
+void foo(void) {
+  int i = ({
+init();
+i;
+  });
+}
+
+void foo_bad(void) {
+  int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when used 
within its own initialization}}
+init();
+i;
+  });
+}
+
+struct widget {
+  int x, y;
+};
+void init2(struct widget *);
+
+void bar(void) {
+  struct widget my_widget = ({
+init2(_widget);
+my_widget;
+  });
+}
+
+void bar_bad(void) {
+  struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is 
uninitialized when used within its own initialization}}
+int x = my_widget.x; //FIXME: There should be an uninitialized 
warning here
+init2(_widget);
+my_widget;
+  });
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a; // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget *a = ({
+init2(a); // expected-warning{{variable 'a' is uninitialized when used 
within its own initialization}}
+a;
+  });
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10886,6 +10886,11 @@
 if (DRE->getDecl() == OrigDecl)
   return;
 
+if (cast(OrigDecl)->getType()->isRecordType() &&
+dyn_cast(E)) {
+  return;
+}
+
 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
   }
 } // end anonymous namespace


Index: clang/test/Sema/warn-uninitialized-statement-expression.c
===
--- /dev/null
+++ clang/test/Sema/warn-uninitialized-statement-expression.c
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+
+void init(int *);
+
+void foo(void) {
+  int i = ({
+init();
+i;
+  });
+}
+
+void foo_bad(void) {
+  int i = ({
+int z = i; // expected-warning{{variable 'i' is uninitialized when used within its own initialization}}
+init();
+i;
+  });
+}
+
+struct widget {
+  int x, y;
+};
+void init2(struct widget *);
+
+void bar(void) {
+  struct widget my_widget = ({
+init2(_widget);
+my_widget;
+  });
+}
+
+void bar_bad(void) {
+  struct widget my_widget = ({
+struct widget z = my_widget; // expected-warning{{variable 'my_widget' is uninitialized when used within its own initialization}}
+int x = my_widget.x; //FIXME: There should be an uninitialized warning here
+init2(_widget);
+my_widget;
+  });
+}
+
+void baz(void) {
+  struct widget a = ({
+struct widget b = ({
+  b = a; // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+});
+a;
+  });
+}
+
+void f(void) {
+  struct widget *a = ({
+init2(a); // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
+a;
+  });
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10886,6 +10886,11 @@
 if (DRE->getDecl() == OrigDecl)
   return;
 
+if (cast(OrigDecl)->getType()->isRecordType() &&
+dyn_cast(E)) {
+  return;
+}
+
 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
   }
 } // end anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63048: Update __VERSION__ to remove the hardcoded 4.2.1 version

2019-07-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D63048



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


[PATCH] D64666: [Sema] Enable -Wimplicit-float-conversion for integral to floating point precision loss

2019-07-15 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D64666#1583792 , @xbolva00 wrote:

> I had duplicated warning for C++11+ - my new warning and C++11’s narrowing 
> warning.


Why would narrowing be C++11 specific? I would think that narrowing applies 
anywhere integrals are used?


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

https://reviews.llvm.org/D64666



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


  1   2   3   >