r340386 - [AST] correct the behavior of -fvisibility-inlines-hidden option (don't make static local variables hidden)

2018-08-21 Thread Hiroshi Inoue via cfe-commits
Author: inouehrs
Date: Tue Aug 21 22:43:27 2018
New Revision: 340386

URL: http://llvm.org/viewvc/llvm-project?rev=340386=rev
Log:
[AST] correct the behavior of -fvisibility-inlines-hidden option (don't make 
static local variables hidden)

The command line option -fvisibility-inlines-hidden makes inlined method 
hidden, but it is expected not to affect the visibility of static local 
variables in the function.
However, Clang makes the static local variables in the function also hidden as 
reported in PR37595. This problem causes LLVM bootstarp failure on Fedora 28 if 
configured with -DBUILD_SHARED_LIBS=ON.

This patch makes the behavior of -fvisibility-inlines-hidden option to be 
consistent with that of gcc; the option does not change the visibility of the 
static local variables if the containing function does not associated with 
explicit visibility attribute and becomes hidden due to this option.

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


Added:
cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden-staticvar.cpp
Modified:
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=340386=340385=340386=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Aug 21 22:43:27 2018
@@ -1262,6 +1262,16 @@ LinkageInfo LinkageComputer::getLVForLoc
 !isTemplateInstantiation(FD->getTemplateSpecializationKind()))
   return LinkageInfo::none();
 
+// If a function is hidden by -fvisibility-inlines-hidden option and
+// is not explicitly attributed as a hidden function,
+// we should not make static local variables in the function hidden.
+if (isa(D) && useInlineVisibilityHidden(FD) &&
+!(!hasExplicitVisibilityAlready(computation) &&
+  getExplicitVisibility(FD, computation))) {
+  assert(cast(D)->isStaticLocal());
+  return LinkageInfo(VisibleNoLinkage, DefaultVisibility, false);
+}
+
 LV = getLVForDecl(FD, computation);
   }
   if (!isExternallyVisible(LV.getLinkage()))

Added: cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden-staticvar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden-staticvar.cpp?rev=340386=auto
==
--- cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden-staticvar.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/visibility-inlines-hidden-staticvar.cpp Tue Aug 
21 22:43:27 2018
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 
-fvisibility-inlines-hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | 
FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 -emit-llvm -o - %s 
-O2 -disable-llvm-passes | FileCheck -check-prefixes=CHECK-NO-VIH %s
+
+// When a function is hidden due to -fvisibility-inlines-hidden option, static 
local variables of the function should not be hidden by the option.
+
+// CHECK-DAG: @_ZZ4funcvE3var = internal global i32 0
+// CHECK-DAG: @_ZZ11hidden_funcvE3var = internal global i32 0
+// CHECK-DAG: @_ZZ12default_funcvE3var = internal global i32 0
+// CHECK-DAG: @_ZZ11inline_funcvE3var = linkonce_odr global i32 0, comdat
+// CHECK-DAG: @_ZZ18inline_hidden_funcvE3var = linkonce_odr hidden global i32 
0, comdat
+// CHECK-DAG: @_ZZ19inline_default_funcvE3var = linkonce_odr global i32 0, 
comdat
+// CHECK-DAG: define i32 @_Z4funcv()
+// CHECK-DAG: define hidden i32 @_Z11hidden_funcv()
+// CHECK-DAG: define i32 @_Z12default_funcv()
+// CHECK-DAG: define linkonce_odr hidden i32 @_Z11inline_funcv()
+// CHECK-DAG: define linkonce_odr hidden i32 @_Z18inline_hidden_funcv()
+// CHECK-DAG: define linkonce_odr i32 @_Z19inline_default_funcv()
+
+// CHECK-NO-VIH-DAG: @_ZZ4funcvE3var = internal global i32 0
+// CHECK-NO-VIH-DAG: @_ZZ11hidden_funcvE3var = internal global i32 0
+// CHECK-NO-VIH-DAG: @_ZZ12default_funcvE3var = internal global i32 0
+// CHECK-NO-VIH-DAG: @_ZZ11inline_funcvE3var = linkonce_odr global i32 0, 
comdat
+// CHECK-NO-VIH-DAG: @_ZZ18inline_hidden_funcvE3var = linkonce_odr hidden 
global i32 0, comdat
+// CHECK-NO-VIH-DAG: @_ZZ19inline_default_funcvE3var = linkonce_odr global i32 
0, comdat
+// CHECK-NO-VIH-DAG: define i32 @_Z4funcv()
+// CHECK-NO-VIH-DAG: define hidden i32 @_Z11hidden_funcv()
+// CHECK-NO-VIH-DAG: define i32 @_Z12default_funcv()
+// CHECK-NO-VIH-DAG: define linkonce_odr i32 @_Z11inline_funcv()
+// CHECK-NO-VIH-DAG: define linkonce_odr hidden i32 @_Z18inline_hidden_funcv()
+// CHECK-NO-VIH-DAG: define linkonce_odr i32 @_Z19inline_default_funcv()
+
+
+int func(void) {
+  static int var = 0;
+  return var++;
+}
+inline int inline_func(void) {
+  static int var = 0;
+  return var++;
+}
+int __attribute__((visibility("hidden"))) hidden_func(void) {
+  static int var = 0;
+  return var++;
+}
+inline int 

[PATCH] D51084: Implement -Watomic-implicit-seq-cst

2018-08-21 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
jfb added a reviewer: rjmccall.
Herald added subscribers: cfe-commits, dexonsmith.

_Atomic and __sync_* operations are implicitly sequentially-consistent. Some
codebases want to force explicit usage of memory order instead. This warning
allows them to know where implicit sequentially-consistent memory order is used.
The warning isn't on by default because _Atomic was purposefully designed to
have seq_cst as the default: the idea was that it's the right thing to use most
of the time. This warning allows developers who disagree to enforce explicit
usage instead.

A follow-up patch will take care of C++'s std::atomic. It'll be different enough
from this patch that I think it should be separate: for C++ the atomic
operations all have a memory order parameter (or two), but it's defaulted. I
believe this warning should trigger when the default is used, but not when
seq_cst is used explicitly (or implicitly as the failure order for cmpxchg).

rdar://problem/28172966


Repository:
  rC Clang

https://reviews.llvm.org/D51084

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/atomic-implicit-seq_cst.c
  test/Sema/sync-implicit-seq_cst.c

Index: test/Sema/sync-implicit-seq_cst.c
===
--- /dev/null
+++ test/Sema/sync-implicit-seq_cst.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11 -Watomic-implicit-seq-cst -Wno-sync-fetch-and-nand-semantics-changed
+
+// __sync_* operations are implicitly sequentially-consistent. Some codebases
+// want to force explicit usage of memory order instead.
+
+void fetch_and_add(int *ptr, int val) { __sync_fetch_and_add(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_sub(int *ptr, int val) { __sync_fetch_and_sub(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_or(int *ptr, int val) { __sync_fetch_and_or(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_and(int *ptr, int val) { __sync_fetch_and_and(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_xor(int *ptr, int val) { __sync_fetch_and_xor(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void fetch_and_nand(int *ptr, int val) { __sync_fetch_and_nand(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+
+void add_and_fetch(int *ptr, int val) { __sync_add_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void sub_and_fetch(int *ptr, int val) { __sync_sub_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void or_and_fetch(int *ptr, int val) { __sync_or_and_fetch(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void and_and_fetch(int *ptr, int val) { __sync_and_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void xor_and_fetch(int *ptr, int val) { __sync_xor_and_fetch(ptr, val); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void nand_and_fetch(int *ptr, int val) { __sync_nand_and_fetch(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+
+void bool_compare_and_swap(int *ptr, int oldval, int newval) { __sync_bool_compare_and_swap(ptr, oldval, newval); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void val_compare_and_swap(int *ptr, int oldval, int newval) { __sync_val_compare_and_swap(ptr, oldval, newval); }   // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+
+void synchronize(void) { __sync_synchronize(); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+
+void lock_test_and_set(int *ptr, int val) { __sync_lock_test_and_set(ptr, val); } // expected-warning {{implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary}}
+void lock_release(int *ptr) { __sync_lock_release(ptr); }  

[libcxx] r340385 - Fix Bug 38644: multimap::clear() missing exception specifier. Add noexcept tests for all the containers that have clear().

2018-08-21 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Aug 21 21:28:43 2018
New Revision: 340385

URL: http://llvm.org/viewvc/llvm-project?rev=340385=rev
Log:
Fix Bug 38644: multimap::clear() missing exception specifier. Add noexcept 
tests for all the containers that have clear().

Added:

libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/clear.pass.cpp
Modified:
libcxx/trunk/include/map

libcxx/trunk/test/std/containers/associative/map/map.modifiers/clear.pass.cpp

libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
libcxx/trunk/test/std/containers/associative/multiset/clear.pass.cpp
libcxx/trunk/test/std/containers/associative/set/clear.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp

libcxx/trunk/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.multiset/clear.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.set/clear.pass.cpp

Modified: libcxx/trunk/include/map
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=340385=340384=340385=diff
==
--- libcxx/trunk/include/map (original)
+++ libcxx/trunk/include/map Tue Aug 21 21:28:43 2018
@@ -1884,7 +1884,7 @@ public:
 #endif
 
 _LIBCPP_INLINE_VISIBILITY
-void clear() {__tree_.clear();}
+void clear() _NOEXCEPT {__tree_.clear();}
 
 _LIBCPP_INLINE_VISIBILITY
 void swap(multimap& __m)

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.modifiers/clear.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.modifiers/clear.pass.cpp?rev=340385=340384=340385=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.modifiers/clear.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.modifiers/clear.pass.cpp 
Tue Aug 21 21:28:43 2018
@@ -11,11 +11,12 @@
 
 // class map
 
-// void clear();
+// void clear() noexcept;
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -36,6 +37,7 @@ int main()
 };
 M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
 assert(m.size() == 8);
+ASSERT_NOEXCEPT(m.clear());
 m.clear();
 assert(m.size() == 0);
 }
@@ -56,6 +58,7 @@ int main()
 };
 M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
 assert(m.size() == 8);
+ASSERT_NOEXCEPT(m.clear());
 m.clear();
 assert(m.size() == 0);
 }

Modified: 
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp?rev=340385=340384=340385=diff
==
--- 
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
 Tue Aug 21 21:28:43 2018
@@ -11,11 +11,12 @@
 
 // class multimap
 
-// void clear();
+// void clear() noexcept;
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -36,6 +37,7 @@ int main()
 };
 M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
 assert(m.size() == 8);
+ASSERT_NOEXCEPT(m.clear());
 m.clear();
 assert(m.size() == 0);
 }
@@ -56,6 +58,7 @@ int main()
 };
 M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
 assert(m.size() == 8);
+ASSERT_NOEXCEPT(m.clear());
 m.clear();
 assert(m.size() == 0);
 }

Modified: libcxx/trunk/test/std/containers/associative/multiset/clear.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multiset/clear.pass.cpp?rev=340385=340384=340385=diff
==
--- libcxx/trunk/test/std/containers/associative/multiset/clear.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/associative/multiset/clear.pass.cpp Tue 
Aug 21 21:28:43 2018
@@ -11,11 +11,12 @@
 
 // class multiset
 
-// void clear();
+// void clear() noexcept;
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "min_allocator.h"
 
 int main()
@@ -36,6 +37,7 @@ int main()
 };
 M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
 assert(m.size() == 8);
+ASSERT_NOEXCEPT(m.clear());
 m.clear();
 

[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-21 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

In https://reviews.llvm.org/D50564#1208169, @cdavis5x wrote:

> OK, I've removed some of the dependencies on Windows-specific types. The code 
> in `Unwind-seh.cpp` is very Windows-specific, though, so I left it alone.


Much appreciated, thank you for your work. LGTM in terms of semantics.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564



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


[PATCH] D51036: clang-format: Fix formatting C++ namespaces with preceding 'inline' or 'export' specifier

2018-08-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:128-133
+  // Detect "(inline|export)? namespace" in the beginning of a line.
+  if (NamespaceTok->is(tok::kw_inline) || NamespaceTok->is(tok::kw_export))
 NamespaceTok = NamespaceTok->getNextNonComment();
   if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))
 return nullptr;
   return NamespaceTok;

owenpan wrote:
> These lines are functionally the same as lines 523-528 in FormatToken.h. 
> Refactor them?
I think this is better:

```
  return NamespaceTok->getNamespaceToken();
```


Repository:
  rC Clang

https://reviews.llvm.org/D51036



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


[PATCH] D51072: [analyzer] [NFC] Fix minor formatting issues in RetainCountChecker

2018-08-21 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340378: [analyzer] [NFC] Fix minor formatting issues in 
RetainCountChecker (authored by george.karpenkov, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51072?vs=161844=161873#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51072

Files:
  
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
  
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp


Index: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
===
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
@@ -218,7 +218,6 @@
   }
 
   // Comparison, profiling, and pretty-printing.
-
   bool hasSameState(const RefVal ) const {
 return getKind() == X.getKind() && Cnt == X.Cnt && ACnt == X.ACnt &&
getIvarAccessHistory() == X.getIvarAccessHistory();
Index: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
===
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -457,8 +457,7 @@
 "  This violates the naming convention rules"
 " given in the Memory Management Guide for Cocoa";
 }
-  }
-  else {
+  } else {
 const FunctionDecl *FD = cast(D);
 os << "whose name ('" << *FD
<< "') does not contain 'Copy' or 'Create'.  This violates the 
naming"
Index: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -409,8 +409,7 @@
   }
 
   // Evaluate the effect on the message receiver.
-  const ObjCMethodCall *MsgInvocation = dyn_cast();
-  if (MsgInvocation) {
+  if (const auto *MsgInvocation = dyn_cast()) {
 if (SymbolRef Sym = MsgInvocation->getReceiverSVal().getAsLocSymbol()) {
   if (Summ.getReceiverEffect() == StopTrackingHard) {
 state = removeRefBinding(state, Sym);
@@ -987,7 +986,7 @@
   // does not understand.
   ProgramStateRef state = C.getState();
 
-  if (Optional regionLoc = loc.getAs()) {
+  if (auto regionLoc = loc.getAs()) {
 escapes = !regionLoc->getRegion()->hasStackStorage();
 
 if (!escapes) {
@@ -1011,7 +1010,7 @@
   // If we are storing the value into an auto function scope variable annotated
   // with (__attribute__((cleanup))), stop tracking the value to avoid leak
   // false positives.
-  if (const VarRegion *LVR = dyn_cast_or_null(loc.getAsRegion())) {
+  if (const auto *LVR = dyn_cast_or_null(loc.getAsRegion())) {
 const VarDecl *VD = LVR->getDecl();
 if (VD->hasAttr()) {
   escapes = true;
@@ -1031,8 +1030,8 @@
 }
 
 ProgramStateRef RetainCountChecker::evalAssume(ProgramStateRef state,
-   SVal Cond,
-   bool Assumption) const {
+   SVal Cond,
+   bool Assumption) const {
   // FIXME: We may add to the interface of evalAssume the list of symbols
   //  whose assumptions have changed.  For now we just iterate through the
   //  bindings and check if any of the tracked symbols are NULL.  This isn't
@@ -1253,7 +1252,8 @@
 QualType Ty = Param->getType();
 const ArgEffect *AE = CalleeSideArgEffects.lookup(idx);
 if (AE && *AE == DecRef && isISLObjectRef(Ty)) {
-  state = setRefBinding(state, Sym, 
RefVal::makeOwned(RetEffect::ObjKind::Generalized, Ty));
+  state = setRefBinding(
+  state, Sym, RefVal::makeOwned(RetEffect::ObjKind::Generalized, Ty));
 } else if (isISLObjectRef(Ty)) {
   state = setRefBinding(
   state, Sym,


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
@@ -218,7 +218,6 @@
   }
 
   // Comparison, profiling, and pretty-printing.
-
   bool hasSameState(const RefVal ) const {
 return getKind() == X.getKind() && Cnt == X.Cnt && ACnt == X.ACnt &&
getIvarAccessHistory() == X.getIvarAccessHistory();
Index: 

[PATCH] D51072: [analyzer] [NFC] Fix minor formatting issues in RetainCountChecker

2018-08-21 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340378: [analyzer] [NFC] Fix minor formatting issues in 
RetainCountChecker (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51072?vs=161844=161872#toc

Repository:
  rC Clang

https://reviews.llvm.org/D51072

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
  lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp


Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
@@ -218,7 +218,6 @@
   }
 
   // Comparison, profiling, and pretty-printing.
-
   bool hasSameState(const RefVal ) const {
 return getKind() == X.getKind() && Cnt == X.Cnt && ACnt == X.ACnt &&
getIvarAccessHistory() == X.getIvarAccessHistory();
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
@@ -457,8 +457,7 @@
 "  This violates the naming convention rules"
 " given in the Memory Management Guide for Cocoa";
 }
-  }
-  else {
+  } else {
 const FunctionDecl *FD = cast(D);
 os << "whose name ('" << *FD
<< "') does not contain 'Copy' or 'Create'.  This violates the 
naming"
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -409,8 +409,7 @@
   }
 
   // Evaluate the effect on the message receiver.
-  const ObjCMethodCall *MsgInvocation = dyn_cast();
-  if (MsgInvocation) {
+  if (const auto *MsgInvocation = dyn_cast()) {
 if (SymbolRef Sym = MsgInvocation->getReceiverSVal().getAsLocSymbol()) {
   if (Summ.getReceiverEffect() == StopTrackingHard) {
 state = removeRefBinding(state, Sym);
@@ -987,7 +986,7 @@
   // does not understand.
   ProgramStateRef state = C.getState();
 
-  if (Optional regionLoc = loc.getAs()) {
+  if (auto regionLoc = loc.getAs()) {
 escapes = !regionLoc->getRegion()->hasStackStorage();
 
 if (!escapes) {
@@ -1011,7 +1010,7 @@
   // If we are storing the value into an auto function scope variable annotated
   // with (__attribute__((cleanup))), stop tracking the value to avoid leak
   // false positives.
-  if (const VarRegion *LVR = dyn_cast_or_null(loc.getAsRegion())) {
+  if (const auto *LVR = dyn_cast_or_null(loc.getAsRegion())) {
 const VarDecl *VD = LVR->getDecl();
 if (VD->hasAttr()) {
   escapes = true;
@@ -1031,8 +1030,8 @@
 }
 
 ProgramStateRef RetainCountChecker::evalAssume(ProgramStateRef state,
-   SVal Cond,
-   bool Assumption) const {
+   SVal Cond,
+   bool Assumption) const {
   // FIXME: We may add to the interface of evalAssume the list of symbols
   //  whose assumptions have changed.  For now we just iterate through the
   //  bindings and check if any of the tracked symbols are NULL.  This isn't
@@ -1253,7 +1252,8 @@
 QualType Ty = Param->getType();
 const ArgEffect *AE = CalleeSideArgEffects.lookup(idx);
 if (AE && *AE == DecRef && isISLObjectRef(Ty)) {
-  state = setRefBinding(state, Sym, 
RefVal::makeOwned(RetEffect::ObjKind::Generalized, Ty));
+  state = setRefBinding(
+  state, Sym, RefVal::makeOwned(RetEffect::ObjKind::Generalized, Ty));
 } else if (isISLObjectRef(Ty)) {
   state = setRefBinding(
   state, Sym,


Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
@@ -218,7 +218,6 @@
   }
 
   // Comparison, profiling, and pretty-printing.
-
   bool hasSameState(const RefVal ) const {
 return getKind() == X.getKind() && Cnt == X.Cnt && ACnt == X.ACnt &&
getIvarAccessHistory() == X.getIvarAccessHistory();
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
===
--- 

r340378 - [analyzer] [NFC] Fix minor formatting issues in RetainCountChecker

2018-08-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Aug 21 18:17:09 2018
New Revision: 340378

URL: http://llvm.org/viewvc/llvm-project?rev=340378=rev
Log:
[analyzer] [NFC] Fix minor formatting issues in RetainCountChecker

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

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=340378=340377=340378=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Tue Aug 21 18:17:09 2018
@@ -409,8 +409,7 @@ void RetainCountChecker::processSummaryO
   }
 
   // Evaluate the effect on the message receiver.
-  const ObjCMethodCall *MsgInvocation = dyn_cast();
-  if (MsgInvocation) {
+  if (const auto *MsgInvocation = dyn_cast()) {
 if (SymbolRef Sym = MsgInvocation->getReceiverSVal().getAsLocSymbol()) {
   if (Summ.getReceiverEffect() == StopTrackingHard) {
 state = removeRefBinding(state, Sym);
@@ -987,7 +986,7 @@ void RetainCountChecker::checkBind(SVal
   // does not understand.
   ProgramStateRef state = C.getState();
 
-  if (Optional regionLoc = loc.getAs()) {
+  if (auto regionLoc = loc.getAs()) {
 escapes = !regionLoc->getRegion()->hasStackStorage();
 
 if (!escapes) {
@@ -1011,7 +1010,7 @@ void RetainCountChecker::checkBind(SVal
   // If we are storing the value into an auto function scope variable annotated
   // with (__attribute__((cleanup))), stop tracking the value to avoid leak
   // false positives.
-  if (const VarRegion *LVR = dyn_cast_or_null(loc.getAsRegion())) {
+  if (const auto *LVR = dyn_cast_or_null(loc.getAsRegion())) {
 const VarDecl *VD = LVR->getDecl();
 if (VD->hasAttr()) {
   escapes = true;
@@ -1031,8 +1030,8 @@ void RetainCountChecker::checkBind(SVal
 }
 
 ProgramStateRef RetainCountChecker::evalAssume(ProgramStateRef state,
-   SVal Cond,
-   bool Assumption) const {
+   SVal Cond,
+   bool Assumption) const {
   // FIXME: We may add to the interface of evalAssume the list of symbols
   //  whose assumptions have changed.  For now we just iterate through the
   //  bindings and check if any of the tracked symbols are NULL.  This isn't
@@ -1253,7 +1252,8 @@ void RetainCountChecker::checkBeginFunct
 QualType Ty = Param->getType();
 const ArgEffect *AE = CalleeSideArgEffects.lookup(idx);
 if (AE && *AE == DecRef && isISLObjectRef(Ty)) {
-  state = setRefBinding(state, Sym, 
RefVal::makeOwned(RetEffect::ObjKind::Generalized, Ty));
+  state = setRefBinding(
+  state, Sym, RefVal::makeOwned(RetEffect::ObjKind::Generalized, Ty));
 } else if (isISLObjectRef(Ty)) {
   state = setRefBinding(
   state, Sym,

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h?rev=340378=340377=340378=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.h 
Tue Aug 21 18:17:09 2018
@@ -218,7 +218,6 @@ public:
   }
 
   // Comparison, profiling, and pretty-printing.
-
   bool hasSameState(const RefVal ) const {
 return getKind() == X.getKind() && Cnt == X.Cnt && ACnt == X.ACnt &&
getIvarAccessHistory() == X.getIvarAccessHistory();

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp?rev=340378=340377=340378=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 (original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
 Tue Aug 21 18:17:09 2018
@@ -457,8 +457,7 @@ CFRefLeakReportVisitor::getEndPath(BugRe
 "  This violates the naming convention rules"
 " given in the Memory Management Guide for Cocoa";
 }
-  }
-  else {
+  } else {
 

r340377 - [analyzer] [NFC] Extract a method for creating RefVal from RetEffect in RetainCountChecker

2018-08-21 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Tue Aug 21 18:16:49 2018
New Revision: 340377

URL: http://llvm.org/viewvc/llvm-project?rev=340377=rev
Log:
[analyzer] [NFC] Extract a method for creating RefVal from RetEffect in 
RetainCountChecker

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

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=340377=340376=340377=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Tue Aug 21 18:16:49 2018
@@ -379,6 +379,17 @@ static QualType GetReturnType(const Expr
   return RetTy;
 }
 
+static Optional refValFromRetEffect(RetEffect RE,
+QualType ResultTy) {
+  if (RE.isOwned()) {
+return RefVal::makeOwned(RE.getObjKind(), ResultTy);
+  } else if (RE.notOwned()) {
+return RefVal::makeNotOwned(RE.getObjKind(), ResultTy);
+  }
+
+  return None;
+}
+
 // We don't always get the exact modeling of the function with regards to the
 // retain count checker even when the function is inlined. For example, we need
 // to stop tracking the symbols which were marked with StopTrackingHard.
@@ -515,43 +526,15 @@ void RetainCountChecker::checkSummary(co
   RE = RetEffect::MakeNoRet();
   }
 
-  switch (RE.getKind()) {
-default:
-  llvm_unreachable("Unhandled RetEffect.");
-
-case RetEffect::NoRet:
-case RetEffect::NoRetHard:
-  // No work necessary.
-  break;
-
-case RetEffect::OwnedSymbol: {
-  SymbolRef Sym = CallOrMsg.getReturnValue().getAsSymbol();
-  if (!Sym)
-break;
-
-  // Use the result type from the CallEvent as it automatically adjusts
-  // for methods/functions that return references.
-  QualType ResultTy = CallOrMsg.getResultType();
-  state = setRefBinding(state, Sym, RefVal::makeOwned(RE.getObjKind(),
-  ResultTy));
-
-  // FIXME: Add a flag to the checker where allocations are assumed to
-  // *not* fail.
-  break;
-}
-
-case RetEffect::NotOwnedSymbol: {
+  if (SymbolRef Sym = CallOrMsg.getReturnValue().getAsSymbol()) {
+QualType ResultTy = CallOrMsg.getResultType();
+if (RE.notOwned()) {
   const Expr *Ex = CallOrMsg.getOriginExpr();
-  SymbolRef Sym = CallOrMsg.getReturnValue().getAsSymbol();
-  if (!Sym)
-break;
   assert(Ex);
-  // Use GetReturnType in order to give [NSFoo alloc] the type NSFoo *.
-  QualType ResultTy = GetReturnType(Ex, C.getASTContext());
-  state = setRefBinding(state, Sym, RefVal::makeNotOwned(RE.getObjKind(),
- ResultTy));
-  break;
+  ResultTy = GetReturnType(Ex, C.getASTContext());
 }
+if (Optional updatedRefVal = refValFromRetEffect(RE, ResultTy))
+  state = setRefBinding(state, Sym, *updatedRefVal);
   }
 
   // This check is actually necessary; otherwise the statement builder thinks


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


[PATCH] D51079: Update the docs for using LLVM toolset in Visual Studio

2018-08-21 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340376: Update the docs for using LLVM toolset in Visual 
Studio (authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51079?vs=161863=161870#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51079

Files:
  cfe/trunk/docs/UsersManual.rst


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -2711,25 +2711,26 @@
 up using e.g. `vcvarsall.bat 
`_.
 
 clang-cl can also be used from inside Visual Studio by selecting the LLVM
-Platform Toolset. The toolset is installed by the LLVM installer, which can be
-downloaded from the `LLVM release `_ or
-`snapshot build `_ web pages. To use the toolset,
-select a project in Solution Explorer, open its Property Page (Alt+F7), and in
-the "General" section of "Configuration Properties" change "Platform Toolset"
-to e.g. LLVM-vs2014.
+Platform Toolset. The toolset is not part of the installer, but may be 
installed
+separately from the
+`Visual Studio Marketplace 
`_.
+To use the toolset, select a project in Solution Explorer, open its Property
+Page (Alt+F7), and in the "General" section of "Configuration Properties"
+change "Platform Toolset" to LLVM.  Doing so enables an additional Property
+Page for selecting the clang-cl executable to use for builds.
 
 To use the toolset with MSBuild directly, invoke it with e.g.
-``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl
-toolchain without modifying your project files.
+``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain
+without modifying your project files.
 
 It's also possible to point MSBuild at clang-cl without changing toolset by
 passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``.
 
 When using CMake and the Visual Studio generators, the toolset can be set with 
the ``-T`` flag:
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 ..
+cmake -G"Visual Studio 15 2017" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:


Index: cfe/trunk/docs/UsersManual.rst
===
--- cfe/trunk/docs/UsersManual.rst
+++ cfe/trunk/docs/UsersManual.rst
@@ -2711,25 +2711,26 @@
 up using e.g. `vcvarsall.bat `_.
 
 clang-cl can also be used from inside Visual Studio by selecting the LLVM
-Platform Toolset. The toolset is installed by the LLVM installer, which can be
-downloaded from the `LLVM release `_ or
-`snapshot build `_ web pages. To use the toolset,
-select a project in Solution Explorer, open its Property Page (Alt+F7), and in
-the "General" section of "Configuration Properties" change "Platform Toolset"
-to e.g. LLVM-vs2014.
+Platform Toolset. The toolset is not part of the installer, but may be installed
+separately from the
+`Visual Studio Marketplace `_.
+To use the toolset, select a project in Solution Explorer, open its Property
+Page (Alt+F7), and in the "General" section of "Configuration Properties"
+change "Platform Toolset" to LLVM.  Doing so enables an additional Property
+Page for selecting the clang-cl executable to use for builds.
 
 To use the toolset with MSBuild directly, invoke it with e.g.
-``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl
-toolchain without modifying your project files.
+``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain
+without modifying your project files.
 
 It's also possible to point MSBuild at clang-cl without changing toolset by
 passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``.
 
 When using CMake and the Visual Studio generators, the toolset can be set with the ``-T`` flag:
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 ..
+cmake -G"Visual Studio 15 2017" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340376 - Update the docs for using LLVM toolset in Visual Studio

2018-08-21 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Tue Aug 21 18:11:18 2018
New Revision: 340376

URL: http://llvm.org/viewvc/llvm-project?rev=340376=rev
Log:
Update the docs for using LLVM toolset in Visual Studio

Reviewers: hans

Subscribers: cfe-commits

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

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=340376=340375=340376=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Tue Aug 21 18:11:18 2018
@@ -2711,16 +2711,17 @@ Command Prompt or a regular Command Prom
 up using e.g. `vcvarsall.bat 
`_.
 
 clang-cl can also be used from inside Visual Studio by selecting the LLVM
-Platform Toolset. The toolset is installed by the LLVM installer, which can be
-downloaded from the `LLVM release `_ or
-`snapshot build `_ web pages. To use the toolset,
-select a project in Solution Explorer, open its Property Page (Alt+F7), and in
-the "General" section of "Configuration Properties" change "Platform Toolset"
-to e.g. LLVM-vs2014.
+Platform Toolset. The toolset is not part of the installer, but may be 
installed
+separately from the
+`Visual Studio Marketplace 
`_.
+To use the toolset, select a project in Solution Explorer, open its Property
+Page (Alt+F7), and in the "General" section of "Configuration Properties"
+change "Platform Toolset" to LLVM.  Doing so enables an additional Property
+Page for selecting the clang-cl executable to use for builds.
 
 To use the toolset with MSBuild directly, invoke it with e.g.
-``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl
-toolchain without modifying your project files.
+``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain
+without modifying your project files.
 
 It's also possible to point MSBuild at clang-cl without changing toolset by
 passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``.
@@ -2729,7 +2730,7 @@ When using CMake and the Visual Studio g
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 ..
+cmake -G"Visual Studio 15 2017" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:


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


[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-08-21 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 161866.
Quuxplusone added a comment.

Update to match the wording in D1144R0 draft revision 13. There's no longer any 
need to fail when we see a mutable member; on the other hand, we *always* need 
to perform the special member lookup to find out if our class is 
move-constructible and destructible.


Repository:
  rC Clang

https://reviews.llvm.org/D50119

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/DeclCXX.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Features.def
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/Type.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/Lexer/has_extension_cxx.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/SemaCXX/trivially-relocatable.cpp

Index: test/SemaCXX/trivially-relocatable.cpp
===
--- /dev/null
+++ test/SemaCXX/trivially-relocatable.cpp
@@ -0,0 +1,592 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// expected-diagnostics
+
+static_assert(__has_extension(trivially_relocatable), "");
+
+// It shall appear at most once in each attribute-list
+// and no attribute-argument-clause shall be present.
+
+struct [[trivially_relocatable, trivially_relocatable]] B1 {};
+// expected-error@-1{{attribute 'trivially_relocatable' cannot appear multiple times in an attribute specifier}}
+
+struct [[trivially_relocatable]] [[trivially_relocatable]] B2 {}; // should really be an error
+
+struct [[trivially_relocatable(42)]] B3 {};
+// expected-error@-1{{attribute 'trivially_relocatable' cannot have an argument list}}
+
+
+//   The first declaration of a type shall specify the
+//   trivially_relocatable attribute if any declaration of that
+//   type specifies the trivially_relocatable attribute.
+
+struct [[trivially_relocatable]] A1 {};  // ok
+struct [[trivially_relocatable]] A1;
+
+struct [[trivially_relocatable]] A2;  // ok
+struct [[trivially_relocatable]] A2 {};
+
+struct [[trivially_relocatable]] A3 {};  // ok
+struct A3;
+
+struct [[trivially_relocatable]] A4;  // ok
+struct A4 {};
+
+struct A5 {};
+struct [[trivially_relocatable]] A5;
+// expected-error@-1{{type A5 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+// expected-warning@-3{{attribute declaration must precede definition}}
+// expected-note@-5{{previous definition is here}}
+
+struct A6;
+struct [[trivially_relocatable]] A6 {};
+// expected-error@-1{{type A6 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+
+
+// If a type T is declared with the trivially_relocatable attribute, and T is
+// either not move-constructible or not destructible, the program is ill-formed.
+
+struct NonDestructible {
+NonDestructible(const NonDestructible&) = default;
+NonDestructible(NonDestructible&&) = default;
+~NonDestructible() = delete;
+};
+struct NonCopyConstructible {
+NonCopyConstructible(const NonCopyConstructible&) = delete;
+};
+struct NonMoveConstructible {
+NonMoveConstructible(const NonMoveConstructible&) = default;
+NonMoveConstructible(NonMoveConstructible&&) = delete;
+};
+static_assert(!__is_trivially_relocatable(NonDestructible), "");
+static_assert(!__is_trivially_relocatable(NonCopyConstructible), "");
+static_assert(!__is_constructible(NonCopyConstructible, NonCopyConstructible&&), "");
+static_assert(!__is_trivially_relocatable(NonMoveConstructible), "");
+static_assert(!__is_constructible(NonMoveConstructible, NonMoveConstructible&&), "");
+
+struct [[trivially_relocatable]] D1 { ~D1() = delete; };
+// expected-error@-1{{cannot be applied to struct 'D1' because it is not destructible}}
+
+struct [[trivially_relocatable]] D2 : private NonDestructible { };
+// expected-error@-1{{cannot be applied to struct 'D2' because it is not destructible}}
+
+struct [[trivially_relocatable]] D3 { D3(const D3&) = delete; };
+// expected-error@-1{{cannot be applied to struct 'D3' because it is not move-constructible}}
+
+struct [[trivially_relocatable]] D4 { D4(const D4&) = default; D4(D4&&) = delete; };
+// expected-error@-1{{cannot be applied to struct 'D4' because it is not move-constructible}}
+
+struct [[trivially_relocatable]] D5 : private NonCopyConstructible { };
+// expected-error@-1{{cannot be applied to struct 'D5' because it is not move-constructible}}
+static_assert(!__is_constructible(D5, D5&&), "");
+
+struct [[trivially_relocatable]] D6 : private NonMoveConstructible { D6(D6&&) = 

[PATCH] D50571: [clangd] add an extension field to LSP to transfer the diagnostic's category

2018-08-21 Thread João Távora via Phabricator via cfe-commits
joaotavora added a comment.



In https://reviews.llvm.org/D50571#1206020, @arphaman wrote:

> In https://reviews.llvm.org/D50571#1205650, @joaotavora wrote:
>
> > > LGTM. Let's watch out for possible breakages in any of the clients, 
> > > though. I've checked VSCode and it seems to be fine with the added fields.
> >
> > This isn't in the spec and broke the LSP client eglot 
> > (https://github.com/joaotavora/eglot/pull/81). Why don't you put this in 
> > the "source" field, or concat it to the "message" field.  Who can even use 
> > this information if it's not in the spec? Are clients supposed to code 
> > against every LSP server's whim?
>
>
> Thanks for the feedback. I'll make a patch that turns this off by default so 
> that clients can opt-in into it.


Thank you very much, and sorry if I came across a bit hostile.  What is this 
category field good for?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50571



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


[PATCH] D51079: Update the docs for using LLVM toolset in Visual Studio

2018-08-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D51079



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


[PATCH] D51069: Notify pending API removal in the release notes

2018-08-21 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340375: Notify pending API removal in the release notes 
(authored by hans, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51069

Files:
  cfe/branches/release_70/docs/ReleaseNotes.rst


Index: cfe/branches/release_70/docs/ReleaseNotes.rst
===
--- cfe/branches/release_70/docs/ReleaseNotes.rst
+++ cfe/branches/release_70/docs/ReleaseNotes.rst
@@ -265,7 +265,10 @@
 Clang. If upgrading an external codebase that uses Clang as a library,
 this section should help get you past the largest hurdles of upgrading.
 
--  ...
+- The methods ``getLocStart``, ``getStartLoc`` and ``getLocEnd`` in the AST 
+  classes are deprecated.  New APIs ``getBeginLoc`` and ``getEndLoc`` should 
+  be used instead.  While the old methods remain in this release, they will 
+  not be present in the next release of Clang.
 
 AST Matchers
 


Index: cfe/branches/release_70/docs/ReleaseNotes.rst
===
--- cfe/branches/release_70/docs/ReleaseNotes.rst
+++ cfe/branches/release_70/docs/ReleaseNotes.rst
@@ -265,7 +265,10 @@
 Clang. If upgrading an external codebase that uses Clang as a library,
 this section should help get you past the largest hurdles of upgrading.
 
--  ...
+- The methods ``getLocStart``, ``getStartLoc`` and ``getLocEnd`` in the AST 
+  classes are deprecated.  New APIs ``getBeginLoc`` and ``getEndLoc`` should 
+  be used instead.  While the old methods remain in this release, they will 
+  not be present in the next release of Clang.
 
 AST Matchers
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51069: Notify pending API removal in the release notes

2018-08-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D51069#1208591, @steveire wrote:

> @hans Could you commit this on my behalf? I was not able to do it myself for 
> some reason.
>
> $ svn commit 
>  svn: E175002: Commit failed (details follow):
>  svn: E175002: Unexpected HTTP status 400 'Bad Request' on 
> '/svn/llvm-project/!svn/act/2ca88059-6dd7-44fe-aa3e-9fc9f021f0bb'


Committed r340375.


Repository:
  rL LLVM

https://reviews.llvm.org/D51069



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


[PATCH] D51079: Update the docs for using LLVM toolset in Visual Studio

2018-08-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

@hans Consider backporting this.


Repository:
  rC Clang

https://reviews.llvm.org/D51079



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


[PATCH] D51069: Notify pending API removal in the release notes

2018-08-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

@hans Could you commit this on my behalf? I was not able to do it myself for 
some reason.

$ svn commit 
svn: E175002: Commit failed (details follow):
svn: E175002: Unexpected HTTP status 400 'Bad Request' on 
'/svn/llvm-project/!svn/act/2ca88059-6dd7-44fe-aa3e-9fc9f021f0bb'


Repository:
  rC Clang

https://reviews.llvm.org/D51069



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


[PATCH] D51079: Update the docs for using LLVM toolset in Visual Studio

2018-08-21 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: hans.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D51079

Files:
  docs/UsersManual.rst


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2711,25 +2711,26 @@
 up using e.g. `vcvarsall.bat 
`_.
 
 clang-cl can also be used from inside Visual Studio by selecting the LLVM
-Platform Toolset. The toolset is installed by the LLVM installer, which can be
-downloaded from the `LLVM release `_ or
-`snapshot build `_ web pages. To use the toolset,
-select a project in Solution Explorer, open its Property Page (Alt+F7), and in
-the "General" section of "Configuration Properties" change "Platform Toolset"
-to e.g. LLVM-vs2014.
+Platform Toolset. The toolset is not part of the installer, but may be 
installed
+separately from the
+`Visual Studio Marketplace 
`_.
+To use the toolset, select a project in Solution Explorer, open its Property
+Page (Alt+F7), and in the "General" section of "Configuration Properties"
+change "Platform Toolset" to LLVM.  Doing so enables an additional Property
+Page for selecting the clang-cl executable to use for builds.
 
 To use the toolset with MSBuild directly, invoke it with e.g.
-``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl
-toolchain without modifying your project files.
+``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain
+without modifying your project files.
 
 It's also possible to point MSBuild at clang-cl without changing toolset by
 passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``.
 
 When using CMake and the Visual Studio generators, the toolset can be set with 
the ``-T`` flag:
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 ..
+cmake -G"Visual Studio 15 2017" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2711,25 +2711,26 @@
 up using e.g. `vcvarsall.bat `_.
 
 clang-cl can also be used from inside Visual Studio by selecting the LLVM
-Platform Toolset. The toolset is installed by the LLVM installer, which can be
-downloaded from the `LLVM release `_ or
-`snapshot build `_ web pages. To use the toolset,
-select a project in Solution Explorer, open its Property Page (Alt+F7), and in
-the "General" section of "Configuration Properties" change "Platform Toolset"
-to e.g. LLVM-vs2014.
+Platform Toolset. The toolset is not part of the installer, but may be installed
+separately from the
+`Visual Studio Marketplace `_.
+To use the toolset, select a project in Solution Explorer, open its Property
+Page (Alt+F7), and in the "General" section of "Configuration Properties"
+change "Platform Toolset" to LLVM.  Doing so enables an additional Property
+Page for selecting the clang-cl executable to use for builds.
 
 To use the toolset with MSBuild directly, invoke it with e.g.
-``/p:PlatformToolset=LLVM-vs2014``. This allows trying out the clang-cl
-toolchain without modifying your project files.
+``/p:PlatformToolset=LLVM``. This allows trying out the clang-cl toolchain
+without modifying your project files.
 
 It's also possible to point MSBuild at clang-cl without changing toolset by
 passing ``/p:CLToolPath=c:\llvm\bin /p:CLToolExe=clang-cl.exe``.
 
 When using CMake and the Visual Studio generators, the toolset can be set with the ``-T`` flag:
 
   ::
 
-cmake -G"Visual Studio 15 2017" -T LLVM-vs2014 ..
+cmake -G"Visual Studio 15 2017" -T LLVM ..
 
 When using CMake with the Ninja generator, set the ``CMAKE_C_COMPILER`` and
 ``CMAKE_CXX_COMPILER`` variables to clang-cl:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Parse/ParseExpr.cpp:1126
+
+Actions.StartCheckingNoDeref();
+

leonardchan wrote:
> rsmith wrote:
> > This parser-driven start/stop mechanism will not work in C++ templates. 
> > Instead, can you remove the "start" part and check the noderef exprs as 
> > part of popping the ExprEvaluationContextRecord?
> I'm not sure if I should remove the the start and stop methods because for a 
> regular C program, the Push/PopExprEvaluationContextRecord functions don't 
> seem to be called, and even when they are called in C++, the initial record 
> that exists on the stack isn't popped at all.
> 
> Since pending noderef expressions are still parsed and added to the last 
> record during template instantiation, doing another check when popping covers 
> all noderef exprs added during instantiation.
`PushExpressionEvaluationContext` / `PopExpressionEvaluationContext` are called 
regardless of which language we're parsing. If we're missing 
`ExpressionEvaluationContext` records around some expression parsing, we should 
fix that. We should never be creating expressions within the initial 
`ExpressionEvaluationContext` record (except perhaps during error recovery).

> Since pending noderef expressions are still parsed and added to the last 
> record during template instantiation, doing another check when popping covers 
> all noderef exprs added during instantiation.

That's not how template instantiation works in Clang. We don't re-parse, we 
perform a recursive tree transformation that does not involve the parser.



Comment at: lib/Sema/SemaExpr.cpp:14230-14242
+class DeclRefFinder : public ConstEvaluatedExprVisitor {
+public:
+  typedef ConstEvaluatedExprVisitor Inherited;
+
+  DeclRefFinder(ASTContext ) : Inherited(Ctx) {}
+
+  void VisitDeclRefExpr(const DeclRefExpr *E) { DeclRef = E; }

leonardchan wrote:
> rsmith wrote:
> > rsmith wrote:
> > > I don't see any reason to assume that the `DeclRefExpr` found by this 
> > > visitor will be the one you're interested in (the one the `noderef` 
> > > attribute came from).
> > > 
> > > How about instead you walk over only expressions that you *know* preserve 
> > > `noderef`, and if you can't find a declaration as the source of the 
> > > `noderef` attribute, produce a differently-worded diagnostic that doesn't 
> > > give a variable name?
> > This comment is marked done but has not been addressed.
> My bad. My response to this was adding a check in 
> `StopCheckingNoDerefAndWarn` where we check if the `DeclRefExpr` is `nullptr` 
> and throw the appropriate error if it is found or not.
> 
> Although I can't come up with an example where this doesn't get the declref 
> we want, since the expressions we pass to this visitor are all our marked 
> noderef expressions (which we check via the attribute on the type). So even 
> if we have a complex expression that has multiple declrefs, all noderef 
> declrefs should be checked by this.
How about this:

```
int __attribute__((noderef)) *a;
int __attribute__((noderef)) *b;
int __attribute__((noderef)) *c;
*(a = b, c);
```

The first noderef pointer the visitor finds will be `a`, but that's not the one 
that was dereferenced.



Comment at: lib/Sema/SemaExpr.cpp:14251-14253
+if (const auto *Ptr = dyn_cast(Ty))
+  Inner = Ptr->getPointeeType();
+else if (const auto *Arr = dyn_cast(Ty))

aaron.ballman wrote:
> I don't think this strips off sugar from the type, so I suspect it won't 
> properly handle a typedef to a pointer type, for instance, or a type 
> including parens. You should add tests for these cases.
Calling `getDesugaredType` is not the right way to address this: use 
`Ty->getAs()` and `Context.getAsArrayType(Ty)` instead.



Comment at: lib/Sema/SemaExpr.cpp:4164-4177
+bool Sema::TypeHasNoDeref(QualType Ty) {
+  // Strip off everything but attributes.
+  QualType OldTy;
+  while (Ty != OldTy && !isa(Ty)) {
+OldTy = Ty;
+Ty = Ty.getSingleStepDesugaredType(Context);
+  }

You can just use `Ty->hasAttr(attr::NoDeref)` for this now.



Comment at: lib/Sema/SemaExpr.cpp:4263-4266
+  auto FoundExpr = LastRecord.PossibleDerefs.find(StrippedExpr);
+  if (FoundExpr != LastRecord.PossibleDerefs.end()) {
+LastRecord.PossibleDerefs.erase(*FoundExpr);
+  }

Do you need to do this both here and after walking into the `.` expressions? It 
seems to me that it would be sufficient to first walk into the LHS of any `.` 
expressions, and then remove the result from `PossibleDerefs`.



Comment at: lib/Sema/SemaExpr.cpp:4269
+  const Expr *Base = nullptr;
+  while (const auto *Member = dyn_cast(StrippedExpr)) {
+Base = Member->getBase()->IgnoreParenImpCasts();

You should check the `MemberExpr` is a `.` rather than a `->` before stepping 
into it.




[PATCH] D51077: [clangd] send diagnostic categories only when 'categorySupport' capability was given by the client

2018-08-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, dexonsmith, jkorous, MaskRay, ioeric.

After https://reviews.llvm.org/D50571 Clangd started sending categories with 
each diagnostic, but that broke the eglot client. This patch puts the 
categories behind a capability to fix that breakage.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51077

Files:
  clangd/ClangdLSPServer.cpp
  clangd/Diagnostics.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/compile-commands-path-in-initialize.test
  test/clangd/compile-commands-path.test
  test/clangd/diagnostic-category.test
  test/clangd/diagnostics.test
  test/clangd/did-change-configuration-params.test
  test/clangd/execute-command.test
  test/clangd/extra-flags.test
  test/clangd/fixits-embed-in-diagnostic.test
  test/clangd/fixits.test

Index: test/clangd/fixits.test
===
--- test/clangd/fixits.test
+++ test/clangd/fixits.test
@@ -6,7 +6,6 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/fixits-embed-in-diagnostic.test
===
--- test/clangd/fixits-embed-in-diagnostic.test
+++ test/clangd/fixits-embed-in-diagnostic.test
@@ -6,7 +6,6 @@
 # CHECK-NEXT:"params": {
 # CHECK-NEXT: "diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"clangd_fixes": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"edit": {
Index: test/clangd/extra-flags.test
===
--- test/clangd/extra-flags.test
+++ test/clangd/extra-flags.test
@@ -6,7 +6,6 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"message": "Variable 'i' is uninitialized when used here",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
@@ -29,7 +28,6 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"message": "Variable 'i' is uninitialized when used here",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/execute-command.test
===
--- test/clangd/execute-command.test
+++ test/clangd/execute-command.test
@@ -6,7 +6,6 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/did-change-configuration-params.test
===
--- test/clangd/did-change-configuration-params.test
+++ test/clangd/did-change-configuration-params.test
@@ -24,7 +24,6 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"message": "Variable 'i' is uninitialized when used here",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/diagnostics.test
===
--- test/clangd/diagnostics.test
+++ test/clangd/diagnostics.test
@@ -6,7 +6,6 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
-# CHECK-NEXT:"category": "Semantic Issue",
 # CHECK-NEXT:"message": "Return type of 'main' is not 'int'",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/diagnostic-category.test
===
--- /dev/null
+++ test/clangd/diagnostic-category.test
@@ -0,0 +1,43 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":{"publishDiagnostics":{"categorySupport":true}}},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"struct Point {}; union Point p;"}}}
+#  CHECK:"method": "textDocument/publishDiagnostics",
+# CHECK-NEXT:"params": {
+# CHECK-NEXT: "diagnostics": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"category": "Semantic Issue",
+# CHECK-NEXT:"message": "Use of 'Point' with tag type that does not 

[PATCH] D51068: [Android] Default to -fno-math-errno

2018-08-21 Thread Stephen Hines via Phabricator via cfe-commits
srhines accepted this revision.
srhines added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Driver/ToolChains/Linux.cpp:913
+return false;
+  return Generic_ELF::IsMathErrnoDefault();
+}

pirama wrote:
> I tried to be defensive here in case the default changes in the future.  I 
> can simplify to just return true here if that'd be simpler.
I agree with this, since this matches the present behavior.


Repository:
  rC Clang

https://reviews.llvm.org/D51068



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


[PATCH] D51069: Notify pending API removal in the release notes

2018-08-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Looks great, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D51069



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


[PATCH] D50814: [clangd] transfer the fixits with the notes instead of adding them to the main diagnostic if request by the client

2018-08-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D50814#1207219, @ilya-biryukov wrote:

> Just to make sure I fully understand the use-case: could you elaborate a 
> little more? Do you need to get exactly the same set of notes that clang 
> provides?


Yep. We are replacing libclang in a client that currently consumes diagnostics 
as provided by clang. We'd like to avoid regressions in the client, so we are 
looking to match the diagnostics provided by clangd, at least for now.
It might be possible to recreate the original hierarchy using the diagnostics 
that are currently provided by clangd using some heroics on the client-side. 
However, we'd like to avoid them for now and get the data from Clangd directly 
:)

> Our current model seems to follow the clang's model, but it removes some 
> notes and shows them as fix-its for the main diagnostic instead.
>  (We think it should provide a better user experience, because those notes do 
> look like a way to present a fix-it to the user when you have only text-based 
> output and they seem redundant when one has an editor-based UI with fix-its).

The current Clangd model certainly works well for newer clients who are built 
with LSP in mind from the get go. Sending diagnostics in a format similar to 
Clang's originals diagnostics would be helpful to clients that are 
transitioning though :)

> Not opposed to changing the model to meet other needs, but want to make sure 
> what we're currently doing in clangd makes sense and understand your use-case 
> better.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50814



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


[PATCH] D50926: [SourceManager] Extract 'findFileIDsForFile' from 'translateFile' to allow mapping from one file entry to multiple FileIDs

2018-08-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Basic/SourceManager.cpp:1705
 
   // If we haven't found what we want yet, try again, but this time stat()
   // each of the files in case the files have changed since we originally

ioeric wrote:
> Do we also need this in `findFileIDsForFile`?
I don't really need this for my use case.


Repository:
  rC Clang

https://reviews.llvm.org/D50926



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


[PATCH] D50926: [SourceManager] Extract 'findFileIDsForFile' from 'translateFile' to allow mapping from one file entry to multiple FileIDs

2018-08-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 161847.
arphaman marked an inline comment as done.
arphaman added a comment.

Address review comments


Repository:
  rC Clang

https://reviews.llvm.org/D50926

Files:
  include/clang/Basic/SourceManager.h
  lib/Basic/SourceManager.cpp
  unittests/Basic/SourceManagerTest.cpp

Index: unittests/Basic/SourceManagerTest.cpp
===
--- unittests/Basic/SourceManagerTest.cpp
+++ unittests/Basic/SourceManagerTest.cpp
@@ -377,6 +377,60 @@
   EXPECT_TRUE(SourceMgr.isBeforeInTranslationUnit(Macros[10].Loc, Macros[11].Loc));
 }
 
+TEST_F(SourceManagerTest, findFileIDsForFile) {
+  const char *header = "int x;";
+
+  const char *main = "#include \n"
+ "#include \n";
+
+  std::unique_ptr HeaderBuf =
+  llvm::MemoryBuffer::getMemBuffer(header);
+  std::unique_ptr MainBuf =
+  llvm::MemoryBuffer::getMemBuffer(main);
+
+  const FileEntry *HeaderFile =
+  FileMgr.getVirtualFile("/test-header.h", HeaderBuf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(HeaderFile, std::move(HeaderBuf));
+  const FileEntry *MainFile =
+  FileMgr.getVirtualFile("main.cpp", MainBuf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(MainFile, std::move(MainBuf));
+  SourceMgr.setMainFileID(
+  SourceMgr.createFileID(MainFile, SourceLocation(), SrcMgr::C_User));
+
+  TrivialModuleLoader ModLoader;
+  MemoryBufferCache PCMCache;
+  HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+  Diags, LangOpts, &*Target);
+  Preprocessor PP(std::make_shared(), Diags, LangOpts,
+  SourceMgr, PCMCache, HeaderInfo, ModLoader,
+  /*IILookup =*/nullptr,
+  /*OwnsHeaderSearch =*/false);
+  PP.Initialize(*Target);
+
+  PP.EnterMainSourceFile();
+
+  while (1) {
+Token tok;
+PP.Lex(tok);
+if (tok.is(tok::eof))
+  break;
+  }
+
+  llvm::SmallVector MainFileID =
+  SourceMgr.findFileIDsForFile(MainFile);
+  ASSERT_EQ(1U, MainFileID.size());
+  ASSERT_EQ(MainFileID[0], SourceMgr.getMainFileID());
+
+  llvm::SmallVector Files = SourceMgr.findFileIDsForFile(HeaderFile);
+
+  ASSERT_EQ(2U, Files.size());
+  ASSERT_NE(Files[0], Files[1]);
+  SourceLocation Loc1 = SourceMgr.translateLineCol(Files[0], 1, 1);
+  SourceLocation Loc2 = SourceMgr.translateLineCol(Files[1], 1, 1);
+  ASSERT_NE(Loc1, Loc2);
+  ASSERT_TRUE(SourceMgr.isBeforeInTranslationUnit(Loc1, Loc2));
+}
+
 #endif
 
 } // anonymous namespace
Index: lib/Basic/SourceManager.cpp
===
--- lib/Basic/SourceManager.cpp
+++ lib/Basic/SourceManager.cpp
@@ -1602,6 +1602,47 @@
   return translateLineCol(FirstFID, Line, Col);
 }
 
+bool SourceManager::findFileIDsForFile(
+const FileEntry *SourceFile,
+llvm::function_ref Callback) const {
+  assert(SourceFile && "Null source file!");
+
+  // Look through all of the local source locations.
+  for (unsigned I = 0, N = local_sloc_entry_size(); I != N; ++I) {
+bool Invalid = false;
+const SLocEntry  = getLocalSLocEntry(I, );
+if (Invalid)
+  return false;
+
+if (SLoc.isFile() && SLoc.getFile().getContentCache() &&
+SLoc.getFile().getContentCache()->OrigEntry == SourceFile) {
+  if (Callback(FileID::get(I)))
+return true;
+}
+  }
+
+  // If that still didn't help, try the modules.
+  for (unsigned I = 0, N = loaded_sloc_entry_size(); I != N; ++I) {
+const SLocEntry  = getLoadedSLocEntry(I);
+if (SLoc.isFile() && SLoc.getFile().getContentCache() &&
+SLoc.getFile().getContentCache()->OrigEntry == SourceFile) {
+  if (Callback(FileID::get(-int(I) - 2)))
+return true;
+}
+  }
+  return false;
+}
+
+llvm::SmallVector
+SourceManager::findFileIDsForFile(const FileEntry *SourceFile) const {
+  llvm::SmallVector Result;
+  findFileIDsForFile(SourceFile, [&](FileID F) {
+Result.push_back(F);
+return false;
+  });
+  return Result;
+}
+
 /// Get the FileID for the given file.
 ///
 /// If the source file is included multiple times, the FileID will be the
@@ -1650,35 +1691,16 @@
 }
   }
 
-  if (FirstFID.isInvalid()) {
-// The location we're looking for isn't in the main file; look
-// through all of the local source locations.
-for (unsigned I = 0, N = local_sloc_entry_size(); I != N; ++I) {
-  bool Invalid = false;
-  const SLocEntry  = getLocalSLocEntry(I, );
-  if (Invalid)
-return FileID();
+  if (FirstFID.isValid())
+return FirstFID;
 
-  if (SLoc.isFile() &&
-  SLoc.getFile().getContentCache() &&
-  SLoc.getFile().getContentCache()->OrigEntry == SourceFile) {
-FirstFID = FileID::get(I);
-break;
-  }
-}
-// If that still didn't help, try the modules.
-if (FirstFID.isInvalid()) {
-  for (unsigned I = 0, N = loaded_sloc_entry_size(); I != N; ++I) {
-const SLocEntry  = 

r340357 - Add space to TemplateArgument dump

2018-08-21 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Aug 21 15:55:26 2018
New Revision: 340357

URL: http://llvm.org/viewvc/llvm-project?rev=340357=rev
Log:
Add space to TemplateArgument dump

Add a missing space when dumping a template argument which is a template
expansion.  Found during debugging so no test.

Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=340357=340356=340357=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue Aug 21 15:55:26 2018
@@ -997,7 +997,7 @@ void ASTDumper::dumpTemplateArgument(con
   A.getAsTemplate().dump(OS);
   break;
 case TemplateArgument::TemplateExpansion:
-  OS << " template expansion";
+  OS << " template expansion ";
   A.getAsTemplateOrTemplatePattern().dump(OS);
   break;
 case TemplateArgument::Expression:


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


Re: r340181 - [OPENMP][BLOCKS]Fix PR38923: reference to a global variable is captured

2018-08-21 Thread Hans Wennborg via cfe-commits
Merged to 7.0 in r340352.

On Mon, Aug 20, 2018 at 9:00 AM, Alexey Bataev via cfe-commits
 wrote:
> Author: abataev
> Date: Mon Aug 20 09:00:22 2018
> New Revision: 340181
>
> URL: http://llvm.org/viewvc/llvm-project?rev=340181=rev
> Log:
> [OPENMP][BLOCKS]Fix PR38923: reference to a global variable is captured
> by a block.
>
> Added checks for capturing of the variable in the block when trying to
> emit correct address for the variable with the reference type. This
> extra check allows correctly identify the variables that are not
> captured in the block context.
>
> Added:
> cfe/trunk/test/CodeGenCXX/block-byref.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGExpr.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=340181=340180=340181=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Aug 20 09:00:22 2018
> @@ -2437,6 +2437,7 @@ LValue CodeGenFunction::EmitDeclRefLValu
>  // A DeclRefExpr for a reference initialized by a constant expression can
>  // appear without being odr-used. Directly emit the constant initializer.
>  const Expr *Init = VD->getAnyInitializer(VD);
> +const auto *BD = dyn_cast_or_null(CurCodeDecl);
>  if (Init && !isa(VD) && VD->getType()->isReferenceType() &&
>  VD->isUsableInConstantExpressions(getContext()) &&
>  VD->checkInitIsICE() &&
> @@ -2446,7 +2447,7 @@ LValue CodeGenFunction::EmitDeclRefLValu
>  (LocalDeclMap.count(VD->getCanonicalDecl()) ||
>   CapturedStmtInfo->lookup(VD->getCanonicalDecl( ||
> LambdaCaptureFields.lookup(VD->getCanonicalDecl()) ||
> -   isa(CurCodeDecl {
> +   (BD && BD->capturesVariable(VD) {
>llvm::Constant *Val =
>  ConstantEmitter(*this).emitAbstract(E->getLocation(),
>  *VD->evaluateValue(),
>
> Added: cfe/trunk/test/CodeGenCXX/block-byref.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/block-byref.cpp?rev=340181=auto
> ==
> --- cfe/trunk/test/CodeGenCXX/block-byref.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/block-byref.cpp Mon Aug 20 09:00:22 2018
> @@ -0,0 +1,15 @@
> +// RUN: %clang_cc1 %s -fblocks -triple x86_64-apple-darwin -std=c++11 
> -emit-llvm -o - | FileCheck %s
> +// REQUIRES: x86-registered-target
> +
> +// CHECK: @b = global i32 0,
> +
> +// CHECK: define {{.*}}void @{{.*}}test{{.*}}_block_invoke(
> +// CHECK: store i32 2, i32* @b,
> +// CHECK: ret void
> +
> +int b;
> +
> +void test() {
> +  int  = b;
> +  ^{ a = 2; };
> +}
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r340191 - [OPENMP] Fix crash on the emission of the weak function declaration.

2018-08-21 Thread Hans Wennborg via cfe-commits
Merged to 7.0 in r340351.

On Mon, Aug 20, 2018 at 11:03 AM, Alexey Bataev via cfe-commits
 wrote:
> Author: abataev
> Date: Mon Aug 20 11:03:40 2018
> New Revision: 340191
>
> URL: http://llvm.org/viewvc/llvm-project?rev=340191=rev
> Log:
> [OPENMP] Fix crash on the emission of the weak function declaration.
>
> If the function is actually a weak reference, it should not be marked as
> deferred definition as this is only a declaration. Patch adds checks for
> the definitions if they must be emitted. Otherwise, only declaration is
> emitted.
>
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/test/OpenMP/declare_target_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=340191=340190=340191=diff
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Aug 20 11:03:40 2018
> @@ -2558,15 +2558,17 @@ llvm::Constant *CodeGenModule::GetOrCrea
>  if (getLangOpts().OpenMPIsDevice && OpenMPRuntime &&
>  !OpenMPRuntime->markAsGlobalTarget(GD) && FD->isDefined() &&
>  !DontDefer && !IsForDefinition) {
> -  const FunctionDecl *FDDef = FD->getDefinition();
> -  GlobalDecl GDDef;
> -  if (const auto *CD = dyn_cast(FDDef))
> -GDDef = GlobalDecl(CD, GD.getCtorType());
> -  else if (const auto *DD = dyn_cast(FDDef))
> -GDDef = GlobalDecl(DD, GD.getDtorType());
> -  else
> -GDDef = GlobalDecl(FDDef);
> -  addDeferredDeclToEmit(GDDef);
> +  if (const FunctionDecl *FDDef = FD->getDefinition())
> +if (getContext().DeclMustBeEmitted(FDDef)) {
> +  GlobalDecl GDDef;
> +  if (const auto *CD = dyn_cast(FDDef))
> +GDDef = GlobalDecl(CD, GD.getCtorType());
> +  else if (const auto *DD = dyn_cast(FDDef))
> +GDDef = GlobalDecl(DD, GD.getDtorType());
> +  else
> +GDDef = GlobalDecl(FDDef);
> +  addDeferredDeclToEmit(GDDef);
> +}
>  }
>
>  if (FD->isMultiVersion()) {
>
> Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=340191=340190=340191=diff
> ==
> --- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Mon Aug 20 11:03:40 2018
> @@ -128,5 +128,19 @@ int baz2() {
>return 2 + baz3();
>  }
>
> +extern int create() throw();
> +
> +static __typeof(create) __t_create __attribute__((__weakref__("__create")));
> +
> +int baz5() {
> +  bool a;
> +// CHECK-DAG: define weak void 
> @__omp_offloading_{{.*}}baz5{{.*}}_l[[@LINE+1]](i64 {{.*}})
> +#pragma omp target
> +  a = __extension__(void *) & __t_create != 0;
> +  return a;
> +}
> +
> +// CHECK-DAG: declare extern_weak signext i32 @__create()
> +
>  // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}}
>  #endif // HEADER
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51068: [Android] Default to -fno-math-errno

2018-08-21 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added inline comments.



Comment at: lib/Driver/ToolChains/Linux.cpp:913
+return false;
+  return Generic_ELF::IsMathErrnoDefault();
+}

I tried to be defensive here in case the default changes in the future.  I can 
simplify to just return true here if that'd be simpler.


Repository:
  rC Clang

https://reviews.llvm.org/D51068



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


[PATCH] D51068: [Android] Default to -fno-math-errno

2018-08-21 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added reviewers: srhines, enh.

Android's libm does not set errno.


Repository:
  rC Clang

https://reviews.llvm.org/D51068

Files:
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  test/Driver/fast-math.c


Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -95,6 +95,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-fuchsia -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 //
 // Check that -ffast-math disables -fmath-errno, and -fno-fast-math merely
 // preserves the target default. Also check various flag set operations between
Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -38,6 +38,7 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
   bool isPIEDefault() const override;
+  bool IsMathErrnoDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -907,6 +907,12 @@
   getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
+bool Linux::IsMathErrnoDefault() const {
+  if (getTriple().isAndroid())
+return false;
+  return Generic_ELF::IsMathErrnoDefault();
+}
+
 SanitizerMask Linux::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;


Index: test/Driver/fast-math.c
===
--- test/Driver/fast-math.c
+++ test/Driver/fast-math.c
@@ -95,6 +95,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-fuchsia -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 //
 // Check that -ffast-math disables -fmath-errno, and -fno-fast-math merely
 // preserves the target default. Also check various flag set operations between
Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -38,6 +38,7 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
   bool isPIEDefault() const override;
+  bool IsMathErrnoDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -907,6 +907,12 @@
   getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
+bool Linux::IsMathErrnoDefault() const {
+  if (getTriple().isAndroid())
+return false;
+  return Generic_ELF::IsMathErrnoDefault();
+}
+
 SanitizerMask Linux::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43424: [clang-doc] Implement a (simple) Markdown generator

2018-08-21 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett reopened this revision.
juliehockett added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: kadircet.

Reopening because it was reverted and I haven't had time to look into it yet


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43424



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


[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2018-08-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clangd/Threading.cpp:76
+
+  if (::pthread_attr_setstacksize(, 8 * 1024 * 1024) != 0)
+return;

please use clang::DesiredStackSize instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50993



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


[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2018-08-21 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r340348, thanks!


https://reviews.llvm.org/D50979



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


r340348 - Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2018-08-21 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Aug 21 15:19:55 2018
New Revision: 340348

URL: http://llvm.org/viewvc/llvm-project?rev=340348=rev
Log:
Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

EmitX86BuiltinExpr() emits all args into Ops at the beginning, so don't do that
work again.

This changes behavior: If e.g. ++a was passed as an arg, we incremented a twice
previously. This change fixes that bug.

https://reviews.llvm.org/D50979

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/ms-intrinsics.c
cfe/trunk/test/CodeGen/ms-x86-intrinsics.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=340348=340347=340348=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Aug 21 15:19:55 2018
@@ -10528,14 +10528,11 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 llvm::Type *Int128PtrTy = Int128Ty->getPointerTo();
 
 Value *Destination =
-Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)), Int128PtrTy);
-Value *ExchangeHigh128 =
-Builder.CreateZExt(EmitScalarExpr(E->getArg(1)), Int128Ty);
-Value *ExchangeLow128 =
-Builder.CreateZExt(EmitScalarExpr(E->getArg(2)), Int128Ty);
-Address ComparandResult(
-Builder.CreateBitCast(EmitScalarExpr(E->getArg(3)), Int128PtrTy),
-getContext().toCharUnitsFromBits(128));
+Builder.CreateBitCast(Ops[0], Int128PtrTy);
+Value *ExchangeHigh128 = Builder.CreateZExt(Ops[1], Int128Ty);
+Value *ExchangeLow128 = Builder.CreateZExt(Ops[2], Int128Ty);
+Address ComparandResult(Builder.CreateBitCast(Ops[3], Int128PtrTy),
+getContext().toCharUnitsFromBits(128));
 
 Value *Exchange = Builder.CreateOr(
 Builder.CreateShl(ExchangeHigh128, 64, "", false, false),
@@ -10586,8 +10583,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__readfsdword:
   case X86::BI__readfsqword: {
 llvm::Type *IntTy = ConvertType(E->getType());
-Value *Ptr = Builder.CreateIntToPtr(EmitScalarExpr(E->getArg(0)),
-llvm::PointerType::get(IntTy, 257));
+Value *Ptr =
+Builder.CreateIntToPtr(Ops[0], llvm::PointerType::get(IntTy, 257));
 LoadInst *Load = Builder.CreateAlignedLoad(
 IntTy, Ptr, getContext().getTypeAlignInChars(E->getType()));
 Load->setVolatile(true);
@@ -10598,8 +10595,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__readgsdword:
   case X86::BI__readgsqword: {
 llvm::Type *IntTy = ConvertType(E->getType());
-Value *Ptr = Builder.CreateIntToPtr(EmitScalarExpr(E->getArg(0)),
-llvm::PointerType::get(IntTy, 256));
+Value *Ptr =
+Builder.CreateIntToPtr(Ops[0], llvm::PointerType::get(IntTy, 256));
 LoadInst *Load = Builder.CreateAlignedLoad(
 IntTy, Ptr, getContext().getTypeAlignInChars(E->getType()));
 Load->setVolatile(true);

Modified: cfe/trunk/test/CodeGen/ms-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics.c?rev=340348=340347=340348=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics.c Tue Aug 21 15:19:55 2018
@@ -416,14 +416,21 @@ __int64 test_InterlockedCompareExchange6
 // CHECK: }
 
 #if defined(__x86_64__)
-unsigned char test_InterlockedCompareExchange128(__int64 volatile 
*Destination, __int64 ExchangeHigh, __int64 ExchangeLow, __int64* 
ComparandResult) {
-  return _InterlockedCompareExchange128(Destination, ExchangeHigh, 
ExchangeLow, ComparandResult);
+unsigned char test_InterlockedCompareExchange128(
+__int64 volatile *Destination, __int64 ExchangeHigh,
+__int64 ExchangeLow, __int64 *ComparandResult) {
+  return _InterlockedCompareExchange128(++Destination, ++ExchangeHigh,
+++ExchangeLow, ++ComparandResult);
 }
 // CHECK-X64: define{{.*}}i8 @test_InterlockedCompareExchange128(i64*{{[a-z_ 
]*}}%Destination, i64{{[a-z_ ]*}}%ExchangeHigh, i64{{[a-z_ ]*}}%ExchangeLow, 
i64*{{[a-z_ ]*}}%ComparandResult){{.*}}{
-// CHECK-X64: [[DST:%[0-9]+]] = bitcast i64* %Destination to i128*
-// CHECK-X64: [[EH:%[0-9]+]] = zext i64 %ExchangeHigh to i128
-// CHECK-X64: [[EL:%[0-9]+]] = zext i64 %ExchangeLow to i128
-// CHECK-X64: [[CNR:%[0-9]+]] = bitcast i64* %ComparandResult to i128*
+// CHECK-X64: %incdec.ptr = getelementptr inbounds i64, i64* %Destination, i64 
1
+// CHECK-X64: %inc = add nsw i64 %ExchangeHigh, 1
+// CHECK-X64: %inc1 = add nsw i64 %ExchangeLow, 1
+// CHECK-X64: %incdec.ptr2 = getelementptr inbounds i64, i64* 
%ComparandResult, i64 1
+// CHECK-X64: [[DST:%[0-9]+]] = bitcast i64* %incdec.ptr to i128*
+// CHECK-X64: [[EH:%[0-9]+]] = zext i64 %inc to i128

[PATCH] D51011: [Preprocessor] raise gcc compatibility macros.

2018-08-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Thanks Eli.  I wholeheartedly prefer feature detection to explicit version 
checks.  One thing that makes this hard is the lack of __has_attribute in gcc: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66970.


Repository:
  rC Clang

https://reviews.llvm.org/D51011



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


[PATCH] D51011: [Preprocessor] raise gcc compatibility macros.

2018-08-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I'd suggest something like this, if you really need to detect the compiler:

  #if defined(__clang__)
  // clang
  #elif defined(__INTEL_COMPILER)
  // icc
  #elif defined(__GNUC__)
  // gcc
  #else
  #error "Unknown compiler"
  #endif



> Regarding the glibc headers, do you know why glibc doesn't just add code for 
> __clang__ rather than Clang (and ICC) claim to be a gcc compatible to a point 
> compiler?

clang pretends to be gcc 4.2 because that was the simplest way to make a lot of 
existing code work, at the time clang was written. clang supports almost all 
the language extensions supported by that version of gcc, so code was more 
likely to work if clang pretended to be gcc, rather than some unknown compiler. 
 And now, it would break a bunch of code if it changed, so it basically can't 
be changed.  This is similar to the history of web browser user agent strings.

For new code, we encourage users to use the feature checking macros 
(https://clang.llvm.org/docs/LanguageExtensions.html#feature-checking-macros ), 
rather than checking for specific compiler versions, where possible.


Repository:
  rC Clang

https://reviews.llvm.org/D51011



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


[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-21 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment.

In https://reviews.llvm.org/D50619#1207785, @JonasToth wrote:

> @shuaiwang Unfortunatly the analysis does not pass and fails on an assertion
>
>   → ~/opt/llvm/build/bin/clang-tidy 
> -checks=-*,cppcoreguidelines-const-correctness ItaniumDemangle.cpp --
>   clang-tidy: ../tools/clang/include/clang/AST/ExprCXX.h:3581: clang::Expr* 
> clang::CXXDependentScopeMemberExpr::getBase() const: Assertion 
> `!isImplicitAccess()' failed.
>   Abgebrochen (Speicherabzug geschrieben)
>
>
> I did not investigate further, sorry for the long time to try it out.


https://reviews.llvm.org/D50617 updated, could you help try again? Thanks!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50619



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


[PATCH] D50617: [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr

2018-08-21 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 161830.
shuaiwang added a comment.

Fix issue with implicit access.


Repository:
  rC Clang

https://reviews.llvm.org/D50617

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1517,6 +1517,26 @@
 "struct X { int m; }; void f(X* x) { x->m; }",
 memberExpr(hasObjectExpression(
   hasType(pointsTo(recordDecl(hasName("X";
+  EXPECT_TRUE(matches("template  struct X { void f() { T t; t.m; } };",
+  cxxDependentScopeMemberExpr(hasObjectExpression(
+  declRefExpr(to(namedDecl(hasName("t";
+  EXPECT_TRUE(
+  matches("template  struct X { void f() { T t; t->m; } };",
+  cxxDependentScopeMemberExpr(hasObjectExpression(
+  declRefExpr(to(namedDecl(hasName("t";
+}
+
+TEST(HasObjectExpression, MatchesBaseOfMemberFunc) {
+  EXPECT_TRUE(matches(
+  "struct X { void f(); }; void g(X x) { x.f(); }",
+  memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")));
+  EXPECT_TRUE(matches("struct X { template  void f(); };"
+  "template  void g(X x) { x.f(); }",
+  unresolvedMemberExpr(hasObjectExpression(
+  hasType(recordDecl(hasName("X")));
+  EXPECT_TRUE(matches("template  void f(T t) { t.g(); }",
+  cxxDependentScopeMemberExpr(hasObjectExpression(
+  declRefExpr(to(namedDecl(hasName("t";
 }
 
 TEST(HasObjectExpression,
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -4806,8 +4806,17 @@
 ///   matches "x.m" and "m"
 /// with hasObjectExpression(...)
 ///   matching "x" and the implicit object expression of "m" which has type X*.
-AST_MATCHER_P(MemberExpr, hasObjectExpression,
-  internal::Matcher, InnerMatcher) {
+AST_POLYMORPHIC_MATCHER_P(
+hasObjectExpression,
+AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr,
+CXXDependentScopeMemberExpr),
+internal::Matcher, InnerMatcher) {
+  if (const auto *E = dyn_cast())
+if (E->isImplicitAccess())
+  return false;
+  if (const auto *E = dyn_cast())
+if (E->isImplicitAccess())
+  return false;
   return InnerMatcher.matches(*Node.getBase(), Finder, Builder);
 }
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -4668,6 +4668,20 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html;>CXXDependentScopeMemberExprhasObjectExpressionMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Expr.html;>Expr InnerMatcher
+Matches a member expression where the object expression is
+matched by a given matcher.
+
+Given
+  struct X { int m; };
+  void f(X x) { x.m; m; }
+memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))
+  matches "x.m" and "m"
+with hasObjectExpression(...)
+  matching "x" and the implicit object expression of "m" which has type X*.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html;>CXXForRangeStmthasBodyMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>Stmt InnerMatcher
 Matches a 'for', 'while', 'do while' statement or a function
 definition that has a given body.
@@ -6692,6 +6706,20 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html;>UnresolvedMemberExprhasObjectExpressionMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Expr.html;>Expr InnerMatcher
+Matches a member expression where the object expression is
+matched by a given matcher.
+
+Given
+  struct X { int m; };
+  void f(X x) { x.m; m; }
+memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))
+  matches "x.m" and "m"
+with hasObjectExpression(...)
+  matching "x" and the implicit object expression of "m" which has type X*.
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html;>UnresolvedUsingTypehasDeclarationconst Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl  InnerMatcher
 Matches a node if the declaration associated with that node
 matches the given matcher.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2018-08-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D50979



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


[PATCH] D50580: [clang-tidy] Abseil: no namespace check

2018-08-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:60
 
+- New :doc:`abseil-no-namespace
+  ` check.

Please sort new checks list alphabetically.



Comment at: docs/ReleaseNotes.rst:79
 
+>>> .r340314
 Improvements to include-fixer

Please remove merge conflict residual.


https://reviews.llvm.org/D50580



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


[PATCH] D50580: [clang-tidy] Abseil: no namespace check

2018-08-21 Thread Deanna Garcia via Phabricator via cfe-commits
deannagarcia updated this revision to Diff 161827.
deannagarcia marked 11 inline comments as done.

https://reviews.llvm.org/D50580

Files:
  clang-tidy/abseil/AbseilMatcher.h
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/NoNamespaceCheck.cpp
  clang-tidy/abseil/NoNamespaceCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-no-namespace.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/absl/external-file.h
  test/clang-tidy/Inputs/absl/strings/internal-file.h
  test/clang-tidy/abseil-no-namespace.cpp

Index: test/clang-tidy/abseil-no-namespace.cpp
===
--- test/clang-tidy/abseil-no-namespace.cpp
+++ test/clang-tidy/abseil-no-namespace.cpp
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s abseil-no-namespace %t -- -- -I %S/Inputs
+// RUN: clang-tidy -checks='-*, abseil-no-namespace' -header-filter='.*' %s -- -I %S/Inputs 2>&1 | FileCheck %s
+
+/// Warning will not be triggered on internal Abseil code that is included.
+#include "absl/strings/internal-file.h"
+// CHECK-NOT: warning:
+
+/// Warning will be triggered on code that is not internal that is included.
+#include "absl/external-file.h"
+// CHECK: absl/external-file.h:1:11: warning: namespace 'absl' is reserved
+// for implementation of the Abseil library and should not be opened in user
+// code [abseil-no-namespace]
+
+namespace absl {}
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'absl' is reserved for
+// implementation of the Abseil library and should not be opened in the user
+// code [abseil-no-namespace]
+
+namespace absl {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace 'absl'
+namespace std {
+int i = 5;
+}
+}
+
+// Things that shouldn't trigger the check
+int i = 5;
+namespace std {}
Index: test/clang-tidy/Inputs/absl/strings/internal-file.h
===
--- test/clang-tidy/Inputs/absl/strings/internal-file.h
+++ test/clang-tidy/Inputs/absl/strings/internal-file.h
@@ -0,0 +1 @@
+namespace absl {}
Index: test/clang-tidy/Inputs/absl/external-file.h
===
--- test/clang-tidy/Inputs/absl/external-file.h
+++ test/clang-tidy/Inputs/absl/external-file.h
@@ -0,0 +1 @@
+namespace absl {}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
 
 .. toctree::
abseil-duration-division
+   abseil-no-namespace
abseil-string-find-startswith
android-cloexec-accept
android-cloexec-accept4
Index: docs/clang-tidy/checks/abseil-no-namespace.rst
===
--- docs/clang-tidy/checks/abseil-no-namespace.rst
+++ docs/clang-tidy/checks/abseil-no-namespace.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - abseil-no-namespace
+
+abseil-no-namespace
+===
+
+Ensures code does not open ``namespace absl`` as that violates Abseil's
+compatibility guidelines. Code should not open ``namespace absl`` as that
+conflicts with Abseil's compatibility guidelines and may result in breakage.
+
+Any code that uses:
+
+.. code-block:: c++
+
+ namespace absl {
+  ...
+ }
+
+will be prompted with a warning.
+
+See `the full Abseil compatibility guidelines `_ for more information.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,12 @@
 Improvements to clang-tidy
 --
 
+- New :doc:`abseil-no-namespace
+  ` check.
+
+  Ensures code does not open ``namespace absl`` as that violates Abseil's
+  compatibility guidelines.
+
 - New :doc:`abseil-duration-division
   ` check.
 
@@ -70,6 +76,7 @@
   Detects usage of magic numbers, numbers that are used as literals instead of
   introduced via constants or symbols.
 
+>>> .r340314
 Improvements to include-fixer
 -
 
Index: clang-tidy/abseil/NoNamespaceCheck.h
===
--- clang-tidy/abseil/NoNamespaceCheck.h
+++ clang-tidy/abseil/NoNamespaceCheck.h
@@ -0,0 +1,36 @@
+//===--- NoNamespaceCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_NONAMESPACECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_NONAMESPACECHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+/// This check ensures users don't open namespace absl, as that violates
+/// Abseil's compatibility 

[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2018-08-21 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 161824.
thakis edited the summary of this revision.
thakis added a comment.

Add tests.


https://reviews.llvm.org/D50979

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/ms-intrinsics.c
  clang/test/CodeGen/ms-x86-intrinsics.c

Index: clang/test/CodeGen/ms-x86-intrinsics.c
===
--- clang/test/CodeGen/ms-x86-intrinsics.c
+++ clang/test/CodeGen/ms-x86-intrinsics.c
@@ -7,34 +7,38 @@
 
 #if defined(__i386__)
 char test__readfsbyte(unsigned long Offset) {
-  return __readfsbyte(Offset);
+  return __readfsbyte(++Offset);
 }
 // CHECK-I386-LABEL: define dso_local signext i8 @test__readfsbyte(i32 %Offset)
-// CHECK-I386:   [[PTR:%[0-9]+]] = inttoptr i32 %Offset to i8 addrspace(257)*
+// CHECK-I386:   %inc = add i32 %Offset, 1
+// CHECK-I386:   [[PTR:%[0-9]+]] = inttoptr i32 %inc to i8 addrspace(257)*
 // CHECK-I386:   [[VALUE:%[0-9]+]] = load volatile i8, i8 addrspace(257)* [[PTR]], align 1
 // CHECK-I386:   ret i8 [[VALUE:%[0-9]+]]
 
 short test__readfsword(unsigned long Offset) {
-  return __readfsword(Offset);
+  return __readfsword(++Offset);
 }
 // CHECK-I386-LABEL: define dso_local signext i16 @test__readfsword(i32 %Offset)
-// CHECK-I386:   [[PTR:%[0-9]+]] = inttoptr i32 %Offset to i16 addrspace(257)*
+// CHECK-I386:   %inc = add i32 %Offset, 1
+// CHECK-I386:   [[PTR:%[0-9]+]] = inttoptr i32 %inc to i16 addrspace(257)*
 // CHECK-I386:   [[VALUE:%[0-9]+]] = load volatile i16, i16 addrspace(257)* [[PTR]], align 2
 // CHECK-I386:   ret i16 [[VALUE:%[0-9]+]]
 
 long test__readfsdword(unsigned long Offset) {
-  return __readfsdword(Offset);
+  return __readfsdword(++Offset);
 }
 // CHECK-I386-LABEL: define dso_local i32 @test__readfsdword(i32 %Offset)
-// CHECK-I386:   [[PTR:%[0-9]+]] = inttoptr i32 %Offset to i32 addrspace(257)*
+// CHECK-I386:   %inc = add i32 %Offset, 1
+// CHECK-I386:   [[PTR:%[0-9]+]] = inttoptr i32 %inc to i32 addrspace(257)*
 // CHECK-I386:   [[VALUE:%[0-9]+]] = load volatile i32, i32 addrspace(257)* [[PTR]], align 4
 // CHECK-I386:   ret i32 [[VALUE:%[0-9]+]]
 
 long long test__readfsqword(unsigned long Offset) {
-  return __readfsqword(Offset);
+  return __readfsqword(++Offset);
 }
 // CHECK-I386-LABEL: define dso_local i64 @test__readfsqword(i32 %Offset)
-// CHECK-I386:   [[PTR:%[0-9]+]] = inttoptr i32 %Offset to i64 addrspace(257)*
+// CHECK-I386:   %inc = add i32 %Offset, 1
+// CHECK-I386:   [[PTR:%[0-9]+]] = inttoptr i32 %inc to i64 addrspace(257)*
 // CHECK-I386:   [[VALUE:%[0-9]+]] = load volatile i64, i64 addrspace(257)* [[PTR]], align 8
 // CHECK-I386:   ret i64 [[VALUE:%[0-9]+]]
 #endif
@@ -60,37 +64,41 @@
 #if defined(__x86_64__)
 
 char test__readgsbyte(unsigned long Offset) {
-  return __readgsbyte(Offset);
+  return __readgsbyte(++Offset);
 }
 // CHECK-X64-LABEL: define dso_local i8 @test__readgsbyte(i32 %Offset)
-// CHECK-X64:   [[ZEXT:%[0-9]+]] = zext i32 %Offset to i64
+// CHECK-X64:   %inc = add i32 %Offset, 1
+// CHECK-X64:   [[ZEXT:%[0-9]+]] = zext i32 %inc to i64
 // CHECK-X64:   [[PTR:%[0-9]+]] = inttoptr i64 [[ZEXT]] to i8 addrspace(256)*
 // CHECK-X64:   [[VALUE:%[0-9]+]] = load volatile i8, i8 addrspace(256)* [[PTR]], align 1
 // CHECK-X64:   ret i8 [[VALUE:%[0-9]+]]
 
 short test__readgsword(unsigned long Offset) {
-  return __readgsword(Offset);
+  return __readgsword(++Offset);
 }
 // CHECK-X64-LABEL: define dso_local i16 @test__readgsword(i32 %Offset)
-// CHECK-X64:   [[ZEXT:%[0-9]+]] = zext i32 %Offset to i64
+// CHECK-X64:   %inc = add i32 %Offset, 1
+// CHECK-X64:   [[ZEXT:%[0-9]+]] = zext i32 %inc to i64
 // CHECK-X64:   [[PTR:%[0-9]+]] = inttoptr i64 [[ZEXT]] to i16 addrspace(256)*
 // CHECK-X64:   [[VALUE:%[0-9]+]] = load volatile i16, i16 addrspace(256)* [[PTR]], align 2
 // CHECK-X64:   ret i16 [[VALUE:%[0-9]+]]
 
 long test__readgsdword(unsigned long Offset) {
-  return __readgsdword(Offset);
+  return __readgsdword(++Offset);
 }
 // CHECK-X64-LABEL: define dso_local i32 @test__readgsdword(i32 %Offset)
-// CHECK-X64:   [[ZEXT:%[0-9]+]] = zext i32 %Offset to i64
+// CHECK-X64:   %inc = add i32 %Offset, 1
+// CHECK-X64:   [[ZEXT:%[0-9]+]] = zext i32 %inc to i64
 // CHECK-X64:   [[PTR:%[0-9]+]] = inttoptr i64 [[ZEXT]] to i32 addrspace(256)*
 // CHECK-X64:   [[VALUE:%[0-9]+]] = load volatile i32, i32 addrspace(256)* [[PTR]], align 4
 // CHECK-X64:   ret i32 [[VALUE:%[0-9]+]]
 
 long long test__readgsqword(unsigned long Offset) {
-  return __readgsqword(Offset);
+  return __readgsqword(++Offset);
 }
 // CHECK-X64-LABEL: define dso_local i64 @test__readgsqword(i32 %Offset)
-// CHECK-X64:   [[ZEXT:%[0-9]+]] = zext i32 %Offset to i64
+// CHECK-X64:   %inc = add i32 %Offset, 1
+// CHECK-X64:   [[ZEXT:%[0-9]+]] = zext i32 %inc to i64
 // CHECK-X64:   [[PTR:%[0-9]+]] = inttoptr i64 [[ZEXT]] to i64 addrspace(256)*
 // CHECK-X64:   [[VALUE:%[0-9]+]] = load volatile i64, i64 addrspace(256)* [[PTR]], align 8
 // CHECK-X64:   ret i64 [[VALUE:%[0-9]+]]

[PATCH] D50547: [Driver] Use normalized triples for multiarch runtime path

2018-08-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:372
 
-  const Driver  = getDriver();
-  SmallString<128> P(D.ResourceDir);
-  llvm::sys::path::append(P, D.getTargetTriple(), "lib");
-  if (getVFS().exists(P)) {
+  for (const auto  : getLibraryPaths()) {
+SmallString<128> P(LibPath);

One possible alternative I've considered would be to simply return 
`-lclang_rt..` instead of returning the full path when 
`getLibraryPaths()` is not empty. That should work because we add all paths in 
this list as `-L` in `AddFilePathLibArgs` and it's more consistent with e.g. 
`-lgcc_s`.


Repository:
  rC Clang

https://reviews.llvm.org/D50547



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


[PATCH] D50547: [Driver] Use normalized triples for multiarch runtime path

2018-08-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 161821.
Herald added a reviewer: javed.absar.

Repository:
  rC Clang

https://reviews.llvm.org/D50547

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan-preinit.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.fuzzer.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.scudo.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/i386-linux-gnu/lib/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan-preinit.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.fuzzer.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.scudo.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-linux-gnu/lib/libclang_rt.builtins.a


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -74,10 +74,17 @@
  const ArgList )
 : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
   CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
-  SmallString<128> P(D.ResourceDir);
+  SmallString<128> P;
+
+  P.assign(D.ResourceDir);
   llvm::sys::path::append(P, D.getTargetTriple(), "lib");
   if (getVFS().exists(P))
-getFilePaths().push_back(P.str());
+getLibraryPaths().push_back(P.str());
+
+  P.assign(D.ResourceDir);
+  llvm::sys::path::append(P, Triple.str(), "lib");
+  if (getVFS().exists(P))
+getLibraryPaths().push_back(P.str());
 
   std::string CandidateLibPath = getArchSpecificLibPath();
   if (getVFS().exists(CandidateLibPath))
@@ -362,12 +369,11 @@
   const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
 
-  const Driver  = getDriver();
-  SmallString<128> P(D.ResourceDir);
-  llvm::sys::path::append(P, D.getTargetTriple(), "lib");
-  if (getVFS().exists(P)) {
+  for (const auto  : getLibraryPaths()) {
+SmallString<128> P(LibPath);
 llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + 
Suffix);
-return P.str();
+if (getVFS().exists(P))
+  return P.str();
   }
 
   StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
@@ -765,6 +771,10 @@
   for (const auto  : getFilePaths())
 if(LibPath.length() > 0)
   CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+
+  for (const auto  : getLibraryPaths())
+if(LibPath.length() > 0)
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
 }
 
 void ToolChain::AddCCKextLibArgs(const ArgList ,
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -122,6 +122,9 @@
   /// The list of toolchain specific path prefixes to search for programs.
   path_list ProgramPaths;
 
+  /// The list of toolchain specific path prefixes to search for libraries.
+  path_list LibraryPaths;
+
   mutable std::unique_ptr Clang;
   mutable std::unique_ptr Assemble;
   mutable std::unique_ptr Link;
@@ -219,6 +222,9 @@
   path_list () { return ProgramPaths; }
   const path_list () const { return ProgramPaths; }
 
+  path_list () { return LibraryPaths; }
+  const path_list () const { return LibraryPaths; }
+
   const MultilibSet () const { return Multilibs; }
 
   const SanitizerArgs& getSanitizerArgs() const;


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -74,10 +74,17 @@
  const ArgList )
 : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
   CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
-  SmallString<128> P(D.ResourceDir);
+  SmallString<128> P;
+
+  P.assign(D.ResourceDir);
   llvm::sys::path::append(P, D.getTargetTriple(), "lib");
   if (getVFS().exists(P))
-getFilePaths().push_back(P.str());
+getLibraryPaths().push_back(P.str());
+
+  P.assign(D.ResourceDir);
+  llvm::sys::path::append(P, Triple.str(), "lib");
+  if (getVFS().exists(P))
+

[PATCH] D50547: [Driver] Use normalized triples for multiarch runtime path

2018-08-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I also need to create the following empty files for tests to pass (somehow 
those are not displayed by Phabricator):

  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan-preinit.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.asan.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.fuzzer.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.scudo.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/i386-linux-gnu/lib/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan-preinit.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.asan.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.builtins.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.fuzzer.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.scudo.so
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-linux-gnu/lib/libclang_rt.builtins.a


Repository:
  rC Clang

https://reviews.llvm.org/D50547



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


[PATCH] D50547: [Driver] Use normalized triples for multiarch runtime path

2018-08-21 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 161818.

Repository:
  rC Clang

https://reviews.llvm.org/D50547

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -74,10 +74,8 @@
  const ArgList )
 : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
   CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
-  SmallString<128> P(D.ResourceDir);
-  llvm::sys::path::append(P, D.getTargetTriple(), "lib");
-  if (getVFS().exists(P))
-getFilePaths().push_back(P.str());
+  if (llvm::Optional TargetLibPath = getTargetLibPath())
+getFilePaths().push_back(*TargetLibPath);
 
   std::string CandidateLibPath = getArchSpecificLibPath();
   if (getVFS().exists(CandidateLibPath))
@@ -362,10 +360,8 @@
   const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
 
-  const Driver  = getDriver();
-  SmallString<128> P(D.ResourceDir);
-  llvm::sys::path::append(P, D.getTargetTriple(), "lib");
-  if (getVFS().exists(P)) {
+  if (llvm::Optional TargetLibPath = getTargetLibPath()) {
+SmallString<128> P(*TargetLibPath);
 llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + 
Suffix);
 return P.str();
   }
@@ -384,6 +380,21 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
 }
 
+Optional ToolChain::getTargetLibPath() const {
+  const Driver  = getDriver();
+  SmallString<128> P(D.ResourceDir);
+  llvm::sys::path::append(P, D.getTargetTriple(), "lib");
+  if (getVFS().exists(P)) {
+return std::string(P.str());
+  } else {
+P.assign(D.ResourceDir);
+llvm::sys::path::append(P, Triple.str(), "lib");
+if (getVFS().exists(P))
+  return std::string(P.str());
+  }
+  return None;
+}
+
 std::string ToolChain::getArchSpecificLibPath() const {
   SmallString<128> Path(getDriver().ResourceDir);
   llvm::sys::path::append(Path, "lib", getOSLibName(),
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -362,6 +362,10 @@
  StringRef Component,
  bool Shared = false) const;
 
+  // Returns /lib/. This is used by runtimes to find
+  // per-target libraries.
+  Optional getTargetLibPath() const;
+
   // Returns /lib//.  This is used by runtimes (such
   // as OpenMP) to find arch-specific libraries.
   std::string getArchSpecificLibPath() const;


Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -74,10 +74,8 @@
  const ArgList )
 : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
   CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
-  SmallString<128> P(D.ResourceDir);
-  llvm::sys::path::append(P, D.getTargetTriple(), "lib");
-  if (getVFS().exists(P))
-getFilePaths().push_back(P.str());
+  if (llvm::Optional TargetLibPath = getTargetLibPath())
+getFilePaths().push_back(*TargetLibPath);
 
   std::string CandidateLibPath = getArchSpecificLibPath();
   if (getVFS().exists(CandidateLibPath))
@@ -362,10 +360,8 @@
   const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
   : (IsITANMSVCWindows ? ".lib" : ".a");
 
-  const Driver  = getDriver();
-  SmallString<128> P(D.ResourceDir);
-  llvm::sys::path::append(P, D.getTargetTriple(), "lib");
-  if (getVFS().exists(P)) {
+  if (llvm::Optional TargetLibPath = getTargetLibPath()) {
+SmallString<128> P(*TargetLibPath);
 llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + Suffix);
 return P.str();
   }
@@ -384,6 +380,21 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
 }
 
+Optional ToolChain::getTargetLibPath() const {
+  const Driver  = getDriver();
+  SmallString<128> P(D.ResourceDir);
+  llvm::sys::path::append(P, D.getTargetTriple(), "lib");
+  if (getVFS().exists(P)) {
+return std::string(P.str());
+  } else {
+P.assign(D.ResourceDir);
+llvm::sys::path::append(P, Triple.str(), "lib");
+if (getVFS().exists(P))
+  return std::string(P.str());
+  }
+  return None;
+}
+
 std::string ToolChain::getArchSpecificLibPath() const {
   SmallString<128> Path(getDriver().ResourceDir);
   llvm::sys::path::append(Path, "lib", getOSLibName(),
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -362,6 +362,10 @@
  

[PATCH] D51011: [Preprocessor] raise gcc compatibility macros.

2018-08-21 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Richard,
Thanks for the review, context, and suggestions.  I appreciate it.

> Can you instead change the kernel to require GCC >= 4.6 or some suitable 
> version of Clang?

Can you help me create an accurate C preprocessor check that the compiler in 
use is actually GCC and not Clang or ICC in emulation?

  #if defined(__GNU_C__) && !defined(__clang__)
  // we're gcc
  #elif defined(__clang__)
  // we're clang
  #elif defined(__INTEL_COMPILER)
  // we're icc
  #endif

Or maybe:

  #ifdef(__clang__)
  // we're clang
  #elif defined(__INTEL_COMPILER)
  // we're icc
  #else
  // default to gcc
  #endif

Maybe GCC has something better for this case than `__GNU_C__`?

Regarding the glibc headers, do you know why glibc doesn't just add code for 
`__clang__` rather than Clang (and ICC) claim to be a gcc compatible to a point 
compiler?

Regarding the command line addition, I'd prefer to fix the kernel's compiler 
detection, but I will keep your idea in mind.  It's good to have a few 
solutions in our back pockets should the preferred be shown to be faulty.

Thanks again.


Repository:
  rC Clang

https://reviews.llvm.org/D51011



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


Re: r314872 - We allow implicit function declarations as an extension in all C dialects. Remove OpenCL special case.

2018-08-21 Thread Richard Smith via cfe-commits
On Tue, 21 Aug 2018 at 07:41, Anastasia Stulova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> If there are no objections I would like to revert this old commit that
> coverts error about implicit function declaration into a warning.
>
>
> We have decided to generate an error for this
> https://reviews.llvm.org/D31745 because for OpenCL variadic prototypes
> are disallowed (section 6.9.e,
> https://www.khronos.org/registry/OpenCL/specs/opencl-2.0-openclc.pdf) and
> the implicit prototype requires variadic support.
>

This is incorrect. Implicit function declarations declare unprototyped
functions, which are *not* variadic, and are in fact supported by Clang's
OpenCL language mode.

See C90 6.5.4.3 Semantics, last paragraph, and 6.3.2.2 Semantics, second
paragraph.

So that argument does not appear to apply. The reason we accept
implicitly-declared functions outside of our C89 mode is because this is an
explicit, supported Clang extension. Generally, Clang intends to support
using all of its extensions together, unless there is some fundamental
reason why they cannot be combined. So, just as it doesn't make sense for
our OpenCL language mode to conflict with, say, AltiVec vector extensions,
it doesn't make sense for the OpenCL language mode to conflict with our
implicitly-declared functions extension.

I would have sympathy for your position if we did not produce an extension
warning on this construct by default. But we do, and it says the construct
is invalid in OpenCL; moreover, in our strict conformance mode
(-pedantic-errors), we reject the code.


> As most vendors that support OpenCL don't support variadic functions it
> was decided to restrict this explicitly in the spec (section s6.9.u). There
> is a little bit of more history in https://reviews.llvm.org/D17438.
>
> Currently the code that can't run correctly on most OpenCL targets
> compiles successfully. The problem can't be easily seen by the OpenCL
> developers since it's not very common to retrieve the compilation warning
> log during online compilation. Also generated IR doesn't seem to be
> correct if I compare with the similar code in C.
>
> Example:
>  1 typedef long long16 __attribute__((ext_vector_type(16)));
>  2 void test_somefunc( __global int *d, __global void *s )
>  3 {
>  4   int i = get_global_id(0);
>  5   d[i] = somefunc((( __global long16 *)s)[i]);
>  6 }
>
> Is generated to:
>
> %call1 = call i32 (<16 x i64>*, ...) bitcast (i32 ()* @somefunc to i32
> (<16 x i64>*, ...)*)(<16 x i64>* byval nonnull align 128
> %indirect-arg-temp) #2
> ...
>
> declare i32 @somefunc() local_unnamed_addr #1
>
> Equivalent C code at least generates variadic function prototype correctly
> :
>
> %call1 = call i32 (<16 x i64>*, ...) bitcast (i32 (...)* @somefunc to i32
> (<16 x i64>*, ...)*)(<16 x i64>* byval align 128 %indirect-arg-temp)
> ...
> declare i32 @somefunc(...)
>
> Anastasia
> --
> *From:* cfe-commits  on behalf of
> Richard Smith via cfe-commits 
> *Sent:* 04 October 2017 02:58
> *To:* cfe-commits@lists.llvm.org
> *Subject:* r314872 - We allow implicit function declarations as an
> extension in all C dialects. Remove OpenCL special case.
>
> Author: rsmith
> Date: Tue Oct  3 18:58:22 2017
> New Revision: 314872
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314872=rev
> Log:
> We allow implicit function declarations as an extension in all C dialects.
> Remove OpenCL special case.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl
> cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=314872=314871=314872=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct  3
> 18:58:22 2017
> @@ -355,7 +355,7 @@ def warn_implicit_function_decl : Warnin
>"implicit declaration of function %0">,
>InGroup, DefaultIgnore;
>  def ext_implicit_function_decl : ExtWarn<
> -  "implicit declaration of function %0 is invalid in C99">,
> +  "implicit declaration of function %0 is invalid in
> %select{C99|OpenCL}1">,
>InGroup;
>  def note_function_suggestion : Note<"did you mean %0?">;
>
> @@ -8449,8 +8449,6 @@ def err_opencl_scalar_type_rank_greater_
>  "element. (%0 and %1)">;
>  def err_bad_kernel_param_type : Error<
>"%0 cannot be used as the type of a kernel parameter">;
> -def err_opencl_implicit_function_decl : Error<
> -  "implicit declaration of function %0 is invalid in OpenCL">;
>  def err_record_with_pointers_kernel_param : Error<
>"%select{struct|union}0 kernel parameters may not contain pointers">;
>  def note_within_field_of_type : Note<
>
> 

[PATCH] D47814: Teach libc++ to use native NetBSD's max_align_t

2018-08-21 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

(To be clear, this continues to not be related to this patch, but happy to 
discuss...)




Comment at: include/stddef.h:55
 
 // Re-use the compiler's  max_align_t where possible.
 #if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) && \

ldionne wrote:
> chandlerc wrote:
> > Unrelated to your patch, but this comment is now amazingly out of place.
> Nope, based on `git blame` I think it's still where it should be.
I don't understand ... I'm not saying this patch has anything to do with it. 
But commenting *this* block with the above comment doesn't parse for me at 
all... Maybe its that the wording of the comment doesn't parse for me.

Perhaps what it means is "Only provide our own max_align_t (rather than relying 
on a compiler-provided one) when we have to by testing for the cases where the 
compiler's  won't work."?


Repository:
  rCXX libc++

https://reviews.llvm.org/D47814



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


[PATCH] D51026: [CodeGen] Implicitly set stackrealign on the main function, if custom stack alignment is used

2018-08-21 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340334: [CodeGen] Implicitly set stackrealign on the main 
function, if custom stack… (authored by mstorsjo, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51026?vs=161653=161809#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51026

Files:
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/CodeGen/stackrealign-main.c


Index: cfe/trunk/test/CodeGen/stackrealign-main.c
===
--- cfe/trunk/test/CodeGen/stackrealign-main.c
+++ cfe/trunk/test/CodeGen/stackrealign-main.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - 
-mstack-alignment=64 %s | FileCheck %s
+
+// CHECK-LABEL: define void @other()
+// CHECK: [[OTHER:#[0-9]+]]
+// CHECK: {
+void other(void) {}
+
+// CHECK-LABEL: define i32 @main(
+// CHECK: [[MAIN:#[0-9]+]]
+// CHECK: {
+int main(int argc, char **argv) {
+  other();
+  return 0;
+}
+
+// CHECK: attributes [[OTHER]] = { noinline nounwind optnone
+// CHECK-NOT: "stackrealign"
+// CHECK: }
+// CHECK: attributes [[MAIN]] = { noinline nounwind optnone 
{{.*}}"stackrealign"{{.*}} }
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -979,6 +979,13 @@
   if (FD->isMain())
 Fn->addFnAttr(llvm::Attribute::NoRecurse);
 
+  // If a custom alignment is used, force realigning to this alignment on
+  // any main function which certainly will need it.
+  if (const FunctionDecl *FD = dyn_cast_or_null(D))
+if ((FD->isMain() || FD->isMSVCRTEntryPoint()) &&
+CGM.getCodeGenOpts().StackAlignment)
+  Fn->addFnAttr("stackrealign");
+
   llvm::BasicBlock *EntryBB = createBasicBlock("entry", CurFn);
 
   // Create a marker to make it easy to insert allocas into the entryblock


Index: cfe/trunk/test/CodeGen/stackrealign-main.c
===
--- cfe/trunk/test/CodeGen/stackrealign-main.c
+++ cfe/trunk/test/CodeGen/stackrealign-main.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - -mstack-alignment=64 %s | FileCheck %s
+
+// CHECK-LABEL: define void @other()
+// CHECK: [[OTHER:#[0-9]+]]
+// CHECK: {
+void other(void) {}
+
+// CHECK-LABEL: define i32 @main(
+// CHECK: [[MAIN:#[0-9]+]]
+// CHECK: {
+int main(int argc, char **argv) {
+  other();
+  return 0;
+}
+
+// CHECK: attributes [[OTHER]] = { noinline nounwind optnone
+// CHECK-NOT: "stackrealign"
+// CHECK: }
+// CHECK: attributes [[MAIN]] = { noinline nounwind optnone {{.*}}"stackrealign"{{.*}} }
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -979,6 +979,13 @@
   if (FD->isMain())
 Fn->addFnAttr(llvm::Attribute::NoRecurse);
 
+  // If a custom alignment is used, force realigning to this alignment on
+  // any main function which certainly will need it.
+  if (const FunctionDecl *FD = dyn_cast_or_null(D))
+if ((FD->isMain() || FD->isMSVCRTEntryPoint()) &&
+CGM.getCodeGenOpts().StackAlignment)
+  Fn->addFnAttr("stackrealign");
+
   llvm::BasicBlock *EntryBB = createBasicBlock("entry", CurFn);
 
   // Create a marker to make it easy to insert allocas into the entryblock
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340334 - [CodeGen] Implicitly set stackrealign on the main function, if custom stack alignment is used

2018-08-21 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Tue Aug 21 13:41:17 2018
New Revision: 340334

URL: http://llvm.org/viewvc/llvm-project?rev=340334=rev
Log:
[CodeGen] Implicitly set stackrealign on the main function, if custom stack 
alignment is used

If using a custom stack alignment, one is expected to make sure
that all callers provide such alignment, or realign the stack in
all entry points (and callbacks).

Despite this, the compiler can assume that the main function will
need realignment in these cases, since the startup routines calling
the main function most probably won't provide the custom alignment.

This matches what GCC does in similar cases; if compiling with
-mincoming-stack-boundary=X -mpreferred-stack-boundary=X, GCC normally
assumes such alignment on entry to a function, but specifically for
the main function still does realignment.

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

Added:
cfe/trunk/test/CodeGen/stackrealign-main.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=340334=340333=340334=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Aug 21 13:41:17 2018
@@ -979,6 +979,13 @@ void CodeGenFunction::StartFunction(Glob
   if (FD->isMain())
 Fn->addFnAttr(llvm::Attribute::NoRecurse);
 
+  // If a custom alignment is used, force realigning to this alignment on
+  // any main function which certainly will need it.
+  if (const FunctionDecl *FD = dyn_cast_or_null(D))
+if ((FD->isMain() || FD->isMSVCRTEntryPoint()) &&
+CGM.getCodeGenOpts().StackAlignment)
+  Fn->addFnAttr("stackrealign");
+
   llvm::BasicBlock *EntryBB = createBasicBlock("entry", CurFn);
 
   // Create a marker to make it easy to insert allocas into the entryblock

Added: cfe/trunk/test/CodeGen/stackrealign-main.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/stackrealign-main.c?rev=340334=auto
==
--- cfe/trunk/test/CodeGen/stackrealign-main.c (added)
+++ cfe/trunk/test/CodeGen/stackrealign-main.c Tue Aug 21 13:41:17 2018
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - 
-mstack-alignment=64 %s | FileCheck %s
+
+// CHECK-LABEL: define void @other()
+// CHECK: [[OTHER:#[0-9]+]]
+// CHECK: {
+void other(void) {}
+
+// CHECK-LABEL: define i32 @main(
+// CHECK: [[MAIN:#[0-9]+]]
+// CHECK: {
+int main(int argc, char **argv) {
+  other();
+  return 0;
+}
+
+// CHECK: attributes [[OTHER]] = { noinline nounwind optnone
+// CHECK-NOT: "stackrealign"
+// CHECK: }
+// CHECK: attributes [[MAIN]] = { noinline nounwind optnone 
{{.*}}"stackrealign"{{.*}} }


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


Re: [PATCH] D50652: [libcxx] By default, do not use internal_linkage to hide symbols from the ABI

2018-08-21 Thread Hans Wennborg via cfe-commits
Yes. But in practice nothing really changed though, right? It's just
going forward that things might break:

"This is a change in contract but not a change in behavior, since the
current implementation still allows linking TUs built with different
libc++ versions together."

On Fri, Aug 17, 2018 at 10:03 AM, Louis Dionne via Phabricator
 wrote:
> ldionne added a comment.
>
> In https://reviews.llvm.org/D50652#1202524, @hans wrote:
>
>> Thanks! Merged to 7.0 in r339882.
>
>
> Now that this has been done, I guess we need to document somewhere in the 
> release notes that the default contract given by libc++ is changing in LLVM 
> 7, right?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D50652
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51025: [CodeGen] Fix handling of variables captured by a block that is nested inside a lambda

2018-08-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D51025



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


[PATCH] D50892: [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees

2018-08-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:187-191
   // If FR is a pointer pointing to a non-primitive type.
   if (Optional RecordV =
   DerefdV.getAs()) {
 
 const TypedValueRegion *R = RecordV->getRegion();

Szelethus wrote:
> NoQ wrote:
> > This looks like one more situation where we dereference a location to get a 
> > value and then struggle to get back to the location that we've dereferenced 
> > by looking at the value. Can we just use `V`?
> I've struggled with derefencing for months now -- I'm afraid I just don't 
> really get what you'd like to see here.
> 
> Here's what I attempted to implement:
> I'd like to obtain the pointee's region of a `Loc` region, even if it has to 
> be casted to another type, like through void pointers and 
> `nonloc::LocAsInteger`, and continue analysis on said region as usual.
> 
> The trickiest part I can't seem to get right is the acquisition of the 
> pointee region. For the problem this patch attempts to solve, even though 
> `DynT` correctly says that the dynamic type is `DynTDerived2 *`, `DerefdV` 
> contains a region for `DynTBase`.
> 
> I uploaded a new patch, D51057, which hopefully settles derefence related 
> issues. Please note that it **does not **replace this diff, as the acquired 
> region is still of type `DynTBase`.
> 
> I find understanding these intricate details of the analyzer very difficult, 
> as I found very little documentation about how this works, which often left 
> me guessing what the proper way to do this is. Can you recommend some 
> literature for me on this field?
> Can you recommend some literature for me on this field?

This is pretty specific to our analyzer. `SVal`/`SymExpr`/`MemRegion` hierarchy 
is tightly coupled to implementation details of the `RegionStore`, which is our 
memory model. There's a paper on it [1]. We have some in-tree documentation of 
the `RegionStore` [2] (other docs there are also interesting to read). And 
there's my old workbook [3]. And i guess that's it.

[1] Xu, Zhongxing & Kremenek, Ted & Zhang, Jian. (2010). A Memory Model for 
Static Analysis of C Programs. 535-548. 10.1007/978-3-642-16558-0_44.
[2] 
https://github.com/llvm-mirror/clang/blob/master/docs/analyzer/RegionStore.txt
[3] 
https://github.com/haoNoQ/clang-analyzer-guide/releases/download/v0.1/clang-analyzer-guide-v0.1.pdf


Repository:
  rC Clang

https://reviews.llvm.org/D50892



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


[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-21 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

OK, I've removed some of the dependencies on Windows-specific types. The code 
in `Unwind-seh.cpp` is very Windows-specific, though, so I left it alone.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564



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


[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-21 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x updated this revision to Diff 161807.
cdavis5x added a comment.

- Make a bit more friendly to non-Windows.
- Fix bits that depend on https://reviews.llvm.org/D50413.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564

Files:
  include/__libunwind_config.h
  include/unwind.h
  src/AddressSpace.hpp
  src/CMakeLists.txt
  src/Unwind-seh.cpp
  src/UnwindCursor.hpp
  src/UnwindLevel1-gcc-ext.c
  src/UnwindLevel1.c
  src/config.h
  src/libunwind_ext.h

Index: src/libunwind_ext.h
===
--- src/libunwind_ext.h
+++ src/libunwind_ext.h
@@ -17,6 +17,12 @@
 #include 
 #include 
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32)
+  #include 
+  #include 
+  #include 
+#endif
+
 #define UNW_STEP_SUCCESS 1
 #define UNW_STEP_END 0
 
@@ -33,6 +39,30 @@
 extern void _unw_add_dynamic_fde(unw_word_t fde);
 extern void _unw_remove_dynamic_fde(unw_word_t fde);
 
+// Provide a definition for the DISPATCHER_CONTEXT struct for old (Win7 and
+// earlier) SDKs.
+// MinGW-w64 has always provided this struct.
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && !defined(__MINGW32__) && VER_PRODUCTBUILD < 8000
+  #ifdef _WIN32
+#if defined(__x86_64__)
+struct _DISPATCHER_CONTEXT {
+  ULONG64 ControlPc;
+  ULONG64 ImageBase;
+  PRUNTIME_FUNCTION FunctionEntry;
+  ULONG64 EstablisherFrame;
+  ULONG64 TargetIp;
+  PCONTEXT ContextRecord;
+  PEXCEPTION_ROUTINE LanguageHandler;
+  PVOID HandlerData;
+  PUNWIND_HISTORY_TABLE HistoryTable;
+  ULONG ScopeIndex;
+  ULONG Fill0;
+};
+#endif
+  #endif
+typedef DISPATCHER_CONTEXT* PDISPATCHER_CONTEXT;
+#endif
+
 #if defined(_LIBUNWIND_ARM_EHABI)
 extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*);
 extern _Unwind_Reason_Code _Unwind_VRS_Interpret(_Unwind_Context *context,
Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -38,7 +38,11 @@
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
 #elif defined(_WIN32)
-  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+  #ifdef __SEH__
+#define _LIBUNWIND_SUPPORT_SEH_UNWIND 1
+  #else
+#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
+  #endif
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: src/UnwindLevel1.c
===
--- src/UnwindLevel1.c
+++ src/UnwindLevel1.c
@@ -32,6 +32,8 @@
 
 #if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__)
 
+#ifndef _LIBUNWIND_SUPPORT_SEH_UNWIND
+
 static _Unwind_Reason_Code
 unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
   unw_init_local(cursor, uc);
@@ -449,6 +451,7 @@
   return result;
 }
 
+#endif // !_LIBUNWIND_SUPPORT_SEH_UNWIND
 
 /// Called by personality handler during phase 2 if a foreign exception
 // is caught.
Index: src/UnwindLevel1-gcc-ext.c
===
--- src/UnwindLevel1-gcc-ext.c
+++ src/UnwindLevel1-gcc-ext.c
@@ -25,6 +25,10 @@
 
 #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS)
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+#define private_1 private_[0]
+#endif
+
 ///  Called by __cxa_rethrow().
 _LIBUNWIND_EXPORT _Unwind_Reason_Code
 _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) {
Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -18,18 +18,40 @@
 #include 
 #include 
 
+#ifdef _WIN32
+  #include 
+#endif
 #ifdef __APPLE__
   #include 
 #endif
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
+#  ifdef _LIBUNWIND_TARGET_X86_64
+struct UNWIND_INFO {
+  uint8_t Version : 3;
+  uint8_t Flags : 5;
+  uint8_t SizeOfProlog;
+  uint8_t CountOfCodes;
+  uint8_t FrameRegister : 4;
+  uint8_t FrameOffset : 4;
+  uint16_t UnwindCodes[2];
+};
+#  endif
+
+extern "C" _Unwind_Reason_Code __libunwind_seh_personality(
+int, _Unwind_Action, uint64_t, _Unwind_Exception *,
+struct _Unwind_Context *);
+
+#endif
+
 #include "config.h"
 
 #include "AddressSpace.hpp"
 #include "CompactUnwinder.hpp"
 #include "config.h"
 #include "DwarfInstructions.hpp"
 #include "EHHeaderParser.hpp"
-#include "libunwind.h"
+#include "libunwind_ext.h"
 #include "Registers.hpp"
 #include "RWMutex.hpp"
 #include "Unwind-EHABI.h"
@@ -412,6 +434,487 @@
 #endif
 };
 
+#if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) && defined(_WIN32)
+
+/// \c UnwindCursor contains all state (including all register values) during
+/// an unwind.  This is normally stack-allocated inside a unw_cursor_t.
+template 
+class UnwindCursor : public AbstractUnwindCursor {
+  typedef typename A::pint_t pint_t;
+public:
+  UnwindCursor(unw_context_t *context, A );
+  UnwindCursor(CONTEXT *context, A );
+  UnwindCursor(A , void *threadArg);
+  virtual  

[PATCH] D51057: [analyzer][UninitializedObjectChecker] Fixed dereferencing

2018-08-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yup, this looks great and that's exactly how i imagined it.




Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h:261-265
+inline bool isLocType(const QualType ) {
+  return T->isAnyPointerType() || T->isReferenceType() ||
+ T->isBlockPointerType();
+}
+

We have a fancy static `Loc::isLocType()`.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:126-127
   if (V.isUndef()) {
+assert(!FR->getDecl()->getType()->isReferenceType() &&
+   "References must be initialized!");
 return addFieldToUninits(

Good catch.

It might still be possible to initialize a reference with an already-undefined 
pointer if core checkers are turned off, but we don't support turning them off, 
so i guess it's fine.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:177
 
-  if (isPrimitiveUninit(V)) {
+  const SVal  = State->getSVal(loc::MemRegionVal(R));
+  if (isPrimitiveUninit(PointeeV)) {

Just `SVal`. And you should be able to pass `R` directly into `getSVal`.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:210
   assert(V.getAs() && "V must be loc::MemRegionVal!");
+  auto Tmp = V.getAs();
+

We usually just do `.getAsRegion()`.

And then later `dyn_cast` it.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:212-216
+  // We can't reason about symbolic regions, assume its initialized.
+  // Note that this also avoids a potential infinite recursion, because
+  // constructors for list-like classes are checked without being called, and
+  // the Static Analyzer will construct a symbolic region for Node *next; or
+  // similar code snippets.

Ok, i have a new concern that i didn't think about before.

There's nothing special about symbolic regions. You can make a linked list 
entirely of concrete regions:

```
struct List {
  List *next;
  List(): next(this) {}
};

void foo() {
  List list;
}
```

In this case the finite-ness of the type system won't save us.

I guess we could also memoize base regions that we visit :/ This is guaranteed 
to terminate because all of our concrete regions are based either on AST nodes 
(eg. global variables) or on certain events that happened previously during 
analysis (eg. local variables or temporaries, as they depend on the stack frame 
which must have been previously entered). I don't immediately see a better 
solution.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:223
+  const auto *R = Tmp->getRegionAs();
+  assert(R);
+

We might have eliminated symbolic regions but we may still have concrete 
function pointers (which are `TypedRegion`s that aren't `TypedValueRegion`s, 
it's pretty weird), and i guess we might even encounter an `AllocaRegion` 
(which is completely untyped). I guess we should not try to dereference them 
either.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:240-244
+if (Tmp->getRegion()->getSymbolicBase())
   return None;
-}
 
-V = State->getSVal(*Tmp, DynT);
+DynT = DynT->getPointeeType();
+R = Tmp->getRegionAs();

This code seems to be duplicated with the "0th iteration" before the loop. I 
guess you can put everything into the loop.


Repository:
  rC Clang

https://reviews.llvm.org/D51057



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


[PATCH] D51036: clang-format: Fix formatting C++ namespaces with preceding 'inline' or 'export' specifier

2018-08-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:129-130
+  // Detect "(inline|export)? namespace" in the beginning of a line.
+  if (NamespaceTok->is(tok::kw_inline) || NamespaceTok->is(tok::kw_export))
 NamespaceTok = NamespaceTok->getNextNonComment();
   if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))

owenpan wrote:
> ```
>   if (NamespaceTok && NamespaceTok->isOneOf(tok::kw_inline, tok::kw_export))
> ```
Actually, I meant it for line 129 only.


Repository:
  rC Clang

https://reviews.llvm.org/D51036



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


[PATCH] D48896: [libcxx][c++17] P0083R5: Splicing Maps and Sets Part 2: merge

2018-08-21 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D48896



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


[PATCH] D51008: Enable -fsanitize=fuzzer and -fsanitize=fuzzer-no-link on Windows.

2018-08-21 Thread Jonathan Metzman via Phabricator via cfe-commits
metzman abandoned this revision.
metzman added a comment.

Abandoning this revision since I think the libFuzzer on Windows changes would 
be easier to understand as part of one commit instead of three.
New revision here 


Repository:
  rC Clang

https://reviews.llvm.org/D51008



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


[PATCH] D51057: [analyzer][UninitializedObjectChecker] Fixed dereferencing

2018-08-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

@NoQ, is this how you imagined derefercing to work? I'm still a little 
uncertain that I implemented this in a way that addresses all your concerns.


Repository:
  rC Clang

https://reviews.llvm.org/D51057



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


[PATCH] D50892: [analyzer][UninitializedObjectChecker] Correct dynamic type is acquired for record pointees

2018-08-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp:187-191
   // If FR is a pointer pointing to a non-primitive type.
   if (Optional RecordV =
   DerefdV.getAs()) {
 
 const TypedValueRegion *R = RecordV->getRegion();

NoQ wrote:
> This looks like one more situation where we dereference a location to get a 
> value and then struggle to get back to the location that we've dereferenced 
> by looking at the value. Can we just use `V`?
I've struggled with derefencing for months now -- I'm afraid I just don't 
really get what you'd like to see here.

Here's what I attempted to implement:
I'd like to obtain the pointee's region of a `Loc` region, even if it has to be 
casted to another type, like through void pointers and `nonloc::LocAsInteger`, 
and continue analysis on said region as usual.

The trickiest part I can't seem to get right is the acquisition of the pointee 
region. For the problem this patch attempts to solve, even though `DynT` 
correctly says that the dynamic type is `DynTDerived2 *`, `DerefdV` contains a 
region for `DynTBase`.

I uploaded a new patch, D51057, which hopefully settles derefence related 
issues. Please note that it **does not **replace this diff, as the acquired 
region is still of type `DynTBase`.

I find understanding these intricate details of the analyzer very difficult, as 
I found very little documentation about how this works, which often left me 
guessing what the proper way to do this is. Can you recommend some literature 
for me on this field?


Repository:
  rC Clang

https://reviews.llvm.org/D50892



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


[PATCH] D51057: [analyzer][UninitializedObjectChecker] Fixed dereferencing

2018-08-21 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, xazax.hun, rnkovacs.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, 
whisperity.

This patch aims to fix derefencing, which has been debated for months now.

Instead of working with `SVal`s, the function now relies on `TypedValueRegion`.

Since this has been discussed since the inception of the checker, I'd very much 
prefer finding a permanent solution for this before moving forward.


Repository:
  rC Clang

https://reviews.llvm.org/D51057

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
  test/Analysis/cxx-uninitialized-object-ptr-ref.cpp

Index: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
===
--- test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -203,18 +203,14 @@
   CyclicPointerTest1();
 }
 
-// TODO: Currently, the checker ends up in an infinite loop for the following
-// test case.
-/*
 struct CyclicPointerTest2 {
-  int **pptr;
+  int **pptr; // no-crash
   CyclicPointerTest2() : pptr(reinterpret_cast()) {}
 };
 
 void fCyclicPointerTest2() {
   CyclicPointerTest2();
 }
-*/
 
 //===--===//
 // Void pointer tests.
Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
===
--- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedPointee.cpp
@@ -95,11 +95,13 @@
 /// known, and thus FD can not be analyzed.
 static bool isVoidPointer(QualType T);
 
-/// Dereferences \p V and returns the value and dynamic type of the pointee, as
-/// well as wether \p FR needs to be casted back to that type. If for whatever
-/// reason dereferencing fails, returns with None.
-static llvm::Optional>
-dereference(ProgramStateRef State, const FieldRegion *FR);
+using DereferenceInfo = std::pair;
+
+/// Dereferences \p FR and returns with the pointee's region, and whether it
+/// needs to be casted back to it's location type. If for whatever reason
+/// dereferencing fails, returns with None.
+static llvm::Optional dereference(ProgramStateRef State,
+   const FieldRegion *FR);
 
 //===--===//
 //   Methods for FindUninitializedFields.
@@ -110,9 +112,7 @@
 bool FindUninitializedFields::isPointerOrReferenceUninit(
 const FieldRegion *FR, FieldChainInfo LocalChain) {
 
-  assert((FR->getDecl()->getType()->isAnyPointerType() ||
-  FR->getDecl()->getType()->isReferenceType() ||
-  FR->getDecl()->getType()->isBlockPointerType()) &&
+  assert(isLocType(FR->getDecl()->getType()) &&
  "This method only checks pointer/reference objects!");
 
   SVal V = State->getSVal(FR);
@@ -123,6 +123,8 @@
   }
 
   if (V.isUndef()) {
+assert(!FR->getDecl()->getType()->isReferenceType() &&
+   "References must be initialized!");
 return addFieldToUninits(
 LocalChain.add(LocField(FR, /*IsDereferenced*/ false)));
   }
@@ -134,54 +136,46 @@
 
   // At this point the pointer itself is initialized and points to a valid
   // location, we'll now check the pointee.
-  llvm::Optional> DerefInfo =
-  dereference(State, FR);
+  llvm::Optional DerefInfo = dereference(State, FR);
   if (!DerefInfo) {
 IsAnyFieldInitialized = true;
 return false;
   }
 
-  V = std::get<0>(*DerefInfo);
-  QualType DynT = std::get<1>(*DerefInfo);
-  bool NeedsCastBack = std::get<2>(*DerefInfo);
+  const TypedValueRegion *R = DerefInfo->first;
+  const bool NeedsCastBack = DerefInfo->second;
 
-  // If FR is a pointer pointing to a non-primitive type.
-  if (Optional RecordV =
-  V.getAs()) {
+  QualType DynT = R->getLocationType();
+  QualType PointeeT = DynT->getPointeeType();
 
-const TypedValueRegion *R = RecordV->getRegion();
+  if (PointeeT->isStructureOrClassType()) {
+if (NeedsCastBack)
+  return isNonUnionUninit(R, LocalChain.add(NeedsCastLocField(FR, DynT)));
+return isNonUnionUninit(R, LocalChain.add(LocField(FR)));
+  }
 
-if (DynT->getPointeeType()->isStructureOrClassType()) {
+  if (PointeeT->isUnionType()) {
+if (isUnionUninit(R)) {
   if (NeedsCastBack)
-return isNonUnionUninit(R, LocalChain.add(NeedsCastLocField(FR, DynT)));
-  return isNonUnionUninit(R, LocalChain.add(LocField(FR)));
-}
-
-if (DynT->getPointeeType()->isUnionType()) {
-  if (isUnionUninit(R)) {
-if (NeedsCastBack)
-  return 

[PATCH] D51056: [ASTImporter] Add test for SwitchStmt

2018-08-21 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
Herald added subscribers: cfe-commits, martong.
Herald added a reviewer: a.sidorin.

Repository:
  rC Clang

https://reviews.llvm.org/D51056

Files:
  test/Import/switch-stmt/Inputs/F.cpp
  test/Import/switch-stmt/test.cpp


Index: test/Import/switch-stmt/test.cpp
===
--- /dev/null
+++ test/Import/switch-stmt/test.cpp
@@ -0,0 +1,47 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: SwitchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CaseStmt
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: <>
+// CHECK-NEXT: CaseStmt
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: <>
+// CHECK-NEXT: BreakStmt
+
+// CHECK: SwitchStmt
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-NEXT: <>
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CaseStmt
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: <>
+// CHECK-NEXT: BreakStmt
+// CHECK-NEXT: CaseStmt
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: <>
+// CHECK-NEXT: BreakStmt
+
+// CHECK: SwitchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: DefaultStmt
+// CHECK-NEXT: BreakStmt
+
+// CHECK: SwitchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: NullStmt
+
+void expr() {
+  f();
+}
Index: test/Import/switch-stmt/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/switch-stmt/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  switch (1) {
+  case 1:
+  case 2:
+break;
+  }
+  switch (int varname; 1) {
+  case 1:
+break;
+  case 2:
+break;
+  }
+  switch (1)
+  default:
+break;
+  switch (0)
+;
+}


Index: test/Import/switch-stmt/test.cpp
===
--- /dev/null
+++ test/Import/switch-stmt/test.cpp
@@ -0,0 +1,47 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: SwitchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CaseStmt
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: <>
+// CHECK-NEXT: CaseStmt
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: <>
+// CHECK-NEXT: BreakStmt
+
+// CHECK: SwitchStmt
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+// CHECK-NEXT: <>
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: CaseStmt
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: <>
+// CHECK-NEXT: BreakStmt
+// CHECK-NEXT: CaseStmt
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: <>
+// CHECK-NEXT: BreakStmt
+
+// CHECK: SwitchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: DefaultStmt
+// CHECK-NEXT: BreakStmt
+
+// CHECK: SwitchStmt
+// CHECK-NEXT: <>
+// CHECK-NEXT: <>
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: NullStmt
+
+void expr() {
+  f();
+}
Index: test/Import/switch-stmt/Inputs/F.cpp
===
--- /dev/null
+++ test/Import/switch-stmt/Inputs/F.cpp
@@ -0,0 +1,18 @@
+void f() {
+  switch (1) {
+  case 1:
+  case 2:
+break;
+  }
+  switch (int varname; 1) {
+  case 1:
+break;
+  case 2:
+break;
+  }
+  switch (1)
+  default:
+break;
+  switch (0)
+;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51026: [CodeGen] Implicitly set stackrealign on the main function, if custom stack alignment is used

2018-08-21 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




Comment at: lib/CodeGen/CodeGenFunction.cpp:989
+CGM.getCodeGenOpts().StackAlignment)
+  Fn->addFnAttr("stackrealign");
+

mstorsjo wrote:
> erichkeane wrote:
> > Is there not an attribute name for this already in LLVM?  I guess I'm 
> > otherwise fine with this, but would want @craig.topper or @rnk to confirm 
> > that we're Ok just sending this string as an attribute.
> I don't see one in llvm/include/llvm/IR/Attributes.td at least, and all other 
> occurrances in clang just use the plain string.
Yep, we use the string stackrealign attribute.


Repository:
  rC Clang

https://reviews.llvm.org/D51026



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


[PATCH] D51049: Driver: Enable address-significance tables by default when targeting COFF.

2018-08-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Remind me what the approximate size overhead of this is? I expect it is 
negligible, as most symbols are not address taken.


Repository:
  rL LLVM

https://reviews.llvm.org/D51049



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


[PATCH] D51021: ABI-Testsuite: Force the old c++11 ABI in mangling/test.xpp

2018-08-21 Thread Tom Stellard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340322: ABI-Testsuite: Force the old c++11 ABI in 
mangling/test.xpp (authored by tstellar, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D51021

Files:
  test-suite/trunk/ABI-Testsuite/test/mangling/test.xpp


Index: test-suite/trunk/ABI-Testsuite/test/mangling/test.xpp
===
--- test-suite/trunk/ABI-Testsuite/test/mangling/test.xpp
+++ test-suite/trunk/ABI-Testsuite/test/mangling/test.xpp
@@ -1,6 +1,6 @@
 // This file is distributed under the University of Illinois Open Source 
License.
 // See LICENSE.TXT for details.
-// RUN: cxx_compiler cxx_11 -c %s -o %t.o
+// RUN: cxx_compiler cxx_11 -D_GLIBCXX_USE_CXX11_ABI=0 -c %s -o %t.o
 // RUN: bindump %t.o | FileCheck -allow-deprecated-dag-overlap prefixes %s
 
 #include 


Index: test-suite/trunk/ABI-Testsuite/test/mangling/test.xpp
===
--- test-suite/trunk/ABI-Testsuite/test/mangling/test.xpp
+++ test-suite/trunk/ABI-Testsuite/test/mangling/test.xpp
@@ -1,6 +1,6 @@
 // This file is distributed under the University of Illinois Open Source License.
 // See LICENSE.TXT for details.
-// RUN: cxx_compiler cxx_11 -c %s -o %t.o
+// RUN: cxx_compiler cxx_11 -D_GLIBCXX_USE_CXX11_ABI=0 -c %s -o %t.o
 // RUN: bindump %t.o | FileCheck -allow-deprecated-dag-overlap prefixes %s
 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51020: MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMP: Fix build with newer libstdc++

2018-08-21 Thread Tom Stellard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340320: MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMP: Fix 
build with newer libstdc++ (authored by tstellar, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D51020

Files:
  test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h


Index: 
test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
===
--- test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
+++ test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
@@ -99,9 +99,9 @@
 
 struct cmp_str
 {
-   bool operator()(char const *a, char const *b)
+   bool operator()(const string , const string )
{
-  return strcmp(a, b) < 0;
+  return a.compare(b) < 0;
}
 };
 


Index: test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
===
--- test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
+++ test-suite/trunk/MultiSource/Benchmarks/DOE-ProxyApps-C++/CLAMR/MallocPlus.h
@@ -99,9 +99,9 @@
 
 struct cmp_str
 {
-   bool operator()(char const *a, char const *b)
+   bool operator()(const string , const string )
{
-  return strcmp(a, b) < 0;
+  return a.compare(b) < 0;
}
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In https://reviews.llvm.org/D49511#1206267, @rsmith wrote:

> In https://reviews.llvm.org/D49511#1206265, @rsmith wrote:
>
> > In https://reviews.llvm.org/D49511#1194716, @leonardchan wrote:
> >
> > > @rsmith any more feedback on this current version? If it still looks 
> > > incorrect to use the record this way, I don't mind simplifying it to work 
> > > on lvalue to rvalue conversions without checking for a leading address 
> > > space operation.
> >
> >
> > I've been thinking more about cleaner ways to implement this (and in 
> > particular, approaches that will provide more reasonable semantics in C++ 
> > -- allowing references to `noderef`, for example). We want to disallow 
> > operands of type `noderef T` to all operations by default, and only allow 
> > very specific operations on lvalues of type `noderef T` -- taking the 
> > address, performing member accesses, lvalue casts. The most natural way to 
> > get that effect would be to add a new form of placeholder type for a 
> > "dereferenced noderef" expression, that `CheckPlaceholderExpr` rejects, and 
> > that we add explicit support for in the contexts where such a construct is 
> > valid. (This is similar to how we handle overloaded function names and 
> > bound member function expressions in C++, for example.) (When we reach a 
> > context that "consumes" a dereferenced noderef expression, we'd need to go 
> > back and patch up its type, but I think that can be handled in a 
> > straightforward way.)
> >
> > I think we should also treat `noderef` more like a type qualifier: as an 
> > important example, if we have a pointer or reference to `noderef struct X`, 
> > then member access for a member of type `T` should give an lvalue of type 
> > `noderef T`.
>
>
> Sorry, I forgot to say: I do not think we need to do this for the initial 
> version of this functionality. This is mostly about cleanly extending the 
> functionality to cover more C++ constructs.


No problem. After this, I will make another patch that does this.


Repository:
  rC Clang

https://reviews.llvm.org/D49511



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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: lib/Parse/ParseExpr.cpp:1126
+
+Actions.StartCheckingNoDeref();
+

rsmith wrote:
> This parser-driven start/stop mechanism will not work in C++ templates. 
> Instead, can you remove the "start" part and check the noderef exprs as part 
> of popping the ExprEvaluationContextRecord?
I'm not sure if I should remove the the start and stop methods because for a 
regular C program, the Push/PopExprEvaluationContextRecord functions don't seem 
to be called, and even when they are called in C++, the initial record that 
exists on the stack isn't popped at all.

Since pending noderef expressions are still parsed and added to the last record 
during template instantiation, doing another check when popping covers all 
noderef exprs added during instantiation.



Comment at: lib/Sema/SemaExpr.cpp:14230-14242
+class DeclRefFinder : public ConstEvaluatedExprVisitor {
+public:
+  typedef ConstEvaluatedExprVisitor Inherited;
+
+  DeclRefFinder(ASTContext ) : Inherited(Ctx) {}
+
+  void VisitDeclRefExpr(const DeclRefExpr *E) { DeclRef = E; }

rsmith wrote:
> rsmith wrote:
> > I don't see any reason to assume that the `DeclRefExpr` found by this 
> > visitor will be the one you're interested in (the one the `noderef` 
> > attribute came from).
> > 
> > How about instead you walk over only expressions that you *know* preserve 
> > `noderef`, and if you can't find a declaration as the source of the 
> > `noderef` attribute, produce a differently-worded diagnostic that doesn't 
> > give a variable name?
> This comment is marked done but has not been addressed.
My bad. My response to this was adding a check in `StopCheckingNoDerefAndWarn` 
where we check if the `DeclRefExpr` is `nullptr` and throw the appropriate 
error if it is found or not.

Although I can't come up with an example where this doesn't get the declref we 
want, since the expressions we pass to this visitor are all our marked noderef 
expressions (which we check via the attribute on the type). So even if we have 
a complex expression that has multiple declrefs, all noderef declrefs should be 
checked by this.



Comment at: lib/Sema/SemaExpr.cpp:4291
+  const QualType  = Base->getType();
+  QualType ElemTy;
+  if (const auto *ArrayTy = dyn_cast(BaseTy))

rsmith wrote:
> Did you mean to use ElemTy somewhere below? (I'd guess you intended to check 
> whether it's marked noderef?)
Forgot to remove this.



Comment at: lib/Sema/SemaType.cpp:4816
+
+if (const auto *AT = dyn_cast(T))
+  IsNoDeref = AT->getAttrKind() == AttributedType::attr_noderef;

rsmith wrote:
> rsmith wrote:
> > Move this after the check below (directly setting ExpectNoDerefChunk 
> > instead), and remove the unnecessary IsNoDeref variable.
> This is not correct: there could be multiple attributes at this level. You 
> could fix this locally either by looping through the attributes on the type 
> or iterating through the ParsedAttrs on the chunk. But I think my preference 
> would be to store state indicating that we have an unvalidated noderef 
> attribute on the TypeProcessingState at the point where you create the 
> AttributedType, and check and clear that flag here when creating a type chunk.
After https://reviews.llvm.org/D50526, it seems that the attribute can also be 
applied in `ConvertDeclSpecToType`, so I added another check for the attributes 
there.


Repository:
  rC Clang

https://reviews.llvm.org/D49511



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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-08-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 161785.
leonardchan marked 6 inline comments as done and an inline comment as not done.

Repository:
  rC Clang

https://reviews.llvm.org/D49511

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaType.cpp
  test/Frontend/noderef.c
  test/Frontend/noderef_on_non_pointers.cpp
  test/Frontend/noderef_on_non_pointers.m
  test/Frontend/noderef_templates.cpp

Index: test/Frontend/noderef_templates.cpp
===
--- /dev/null
+++ test/Frontend/noderef_templates.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+template 
+int func(T NODEREF *a) { // expected-note 2 {{a declared here}}
+  return *a + 1; // expected-warning 2 {{dereferencing a; was declared with a 'noderef' type}}
+}
+
+void func() {
+  float NODEREF *f;
+  int NODEREF *i;
+  func(f); // expected-note{{in instantiation of function template specialization 'func' requested here}}
+  func(i); // expected-note{{in instantiation of function template specialization 'func' requested here}}
+}
Index: test/Frontend/noderef_on_non_pointers.m
===
--- /dev/null
+++ test/Frontend/noderef_on_non_pointers.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+@interface NSObject
++ (id)new;
+@end
+
+void func() {
+  id NODEREF obj = [NSObject new]; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
Index: test/Frontend/noderef_on_non_pointers.cpp
===
--- /dev/null
+++ test/Frontend/noderef_on_non_pointers.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fblocks -verify %s
+
+/**
+ * Test 'noderef' attribute against other pointer-like types.
+ */
+
+#define NODEREF __attribute__((noderef))
+
+void Normal() {
+  int NODEREF i;// expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int NODEREF *i_ptr;   // ok
+  int NODEREF **i_ptr2; // ok
+  int *NODEREF i_ptr3;  // expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int *NODEREF *i_ptr4; // ok
+
+  auto NODEREF *auto_i_ptr = i_ptr;
+  auto NODEREF auto_i = i; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+
+  struct {
+int x;
+int y;
+  } NODEREF *s;
+
+  int __attribute__((noderef(10))) * no_args; // expected-error{{'noderef' attribute takes no arguments}}
+}
+
+const int NODEREF *const_i_ptr;
+static int NODEREF *static_i_ptr;
+
+void ParenTypes() {
+  int NODEREF(*i_ptr);// ok (same as `int NODEREF *`)
+  int NODEREF *(*i_ptr2); // ok (same as `int NODEREF **`)
+}
+
+// Function declarations
+int NODEREF func();   // expected-warning{{'noderef' can only be used on an array or pointer type}}
+int NODEREF *func2(); // ok (returning pointer)
+
+typedef int NODEREF (*func3)(int); // expected-warning{{'noderef' can only be used on an array or pointer type}}
+typedef int NODEREF *(*func4)(int);
+
+void Arrays() {
+  int NODEREF i_arr[10];  // ok
+  int NODEREF i_arr2[10][10]; // ok
+  int NODEREF *i_arr3[10];// ok
+  int NODEREF i_arr4[] = {1, 2};
+}
+
+void ParenArrays() {
+  int NODEREF(i_ptr[10]);
+  int NODEREF(i_ptr2[10])[10];
+}
+
+typedef int NODEREF *(*func5[10])(int);
+
+// Arguments
+void func6(int NODEREF x); // expected-warning{{'noderef' can only be used on an array or pointer type}}
+void func7(int NODEREF *x);
+void func8() NODEREF;
+
+void References() {
+  int x = 2;
+  int NODEREF  = x; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+  int *xp = 
+  int NODEREF * = xp; // ok (reference to a NODEREF *)
+  int *NODEREF  = xp; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
+
+void BlockPointers() {
+  typedef int NODEREF (^IntBlock)(); // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
+
+class A {
+public:
+  int member;
+  int NODEREF *member2;
+  int NODEREF member3; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+};
+
+void MemberPointer() {
+  int NODEREF A::*var = ::member; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+}
+
+template 
+class B {
+  Ty NODEREF *member;
+  Ty NODEREF member2; // expected-warning{{'noderef' can only be used on an array or pointer type}}
+};
Index: test/Frontend/noderef.c
===
--- /dev/null
+++ test/Frontend/noderef.c
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -Wno-unused-value -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+struct S {
+  

[PATCH] D50564: Add support for SEH unwinding on Windows.

2018-08-21 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

In https://reviews.llvm.org/D50564#1207493, @kristina wrote:

> In https://reviews.llvm.org/D50564#1206393, @mstorsjo wrote:
>
> > In https://reviews.llvm.org/D50564#1206370, @cdavis5x wrote:
> >
> > > In https://reviews.llvm.org/D50564#1206302, @kristina wrote:
> > >
> > > > I'm all for this change except the core issue is that you're using 
> > > > libunwind as a shim around the actual unwinding API provided by 
> > > > Windows. It would be nice to have something that did not have to do 
> > > > that and was capable of performing unwinding of SEH-style exceptions 
> > > > without needing additional runtime support.
> > >
> > >
> > > It would be nice, but that would require extra work. We'd have to 
> > > implement reading and interpreting unwind codes, and calling any handlers 
> > > present at each frame (which all have a different calling convention from 
> > > Itanium handlers), and handling chained unwind info... Or we could use 
> > > the implementation that MS provided to us for free--and which gets loaded 
> > > into every process anyway by virtue of being in NTDLL, and which is 
> > > extremely well tested. Given all that, I'm wondering what implementing 
> > > all that ourselves would gain us. I suppose we could eventually do all 
> > > that, but for now, I think this is outside the scope of my change.
> >
> >
> > +1. I guess such a library would be very nice to have, but from the point 
> > of view of implementing exception handling, using the underlying APIs 
> > probably is the way to go. The other question, as posted before, is whether 
> > we want to wrap the whole CONTEXT structs in the UnwindCursor class and 
> > expose it via the unw_* set of APIs. It gives quite a significant amount of 
> > extra code here compared to libgcc's unwind-seh.c which is <500 loc 
> > altogether, providing only the _Unwind_* API, implementing it directly with 
> > the Windows Rtl* APIs from ntdll. That would give only a partial libunwind, 
> > with only the higher level API available, but that's the only part used for 
> > exception handling at least.
>
>
> That still makes the underlying assumption that SEH is exclusive to Windows 
> (and by that virtue PE/COFF) which doesn't necessarily hold true. There is 
> also the issue of generic names like `_LIBUNWIND_SUPPORT_SEH_UNWIND` to guard 
> includes of Windows specific headers which ties into my previous point. Would 
> it be possible to somehow abstract away the Windows runtime function call and 
> Windows specific header includes, even if it's via CMake options.
>
> I'm raising this issue as there are other implementations of SEH that share 
> the same (or extremely similar, depending on SDK versions) structures, but 
> would not have the Windows headers available when compiling libunwind, and 
> while the runtime function call to the `Rtl*` API is easy to change later on, 
> separating rest of it from Windows headers is slightly messier.
>
> Would it, at very least, be possible to decouple most of it from a dependency 
> on Windows headers and if possible use things like `void*` in place of 
> `PVOID` or anything that's `stdint.h/inttypes.h` friendly? It's an excellent 
> patch regardless but loosening the Windows SDK dependencies a bit would make 
> it a lot better.
>
> Would be much appreciated, as I'm going through a backlog of patches I'd like 
> to put up for review one of which includes SEH for x86_64 Linux (ELF) 
> implemented using RT signals and additional compiler runtime glue code, 
> currently residing within compiler-rt builtins (one of the issues I want to 
> address before). It's quite a wonky ABI since I tried to keep as much 
> compatible with 64-bit Windows SEH (`.xdata` variation) in terms of frame 
> lowering etc, but run-time mechanisms differ vastly for obvious reasons. 
> Having it interop with libunwind smoothly without rewriting much of existing 
> code in this patch would be nice, or even worse resorting to a million 
> preprocessor guards to cover all the cases.


Very well, then. I'll see what I can do.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50564



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


[PATCH] D44539: [Sema][Objective-C] Add check to warn when property of objc type has assign attribute

2018-08-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D44539



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


[PATCH] D51036: clang-format: Fix formatting C++ namespaces with preceding 'inline' or 'export' specifier

2018-08-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan requested changes to this revision.
owenpan added a comment.
This revision now requires changes to proceed.

By the way, I didn't review the test cases.




Comment at: lib/Format/FormatToken.h:524-525
+// Detect "(inline|export)? namespace" in the beginning of a line.
+if (NamespaceTok &&
+(NamespaceTok->is(tok::kw_inline) || NamespaceTok->is(tok::kw_export)))
   NamespaceTok = NamespaceTok->getNextNonComment();

```
if (NamespaceTok && NamespaceTok->isOneOf(tok::kw_inline, tok::kw_export))
```



Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:128-133
+  // Detect "(inline|export)? namespace" in the beginning of a line.
+  if (NamespaceTok->is(tok::kw_inline) || NamespaceTok->is(tok::kw_export))
 NamespaceTok = NamespaceTok->getNextNonComment();
   if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))
 return nullptr;
   return NamespaceTok;

These lines are functionally the same as lines 523-528 in FormatToken.h. 
Refactor them?



Comment at: lib/Format/NamespaceEndCommentsFixer.cpp:129-130
+  // Detect "(inline|export)? namespace" in the beginning of a line.
+  if (NamespaceTok->is(tok::kw_inline) || NamespaceTok->is(tok::kw_export))
 NamespaceTok = NamespaceTok->getNextNonComment();
   if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))

```
  if (NamespaceTok && NamespaceTok->isOneOf(tok::kw_inline, tok::kw_export))
```



Comment at: lib/Format/UnwrappedLineParser.cpp:992-998
   case tok::kw_inline:
 nextToken();
 if (FormatTok->Tok.is(tok::kw_namespace)) {
   parseNamespace();
   return;
 }
 break;

Move this case to after the case tok::kw_export below.



Comment at: lib/Format/UnwrappedLineParser.cpp:1066-1072
+if (Style.isCpp()) {
+  nextToken();
+  if (FormatTok->Tok.is(tok::kw_namespace)) {
+parseNamespace();
+return;
+  }
+}

```
if (!Style.isCpp())
  break;
  case tok::kw_inline:
nextToken();
if (FormatTok->Tok.is(tok::kw_namespace)) {
  parseNamespace();
  return;
}
```


Repository:
  rC Clang

https://reviews.llvm.org/D51036



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


[PATCH] D49811: [analyzer] Obtain a ReturnStmt from a CFGAutomaticObjDtor

2018-08-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.
Herald added a subscriber: Szelethus.

In https://reviews.llvm.org/D49811#1175927, @NoQ wrote:

> Devin has recently pointed out that we might have as well reordered CFG 
> elements to have return statement kick in after automatic destructors, so 
> that callbacks were called in a different order. I don't see any problems 
> with that solution, but let's stick to the current solution for now, because 
> who knows.




In https://bugs.llvm.org/show_bug.cgi?id=11645#c9 Ted wrote:

> If we treat an occurrence of "return" in the CFG is meaning "bind an 
> expression result for the return value" and not as a transfer of control then 
> it is is fine for the destructors to appear after the "return".  From this 
> view, the transfer back to the caller is when we hit the Exit block.


Another possible solution is to check in the destructor if the newly dangling 
pointer is already bound to the return statement.


Repository:
  rC Clang

https://reviews.llvm.org/D49811



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


[PATCH] D50855: [analyzer] pr37578: Fix lvalue/rvalue problem in field-of-temporary adjustments.

2018-08-21 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov requested changes to this revision.
george.karpenkov added a comment.
This revision now requires changes to proceed.

looks good apart from minor nits




Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h:744
+  const Expr *InitWithAdjustments, const Expr *Result = nullptr,
+  const SubRegion **OutRegionWithAdjustments = nullptr);
 

In general I would say that pair is still preferable, but I agree that with 
pre-c++17 codebase it gets too verbose.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:423
   // correctly in case (Result == Init).
-  State = State->BindExpr(Result, LC, Reg);
+  if (Result->isGLValue())
+State = State->BindExpr(Result, LC, Reg);

could we have braces here? Once we have "else" I would say we should have those.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:2543
   // Handle regular struct fields / member variables.
-  state = createTemporaryRegionIfNeeded(state, LCtx, BaseExpr);
-  SVal baseExprVal = state->getSVal(BaseExpr, LCtx);
+  const SubRegion *MR;
+  state = createTemporaryRegionIfNeeded(state, LCtx, BaseExpr,

Let's initialize that to nullptr


https://reviews.llvm.org/D50855



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


[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-21 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Sure, done in 340311!


Repository:
  rC Clang

https://reviews.llvm.org/D50994



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


r340311 - Address Aaron Ballman's post-commit review comments from r340306, NFC

2018-08-21 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Aug 21 10:50:10 2018
New Revision: 340311

URL: http://llvm.org/viewvc/llvm-project?rev=340311=rev
Log:
Address Aaron Ballman's post-commit review comments from r340306, NFC

Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaCXX/no_destroy.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=340311=340310=340311=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Aug 21 10:50:10 2018
@@ -5918,17 +5918,16 @@ static void handleOpenCLAccessAttr(Sema
 }
 
 static void handleDestroyAttr(Sema , Decl *D, const ParsedAttr ) {
-  if (!isa(D) || !cast(D)->hasGlobalStorage()) {
+  if (!cast(D)->hasGlobalStorage()) {
 S.Diag(D->getLocation(), diag::err_destroy_attr_on_non_static_var)
 << (A.getKind() == ParsedAttr::AT_AlwaysDestroy);
 return;
   }
 
-  if (A.getKind() == ParsedAttr::AT_AlwaysDestroy) {
+  if (A.getKind() == ParsedAttr::AT_AlwaysDestroy)
 handleSimpleAttributeWithExclusions(S, 
D, A);
-  } else {
+  else
 handleSimpleAttributeWithExclusions(S, 
D, A);
-  }
 }
 
 
//===--===//

Modified: cfe/trunk/test/SemaCXX/no_destroy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/no_destroy.cpp?rev=340311=340310=340311=diff
==
--- cfe/trunk/test/SemaCXX/no_destroy.cpp (original)
+++ cfe/trunk/test/SemaCXX/no_destroy.cpp Tue Aug 21 10:50:10 2018
@@ -38,3 +38,9 @@ int main() {
 
 [[clang::always_destroy]] [[clang::no_destroy]] int p; // 
expected-error{{'no_destroy' and 'always_destroy' attributes are not 
compatible}} // expected-note{{here}}
 [[clang::no_destroy]] [[clang::always_destroy]] int p2; // 
expected-error{{'always_destroy' and 'no_destroy' attributes are not 
compatible}} // expected-note{{here}}
+
+[[clang::always_destroy]] void f() {} // expected-warning{{'always_destroy' 
attribute only applies to variables}}
+struct [[clang::no_destroy]] DoesntApply {};  // 
expected-warning{{'no_destroy' attribute only applies to variables}}
+
+[[clang::no_destroy(0)]] int no_args; // expected-error{{'no_destroy' 
attribute takes no arguments}}
+[[clang::always_destroy(0)]] int no_args2; // expected-error{{'always_destroy' 
attribute takes no arguments}}


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


[PATCH] D51049: Driver: Enable address-significance tables by default when targeting COFF.

2018-08-21 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc created this revision.
pcc added a reviewer: rnk.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51049

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/addrsig.c


Index: clang/test/Driver/addrsig.c
===
--- clang/test/Driver/addrsig.c
+++ clang/test/Driver/addrsig.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### -target x86_64-unknown-linux -c %s 2>&1 | FileCheck 
-check-prefix=ADDRSIG %s
+// RUN: %clang -### -target x86_64-pc-win32 -c %s 2>&1 | FileCheck 
-check-prefix=ADDRSIG %s
 // RUN: %clang -### -target x86_64-unknown-linux -fno-integrated-as -c %s 2>&1 
| FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-unknown-linux -fno-integrated-as -faddrsig 
-c %s 2>&1 | FileCheck -check-prefix=ADDRSIG %s
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | 
FileCheck -check-prefix=NO-ADDRSIG %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4852,7 +4852,8 @@
   }
 
   if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,
-   getToolChain().getTriple().isOSBinFormatELF() &&
+   (getToolChain().getTriple().isOSBinFormatELF() ||
+getToolChain().getTriple().isOSBinFormatCOFF()) &&
getToolChain().useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 


Index: clang/test/Driver/addrsig.c
===
--- clang/test/Driver/addrsig.c
+++ clang/test/Driver/addrsig.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### -target x86_64-unknown-linux -c %s 2>&1 | FileCheck -check-prefix=ADDRSIG %s
+// RUN: %clang -### -target x86_64-pc-win32 -c %s 2>&1 | FileCheck -check-prefix=ADDRSIG %s
 // RUN: %clang -### -target x86_64-unknown-linux -fno-integrated-as -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-unknown-linux -fno-integrated-as -faddrsig -c %s 2>&1 | FileCheck -check-prefix=ADDRSIG %s
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4852,7 +4852,8 @@
   }
 
   if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,
-   getToolChain().getTriple().isOSBinFormatELF() &&
+   (getToolChain().getTriple().isOSBinFormatELF() ||
+getToolChain().getTriple().isOSBinFormatCOFF()) &&
getToolChain().useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Some minor nits that can be handled post-commit.




Comment at: lib/Sema/SemaDeclAttr.cpp:5921
+static void handleDestroyAttr(Sema , Decl *D, const ParsedAttr ) {
+  if (!isa(D) || !cast(D)->hasGlobalStorage()) {
+S.Diag(D->getLocation(), diag::err_destroy_attr_on_non_static_var)

There is no need to check `VarDecl` here -- that's already done for you by the 
subject.



Comment at: lib/Sema/SemaDeclAttr.cpp:5927-5931
+  if (A.getKind() == ParsedAttr::AT_AlwaysDestroy) {
+handleSimpleAttributeWithExclusions(S, 
D, A);
+  } else {
+handleSimpleAttributeWithExclusions(S, 
D, A);
+  }

Elide braces.



Comment at: test/SemaCXX/no_destroy.cpp:33-34
+int main() {
+  [[clang::no_destroy]] int p; // expected-error{{no_destroy attribute can 
only be applied to a variable with static or thread storage duration}}
+  [[clang::always_destroy]] int p2; // expected-error{{always_destroy 
attribute can only be applied to a variable with static or thread storage 
duration}}
+  [[clang::no_destroy]] static int p3;

Please also add tests demonstrating that the attribute does not appertain to 
things that don't look like variables (like a function or struct declaration) 
and that it does not accept arguments.


Repository:
  rC Clang

https://reviews.llvm.org/D50994



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


[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340306: Add a new flag and attributes to control static 
destructor registration (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50994?vs=161594=161757#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50994

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/AST/Decl.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGenCXX/always_destroy.cpp
  test/CodeGenCXX/no_destroy.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/SemaCXX/no_destroy.cpp
  test/SemaCXX/warn-exit-time-destructors.cpp

Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4832,6 +4832,10 @@
options::OPT_fno_complete_member_pointers, false))
 CmdArgs.push_back("-fcomplete-member-pointers");
 
+  if (!Args.hasFlag(options::OPT_fcxx_static_destructors,
+options::OPT_fno_cxx_static_destructors, true))
+CmdArgs.push_back("-fno-c++-static-destructors");
+
   if (Arg *A = Args.getLastArg(options::OPT_moutline,
options::OPT_mno_outline)) {
 if (A->getOption().matches(options::OPT_moutline)) {
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -2449,6 +2449,12 @@
   return hasDefinition();
 }
 
+bool VarDecl::isNoDestroy(const ASTContext ) const {
+  return hasGlobalStorage() && (hasAttr() ||
+(!Ctx.getLangOpts().RegisterStaticDestructors &&
+ !hasAttr()));
+}
+
 MemberSpecializationInfo *VarDecl::getMemberSpecializationInfo() const {
   if (isStaticDataMember())
 // FIXME: Remove ?
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -12910,6 +12910,9 @@
   if (ClassDecl->hasIrrelevantDestructor()) return;
   if (ClassDecl->isDependentContext()) return;
 
+  if (VD->isNoDestroy(getASTContext()))
+return;
+
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
   MarkFunctionReferenced(VD->getLocation(), Destructor);
   CheckDestructorAccess(VD->getLocation(), Destructor,
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5917,6 +5917,20 @@
   AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
+static void handleDestroyAttr(Sema , Decl *D, const ParsedAttr ) {
+  if (!isa(D) || !cast(D)->hasGlobalStorage()) {
+S.Diag(D->getLocation(), diag::err_destroy_attr_on_non_static_var)
+<< (A.getKind() == ParsedAttr::AT_AlwaysDestroy);
+return;
+  }
+
+  if (A.getKind() == ParsedAttr::AT_AlwaysDestroy) {
+handleSimpleAttributeWithExclusions(S, D, A);
+  } else {
+handleSimpleAttributeWithExclusions(S, D, A);
+  }
+}
+
 //===--===//
 // Top Level Sema Entry Points
 //===--===//
@@ -6587,6 +6601,11 @@
   case ParsedAttr::AT_Reinitializes:
 handleSimpleAttribute(S, D, AL);
 break;
+
+  case ParsedAttr::AT_AlwaysDestroy:
+  case ParsedAttr::AT_NoDestroy:
+handleDestroyAttr(S, D, AL);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2772,6 +2772,8 @@
   // -fallow-editor-placeholders
   Opts.AllowEditorPlaceholders = Args.hasArg(OPT_fallow_editor_placeholders);
 
+  Opts.RegisterStaticDestructors = !Args.hasArg(OPT_fno_cxx_static_destructors);
+
   if (Arg *A = Args.getLastArg(OPT_fclang_abi_compat_EQ)) {
 Opts.setClangABICompat(LangOptions::ClangABI::Latest);
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2342,6 +2342,9 @@
const VarDecl ,
llvm::Constant *dtor,
llvm::Constant *addr) {
+  if (D.isNoDestroy(CGM.getContext()))
+return;
+
   // Use __cxa_atexit if available.
   if (CGM.getCodeGenOpts().CXAAtExit)
 return emitGlobalDtorWithCXAAtExit(CGF, dtor, addr, 

[PATCH] D50994: Add a new flag and attributes to control static destructor registration

2018-08-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340306: Add a new flag and attributes to control static 
destructor registration (authored by epilk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50994?vs=161594=161756#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50994

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/AST/Decl.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/CodeGenCXX/always_destroy.cpp
  cfe/trunk/test/CodeGenCXX/no_destroy.cpp
  cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
  cfe/trunk/test/SemaCXX/no_destroy.cpp
  cfe/trunk/test/SemaCXX/warn-exit-time-destructors.cpp

Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -3486,3 +3486,22 @@
   };
   }];
 }
+
+def AlwaysDestroyDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``always_destroy`` attribute specifies that a variable with static or thread
+storage duration should have its exit-time destructor run. This attribute is the
+default unless clang was invoked with -fno-c++-static-destructors.
+  }];
+}
+
+def NoDestroyDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``no_destroy`` attribute specifies that a variable with static or thread
+storage duration shouldn't have its exit-time destructor run. Annotating every
+static and thread duration variable with this attribute is equivalent to
+invoking clang with -fno-c++-static-destructors.
+  }];
+}
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -3009,3 +3009,15 @@
   let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>;
   let Documentation = [ReinitializesDocs];
 }
+
+def NoDestroy : InheritableAttr {
+  let Spellings = [Clang<"no_destroy", 0>];
+  let Subjects = SubjectList<[Var]>;
+  let Documentation = [NoDestroyDocs];
+}
+
+def AlwaysDestroy : InheritableAttr {
+  let Spellings = [Clang<"always_destroy", 0>];
+  let Subjects = SubjectList<[Var]>;
+  let Documentation = [AlwaysDestroyDocs];
+}
Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -308,6 +308,8 @@
 LANGOPT(PaddingOnUnsignedFixedPoint, 1, 0,
 "unsigned fixed point types having one extra padding bit")
 
+LANGOPT(RegisterStaticDestructors, 1, 1, "Register C++ static destructors")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1809,6 +1809,10 @@
 def note_destructor_type_here : Note<
   "type %0 is declared here">;
 
+def err_destroy_attr_on_non_static_var : Error<
+  "%select{no_destroy|always_destroy}0 attribute can only be applied to a"
+  " variable with static or thread storage duration">;
+
 def err_destructor_template : Error<
   "destructor cannot be declared as a template">;
 
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -898,6 +898,13 @@
Flags<[CC1Option]>, HelpText<"Enable fixed point types">;
 def fno_fixed_point : Flag<["-"], "fno-fixed-point">, Group,
   HelpText<"Disable fixed point types">;
+def fcxx_static_destructors : Flag<["-"], "fc++-static-destructors">,
+  Group,
+  HelpText<"Enable C++ static destructor registration (the default)">;
+def fno_cxx_static_destructors : Flag<["-"], "fno-c++-static-destructors">,
+  Group,
+  Flags<[CC1Option]>,
+  HelpText<"Disable C++ static destructor registration">;
 
 // Begin sanitizer flags. These should all be core options exposed in all driver
 // modes.
Index: cfe/trunk/include/clang/AST/Decl.h
===
--- cfe/trunk/include/clang/AST/Decl.h
+++ 

r340306 - Add a new flag and attributes to control static destructor registration

2018-08-21 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Aug 21 10:24:06 2018
New Revision: 340306

URL: http://llvm.org/viewvc/llvm-project?rev=340306=rev
Log:
Add a new flag and attributes to control static destructor registration

This commit adds the flag -fno-c++-static-destructors and the attributes
[[clang::no_destroy]] and [[clang::always_destroy]]. no_destroy specifies that a
specific static or thread duration variable shouldn't have it's destructor
registered, and is the default in -fno-c++-static-destructors mode.
always_destroy is the opposite, and is the default in -fc++-static-destructors
mode.

A variable whose destructor is disabled (either because of
-fno-c++-static-destructors or [[clang::no_destroy]]) doesn't count as a use of
the destructor, so we don't do any access checking or mark it referenced. We
also don't emit -Wexit-time-destructors for these variables.

rdar://21734598

Differential revision: https://reviews.llvm.org/D50994

Added:
cfe/trunk/test/CodeGenCXX/always_destroy.cpp
cfe/trunk/test/CodeGenCXX/no_destroy.cpp
cfe/trunk/test/SemaCXX/no_destroy.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
cfe/trunk/test/SemaCXX/warn-exit-time-destructors.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=340306=340305=340306=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Aug 21 10:24:06 2018
@@ -1469,6 +1469,9 @@ public:
   // has no definition within this source file.
   bool isKnownToBeDefined() const;
 
+  /// Do we need to emit an exit-time destructor for this variable?
+  bool isNoDestroy(const ASTContext &) const;
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classofKind(Kind K) { return K >= firstVar && K <= lastVar; }

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=340306=340305=340306=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Aug 21 10:24:06 2018
@@ -3009,3 +3009,15 @@ def Reinitializes : InheritableAttr {
   let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>;
   let Documentation = [ReinitializesDocs];
 }
+
+def NoDestroy : InheritableAttr {
+  let Spellings = [Clang<"no_destroy", 0>];
+  let Subjects = SubjectList<[Var]>;
+  let Documentation = [NoDestroyDocs];
+}
+
+def AlwaysDestroy : InheritableAttr {
+  let Spellings = [Clang<"always_destroy", 0>];
+  let Subjects = SubjectList<[Var]>;
+  let Documentation = [AlwaysDestroyDocs];
+}

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=340306=340305=340306=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Aug 21 10:24:06 2018
@@ -3486,3 +3486,22 @@ a container class:
   };
   }];
 }
+
+def AlwaysDestroyDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``always_destroy`` attribute specifies that a variable with static or 
thread
+storage duration should have its exit-time destructor run. This attribute is 
the
+default unless clang was invoked with -fno-c++-static-destructors.
+  }];
+}
+
+def NoDestroyDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``no_destroy`` attribute specifies that a variable with static or thread
+storage duration shouldn't have its exit-time destructor run. Annotating every
+static and thread duration variable with this attribute is equivalent to
+invoking clang with -fno-c++-static-destructors.
+  }];
+}

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=340306=340305=340306=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue 

[PATCH] D50737: [ASTImporter] Add test for CXXNoexceptExpr

2018-08-21 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340304: [ASTImporter] Add test for CXXNoexceptExpr (authored 
by teemperor, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D50737

Files:
  test/Import/cxx-noexcept-expr/Inputs/F.cpp
  test/Import/cxx-noexcept-expr/test.cpp


Index: test/Import/cxx-noexcept-expr/test.cpp
===
--- test/Import/cxx-noexcept-expr/test.cpp
+++ test/Import/cxx-noexcept-expr/test.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXNoexceptExpr
+// CHECK-NEXT: IntegerLiteral
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-noexcept-expr/Inputs/F.cpp
===
--- test/Import/cxx-noexcept-expr/Inputs/F.cpp
+++ test/Import/cxx-noexcept-expr/Inputs/F.cpp
@@ -0,0 +1 @@
+bool f() { return noexcept(1); }


Index: test/Import/cxx-noexcept-expr/test.cpp
===
--- test/Import/cxx-noexcept-expr/test.cpp
+++ test/Import/cxx-noexcept-expr/test.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: CXXNoexceptExpr
+// CHECK-NEXT: IntegerLiteral
+
+void expr() {
+  f();
+}
Index: test/Import/cxx-noexcept-expr/Inputs/F.cpp
===
--- test/Import/cxx-noexcept-expr/Inputs/F.cpp
+++ test/Import/cxx-noexcept-expr/Inputs/F.cpp
@@ -0,0 +1 @@
+bool f() { return noexcept(1); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340304 - [ASTImporter] Add test for CXXNoexceptExpr

2018-08-21 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Tue Aug 21 10:15:57 2018
New Revision: 340304

URL: http://llvm.org/viewvc/llvm-project?rev=340304=rev
Log:
[ASTImporter] Add test for CXXNoexceptExpr

Reviewers: a.sidorin, a_sidorin

Reviewed By: a_sidorin

Subscribers: a_sidorin, hiraditya, martong, cfe-commits

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

Added:
cfe/trunk/test/Import/cxx-noexcept-expr/
cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/
cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp
cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp

Added: cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp?rev=340304=auto
==
--- cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp (added)
+++ cfe/trunk/test/Import/cxx-noexcept-expr/Inputs/F.cpp Tue Aug 21 10:15:57 
2018
@@ -0,0 +1 @@
+bool f() { return noexcept(1); }

Added: cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp?rev=340304=auto
==
--- cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp (added)
+++ cfe/trunk/test/Import/cxx-noexcept-expr/test.cpp Tue Aug 21 10:15:57 2018
@@ -0,0 +1,8 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXNoexceptExpr
+// CHECK-NEXT: IntegerLiteral
+
+void expr() {
+  f();
+}


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


[PATCH] D50737: [ASTImporter] Add test for CXXNoexceptExpr

2018-08-21 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added inline comments.



Comment at: test/Import/cxx-noexcept-expr/test.cpp:1
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+

hiraditya wrote:
> Can we add a line/comment to explain what this test does? Same for the input 
> files.
Well all the 'Import/' tests just try importing the respective AST 
node type and run checks on the node after importing. But we probably should 
reorganize the `test/Import` folder in the future, so then we can better 
document that the tests in the respective 'node-types` folder or so are 
supposed to do just this kind of check.


Repository:
  rC Clang

https://reviews.llvm.org/D50737



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


[PATCH] D50580: [clang-tidy] Abseil: no namespace check

2018-08-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please rebase from trunk.




Comment at: docs/ReleaseNotes.rst:63
+
+  Checks to ensure code does not open `namespace absl` as that
+  violates Abseil's compatibility guidelines.

Just Ensures. Please use `` for language constructs.



Comment at: docs/clang-tidy/checks/abseil-no-namespace.rst:6
+
+This check gives users a warning if they attempt to open ``namespace absl``.
+Users should not open ``namespace absl`` as that conflicts with abseil's

Please synchronize first sentence with Release Notes.



Comment at: docs/clang-tidy/checks/abseil-no-namespace.rst:7
+This check gives users a warning if they attempt to open ``namespace absl``.
+Users should not open ``namespace absl`` as that conflicts with abseil's
+compatibility guidelines and may result in breakage.

Abseil



Comment at: docs/clang-tidy/checks/abseil-no-namespace.rst:10
+
+Any user that uses:
+

Code instead of user, please.



Comment at: docs/clang-tidy/checks/abseil-no-namespace.rst:20
+
+See `the full Abseil compatibility guidelines `_ for more information.

Please remove space after https:


https://reviews.llvm.org/D50580



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


[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-21 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

@shuaiwang Unfortunatly the analysis does not pass and fails on an assertion

  → ~/opt/llvm/build/bin/clang-tidy 
-checks=-*,cppcoreguidelines-const-correctness ItaniumDemangle.cpp --
  clang-tidy: ../tools/clang/include/clang/AST/ExprCXX.h:3581: clang::Expr* 
clang::CXXDependentScopeMemberExpr::getBase() const: Assertion 
`!isImplicitAccess()' failed.
  Abgebrochen (Speicherabzug geschrieben)

I did not investigate further, sorry for the long time to try it out.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50619



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


[PATCH] D51021: ABI-Testsuite: Force the old c++11 ABI in mangling/test.xpp

2018-08-21 Thread Sunil Srivastava via Phabricator via cfe-commits
Sunil_Srivastava accepted this revision.
Sunil_Srivastava added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rT test-suite

https://reviews.llvm.org/D51021



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


[PATCH] D50970: [clangd] Implement BOOST iterator

2018-08-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/index/dex/Iterator.h:92
+  /// function, the parameter is needed to propagate through the tree.
+  virtual unsigned boost(DocID ID) const = 0;
 

Maybe add a note to the comment on why an `ID` parameter actually is here?
IIUC, we need to because various iterators in the tree may point to different 
elements and we need to know which one we've actually matched.



Comment at: clang-tools-extra/clangd/index/dex/Iterator.h:129
+std::vector>
+consumeAndBoost(Iterator ,
+size_t Limit = std::numeric_limits::max());

Could we describe the rationale for keeping both `consume` and 
`consumeAndBoost` somewhere in the comments?

From the offline conversation, it seems `consumeAndBoost` is more expensive, 
but our clients will all use it at some point in the future.
The idea of paying for boosting without actually using it seems bad, so keeping 
this function separate makes sense.



Comment at: clang-tools-extra/clangd/index/dex/Iterator.h:164
+std::unique_ptr createBoost(std::unique_ptr Child,
+  unsigned Factor);
+

Maybe use `float` scores to align with the scoring code we have for completion?


https://reviews.llvm.org/D50970



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


[PATCH] D50527: [Parser] Support alternative operator token keyword args in Objective-C++

2018-08-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340301: [Parser] Support alternative operator token keyword 
args in Objective-C++ (authored by epilk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50527?vs=159995=161748#toc

Repository:
  rC Clang

https://reviews.llvm.org/D50527

Files:
  lib/Parse/ParseExpr.cpp
  test/Parser/message-expr-alt-op.mm


Index: test/Parser/message-expr-alt-op.mm
===
--- test/Parser/message-expr-alt-op.mm
+++ test/Parser/message-expr-alt-op.mm
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface WeirdInterface
+-(void)allOfThem:(int)a
+ and:(int)b
+  and_eq:(int)c
+  bitand:(int)d
+   bitor:(int)e
+   compl:(int)f
+ not:(int)g
+  not_eq:(int)h
+  or:(int)i
+   or_eq:(int)j
+ xor:(int)k
+  xor_eq:(int)l;
+
+-(void)justAnd:(int)x and:(int)y;
+-(void)and;
+-(void)and:(int)x;
+@end
+
+void call_it(WeirdInterface *x) {
+  [x allOfThem:0
+   and:0
+and_eq:0
+bitand:0
+ bitor:0
+ compl:0
+   not:0
+not_eq:0
+or:0
+ or_eq:0
+   xor:0
+xor_eq:0];
+
+  [x and];
+  [x and:0];
+  [x &&:0]; // expected-error{{expected expression}};
+  [x justAnd:0 and:1];
+  [x and: 0 ? : 1];
+}
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -315,6 +315,19 @@
   return LHS;
 }
 
+// In Objective-C++, alternative operator tokens can be used as keyword 
args
+// in message expressions. Unconsume the token so that it can reinterpreted
+// as an identifier in ParseObjCMessageExpressionBody. i.e., we support:
+//   [foo meth:0 and:0];
+//   [foo not_eq];
+if (getLangOpts().ObjC1 && getLangOpts().CPlusPlus &&
+Tok.isOneOf(tok::colon, tok::r_square) &&
+OpToken.getIdentifierInfo() != nullptr) {
+  PP.EnterToken(Tok);
+  Tok = OpToken;
+  return LHS;
+}
+
 // Special case handling for the ternary operator.
 ExprResult TernaryMiddle(true);
 if (NextTokPrec == prec::Conditional) {


Index: test/Parser/message-expr-alt-op.mm
===
--- test/Parser/message-expr-alt-op.mm
+++ test/Parser/message-expr-alt-op.mm
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface WeirdInterface
+-(void)allOfThem:(int)a
+ and:(int)b
+  and_eq:(int)c
+  bitand:(int)d
+   bitor:(int)e
+   compl:(int)f
+ not:(int)g
+  not_eq:(int)h
+  or:(int)i
+   or_eq:(int)j
+ xor:(int)k
+  xor_eq:(int)l;
+
+-(void)justAnd:(int)x and:(int)y;
+-(void)and;
+-(void)and:(int)x;
+@end
+
+void call_it(WeirdInterface *x) {
+  [x allOfThem:0
+   and:0
+and_eq:0
+bitand:0
+ bitor:0
+ compl:0
+   not:0
+not_eq:0
+or:0
+ or_eq:0
+   xor:0
+xor_eq:0];
+
+  [x and];
+  [x and:0];
+  [x &&:0]; // expected-error{{expected expression}};
+  [x justAnd:0 and:1];
+  [x and: 0 ? : 1];
+}
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -315,6 +315,19 @@
   return LHS;
 }
 
+// In Objective-C++, alternative operator tokens can be used as keyword args
+// in message expressions. Unconsume the token so that it can reinterpreted
+// as an identifier in ParseObjCMessageExpressionBody. i.e., we support:
+//   [foo meth:0 and:0];
+//   [foo not_eq];
+if (getLangOpts().ObjC1 && getLangOpts().CPlusPlus &&
+Tok.isOneOf(tok::colon, tok::r_square) &&
+OpToken.getIdentifierInfo() != nullptr) {
+  PP.EnterToken(Tok);
+  Tok = OpToken;
+  return LHS;
+}
+
 // Special case handling for the ternary operator.
 ExprResult TernaryMiddle(true);
 if (NextTokPrec == prec::Conditional) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340301 - [Parser] Support alternative operator token keyword args in Objective-C++

2018-08-21 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Aug 21 09:47:04 2018
New Revision: 340301

URL: http://llvm.org/viewvc/llvm-project?rev=340301=rev
Log:
[Parser] Support alternative operator token keyword args in Objective-C++

rdar://30741878

Differential revision: https://reviews.llvm.org/D50527

Added:
cfe/trunk/test/Parser/message-expr-alt-op.mm
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=340301=340300=340301=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Aug 21 09:47:04 2018
@@ -315,6 +315,19 @@ Parser::ParseRHSOfBinaryExpression(ExprR
   return LHS;
 }
 
+// In Objective-C++, alternative operator tokens can be used as keyword 
args
+// in message expressions. Unconsume the token so that it can reinterpreted
+// as an identifier in ParseObjCMessageExpressionBody. i.e., we support:
+//   [foo meth:0 and:0];
+//   [foo not_eq];
+if (getLangOpts().ObjC1 && getLangOpts().CPlusPlus &&
+Tok.isOneOf(tok::colon, tok::r_square) &&
+OpToken.getIdentifierInfo() != nullptr) {
+  PP.EnterToken(Tok);
+  Tok = OpToken;
+  return LHS;
+}
+
 // Special case handling for the ternary operator.
 ExprResult TernaryMiddle(true);
 if (NextTokPrec == prec::Conditional) {

Added: cfe/trunk/test/Parser/message-expr-alt-op.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/message-expr-alt-op.mm?rev=340301=auto
==
--- cfe/trunk/test/Parser/message-expr-alt-op.mm (added)
+++ cfe/trunk/test/Parser/message-expr-alt-op.mm Tue Aug 21 09:47:04 2018
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+@interface WeirdInterface
+-(void)allOfThem:(int)a
+ and:(int)b
+  and_eq:(int)c
+  bitand:(int)d
+   bitor:(int)e
+   compl:(int)f
+ not:(int)g
+  not_eq:(int)h
+  or:(int)i
+   or_eq:(int)j
+ xor:(int)k
+  xor_eq:(int)l;
+
+-(void)justAnd:(int)x and:(int)y;
+-(void)and;
+-(void)and:(int)x;
+@end
+
+void call_it(WeirdInterface *x) {
+  [x allOfThem:0
+   and:0
+and_eq:0
+bitand:0
+ bitor:0
+ compl:0
+   not:0
+not_eq:0
+or:0
+ or_eq:0
+   xor:0
+xor_eq:0];
+
+  [x and];
+  [x and:0];
+  [x &&:0]; // expected-error{{expected expression}};
+  [x justAnd:0 and:1];
+  [x and: 0 ? : 1];
+}


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


[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2018-08-21 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Isn't this duplicating code in lib/Support/Unix/Threading.inc with a different 
implementation?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50993



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


[PATCH] D51001: [ASTImporter] Add test for CXXForRangeStmt

2018-08-21 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC340297: [ASTImporter] Add test for CXXForRangeStmt (authored 
by teemperor, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D51001

Files:
  test/Import/cxx-for-range/Inputs/F.cpp
  test/Import/cxx-for-range/test.cpp


Index: test/Import/cxx-for-range/Inputs/F.cpp
===
--- test/Import/cxx-for-range/Inputs/F.cpp
+++ test/Import/cxx-for-range/Inputs/F.cpp
@@ -0,0 +1,11 @@
+struct Container {
+  int *begin();
+  int *end();
+};
+
+void f() {
+  Container c;
+  for (int varname : c) {
+return;
+  }
+}
Index: test/Import/cxx-for-range/test.cpp
===
--- test/Import/cxx-for-range/test.cpp
+++ test/Import/cxx-for-range/test.cpp
@@ -0,0 +1,53 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXForRangeStmt
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: 'c'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .begin
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .end
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: BinaryOperator
+// CHECK-SAME: '!='
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__end1'
+
+// CHECK-NEXT: UnaryOperator
+// CHECK-SAME: '++'
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+
+// CHECK: ReturnStmt
+
+void expr() {
+  f();
+}


Index: test/Import/cxx-for-range/Inputs/F.cpp
===
--- test/Import/cxx-for-range/Inputs/F.cpp
+++ test/Import/cxx-for-range/Inputs/F.cpp
@@ -0,0 +1,11 @@
+struct Container {
+  int *begin();
+  int *end();
+};
+
+void f() {
+  Container c;
+  for (int varname : c) {
+return;
+  }
+}
Index: test/Import/cxx-for-range/test.cpp
===
--- test/Import/cxx-for-range/test.cpp
+++ test/Import/cxx-for-range/test.cpp
@@ -0,0 +1,53 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
+
+// CHECK: CXXForRangeStmt
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: 'c'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .begin
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .end
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: BinaryOperator
+// CHECK-SAME: '!='
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__end1'
+
+// CHECK-NEXT: UnaryOperator
+// CHECK-SAME: '++'
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+
+// CHECK: ReturnStmt
+
+void expr() {
+  f();
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r340297 - [ASTImporter] Add test for CXXForRangeStmt

2018-08-21 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Tue Aug 21 09:36:49 2018
New Revision: 340297

URL: http://llvm.org/viewvc/llvm-project?rev=340297=rev
Log:
[ASTImporter] Add test for CXXForRangeStmt

Reviewers: a.sidorin, martong

Reviewed By: martong

Subscribers: rnkovacs, martong, cfe-commits

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

Added:
cfe/trunk/test/Import/cxx-for-range/
cfe/trunk/test/Import/cxx-for-range/Inputs/
cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp
cfe/trunk/test/Import/cxx-for-range/test.cpp

Added: cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp?rev=340297=auto
==
--- cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp (added)
+++ cfe/trunk/test/Import/cxx-for-range/Inputs/F.cpp Tue Aug 21 09:36:49 2018
@@ -0,0 +1,11 @@
+struct Container {
+  int *begin();
+  int *end();
+};
+
+void f() {
+  Container c;
+  for (int varname : c) {
+return;
+  }
+}

Added: cfe/trunk/test/Import/cxx-for-range/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/cxx-for-range/test.cpp?rev=340297=auto
==
--- cfe/trunk/test/Import/cxx-for-range/test.cpp (added)
+++ cfe/trunk/test/Import/cxx-for-range/test.cpp Tue Aug 21 09:36:49 2018
@@ -0,0 +1,53 @@
+// RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | 
FileCheck %s
+
+// CHECK: CXXForRangeStmt
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: 'c'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .begin
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-NEXT: CXXMemberCallExpr
+// CHECK-SAME: 'int *'
+// CHECK-NEXT: MemberExpr
+// CHECK-SAME: .end
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__range1'
+// CHECK-SAME: Container
+
+// CHECK-NEXT: BinaryOperator
+// CHECK-SAME: '!='
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__end1'
+
+// CHECK-NEXT: UnaryOperator
+// CHECK-SAME: '++'
+// CHECK-NEXT: DeclRefExpr
+// CHECK-SAME: '__begin1'
+
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: VarDecl
+// CHECK-SAME: varname
+
+// CHECK: ReturnStmt
+
+void expr() {
+  f();
+}


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


[PATCH] D50984: AMDGPU: Move target code into TargetParser

2018-08-21 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r340292


https://reviews.llvm.org/D50984



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


r340292 - AMDGPU: Move target code into TargetParser

2018-08-21 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Tue Aug 21 09:13:29 2018
New Revision: 340292

URL: http://llvm.org/viewvc/llvm-project?rev=340292=rev
Log:
AMDGPU: Move target code into TargetParser

Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=340292=340291=340292=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Tue Aug 21 09:13:29 2018
@@ -127,12 +127,14 @@ bool AMDGPUTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) const {
 
+  using namespace llvm::AMDGPU;
+
   // XXX - What does the member GPU mean if device name string passed here?
   if (isAMDGCN(getTriple())) {
 if (CPU.empty())
   CPU = "gfx600";
 
-switch (parseAMDGCNName(CPU).Kind) {
+switch (llvm::AMDGPU::parseArchAMDGCN(CPU)) {
 case GK_GFX906:
   Features["dl-insts"] = true;
   LLVM_FALLTHROUGH;
@@ -169,7 +171,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 if (CPU.empty())
   CPU = "r600";
 
-switch (parseR600Name(CPU).Kind) {
+switch (llvm::AMDGPU::parseArchR600(CPU)) {
 case GK_CAYMAN:
 case GK_CYPRESS:
 case GK_RV770:
@@ -201,7 +203,7 @@ void AMDGPUTargetInfo::adjustTargetOptio
TargetOptions ) const {
   bool hasFP32Denormals = false;
   bool hasFP64Denormals = false;
-  GPUInfo CGOptsGPU = parseGPUName(TargetOpts.CPU);
+
   for (auto  : TargetOpts.FeaturesAsWritten) {
 if (I == "+fp32-denormals" || I == "-fp32-denormals")
   hasFP32Denormals = true;
@@ -210,54 +212,20 @@ void AMDGPUTargetInfo::adjustTargetOptio
   }
   if (!hasFP32Denormals)
 TargetOpts.Features.push_back(
-(Twine(CGOptsGPU.HasFastFMAF && CGOptsGPU.HasFullRateF32Denorms &&
-   !CGOpts.FlushDenorm
-   ? '+'
-   : '-') +
- Twine("fp32-denormals"))
+  (Twine(hasFastFMAF() && hasFullRateDenormalsF32() && !CGOpts.FlushDenorm
+ ? '+' : '-') + Twine("fp32-denormals"))
 .str());
   // Always do not flush fp64 or fp16 denorms.
-  if (!hasFP64Denormals && CGOptsGPU.HasFP64)
+  if (!hasFP64Denormals && hasFP64())
 TargetOpts.Features.push_back("+fp64-fp16-denormals");
 }
 
-constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::InvalidGPU;
-constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::R600GPUs[];
-constexpr AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::AMDGCNGPUs[];
-
-AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseR600Name(StringRef Name) {
-  const auto *Result = llvm::find_if(
-  R600GPUs, [Name](const GPUInfo ) { return GPU.Name == Name; });
-
-  if (Result == std::end(R600GPUs))
-return InvalidGPU;
-  return *Result;
-}
-
-AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseAMDGCNName(StringRef Name) {
-  const auto *Result = llvm::find_if(
-  AMDGCNGPUs, [Name](const GPUInfo ) { return GPU.Name == Name; });
-
-  if (Result == std::end(AMDGCNGPUs))
-return InvalidGPU;
-  return *Result;
-}
-
-AMDGPUTargetInfo::GPUInfo AMDGPUTargetInfo::parseGPUName(StringRef Name) const 
{
-  if (isAMDGCN(getTriple()))
-return parseAMDGCNName(Name);
-  else
-return parseR600Name(Name);
-}
-
 void AMDGPUTargetInfo::fillValidCPUList(
 SmallVectorImpl ) const {
   if (isAMDGCN(getTriple()))
-llvm::for_each(AMDGCNGPUs, [](const GPUInfo ) {
-   Values.emplace_back(GPU.Name);});
+llvm::AMDGPU::fillValidArchListAMDGCN(Values);
   else
-llvm::for_each(R600GPUs, [](const GPUInfo ) {
-   Values.emplace_back(GPU.Name);});
+llvm::AMDGPU::fillValidArchListR600(Values);
 }
 
 void AMDGPUTargetInfo::setAddressSpaceMap(bool DefaultIsPrivate) {
@@ -267,7 +235,12 @@ void AMDGPUTargetInfo::setAddressSpaceMa
 AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple ,
const TargetOptions )
 : TargetInfo(Triple),
-  GPU(isAMDGCN(Triple) ? AMDGCNGPUs[0] : parseR600Name(Opts.CPU)) {
+  GPUKind(isAMDGCN(Triple) ?
+  llvm::AMDGPU::parseArchAMDGCN(Opts.CPU) :
+  llvm::AMDGPU::parseArchR600(Opts.CPU)),
+  GPUFeatures(isAMDGCN(Triple) ?
+  llvm::AMDGPU::getArchAttrAMDGCN(GPUKind) :
+  llvm::AMDGPU::getArchAttrR600(GPUKind)) {
   resetDataLayout(isAMDGCN(getTriple()) ? DataLayoutStringAMDGCN
 : DataLayoutStringR600);
   assert(DataLayout->getAllocaAddrSpace() == Private);
@@ -312,19 +285,22 @@ void AMDGPUTargetInfo::getTargetDefines(
   else
 Builder.defineMacro("__R600__");
 
-  if (GPU.Kind != GK_NONE)
-Builder.defineMacro(Twine("__") + Twine(GPU.CanonicalName) + Twine("__"));
+  if (GPUKind != llvm::AMDGPU::GK_NONE) {
+StringRef CanonName = 

[PATCH] D48027: [analyzer] Improve `CallDescription` to handle c++ method.

2018-08-21 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs accepted this revision.
rnkovacs added a comment.

In https://reviews.llvm.org/D48027#1203944, @MTC wrote:

> However this approach has limit. Given the code below, we cannot distinguish 
> whether the `basic_string` is user-defined struct or namespace. That's means 
> when the user provide {"std", "basic_string", "append"}, we can only know the 
> qualified name of the call sequentially contains `std`, `basic_string`, 
> `append`. We don't know if these names come from `RecordDecl` or 
> `NamespaceDecl`.
>
>   namespace  std {
> namespace basic_string {
>   struct A {
> void append() {}
>   };
> }
>   }
>  
>   void foo() {
> std::basic_string::A a;
> a.append(); // Match
>   }
>
>
> @rnkovacs What do you think? Can this approach meet `InnerPointerChecker`'s 
> needs?


I guess it is highly unlikely for someone to write namespaces like that, and if 
they do, I think they deserve to have them treated as a `std::string`.
Thanks, Henry, this is great!


https://reviews.llvm.org/D48027



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


Re: r340048 - Make __shiftleft128 / __shiftright128 real compiler built-ins.

2018-08-21 Thread Hans Wennborg via cfe-commits
Merged to 7.0 in r340289.

On Fri, Aug 17, 2018 at 10:19 AM, Nico Weber via cfe-commits
 wrote:
> Author: nico
> Date: Fri Aug 17 10:19:06 2018
> New Revision: 340048
>
> URL: http://llvm.org/viewvc/llvm-project?rev=340048=rev
> Log:
> Make __shiftleft128 / __shiftright128 real compiler built-ins.
>
> r337619 added __shiftleft128 / __shiftright128 as functions in intrin.h.
> Microsoft's STL plans on using these functions, and they're using intrin0.h
> which just has declarations of built-ins to not pull in the huge intrin.h
> header in the standard library headers. That requires that these functions are
> real built-ins.
>
> https://reviews.llvm.org/D50907
>
> Modified:
> cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/Headers/intrin.h
> cfe/trunk/test/CodeGen/ms-x86-intrinsics.c
> cfe/trunk/test/Headers/ms-intrin.cpp
>
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86_64.def?rev=340048=340047=340048=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86_64.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86_64.def Fri Aug 17 10:19:06 2018
> @@ -31,6 +31,8 @@ TARGET_HEADER_BUILTIN(_mul128, "LLiLLiLL
>  TARGET_HEADER_BUILTIN(_umul128, "ULLiULLiULLiULLi*", "nch",   "intrin.h", 
> ALL_MS_LANGUAGES, "")
>
>  TARGET_HEADER_BUILTIN(__faststorefence, "v", "nh", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(__shiftleft128, "ULLiULLiULLiUc", "nch", "intrin.h", 
> ALL_MS_LANGUAGES, "")
> +TARGET_HEADER_BUILTIN(__shiftright128, "ULLiULLiULLiUc", "nch", "intrin.h", 
> ALL_MS_LANGUAGES, "")
>
>  TARGET_HEADER_BUILTIN(_InterlockedAnd64, "LLiLLiD*LLi", "nh", 
> "intrin.h", ALL_MS_LANGUAGES, "")
>  TARGET_HEADER_BUILTIN(_InterlockedDecrement64,   "LLiLLiD*","nh", 
> "intrin.h", ALL_MS_LANGUAGES, "")
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=340048=340047=340048=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Aug 17 10:19:06 2018
> @@ -10440,6 +10440,27 @@ Value *CodeGenFunction::EmitX86BuiltinEx
>  return Builder.CreateFence(llvm::AtomicOrdering::SequentiallyConsistent,
> llvm::SyncScope::System);
>}
> +  case X86::BI__shiftleft128:
> +  case X86::BI__shiftright128: {
> +// FIXME: Once fshl/fshr no longer add an unneeded and and cmov, do this:
> +// llvm::Function *F = CGM.getIntrinsic(
> +//   BuiltinID == X86::BI__shiftleft128 ? Intrinsic::fshl : 
> Intrinsic::fshr,
> +//   Int64Ty);
> +// Ops[2] = Builder.CreateZExt(Ops[2], Int64Ty);
> +// return Builder.CreateCall(F, Ops);
> +llvm::Type *Int128Ty = Builder.getInt128Ty();
> +Value *Val = Builder.CreateOr(
> +Builder.CreateShl(Builder.CreateZExt(Ops[1], Int128Ty), 64),
> +Builder.CreateZExt(Ops[0], Int128Ty));
> +Value *Amt = Builder.CreateAnd(Builder.CreateZExt(Ops[2], Int128Ty),
> +   llvm::ConstantInt::get(Int128Ty, 0x3f));
> +Value *Res;
> +if (BuiltinID == X86::BI__shiftleft128)
> +  Res = Builder.CreateLShr(Builder.CreateShl(Val, Amt), 64);
> +else
> +  Res = Builder.CreateLShr(Val, Amt);
> +return Builder.CreateTrunc(Res, Int64Ty);
> +  }
>case X86::BI_ReadWriteBarrier:
>case X86::BI_ReadBarrier:
>case X86::BI_WriteBarrier: {
>
> Modified: cfe/trunk/lib/Headers/intrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=340048=340047=340048=diff
> ==
> --- cfe/trunk/lib/Headers/intrin.h (original)
> +++ cfe/trunk/lib/Headers/intrin.h Fri Aug 17 10:19:06 2018
> @@ -863,20 +863,6 @@ __nop(void) {
>__asm__ volatile ("nop");
>  }
>  #endif
> -#if defined(__x86_64__)
> -static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
> -__shiftleft128(unsigned __int64 __l, unsigned __int64 __h, unsigned char 
> __d) {
> -  unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l;
> -  unsigned __int128 __res = __val << (__d & 63);
> -  return (unsigned __int64)(__res >> 64);
> -}
> -static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
> -__shiftright128(unsigned __int64 __l, unsigned __int64 __h, unsigned char 
> __d) {
> -  unsigned __int128 __val = ((unsigned __int128)__h << 64) | __l;
> -  unsigned __int128 __res = __val >> (__d & 63);
> -  return (unsigned __int64)__res;
> -}
> -#endif
>
>  
> /**\
>  |* Privileged intrinsics
>
> Modified: cfe/trunk/test/CodeGen/ms-x86-intrinsics.c
> URL: 
> 

  1   2   >