[PATCH] D36441: Add Support for Reference Counting of Parameters on the Callee Side in RetainCountChecker

2017-08-07 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:3960-3971
+  for (unsigned idx = 0, e = FD->getNumParams(); idx != e; ++idx) {
+const ParmVarDecl *Param = FD->getParamDecl(idx);
+SymbolRef Sym = state->getSVal(state->getRegion(Param, 
LCtx)).getAsSymbol();
+
+QualType Ty = Param->getType();
+if (hasRCAnnotation(Param, "rc_ownership_consumed"))
+  state = setRefBinding(state, Sym,

malhar1995 wrote:
> Getting function summary and checking for `ArgEffects` doesn't seem like an 
> option to me as currently there is no way to differentiate between Core 
> Foundation and Generalized objects just by looking at their ArgEffects.
> 
> However, this loop results in `check-clang-analysis` failure in 
> `retain-release.m` on lines `1140` and `2237`.
You can differentiate based on the Type of the parameter and use ArgEffects to 
determine what the initial ref binding should be. I'd like there to be a single 
point of truth about what it means for a parameter to annotated. 


Repository:
  rL LLVM

https://reviews.llvm.org/D36441



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D35056#834705, @rnk wrote:

> In https://reviews.llvm.org/D35056#834689, @rsmith wrote:
>
> > I also removed some incorrect assumptions from the Win64 ABI code; this 
> > changed the behavior of one testcase from uncopyable-args.cpp 
> > (`implicitly_deleted_copy_ctor::A` is now passed indirect).
>
>
> That's probably not correct, let me take a look... I remember breaking the 
> rules for small types here.


I forgot to say: the new behavior matches MSVC. (The immediate bug was that we 
didn't consider the possibility that a user-declared copy assignment operator 
could cause the implicit copy constructor to be deleted, but there may have 
been other bugs also caused by this part of CodeGen attempting to work out 
deletedness for itself rather than asking.)


Repository:
  rL LLVM

https://reviews.llvm.org/D35056



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


[PATCH] D36441: Add Support for Reference Counting of Parameters on the Callee Side in RetainCountChecker

2017-08-07 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2521-2523
+  deriveAllocLocation(Ctx, sym);
+  if (!AllocBinding)
+deriveParamLocation(Ctx, sym);

I'm not sure what difference it will make if I change the ordering of the 
invocations of `deriveAllocLocation` and 'deriveParamLocation`.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:2683
 
+  DefaultBool PerformCalleeSideParameterChecking;
+

This might be used in the future in case callee side parameter checking is 
added for Core Foundation and Objective-C objects.



Comment at: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp:3960-3971
+  for (unsigned idx = 0, e = FD->getNumParams(); idx != e; ++idx) {
+const ParmVarDecl *Param = FD->getParamDecl(idx);
+SymbolRef Sym = state->getSVal(state->getRegion(Param, 
LCtx)).getAsSymbol();
+
+QualType Ty = Param->getType();
+if (hasRCAnnotation(Param, "rc_ownership_consumed"))
+  state = setRefBinding(state, Sym,

Getting function summary and checking for `ArgEffects` doesn't seem like an 
option to me as currently there is no way to differentiate between Core 
Foundation and Generalized objects just by looking at their ArgEffects.

However, this loop results in `check-clang-analysis` failure in 
`retain-release.m` on lines `1140` and `2237`.


Repository:
  rL LLVM

https://reviews.llvm.org/D36441



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


[PATCH] D36441: Add Support for Reference Counting of Parameters on the Callee Side in RetainCountChecker

2017-08-07 Thread Malhar Thakkar via Phabricator via cfe-commits
malhar1995 created this revision.
Herald added a subscriber: eraman.

Current RetainCountChecker performs reference counting of function 
arguments/parameters only on the caller side and not on the callee side.

This patch aims to add support for reference counting on the callee-side for 
objects of 'Generalized' ObjKind.

This patch is still a work in progress.


Repository:
  rL LLVM

https://reviews.llvm.org/D36441

Files:
  lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  test/Analysis/retain-release-inline.m

Index: test/Analysis/retain-release-inline.m
===
--- test/Analysis/retain-release-inline.m
+++ test/Analysis/retain-release-inline.m
@@ -302,6 +302,9 @@
 __attribute__((annotate("rc_ownership_returns_retained"))) isl_basic_map *isl_basic_map_cow(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap);
 void free(void *);
 
+void callee_side_parameter_checking_leak(__attribute__((annotate("rc_ownership_consumed"))) isl_basic_map *bmap) { // expected-warning {{Potential leak}}
+}
+
 // As 'isl_basic_map_free' is annotated with 'rc_ownership_trusted_implementation', RetainCountChecker trusts its
 // implementation and doesn't analyze its body. If the annotation 'rc_ownership_trusted_implementation' is removed,
 // a leak warning is raised by RetainCountChecker as the analyzer is unable to detect a decrement in the reference
@@ -348,6 +351,10 @@
   isl_basic_map_free(bmap);
 }
 
+void callee_side_parameter_checking_incorrect_rc_decrement(isl_basic_map *bmap) {
+  isl_basic_map_free(bmap); // expected-warning {{Incorrect decrement of the reference count}}
+}
+
 //===--===//
 // Test returning retained and not-retained values.
 //===--===//
Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -1848,6 +1848,12 @@
 
   class CFRefLeakReport : public CFRefReport {
 const MemRegion* AllocBinding;
+const Stmt *AllocStmt;
+
+void deriveParamLocation(CheckerContext , SymbolRef sym);
+void deriveAllocLocation(CheckerContext , SymbolRef sym);
+void createDescription(CheckerContext , bool GCEnabled, bool IncludeAllocationLine);
+
   public:
 CFRefLeakReport(CFRefBug , const LangOptions , bool GCEnabled,
 const SummaryLogTy , ExplodedNode *n, SymbolRef sym,
@@ -2427,13 +2433,25 @@
   return llvm::make_unique(L, os.str());
 }
 
-CFRefLeakReport::CFRefLeakReport(CFRefBug , const LangOptions ,
- bool GCEnabled, const SummaryLogTy ,
- ExplodedNode *n, SymbolRef sym,
- CheckerContext ,
- bool IncludeAllocationLine)
-  : CFRefReport(D, LOpts, GCEnabled, Log, n, sym, false) {
+void CFRefLeakReport::deriveParamLocation(CheckerContext , SymbolRef sym) {
+  const SourceManager& SMgr = Ctx.getSourceManager();
+
+  if (!sym->getOriginRegion())
+return;
 
+  const DeclRegion *Region = dyn_cast(sym->getOriginRegion());
+  if (Region) {
+const Decl *PDecl = Region->getDecl();
+if (PDecl && isa(PDecl)) {
+  PathDiagnosticLocation ParamLocation = PathDiagnosticLocation::create(PDecl, SMgr);
+  Location = ParamLocation;
+  UniqueingLocation = ParamLocation;
+  UniqueingDecl = Ctx.getLocationContext()->getDecl();
+}
+  }
+}
+
+void CFRefLeakReport::deriveAllocLocation(CheckerContext ,SymbolRef sym) {
   // Most bug reports are cached at the location where they occurred.
   // With leaks, we want to unique them by the location where they were
   // allocated, and only report a single path.  To do this, we need to find
@@ -2457,8 +2475,13 @@
   // FIXME: This will crash the analyzer if an allocation comes from an
   // implicit call (ex: a destructor call).
   // (Currently there are no such allocations in Cocoa, though.)
-  const Stmt *AllocStmt = PathDiagnosticLocation::getStmt(AllocNode);
-  assert(AllocStmt && "Cannot find allocation statement");
+  AllocStmt = PathDiagnosticLocation::getStmt(AllocNode);
+  // assert(AllocStmt && "Cannot find allocation statement");
+
+  if (!AllocStmt) {
+AllocBinding = nullptr;
+return;
+  }
 
   PathDiagnosticLocation AllocLocation =
 PathDiagnosticLocation::createBegin(AllocStmt, SMgr,
@@ -2469,8 +2492,9 @@
   // leaks should be uniqued on the allocation site.
   UniqueingLocation = AllocLocation;
   UniqueingDecl = AllocNode->getLocationContext()->getDecl();
+}
 
-  // Fill in the description of the bug.
+void CFRefLeakReport::createDescription(CheckerContext , bool GCEnabled, bool IncludeAllocationLine) {
   Description.clear();
   llvm::raw_string_ostream os(Description);
   os 

[PATCH] D35670: [StaticAnalyzer] Handle LoopExit CFGElement in the analyzer

2017-08-07 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added inline comments.



Comment at: include/clang/Analysis/ProgramPoint.h:658
 
+class LoopExit : public ProgramPoint {
+public:

Can you add a comment explaining what meaning of this program point is.



Comment at: lib/StaticAnalyzer/Core/CoreEngine.cpp:586
 
+  if ((*Block)[Idx].getKind() == CFGElement::LoopExit) {
+WList->enqueue(N, Block, Idx+1);

I'm surprised both this and the checks for N's location above are needed. How 
does this arise?


https://reviews.llvm.org/D35670



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


[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-07 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

alternatively, you could report the comparison of the old code vs. the new code 
with an existing benchmark, like benchmarks/algorithms.bench.cpp


https://reviews.llvm.org/D36423



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D35056#834689, @rsmith wrote:

> I also removed some incorrect assumptions from the Win64 ABI code; this 
> changed the behavior of one testcase from uncopyable-args.cpp 
> (`implicitly_deleted_copy_ctor::A` is now passed indirect).


That's probably not correct, let me take a look... I remember breaking the 
rules for small types here.


Repository:
  rL LLVM

https://reviews.llvm.org/D35056



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


r310332 - Fix openmp-offload.c test on Windows

2017-08-07 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Aug  7 18:36:16 2017
New Revision: 310332

URL: http://llvm.org/viewvc/llvm-project?rev=310332=rev
Log:
Fix openmp-offload.c test on Windows

Modified:
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/test/Driver/openmp-offload.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload.c?rev=310332=310331=310332=diff
==
--- cfe/trunk/test/Driver/openmp-offload.c (original)
+++ cfe/trunk/test/Driver/openmp-offload.c Mon Aug  7 18:36:16 2017
@@ -666,8 +666,8 @@
 // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %t1.o 
%t2.o 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
 
-// CHK-TWOCUBIN: clang-offload-bundler" "-type=o" "{{.*}}inputs={{.*}}tmp1.o" 
"-outputs={{.*}}.o,{{.*}}tmp1-openmp-nvptx64-nvidia-cuda.cubin" "-unbundle"
-// CHK-TWOCUBIN-NEXT: clang-offload-bundler" "-type=o" 
"{{.*}}inputs={{.*}}tmp2.o" 
"-outputs={{.*}}.o,{{.*}}tmp2-openmp-nvptx64-nvidia-cuda.cubin" "-unbundle"
+// CHK-TWOCUBIN: clang-offload-bundler{{[^"]*}}" "-type=o" 
"{{.*}}inputs={{.*}}tmp1.o" 
"-outputs={{.*}}.o,{{.*}}tmp1-openmp-nvptx64-nvidia-cuda.cubin" "-unbundle"
+// CHK-TWOCUBIN-NEXT: clang-offload-bundler{{[^"]*}}" "-type=o" 
"{{.*}}inputs={{.*}}tmp2.o" 
"-outputs={{.*}}.o,{{.*}}tmp2-openmp-nvptx64-nvidia-cuda.cubin" "-unbundle"
 // CHK-TWOCUBIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" {{.*}} 
"openmp-offload.c.tmp1-openmp-nvptx64-nvidia-cuda.cubin" 
"openmp-offload.c.tmp2-openmp-nvptx64-nvidia-cuda.cubin"
 
 /// ###


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


r310331 - [codeview] Fix class name formatting

2017-08-07 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Aug  7 18:33:53 2017
New Revision: 310331

URL: http://llvm.org/viewvc/llvm-project?rev=310331=rev
Log:
[codeview] Fix class name formatting

In particular, removes spaces between template arguments of class
templates to better match VS type visualizers.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=310331=310330=310331=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Aug  7 18:33:53 2017
@@ -218,6 +218,19 @@ llvm::DIScope *CGDebugInfo::getContextDe
   return Default;
 }
 
+PrintingPolicy CGDebugInfo::getPrintingPolicy() const {
+  PrintingPolicy PP = CGM.getContext().getPrintingPolicy();
+
+  // If we're emitting codeview, it's important to try to match MSVC's naming 
so
+  // that visualizers written for MSVC will trigger for our class names. In
+  // particular, we can't have spaces between arguments of standard templates
+  // like basic_string and vector.
+  if (CGM.getCodeGenOpts().EmitCodeView)
+PP.MSVCFormatting = true;
+
+  return PP;
+}
+
 StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) {
   assert(FD && "Invalid FunctionDecl!");
   IdentifierInfo *FII = FD->getIdentifier();
@@ -238,18 +251,16 @@ StringRef CGDebugInfo::getFunctionName(c
 
   SmallString<128> NS;
   llvm::raw_svector_ostream OS(NS);
-  PrintingPolicy Policy(CGM.getLangOpts());
-  Policy.MSVCFormatting = CGM.getCodeGenOpts().EmitCodeView;
   if (!UseQualifiedName)
 FD->printName(OS);
   else
-FD->printQualifiedName(OS, Policy);
+FD->printQualifiedName(OS, getPrintingPolicy());
 
   // Add any template specialization args.
   if (Info) {
 const TemplateArgumentList *TArgs = Info->TemplateArguments;
 TemplateSpecializationType::PrintTemplateArgumentList(OS, TArgs->asArray(),
-  Policy);
+  getPrintingPolicy());
   }
 
   // Copy this name on the side and use its reference.
@@ -296,7 +307,7 @@ StringRef CGDebugInfo::getClassName(cons
   if (isa(RD)) {
 SmallString<128> Name;
 llvm::raw_svector_ostream OS(Name);
-RD->getNameForDiagnostic(OS, CGM.getContext().getPrintingPolicy(),
+RD->getNameForDiagnostic(OS, getPrintingPolicy(),
  /*Qualified*/ false);
 
 // Copy this name on the side and use its reference.
@@ -908,12 +919,11 @@ llvm::DIType *CGDebugInfo::CreateType(co
 
   SmallString<128> NS;
   llvm::raw_svector_ostream OS(NS);
-  Ty->getTemplateName().print(OS, CGM.getContext().getPrintingPolicy(),
+  Ty->getTemplateName().print(OS, getPrintingPolicy(),
   /*qualified*/ false);
 
   TemplateSpecializationType::PrintTemplateArgumentList(
-  OS, Ty->template_arguments(),
-  CGM.getContext().getPrintingPolicy());
+  OS, Ty->template_arguments(), getPrintingPolicy());
 
   auto *AliasDecl = cast(
   Ty->getTemplateName().getAsTemplateDecl())->getTemplatedDecl();

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=310331=310330=310331=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Aug  7 18:33:53 2017
@@ -558,6 +558,9 @@ private:
  unsigned LineNo, StringRef LinkageName,
  llvm::GlobalVariable *Var, llvm::DIScope *DContext);
 
+  /// Get the printing policy for producing names for debug info.
+  PrintingPolicy getPrintingPolicy() const;
+
   /// Get function name for the given FunctionDecl. If the name is
   /// constructed on demand (e.g., C++ destructor) then the name is
   /// stored on the side.

Modified: cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp?rev=310331=310330=310331=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-codeview-display-name.cpp Mon Aug  7 
18:33:53 2017
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -std=c++98 | \
-// RUN:grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
+// RUN:grep 'DISubprogram\|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
 // RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
 // RUN: 

[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/tools/clang-fuzzer/cxx_proto.proto:17
+syntax = "proto2";
+//option cc_api_version = 2;
+

>> //option cc_api_version = 2;
Please remove



Comment at: clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt:7
+
+add_clang_library(clangProtoToCXX
+  proto_to_cxx.cpp

Formatting of this statement looks weird



Comment at: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp:46
+  switch (x.op()) {
+#define OP(a, b) case BinaryOp::a: os << b; break
+OP(PLUS, "+");

 OP looks to trivial to potentially get into conflicts with some 3rd party macro



Comment at: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp:50
+OP(MUL, "*");
+OP(DIV, "/");
+OP(MOD, "%");

```
switch (x.op()) {
BinaryOp::PLUS: os << "+"; break
BinaryOp::MINUS: os << "-"; break
BinaryOp::MUL: os << "*"; break
```

does not look bad to me



Comment at: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp:102
+  if (!message.ParseFromArray(data, size))
+//   if (!proto2::TextFormat::ParseBinaryMessage({data, data + size}, 
))
+return "#error invalid proto\n";

please remove commented code


https://reviews.llvm.org/D36324



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 110115.
rsmith edited the summary of this revision.
rsmith added a comment.
Herald added a subscriber: klimek.

Remove added calls to `DeclareImplicit*`  and `ShouldDeleteSpecialMember`. In 
their place, figure out whether an implicit special member would be deleted or 
not by querying the AST.

This requires teaching `CXXRecordDecl` to track whether an implicit copy 
constructor for a class would be deleted, in the same way we do for the move 
constructor and move assignment operator; as with those other two cases, we 
fall back to an "ask Sema" state if the computation is not simple, and in that 
case `Sema` eagerly declares the special member in question to compute the 
answer. As a result, this can cause us to declare some copy constructors that 
we didn't declare previously, but in the important common cases we will still 
declare them lazily.

I also removed some incorrect assumptions from the Win64 ABI code; this changed 
the behavior of one testcase from uncopyable-args.cpp 
(`implicitly_deleted_copy_ctor::A` is now passed indirect).


Repository:
  rL LLVM

https://reviews.llvm.org/D35056

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/CodeGen/CGCXXABI.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenCXX/uncopyable-args.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1108,26 +1108,35 @@
 }
 
 TEST(ConstructorDeclaration, Kinds) {
-  EXPECT_TRUE(matches("struct S { S(); };",
-  cxxConstructorDecl(isDefaultConstructor(;
-  EXPECT_TRUE(notMatches("struct S { S(); };",
- cxxConstructorDecl(isCopyConstructor(;
-  EXPECT_TRUE(notMatches("struct S { S(); };",
- cxxConstructorDecl(isMoveConstructor(;
-
-  EXPECT_TRUE(notMatches("struct S { S(const S&); };",
- cxxConstructorDecl(isDefaultConstructor(;
-  EXPECT_TRUE(matches("struct S { S(const S&); };",
-  cxxConstructorDecl(isCopyConstructor(;
-  EXPECT_TRUE(notMatches("struct S { S(const S&); };",
- cxxConstructorDecl(isMoveConstructor(;
-
-  EXPECT_TRUE(notMatches("struct S { S(S&&); };",
- cxxConstructorDecl(isDefaultConstructor(;
-  EXPECT_TRUE(notMatches("struct S { S(S&&); };",
- cxxConstructorDecl(isCopyConstructor(;
-  EXPECT_TRUE(matches("struct S { S(S&&); };",
-  cxxConstructorDecl(isMoveConstructor(;
+  EXPECT_TRUE(matches(
+  "struct S { S(); };",
+  cxxConstructorDecl(isDefaultConstructor(), unless(isImplicit();
+  EXPECT_TRUE(notMatches(
+  "struct S { S(); };",
+  cxxConstructorDecl(isCopyConstructor(), unless(isImplicit();
+  EXPECT_TRUE(notMatches(
+  "struct S { S(); };",
+  cxxConstructorDecl(isMoveConstructor(), unless(isImplicit();
+
+  EXPECT_TRUE(notMatches(
+  "struct S { S(const S&); };",
+  cxxConstructorDecl(isDefaultConstructor(), unless(isImplicit();
+  EXPECT_TRUE(matches(
+  "struct S { S(const S&); };",
+  cxxConstructorDecl(isCopyConstructor(), unless(isImplicit();
+  EXPECT_TRUE(notMatches(
+  "struct S { S(const S&); };",
+  cxxConstructorDecl(isMoveConstructor(), unless(isImplicit();
+
+  EXPECT_TRUE(notMatches(
+  "struct S { S(S&&); };",
+  cxxConstructorDecl(isDefaultConstructor(), unless(isImplicit();
+  EXPECT_TRUE(notMatches(
+  "struct S { S(S&&); };",
+  cxxConstructorDecl(isCopyConstructor(), unless(isImplicit();
+  EXPECT_TRUE(matches(
+  "struct S { S(S&&); };",
+  cxxConstructorDecl(isMoveConstructor(), unless(isImplicit();
 }
 
 TEST(ConstructorDeclaration, IsUserProvided) {
Index: test/CodeGenCXX/uncopyable-args.cpp
===
--- test/CodeGenCXX/uncopyable-args.cpp
+++ test/CodeGenCXX/uncopyable-args.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -emit-llvm -o - %s | FileCheck %s -check-prefix=WIN64
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -emit-llvm -o - %s -fms-compatibility -fms-compatibility-version=18 | FileCheck %s -check-prefix=WIN64 -check-prefix=WIN64-18
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -emit-llvm -o - %s -fms-compatibility -fms-compatibility-version=19 | FileCheck %s -check-prefix=WIN64 -check-prefix=WIN64-19
 
 namespace trivial {
 // Trivial structs should be passed 

[libcxxabi] r310329 - [libc++abi] Use proper calling convention for TLS destructor

2017-08-07 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Aug  7 17:54:33 2017
New Revision: 310329

URL: http://llvm.org/viewvc/llvm-project?rev=310329=rev
Log:
[libc++abi] Use proper calling convention for TLS destructor

This is needed when using Windows threading.

Modified:
libcxxabi/trunk/src/cxa_exception_storage.cpp

Modified: libcxxabi/trunk/src/cxa_exception_storage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception_storage.cpp?rev=310329=310328=310329=diff
==
--- libcxxabi/trunk/src/cxa_exception_storage.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception_storage.cpp Mon Aug  7 17:54:33 2017
@@ -56,7 +56,7 @@ namespace {
 std::__libcpp_tls_key key_;
 std::__libcpp_exec_once_flag flag_ = _LIBCPP_EXEC_ONCE_INITIALIZER;
 
-void destruct_ (void *p) {
+void _LIBCPP_TLS_DESTRUCTOR_CC destruct_ (void *p) {
 __free_with_fallback ( p );
 if ( 0 != std::__libcpp_tls_set ( key_, NULL ) )
 abort_message("cannot zero out thread value for 
__cxa_get_globals()");


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


[libunwind] r310327 - [CMake] Allow overriding lib dir suffix independently from LLVM

2017-08-07 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Aug  7 17:37:59 2017
New Revision: 310327

URL: http://llvm.org/viewvc/llvm-project?rev=310327=rev
Log:
[CMake] Allow overriding lib dir suffix independently from LLVM

This matches the options already supported by libc++ and libc++abi.

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

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/src/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=310327=310326=310327=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Mon Aug  7 17:37:59 2017
@@ -133,6 +133,8 @@ option(LIBUNWIND_ENABLE_THREADS "Build l
 option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." 
${LLVM_INCLUDE_DOCS})
 
+set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
+"Define suffix of library directory name (32/64)")
 set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross 
compiling.")
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
 set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
@@ -165,7 +167,7 @@ set(LIBUNWIND_BINARY_DIR  ${CMAKE_CURREN
 if (LLVM_LIBRARY_OUTPUT_INTDIR)
   set(LIBUNWIND_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
 else()
-  set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+  set(LIBUNWIND_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBUNWIND_LIBDIR_SUFFIX})
 endif()
 
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBUNWIND_LIBRARY_DIR})

Modified: libunwind/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/CMakeLists.txt?rev=310327=310326=310327=diff
==
--- libunwind/trunk/src/CMakeLists.txt (original)
+++ libunwind/trunk/src/CMakeLists.txt Mon Aug  7 17:37:59 2017
@@ -133,6 +133,6 @@ endif()
 add_custom_target(unwind DEPENDS ${LIBUNWIND_TARGETS})
 
 install(TARGETS ${LIBUNWIND_TARGETS}
-  LIBRARY DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LLVM_LIBDIR_SUFFIX}
-  ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LLVM_LIBDIR_SUFFIX})
+  LIBRARY DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LIBUNWIND_LIBDIR_SUFFIX}
+  ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_PREFIX}lib${LIBUNWIND_LIBDIR_SUFFIX})
 


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


[PATCH] D35796: [analyzer] Misused polymorphic object checker

2017-08-07 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

This looks like a useful checker! Have you run this on large codebases yet? 
Does it find bugs? What kind of false positives do you see? Do you have a sense 
of what additional work would it take to bring this out of alpha and have it 
turned on by default?

Other than some super tiny comments in-line, this looks good to me.




Comment at: include/clang/StaticAnalyzer/Checkers/Checkers.td:296
 
+def MisusedPolymorphicObjectChecker: Checker<"MisusedPolymorphicObject">,
+ HelpText<"Reports deletions of polymorphic objects with a non-virtual "

I think users would find it helpful if this had a more specific name. There are 
a lot of ways to misuse polymorphic objects, and this checker won't check all 
of them.

What do you think about "DeleteWithNonVirtualDestructor"?



Comment at: lib/StaticAnalyzer/Checkers/MisusedPolymorphicObjectChecker.cpp:16
+// the last point where the derived-to-base conversion happened.
+//
+//===--===//

I think it would be helpful to future maintainers to provide a high-level 
description of how this differs from `-Wnon-virtual-dtor` and 
`-Wdelete-non-virtual-dtor`.



Comment at: lib/StaticAnalyzer/Checkers/MisusedPolymorphicObjectChecker.cpp:137
+  llvm::raw_svector_ostream OS(Buf);
+  OS << "Derived-to-base conversion happened here";
+  PathDiagnosticLocation Pos(S, BRC.getSourceManager(),

A minor style suggestion to avoid the stacked noun phrase: "Conversion from 
derived to base happened here".


https://reviews.llvm.org/D35796



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-07 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a comment.

Why do we need LLVM_ENABLE_RTTI=ON here?


https://reviews.llvm.org/D36324



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


[PATCH] D36437: [clang] Get rid of "%T" expansions

2017-08-07 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.

Seems reasonable to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D36437



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


[PATCH] D36437: [clang] Get rid of "%T" expansions

2017-08-07 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek created this revision.
kubamracek added a project: clang.
Herald added subscribers: mehdi_amini, klimek.

The `%T` lit expansion expands to a common directory shared between all the 
tests in the same directory, which is unexpected and unintuitive, and more 
importantly, it's been a source of subtle race conditions and flaky tests.  In 
https://reviews.llvm.org/D35396, it was agreed that it would be best to simply 
ban `%T` and only keep `%t`, which is unique to each test.  When a test needs a 
temporary directory, it can just create one using `mkdir %t`.

This patch removes `%T` in clang.


Repository:
  rL LLVM

https://reviews.llvm.org/D36437

Files:
  test/Analysis/html-diags.c
  test/CoverageMapping/abspath.cpp
  test/Driver/compilation_database.c
  test/Driver/cpath.c
  test/Driver/darwin-ld-lto.c
  test/Driver/linker-opts.c
  test/Driver/output-file-cleanup.c
  test/Driver/parse-progname.c
  test/Driver/ps4-linker-non-win.c
  test/Driver/ps4-linker-win.c
  test/Driver/warning-options.cpp
  test/FixIt/fixit-include.c
  test/Format/style-on-command-line.cpp
  test/Lexer/case-insensitive-include-ms.c
  test/Lexer/case-insensitive-include-pr31836.sh
  test/Lexer/case-insensitive-include.c
  test/Lexer/case-insensitive-system-include.c
  test/Modules/crash-typo-correction-visibility.cpp
  test/Modules/modules-cache-path-canonicalization.m
  test/PCH/case-insensitive-include.c
  test/PCH/include-timestamp.cpp
  test/Preprocessor/cuda-types.cu
  test/Tooling/clang-diff-basic.cpp

Index: test/Tooling/clang-diff-basic.cpp
===
--- test/Tooling/clang-diff-basic.cpp
+++ test/Tooling/clang-diff-basic.cpp
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -E %s > %T/src.cpp
-// RUN: %clang_cc1 -E %s > %T/dst.cpp -DDEST
-// RUN: clang-diff -no-compilation-database %T/src.cpp %T/dst.cpp | FileCheck %s
+// RUN: mkdir -p %t
+// RUN: %clang_cc1 -E %s > %t/src.cpp
+// RUN: %clang_cc1 -E %s > %t/dst.cpp -DDEST
+// RUN: clang-diff -no-compilation-database %t/src.cpp %t/dst.cpp | FileCheck %s
 
 #ifndef DEST
 namespace src {
Index: test/Preprocessor/cuda-types.cu
===
--- test/Preprocessor/cuda-types.cu
+++ test/Preprocessor/cuda-types.cu
@@ -5,42 +5,44 @@
 // FIXME: We really should make __GCC_HAVE_SYNC_COMPARE_AND_SWAP identical on
 // host and device, but architecturally this is difficult at the moment.
 
+// RUN: mkdir -p %t
+
 // RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-host-defines-filtered
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/i386-device-defines-filtered
-// RUN: diff %T/i386-host-defines-filtered %T/i386-device-defines-filtered
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/i386-device-defines-filtered
+// RUN: diff %t/i386-host-defines-filtered %t/i386-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/x86_64-host-defines-filtered
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/x86_64-device-defines-filtered
-// RUN: diff %T/x86_64-host-defines-filtered %T/x86_64-device-defines-filtered
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
+// RUN: diff %t/x86_64-host-defines-filtered %t/x86_64-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/powerpc64-host-defines-filtered
+// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
 // RUN:   | grep 'define __[^ ]*\(TYPE\|MAX\|SIZEOF|WIDTH\)\|define __GCC_ATOMIC' \
-// RUN:   | grep -v '__LDBL\|_LONG_DOUBLE' > %T/powerpc64-device-defines-filtered
-// RUN: diff %T/powerpc64-host-defines-filtered %T/powerpc64-device-defines-filtered
+// RUN:   | grep -v 

[PATCH] D36427: [libcxxabi][demangler] Improve representation of substitutions/templates

2017-08-07 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Oh, also found a couple of things you should likely split into prep commits to 
simplify this patch.




Comment at: src/cxa_demangle.cpp:1575-1577
-sub_type names;
-template_param_type subs;
-Vector template_param;

- Why not rename `names` as well?
- Please rename these in a separate prep commit to minimize noise on the final 
patch.


https://reviews.llvm.org/D36427



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


[PATCH] D35056: GCC ABI incompatibility when passing object with trivial copy ctor, trivial dtor, and non-trivial move ctor

2017-08-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

As requested by Vassil, I'm going to upload another version of this that avoids 
declaring implicit special members so frequently.


https://reviews.llvm.org/D35056



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


[PATCH] D36427: [libcxxabi][demangler] Improve representation of substitutions/templates

2017-08-07 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith requested changes to this revision.
dexonsmith added a comment.
This revision now requires changes to proceed.

This looks like a great improvement.  I've littered the patch with nit-picks, 
but my main concern is that there aren't any unit tests for the new data 
structures.  I wonder if there's a hacky way to set that up...




Comment at: src/cxa_demangle.cpp:1460-1461
 
+template 
+class PODSmallVector {
+  static_assert(std::is_pod::value, "");

This seems like a facility that should/could be unit tested (in C++).

I realize there's no precedent for that for the demangler.  Perhaps this file 
could be `#include`d by a test file:

```
// unittest/PODSmallVectorTest.h
#include "../src/cxa_demangle.cpp"

namespace {

TEST(PODSmallVectorTest, ...) {
}

} // namespace
```

Thoughts?



Comment at: src/cxa_demangle.cpp:1462
+class PODSmallVector {
+  static_assert(std::is_pod::value, "");
+

Please add an assertion string, such as `"T is required to be a plain-old data 
type"`.



Comment at: src/cxa_demangle.cpp:1499-1501
+First = Inline;
+Last = Inline;
+Cap = Inline + N;

This is identical to code in the move constructor.  Separate it out into a 
helper?



Comment at: src/cxa_demangle.cpp:1511-1517
+First = Other.First;
+Last = Other.Last;
+Cap = Other.Cap;
+
+Other.First = Other.Inline;
+Other.Last = Other.Inline;
+Other.Cap = Other.Inline + N;

Helper?



Comment at: src/cxa_demangle.cpp:1527-1535
+size_t S = size();
+if (!isInline()) {
+  First = static_cast(std::realloc(First, sizeof(T) * S * 2));
+} else {
+  First = static_cast(std::malloc(sizeof(T) * S * 2));
+  std::copy(std::begin(Inline), std::end(Inline), First);
+}

Should we assert when `nullptr` is returned from `std::malloc` or 
`std::realloc`?



Comment at: src/cxa_demangle.cpp:1540-1542
+  void pop_back() { --Last; }
+
+  void dropBack(size_t Index) { Last = First + Index; }

Assertions on popping/dropping past empty?



Comment at: src/cxa_demangle.cpp:1549-1550
+  size_t size() const { return static_cast(Last - First); }
+  T& back() { return *(Last - 1); }
+  T& operator[](size_t Index) { return *(begin() + Index); }
+  void clear() { Last = First; }

Assertions on invalid access?



Comment at: src/cxa_demangle.cpp:1562
+template
+class SubTable {
+  // Subs hold the actual entries in the table, and PackIndices tells us which

As I read this patch, I keep reading "sub" as a prefix.  Can we just spell this 
out as "SubstitutionTable"?

Also, this probably deserves unit tests as well.



Comment at: src/cxa_demangle.cpp:1577-1580
+  void pushSub(Node* Entry) {
+PackIndices.push_back(static_cast(Subs.size()));
+Subs.push_back(Entry);
+  }

Can/should this be implemented using `pushPack()` and `pushSubIntoPack()`?



Comment at: src/cxa_demangle.cpp:1585
+  void pushPack() { PackIndices.push_back(static_cast(Subs.size())); 
}
+  void pushSubIntoPack(Node* Entry) { Subs.push_back(Entry); }
+

Do you need to assert that `pushPack` has been called at least once (i.e., 
`!PackIndices.empty()`)?



Comment at: src/cxa_demangle.cpp:1595
+  // For use in a range-for loop.
+  struct NodePair {
+Node **First;

Perhaps `NodeRange` would be more clear.



Comment at: src/cxa_demangle.cpp:1596-1599
+Node **First;
+Node **Last;
+Node **begin() { return First; }
+Node **end() { return Last; }

Please be consistent with pointer style in this patch.
- I suspect the rest of the file attaches to the type, i.e., `Node** First`, 
which is why I didn't comment earlier on, e.g., `Node* Entry`.
- LLVM style is to attach to the name, like here.

I have a slight preference for switching toward LLVM style, but if the file 
consistently uses pointers attached to types, that's fine too.  (Just be 
consistent within the patch.)



Comment at: src/cxa_demangle.cpp:1602
+
+  NodePair nthSub(size_t N) {
+assert(N < PackIndices.size());

This could perhaps use a comment.  At least, inside the function to explain the 
math.



Comment at: src/cxa_demangle.cpp:1603
+  NodePair nthSub(size_t N) {
+assert(N < PackIndices.size());
+Node **Begin = Subs.begin() + PackIndices[N];

Once you add this assertion to `operator[]` you can delete it here.



Comment at: src/cxa_demangle.cpp:1604
+assert(N < PackIndices.size());
+Node **Begin = Subs.begin() + PackIndices[N];
+Node **End = (N + 1 == PackIndices.size())

Should there be some assertion on `Subs.size()` 

[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-07 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 110111.
morehouse added a comment.

- Build protobuf-mutator with same build type as current build.
- Remove unnecessary options from clang-proto-fuzzer.
- Expand macro.


https://reviews.llvm.org/D36324

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ClangFuzzer.cpp
  clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp
  clang/tools/clang-fuzzer/cxx_proto.proto
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
  clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp

Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp
@@ -0,0 +1,30 @@
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements a simple driver to print a C++ program from a protobuf.
+//
+//===--===//
+#include 
+#include 
+#include 
+#include 
+
+#include "proto_to_cxx.h"
+
+int main(int argc, char **argv) {
+  for (int i = 1; i < argc; i++) {
+std::fstream in(argv[i]);
+std::string str((std::istreambuf_iterator(in)),
+std::istreambuf_iterator());
+std::cout << "// " << argv[i] << std::endl;
+std::cout << clang_fuzzer::ProtoToCxx(
+reinterpret_cast(str.data()), str.size());
+  }
+}
+
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h
@@ -0,0 +1,22 @@
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+namespace clang_fuzzer {
+class Function;
+std::string FunctionToString(const Function );
+std::string ProtoToCxx(const uint8_t *data, size_t size);
+}
Index: clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
===
--- /dev/null
+++ clang/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp
@@ -0,0 +1,107 @@
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Implements functions for converting between protobufs and C++.
+//
+//===--===//
+
+#include "proto_to_cxx.h"
+#include "cxx_proto.pb.h"
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+
+#define P(Type) std::ostream <<(std::ostream , const Type )
+// Forward decls.
+std::ostream <<(std::ostream , const BinaryOp );
+std::ostream <<(std::ostream , const StatementSeq );
+
+// Proto to C++.
+std::ostream <<(std::ostream , const Const ) {
+  return os << "(" << x.val() << ")";
+}
+std::ostream <<(std::ostream , const VarRef ) {
+  return os << "a[" << (static_cast(x.varnum()) % 100) << "]";
+}
+std::ostream <<(std::ostream , const Lvalue ) {
+  return os << x.varref();
+}
+std::ostream <<(std::ostream , const Rvalue ) {
+if (x.has_varref()) return os << x.varref();
+if (x.has_cons())   return os << x.cons();
+if (x.has_binop())  return os << x.binop();
+return os << "1";
+}
+std::ostream <<(std::ostream , const BinaryOp ) {
+  os << "(" << x.left();
+  switch (x.op()) {
+#define OP(a, b) case BinaryOp::a: os << b; break
+OP(PLUS, "+");
+OP(MINUS, "-");
+OP(MUL, "*");
+OP(DIV, "/");
+OP(MOD, "%");
+OP(XOR, "^");
+OP(AND, "&");
+OP(OR, "|");
+OP(EQ, "==");
+OP(NE, "!=");
+OP(LE, "<=");
+OP(GE, ">=");
+OP(LT, "<");
+OP(GT, ">");
+#undef OP
+default: assert(0);
+  }
+  return os << 

[PATCH] D34324: [clang-format] let PointerAlignment dictate spacing of function ref qualifiers

2017-08-07 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

@djasper bump, any thoughts on this?


https://reviews.llvm.org/D34324



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


[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-07 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

This patch needs benchmarks that demonstrate the performance changes.


https://reviews.llvm.org/D36423



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


[PATCH] D36429: [clang-import-test] Option to dump the IR for an expression

2017-08-07 Thread Sean Callanan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310318: This adds the argument --dump-ir to 
clang-import-test, which allows  (authored by spyffe).

Changed prior to commit:
  https://reviews.llvm.org/D36429?vs=110095=110104#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36429

Files:
  cfe/trunk/test/Import/local-struct/Inputs/Callee.cpp
  cfe/trunk/test/Import/local-struct/test.cpp
  cfe/trunk/test/Import/struct-layout/Inputs/Callee.cpp
  cfe/trunk/test/Import/struct-layout/test.cpp
  cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Index: cfe/trunk/tools/clang-import-test/clang-import-test.cpp
===
--- cfe/trunk/tools/clang-import-test/clang-import-test.cpp
+++ cfe/trunk/tools/clang-import-test/clang-import-test.cpp
@@ -27,6 +27,7 @@
 #include "clang/Parse/ParseAST.h"
 
 #include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
@@ -63,6 +64,10 @@
 DumpAST("dump-ast", llvm::cl::init(false),
 llvm::cl::desc("Dump combined AST"));
 
+static llvm::cl::opt
+DumpIR("dump-ir", llvm::cl::init(false),
+llvm::cl::desc("Dump IR from final parse"));
+
 namespace init_convenience {
 class TestDiagnosticConsumer : public DiagnosticConsumer {
 private:
@@ -264,7 +269,7 @@
 llvm::Expected
 Parse(const std::string ,
   llvm::ArrayRef Imports,
-  bool ShouldDumpAST) {
+  bool ShouldDumpAST, bool ShouldDumpIR) {
   std::unique_ptr CI =
   init_convenience::BuildCompilerInstance();
   auto ST = llvm::make_unique();
@@ -279,6 +284,7 @@
 
   auto LLVMCtx = llvm::make_unique();
   ASTConsumers.push_back(init_convenience::BuildCodeGen(*CI, *LLVMCtx));
+  auto  = *static_cast(ASTConsumers.back().get());
 
   if (ShouldDumpAST)
 ASTConsumers.push_back(CreateASTDumper("", true, false, false));
@@ -292,6 +298,8 @@
 return std::move(PE);
   }
   CI->getDiagnosticClient().EndSourceFile();
+  if (ShouldDumpIR)
+CG.GetModule()->print(llvm::outs(), nullptr);
   if (CI->getDiagnosticClient().getNumErrors()) {
 return llvm::make_error(
 "Errors occured while parsing the expression.", std::error_code());
@@ -309,7 +317,7 @@
   std::vector ImportCIs;
   for (auto I : Imports) {
 llvm::Expected ImportCI =
-  Parse(I, {}, false);
+  Parse(I, {}, false, false);
 if (auto E = ImportCI.takeError()) {
   llvm::errs() << llvm::toString(std::move(E));
   exit(-1);
@@ -325,7 +333,7 @@
 }
   }
   llvm::Expected ExpressionCI =
-  Parse(Expression, Direct ? ImportCIs : IndirectCIs, DumpAST);
+  Parse(Expression, Direct ? ImportCIs : IndirectCIs, DumpAST, DumpIR);
   if (auto E = ExpressionCI.takeError()) {
 llvm::errs() << llvm::toString(std::move(E));
 exit(-1);
Index: cfe/trunk/test/Import/local-struct/Inputs/Callee.cpp
===
--- cfe/trunk/test/Import/local-struct/Inputs/Callee.cpp
+++ cfe/trunk/test/Import/local-struct/Inputs/Callee.cpp
@@ -0,0 +1,12 @@
+struct Bar {
+  void bar(int _a, bool _b) {
+{
+  struct S { int a; };
+  S s = { _a };
+}
+{
+  struct S { bool b; };
+  S t = { _b };
+}
+  };
+};
Index: cfe/trunk/test/Import/local-struct/test.cpp
===
--- cfe/trunk/test/Import/local-struct/test.cpp
+++ cfe/trunk/test/Import/local-struct/test.cpp
@@ -0,0 +1,8 @@
+// RUN: clang-import-test -dump-ir -import %S/Inputs/Callee.cpp -expression %s | FileCheck %s
+// XFAIL: *
+// CHECK: %struct.S = type { i
+// CHECK: %struct.S.0 = type { i1 }
+
+void foo() {
+  return Bar().bar(3, true);
+}
Index: cfe/trunk/test/Import/struct-layout/Inputs/Callee.cpp
===
--- cfe/trunk/test/Import/struct-layout/Inputs/Callee.cpp
+++ cfe/trunk/test/Import/struct-layout/Inputs/Callee.cpp
@@ -0,0 +1,9 @@
+struct S {
+  int a;
+};
+
+struct Bar {
+  void bar(int _a) {
+S s = { _a };
+  };
+};
Index: cfe/trunk/test/Import/struct-layout/test.cpp
===
--- cfe/trunk/test/Import/struct-layout/test.cpp
+++ cfe/trunk/test/Import/struct-layout/test.cpp
@@ -0,0 +1,6 @@
+// RUN: clang-import-test -dump-ir -import %S/Inputs/Callee.cpp -expression %s | FileCheck %s
+// CHECK: %struct.S = type { i
+
+void foo() {
+  return Bar().bar(3);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310318 - This adds the argument --dump-ir to clang-import-test, which allows

2017-08-07 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Mon Aug  7 15:27:30 2017
New Revision: 310318

URL: http://llvm.org/viewvc/llvm-project?rev=310318=rev
Log:
This adds the argument --dump-ir to clang-import-test, which allows 
viewing of the final IR. This is useful for confirming that 
structure layout was correct.

I've added two tests:

- A test that checks that structs in top-level code are completed 
  correctly during struct layout (they are)
- A test that checks that structs defined in function bodies are 
  cpmpleted correctly during struct layout (currently they are not, 
  so this is XFAIL).

The second test fails because LookupSameContext()
(ExternalASTMerger.cpp) can't find the struct. This is an issue I 
intend to resolve separately.

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

Added:
cfe/trunk/test/Import/local-struct/
  - copied from r310276, cfe/trunk/test/Import/import-overrides/
cfe/trunk/test/Import/local-struct/Inputs/Callee.cpp
  - copied, changed from r310276, 
cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp
cfe/trunk/test/Import/struct-layout/
  - copied from r310276, cfe/trunk/test/Import/import-overrides/
cfe/trunk/test/Import/struct-layout/Inputs/Callee.cpp
  - copied, changed from r310276, 
cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp
Removed:
cfe/trunk/test/Import/local-struct/Inputs/Hierarchy.cpp
cfe/trunk/test/Import/struct-layout/Inputs/Hierarchy.cpp
Modified:
cfe/trunk/test/Import/local-struct/test.cpp
cfe/trunk/test/Import/struct-layout/test.cpp
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Copied: cfe/trunk/test/Import/local-struct/Inputs/Callee.cpp (from r310276, 
cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/local-struct/Inputs/Callee.cpp?p2=cfe/trunk/test/Import/local-struct/Inputs/Callee.cpp=cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp=310276=310318=310318=diff
==
--- cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp (original)
+++ cfe/trunk/test/Import/local-struct/Inputs/Callee.cpp Mon Aug  7 15:27:30 
2017
@@ -1,9 +1,12 @@
-class Base {
-public:
-  virtual void foo() {}
-};
-
-class Derived : public Base {
-public:
-  void foo() override {}
+struct Bar {
+  void bar(int _a, bool _b) {
+{
+  struct S { int a; };
+  S s = { _a };
+}
+{
+  struct S { bool b; };
+  S t = { _b };
+}
+  };
 };

Removed: cfe/trunk/test/Import/local-struct/Inputs/Hierarchy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp?rev=310276=auto
==
--- cfe/trunk/test/Import/local-struct/Inputs/Hierarchy.cpp (original)
+++ cfe/trunk/test/Import/local-struct/Inputs/Hierarchy.cpp (removed)
@@ -1,9 +0,0 @@
-class Base {
-public:
-  virtual void foo() {}
-};
-
-class Derived : public Base {
-public:
-  void foo() override {}
-};

Modified: cfe/trunk/test/Import/local-struct/test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/local-struct/test.cpp?rev=310318=310276=310318=diff
==
--- cfe/trunk/test/Import/local-struct/test.cpp (original)
+++ cfe/trunk/test/Import/local-struct/test.cpp Mon Aug  7 15:27:30 2017
@@ -1,7 +1,8 @@
-// RUN: clang-import-test -dump-ast -import %S/Inputs/Hierarchy.cpp 
-expression %s | FileCheck %s
-
-// CHECK: Overrides:{{.*}}Base::foo
+// RUN: clang-import-test -dump-ir -import %S/Inputs/Callee.cpp -expression %s 
| FileCheck %s
+// XFAIL: *
+// CHECK: %struct.S = type { i
+// CHECK: %struct.S.0 = type { i1 }
 
 void foo() {
-  Derived d;
+  return Bar().bar(3, true);
 }

Copied: cfe/trunk/test/Import/struct-layout/Inputs/Callee.cpp (from r310276, 
cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/struct-layout/Inputs/Callee.cpp?p2=cfe/trunk/test/Import/struct-layout/Inputs/Callee.cpp=cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp=310276=310318=310318=diff
==
--- cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp (original)
+++ cfe/trunk/test/Import/struct-layout/Inputs/Callee.cpp Mon Aug  7 15:27:30 
2017
@@ -1,9 +1,9 @@
-class Base {
-public:
-  virtual void foo() {}
+struct S {
+  int a;
 };
 
-class Derived : public Base {
-public:
-  void foo() override {}
+struct Bar {
+  void bar(int _a) {
+S s = { _a };
+  };
 };

Removed: cfe/trunk/test/Import/struct-layout/Inputs/Hierarchy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Import/import-overrides/Inputs/Hierarchy.cpp?rev=310276=auto
==
--- 

[PATCH] D36019: [clang-format] Fix bug with ENAS_DontAlign and empty lines

2017-08-07 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

Thanks. Can you commit this when you get a chance? I don't have permissions.


https://reviews.llvm.org/D36019



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


[PATCH] D36429: [clang-import-test] Option to dump the IR for an expression

2017-08-07 Thread Lang Hames via Phabricator via cfe-commits
lhames accepted this revision.
lhames added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: tools/clang-import-test/clang-import-test.cpp:301-303
+  if (ShouldDumpIR) {
+CG.GetModule()->print(llvm::outs(), nullptr);
+  }

LLVM style says no braces for single line conditionals. :)


https://reviews.llvm.org/D36429



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


Re: [PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-07 Thread David Blaikie via cfe-commits
On Mon, Aug 7, 2017 at 12:08 PM Mandeep Singh Grang via Phabricator <
revi...@reviews.llvm.org> wrote:

> mgrang added a comment.
>
> This patch does 3 things:
>
> 1. Get rid of the unit test objc-modern-metadata-visibility2.mm because
> this test check uses flag -reverse-iterate. This flag will be removed in
> https://reviews.llvm.org/D35043.
>

Sure - please commit that separately (probably once D35043 is approved -
probably best to include that removal in D35043, or a separate patch that
/only/ removes the -reverse-iterate flag (& any tests that use it) as a
standalone change?).

Does this test need a replacement? If this test is removed and the
underlying issue it was testing regresses, will one of the buildbots
(reverse or normal) catch the problem?


> 2. https://reviews.llvm.org/D35043 gets rid of the empty base definition
> for PointerLikeTypeTraits. This results in a compiler warning because
> PointerLikeTypeTrait has been defined as struct here while in the header it
> is a class. So I have changed struct to class.
>

I'd probably go the other way - traits classes like this make more sense as
structs, I think - it only has public members & no implementation really
has any need for supporting private members.


> 3. Since I changed struct PointerLikeTypeTrait to class
> PointerLikeTypeTrait here, the member functions are no longer public now.
> This results in a compiler error. So I explicitly marked them as public
> here.
>
>
> https://reviews.llvm.org/D36386
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36429: [clang-import-test] Option to dump the IR for an expression

2017-08-07 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 110095.
spyffe added a comment.

Eliminate sensitive dependence on `sizeof(int)`.  `bool` should still be 
rendered as `i1` though.


https://reviews.llvm.org/D36429

Files:
  test/Import/local-struct/Inputs/Callee.cpp
  test/Import/local-struct/test.cpp
  test/Import/struct-layout/Inputs/Callee.cpp
  test/Import/struct-layout/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -27,6 +27,7 @@
 #include "clang/Parse/ParseAST.h"
 
 #include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
@@ -63,6 +64,10 @@
 DumpAST("dump-ast", llvm::cl::init(false),
 llvm::cl::desc("Dump combined AST"));
 
+static llvm::cl::opt
+DumpIR("dump-ir", llvm::cl::init(false),
+llvm::cl::desc("Dump IR from final parse"));
+
 namespace init_convenience {
 class TestDiagnosticConsumer : public DiagnosticConsumer {
 private:
@@ -264,7 +269,7 @@
 llvm::Expected
 Parse(const std::string ,
   llvm::ArrayRef Imports,
-  bool ShouldDumpAST) {
+  bool ShouldDumpAST, bool ShouldDumpIR) {
   std::unique_ptr CI =
   init_convenience::BuildCompilerInstance();
   auto ST = llvm::make_unique();
@@ -279,6 +284,7 @@
 
   auto LLVMCtx = llvm::make_unique();
   ASTConsumers.push_back(init_convenience::BuildCodeGen(*CI, *LLVMCtx));
+  auto  = *static_cast(ASTConsumers.back().get());
 
   if (ShouldDumpAST)
 ASTConsumers.push_back(CreateASTDumper("", true, false, false));
@@ -292,6 +298,9 @@
 return std::move(PE);
   }
   CI->getDiagnosticClient().EndSourceFile();
+  if (ShouldDumpIR) {
+CG.GetModule()->print(llvm::outs(), nullptr);
+  }
   if (CI->getDiagnosticClient().getNumErrors()) {
 return llvm::make_error(
 "Errors occured while parsing the expression.", std::error_code());
@@ -309,7 +318,7 @@
   std::vector ImportCIs;
   for (auto I : Imports) {
 llvm::Expected ImportCI =
-  Parse(I, {}, false);
+  Parse(I, {}, false, false);
 if (auto E = ImportCI.takeError()) {
   llvm::errs() << llvm::toString(std::move(E));
   exit(-1);
@@ -325,7 +334,7 @@
 }
   }
   llvm::Expected ExpressionCI =
-  Parse(Expression, Direct ? ImportCIs : IndirectCIs, DumpAST);
+  Parse(Expression, Direct ? ImportCIs : IndirectCIs, DumpAST, DumpIR);
   if (auto E = ExpressionCI.takeError()) {
 llvm::errs() << llvm::toString(std::move(E));
 exit(-1);
Index: test/Import/struct-layout/test.cpp
===
--- test/Import/struct-layout/test.cpp
+++ test/Import/struct-layout/test.cpp
@@ -1,7 +1,6 @@
-// RUN: clang-import-test -dump-ast -import %S/Inputs/Hierarchy.cpp -expression %s | FileCheck %s
+// RUN: clang-import-test -dump-ir -import %S/Inputs/Callee.cpp -expression %s | FileCheck %s
+// CHECK: %struct.S = type { i
 
-// CHECK: Overrides:{{.*}}Base::foo
-
 void foo() {
-  Derived d;
+  return Bar().bar(3);
 }
Index: test/Import/struct-layout/Inputs/Callee.cpp
===
--- test/Import/struct-layout/Inputs/Callee.cpp
+++ test/Import/struct-layout/Inputs/Callee.cpp
@@ -1,9 +1,9 @@
-class Base {
-public:
-  virtual void foo() {}
+struct S {
+  int a;
 };
 
-class Derived : public Base {
-public:
-  void foo() override {}
+struct Bar {
+  void bar(int _a) {
+S s = { _a };
+  };
 };
Index: test/Import/local-struct/test.cpp
===
--- test/Import/local-struct/test.cpp
+++ test/Import/local-struct/test.cpp
@@ -1,7 +1,8 @@
-// RUN: clang-import-test -dump-ast -import %S/Inputs/Hierarchy.cpp -expression %s | FileCheck %s
+// RUN: clang-import-test -dump-ir -import %S/Inputs/Callee.cpp -expression %s | FileCheck %s
+// XFAIL: *
+// CHECK: %struct.S = type { i
+// CHECK: %struct.S.0 = type { i1 }
 
-// CHECK: Overrides:{{.*}}Base::foo
-
 void foo() {
-  Derived d;
+  return Bar().bar(3, true);
 }
Index: test/Import/local-struct/Inputs/Callee.cpp
===
--- test/Import/local-struct/Inputs/Callee.cpp
+++ test/Import/local-struct/Inputs/Callee.cpp
@@ -1,9 +1,12 @@
-class Base {
-public:
-  virtual void foo() {}
+struct Bar {
+  void bar(int _a, bool _b) {
+{
+  struct S { int a; };
+  S s = { _a };
+}
+{
+  struct S { bool b; };
+  S t = { _b };
+}
+  };
 };
-
-class Derived : public Base {
-public:
-  void foo() override {}
-};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D36429: [clang-import-test] Option to dump the IR for an expression

2017-08-07 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 110093.
spyffe added a comment.

Added a passing test for a global struct, so we have something that'll fail if 
the IR dumping breaks.


https://reviews.llvm.org/D36429

Files:
  test/Import/local-struct/Inputs/Callee.cpp
  test/Import/local-struct/test.cpp
  test/Import/struct-layout/Inputs/Callee.cpp
  test/Import/struct-layout/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -27,6 +27,7 @@
 #include "clang/Parse/ParseAST.h"
 
 #include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
@@ -63,6 +64,10 @@
 DumpAST("dump-ast", llvm::cl::init(false),
 llvm::cl::desc("Dump combined AST"));
 
+static llvm::cl::opt
+DumpIR("dump-ir", llvm::cl::init(false),
+llvm::cl::desc("Dump IR from final parse"));
+
 namespace init_convenience {
 class TestDiagnosticConsumer : public DiagnosticConsumer {
 private:
@@ -264,7 +269,7 @@
 llvm::Expected
 Parse(const std::string ,
   llvm::ArrayRef Imports,
-  bool ShouldDumpAST) {
+  bool ShouldDumpAST, bool ShouldDumpIR) {
   std::unique_ptr CI =
   init_convenience::BuildCompilerInstance();
   auto ST = llvm::make_unique();
@@ -279,6 +284,7 @@
 
   auto LLVMCtx = llvm::make_unique();
   ASTConsumers.push_back(init_convenience::BuildCodeGen(*CI, *LLVMCtx));
+  auto  = *static_cast(ASTConsumers.back().get());
 
   if (ShouldDumpAST)
 ASTConsumers.push_back(CreateASTDumper("", true, false, false));
@@ -292,6 +298,9 @@
 return std::move(PE);
   }
   CI->getDiagnosticClient().EndSourceFile();
+  if (ShouldDumpIR) {
+CG.GetModule()->print(llvm::outs(), nullptr);
+  }
   if (CI->getDiagnosticClient().getNumErrors()) {
 return llvm::make_error(
 "Errors occured while parsing the expression.", std::error_code());
@@ -309,7 +318,7 @@
   std::vector ImportCIs;
   for (auto I : Imports) {
 llvm::Expected ImportCI =
-  Parse(I, {}, false);
+  Parse(I, {}, false, false);
 if (auto E = ImportCI.takeError()) {
   llvm::errs() << llvm::toString(std::move(E));
   exit(-1);
@@ -325,7 +334,7 @@
 }
   }
   llvm::Expected ExpressionCI =
-  Parse(Expression, Direct ? ImportCIs : IndirectCIs, DumpAST);
+  Parse(Expression, Direct ? ImportCIs : IndirectCIs, DumpAST, DumpIR);
   if (auto E = ExpressionCI.takeError()) {
 llvm::errs() << llvm::toString(std::move(E));
 exit(-1);
Index: test/Import/struct-layout/test.cpp
===
--- test/Import/struct-layout/test.cpp
+++ test/Import/struct-layout/test.cpp
@@ -1,7 +1,6 @@
-// RUN: clang-import-test -dump-ast -import %S/Inputs/Hierarchy.cpp -expression %s | FileCheck %s
+// RUN: clang-import-test -dump-ir -import %S/Inputs/Callee.cpp -expression %s | FileCheck %s
+// CHECK: %struct.S = type { i32 }
 
-// CHECK: Overrides:{{.*}}Base::foo
-
 void foo() {
-  Derived d;
+  return Bar().bar(3);
 }
Index: test/Import/struct-layout/Inputs/Callee.cpp
===
--- test/Import/struct-layout/Inputs/Callee.cpp
+++ test/Import/struct-layout/Inputs/Callee.cpp
@@ -1,9 +1,9 @@
-class Base {
-public:
-  virtual void foo() {}
+struct S {
+  int a;
 };
 
-class Derived : public Base {
-public:
-  void foo() override {}
+struct Bar {
+  void bar(int _a) {
+S s = { _a };
+  };
 };
Index: test/Import/local-struct/test.cpp
===
--- test/Import/local-struct/test.cpp
+++ test/Import/local-struct/test.cpp
@@ -1,7 +1,8 @@
-// RUN: clang-import-test -dump-ast -import %S/Inputs/Hierarchy.cpp -expression %s | FileCheck %s
+// RUN: clang-import-test -dump-ir -import %S/Inputs/Callee.cpp -expression %s | FileCheck %s
+// XFAIL: *
+// CHECK: %struct.S = type { i32 }
+// CHECK: %struct.S.0 = type { i8 }
 
-// CHECK: Overrides:{{.*}}Base::foo
-
 void foo() {
-  Derived d;
+  return Bar().bar(3, true);
 }
Index: test/Import/local-struct/Inputs/Callee.cpp
===
--- test/Import/local-struct/Inputs/Callee.cpp
+++ test/Import/local-struct/Inputs/Callee.cpp
@@ -1,9 +1,12 @@
-class Base {
-public:
-  virtual void foo() {}
+struct Bar {
+  void bar(int _a, bool _b) {
+{
+  struct S { int a; };
+  S s = { _a };
+}
+{
+  struct S { bool b; };
+  S t = { _b };
+}
+  };
 };
-
-class Derived : public Base {
-public:
-  void foo() override {}
-};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D36429: [clang-import-test] Option to dump the IR for an expression

2017-08-07 Thread Sean Callanan via Phabricator via cfe-commits
spyffe created this revision.

This adds the argument `--dump-ir` to `clang-import-test`, which allows viewing 
of the final IR.   This is useful for confirming that structure layout was 
correct.

I've added an XFAILed test that exercises this, checking that a struct defined 
inside a function body has the right fields.  Currently it does not because 
`LookupSameContext()` (ExternalASTMerger.cpp) can't find the struct.  This is 
an issue I intend to resolve separately.


Repository:
  rL LLVM

https://reviews.llvm.org/D36429

Files:
  test/Import/local-struct/Inputs/Callee.cpp
  test/Import/local-struct/test.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -27,6 +27,7 @@
 #include "clang/Parse/ParseAST.h"
 
 #include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Host.h"
@@ -63,6 +64,10 @@
 DumpAST("dump-ast", llvm::cl::init(false),
 llvm::cl::desc("Dump combined AST"));
 
+static llvm::cl::opt
+DumpIR("dump-ir", llvm::cl::init(false),
+llvm::cl::desc("Dump IR from final parse"));
+
 namespace init_convenience {
 class TestDiagnosticConsumer : public DiagnosticConsumer {
 private:
@@ -264,7 +269,7 @@
 llvm::Expected
 Parse(const std::string ,
   llvm::ArrayRef Imports,
-  bool ShouldDumpAST) {
+  bool ShouldDumpAST, bool ShouldDumpIR) {
   std::unique_ptr CI =
   init_convenience::BuildCompilerInstance();
   auto ST = llvm::make_unique();
@@ -279,6 +284,7 @@
 
   auto LLVMCtx = llvm::make_unique();
   ASTConsumers.push_back(init_convenience::BuildCodeGen(*CI, *LLVMCtx));
+  auto  = *static_cast(ASTConsumers.back().get());
 
   if (ShouldDumpAST)
 ASTConsumers.push_back(CreateASTDumper("", true, false, false));
@@ -292,6 +298,9 @@
 return std::move(PE);
   }
   CI->getDiagnosticClient().EndSourceFile();
+  if (ShouldDumpIR) {
+CG.GetModule()->print(llvm::outs(), nullptr);
+  }
   if (CI->getDiagnosticClient().getNumErrors()) {
 return llvm::make_error(
 "Errors occured while parsing the expression.", std::error_code());
@@ -309,7 +318,7 @@
   std::vector ImportCIs;
   for (auto I : Imports) {
 llvm::Expected ImportCI =
-  Parse(I, {}, false);
+  Parse(I, {}, false, false);
 if (auto E = ImportCI.takeError()) {
   llvm::errs() << llvm::toString(std::move(E));
   exit(-1);
@@ -325,7 +334,7 @@
 }
   }
   llvm::Expected ExpressionCI =
-  Parse(Expression, Direct ? ImportCIs : IndirectCIs, DumpAST);
+  Parse(Expression, Direct ? ImportCIs : IndirectCIs, DumpAST, DumpIR);
   if (auto E = ExpressionCI.takeError()) {
 llvm::errs() << llvm::toString(std::move(E));
 exit(-1);
Index: test/Import/local-struct/test.cpp
===
--- test/Import/local-struct/test.cpp
+++ test/Import/local-struct/test.cpp
@@ -1,7 +1,8 @@
-// RUN: clang-import-test -dump-ast -import %S/Inputs/Hierarchy.cpp -expression %s | FileCheck %s
+// RUN: clang-import-test -dump-ir -import %S/Inputs/Callee.cpp -expression %s | FileCheck %s
+// XFAIL: *
+// CHECK: %struct.S = type { i32 }
+// CHECK: %struct.S.0 = type { i8 }
 
-// CHECK: Overrides:{{.*}}Base::foo
-
 void foo() {
-  Derived d;
+  return Bar().bar(3, true);
 }
Index: test/Import/local-struct/Inputs/Callee.cpp
===
--- test/Import/local-struct/Inputs/Callee.cpp
+++ test/Import/local-struct/Inputs/Callee.cpp
@@ -1,9 +1,12 @@
-class Base {
-public:
-  virtual void foo() {}
+struct Bar {
+  void bar(int _a, bool _b) {
+{
+  struct S { int a; };
+  S s = { _a };
+}
+{
+  struct S { bool b; };
+  S t = { _b };
+}
+  };
 };
-
-class Derived : public Base {
-public:
-  void foo() override {}
-};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-07 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev added a comment.

In https://reviews.llvm.org/D34158#834298, @mibintc wrote:

> In fact I did have trouble writing the new test case to pass with the 
> gnu/Linux toolchain. In the file lib/Driver/ToolChains/Linux.cpp function 
> AddGnuIncludeArgs checks if GCCInstallation.isValid().


You should not be doing stdc-predef.h under GCCInstallation.isValid().
You are handling interaction with libc, so it has nothing to do with the 
presence or absence of gcc toolchain.


https://reviews.llvm.org/D34158



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


[PATCH] D36324: Integrate Kostya's clang-proto-fuzzer with LLVM.

2017-08-07 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added a reviewer: bogner.
kcc added a comment.

+bogner@ FYI




Comment at: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp:25
+
+static void MaybePrint(const std::string ) {
+  static const char *env = getenv("CXXFUZZ_PRINT");

this is debug code, not worth having here, plz remove



Comment at: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp:34
+  MaybePrint(S);
+  HandleCXX(S, {"-O2", "-mllvm", "-scalar-evolution-max-arith-depth=4"});
+  if (getenv("CXX_FUZZ_MORE")) {

Remove "-mllvm", "-scalar-evolution-max-arith-depth=4".
It's there as a workaround for a performance bug 
(https://bugs.llvm.org/show_bug.cgi?id=33494) but it shouldn't be here. 



Comment at: clang/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp:35
+  HandleCXX(S, {"-O2", "-mllvm", "-scalar-evolution-max-arith-depth=4"});
+  if (getenv("CXX_FUZZ_MORE")) {
+HandleCXX(S, {"-O1", "-triple", "arm-apple-darwin10", "-mllvm",

Remove this section. 
In a later change, please allow to change the tripple (and any other flags) 
similar to https://reviews.llvm.org/D36275



Comment at: clang/tools/clang-fuzzer/cxx_proto.proto:16
+
+syntax = "proto2";
+//option cc_api_version = 2;

vitalybuka wrote:
> vitalybuka wrote:
> > I'd suggest proto3
> proto3 has no required, to avoid backward compatibility issues.
> Same is useful for us, we don't wont to discard corpus if we drop some field 
> in the future.
I'm afraid it's much more convenient to have 'required' here. 
How else could you express a binary op node? 



Comment at: clang/tools/clang-fuzzer/cxx_proto.proto:93
+}
+
+package clang_fuzzer;

vitalybuka wrote:
> morehouse wrote:
> > vitalybuka wrote:
> > > message CxxInput {
> > >   required Function f = 1;
> > >   required int/enum opt_level = 2;
> > >   required enum tripple = 3;
> > >   required scalar-evolution-max-arith-depth ...
> > > }
> > Interesting idea.  This would allow for protobuf-mutator to choose 
> > different option combinations, if I understand correctly.
> > 
> > Is that worth adding to this initial patch, though?
> yes, instead of CXX_FUZZ_MORE
For now, keep it as is, please (see my other comment about flags) 


https://reviews.llvm.org/D36324



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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-07 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added inline comments.



Comment at: lib/Format/UnwrappedLineParser.h:238
 
+  unsigned PPIndentLevel;
+  FormatToken *PPMaybeIncludeGuard;

djasper wrote:
> I think this should almost always be PPBranchLevel. Probably the different 
> case is the #else itself, but I think we can handle that easily.
It doesn't look like PPBranchLevel can be used to differentiate between no 
indent and one level of indent, since it starts at -1 and then stays >=0. For 
example:
```
#define A // -1
#if B // -1
#  define C   // 0
#  if D   // 0
#define E // 1
#  endif  // 0
#endif// 0
#define F // 0
```



https://reviews.llvm.org/D35955



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


[PATCH] D36159: clang-format: [JS] handle single lines comments ending in `\\`.

2017-08-07 Thread Martin Probst via Phabricator via cfe-commits
mprobst added a comment.

Friendly ping.


https://reviews.llvm.org/D36159



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


[PATCH] D36359: [clang-format] Put '/**' and '*/' on own lines in jsdocs ending in comment pragmas

2017-08-07 Thread Martin Probst via Phabricator via cfe-commits
mprobst added inline comments.



Comment at: lib/Format/BreakableToken.cpp:688
+  if (DelimitersOnNewline) {
+StringRef TrimmedContent = Content.back().substr(TailOffset).rtrim(Blanks);
+if (!TrimmedContent.empty()) {

Can you add a comment on what this is doing? It's non obvious. Make sure to 
document both intention (why) and implementation (how).



Comment at: lib/Format/BreakableToken.cpp:688
+  if (DelimitersOnNewline) {
+StringRef TrimmedContent = Content.back().substr(TailOffset).rtrim(Blanks);
+if (!TrimmedContent.empty()) {

mprobst wrote:
> Can you add a comment on what this is doing? It's non obvious. Make sure to 
> document both intention (why) and implementation (how).
I don't understand why we're trimming `Content.back()` here, and `Lines.back()` 
below.



Comment at: lib/Format/BreakableToken.cpp:690
+if (!TrimmedContent.empty()) {
+  size_t Whitespaces =
+  Lines.back().size() - Lines.back().rtrim(Blanks).size();

`Whitespaces` seems like a bad variable name, isn't this rather the index of 
trimmed whitespace in the last line?


https://reviews.llvm.org/D36359



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


[PATCH] D36411: Restore previous structure ABI for bitfields with 'packed' attribute for PS4 targets

2017-08-07 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

An ABI change was introduced in r254596 that modified structure layouts when 
the 'packed' attribute was used on one-byte bitfields. Since the PS4 target 
needs to maintain backwards compatibility for all structure layouts, this 
change reintroduces the old behavior for PS4 targets only. It also introduces 
PS4 specific cases to the relevant test.

See the following review for discussion of r254596.
https://reviews.llvm.org/D14872


https://reviews.llvm.org/D36411



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


[PATCH] D36105: [AArch64] Ignore stdcall and similar on aarch64/windows

2017-08-07 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310303: [AArch64] Ignore stdcall and similar on 
aarch64/windows (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D36105?vs=108977=110082#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36105

Files:
  cfe/trunk/lib/Basic/Targets/AArch64.cpp
  cfe/trunk/lib/Basic/Targets/AArch64.h
  cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c


Index: cfe/trunk/lib/Basic/Targets/AArch64.cpp
===
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp
@@ -458,6 +458,23 @@
   return TargetInfo::CharPtrBuiltinVaList;
 }
 
+TargetInfo::CallingConvCheckResult
+MicrosoftARM64TargetInfo::checkCallingConvention(CallingConv CC) const {
+  switch (CC) {
+  case CC_X86StdCall:
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;
+  case CC_C:
+  case CC_OpenCLKernel:
+  case CC_Win64:
+return CCCR_OK;
+  default:
+return CCCR_Warning;
+  }
+}
+
 DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const llvm::Triple ,
  const TargetOptions )
 : DarwinTargetInfo(Triple, Opts) {
Index: cfe/trunk/lib/Basic/Targets/AArch64.h
===
--- cfe/trunk/lib/Basic/Targets/AArch64.h
+++ cfe/trunk/lib/Basic/Targets/AArch64.h
@@ -105,6 +105,8 @@
 MacroBuilder ) const override;
 
   BuiltinVaListKind getBuiltinVaListKind() const override;
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 };
 
 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
Index: cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c
===
--- cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c
+++ cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-windows -fms-compatibility -fsyntax-only 
-verify %s
 
 int __cdecl cdecl(int a, int b, int c, int d) { // expected-no-diagnostics
   return a + b + c + d;


Index: cfe/trunk/lib/Basic/Targets/AArch64.cpp
===
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp
@@ -458,6 +458,23 @@
   return TargetInfo::CharPtrBuiltinVaList;
 }
 
+TargetInfo::CallingConvCheckResult
+MicrosoftARM64TargetInfo::checkCallingConvention(CallingConv CC) const {
+  switch (CC) {
+  case CC_X86StdCall:
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;
+  case CC_C:
+  case CC_OpenCLKernel:
+  case CC_Win64:
+return CCCR_OK;
+  default:
+return CCCR_Warning;
+  }
+}
+
 DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const llvm::Triple ,
  const TargetOptions )
 : DarwinTargetInfo(Triple, Opts) {
Index: cfe/trunk/lib/Basic/Targets/AArch64.h
===
--- cfe/trunk/lib/Basic/Targets/AArch64.h
+++ cfe/trunk/lib/Basic/Targets/AArch64.h
@@ -105,6 +105,8 @@
 MacroBuilder ) const override;
 
   BuiltinVaListKind getBuiltinVaListKind() const override;
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 };
 
 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {
Index: cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c
===
--- cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c
+++ cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-windows -fms-compatibility -fsyntax-only -verify %s
 
 int __cdecl cdecl(int a, int b, int c, int d) { // expected-no-diagnostics
   return a + b + c + d;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310303 - [AArch64] Ignore stdcall and similar on aarch64/windows

2017-08-07 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon Aug  7 13:52:04 2017
New Revision: 310303

URL: http://llvm.org/viewvc/llvm-project?rev=310303=rev
Log:
[AArch64] Ignore stdcall and similar on aarch64/windows

This is similar to what's done on arm and x86_64, where
these calling conventions are silently ignored, as in
SVN r245076.

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

Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp
cfe/trunk/lib/Basic/Targets/AArch64.h
cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=310303=310302=310303=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Mon Aug  7 13:52:04 2017
@@ -458,6 +458,23 @@ MicrosoftARM64TargetInfo::getBuiltinVaLi
   return TargetInfo::CharPtrBuiltinVaList;
 }
 
+TargetInfo::CallingConvCheckResult
+MicrosoftARM64TargetInfo::checkCallingConvention(CallingConv CC) const {
+  switch (CC) {
+  case CC_X86StdCall:
+  case CC_X86ThisCall:
+  case CC_X86FastCall:
+  case CC_X86VectorCall:
+return CCCR_Ignore;
+  case CC_C:
+  case CC_OpenCLKernel:
+  case CC_Win64:
+return CCCR_OK;
+  default:
+return CCCR_Warning;
+  }
+}
+
 DarwinAArch64TargetInfo::DarwinAArch64TargetInfo(const llvm::Triple ,
  const TargetOptions )
 : DarwinTargetInfo(Triple, Opts) {

Modified: cfe/trunk/lib/Basic/Targets/AArch64.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.h?rev=310303=310302=310303=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.h (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.h Mon Aug  7 13:52:04 2017
@@ -105,6 +105,8 @@ public:
 MacroBuilder ) const override;
 
   BuiltinVaListKind getBuiltinVaListKind() const override;
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override;
 };
 
 class LLVM_LIBRARY_VISIBILITY AArch64beTargetInfo : public AArch64TargetInfo {

Modified: cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c?rev=310303=310302=310303=diff
==
--- cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c (original)
+++ cfe/trunk/test/Parser/arm-windows-calling-convention-handling.c Mon Aug  7 
13:52:04 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only 
-verify %s
+// RUN: %clang_cc1 -triple aarch64-windows -fms-compatibility -fsyntax-only 
-verify %s
 
 int __cdecl cdecl(int a, int b, int c, int d) { // expected-no-diagnostics
   return a + b + c + d;


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


Re: r310158 - [ODRHash] Treat some non-templated classes as templated.

2017-08-07 Thread Hans Wennborg via cfe-commits
On Fri, Aug 4, 2017 at 5:54 PM, Richard Trieu via cfe-commits
 wrote:
> Author: rtrieu
> Date: Fri Aug  4 17:54:19 2017
> New Revision: 310158
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310158=rev
> Log:
> [ODRHash] Treat some non-templated classes as templated.
>
> When using nested classes, if the inner class is not templated, but the outer
> class is templated, the inner class will not be templated, but may have some
> traits as if it were.  This is particularly evident if the inner class
> refers to the outer class in some fashion.  Treat any class that is in the
> context of a templated class as also a templated class.
>
> Modified:
> cfe/trunk/lib/AST/ODRHash.cpp

Merged to 5.0 in r310302.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36427: [libcxxabi][demangler] Improve representation of substitutions/templates

2017-08-07 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.

This patch changes the demangler so that it represents substitutions/templates 
more linearly. Previously, substitions were represented by a 
`vector>` and template parameter substitutions by a 
`vector>>`! I wrote a comment in SubTable describing how 
this is done. 
This patch gives a 20%-25% time reduction to demangle the symbols in LLVM, a 
25% reduction in code size for the demangler on my machine, and makes the 
demangler a lot easier to read, IMO.

Thanks for taking a look!
Erik


https://reviews.llvm.org/D36427

Files:
  src/cxa_demangle.cpp

Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -1407,117 +1407,6 @@
   }
 };
 
-template 
-class arena
-{
-static const std::size_t alignment = 16;
-alignas(alignment) char buf_[N];
-char* ptr_;
-
-std::size_t 
-align_up(std::size_t n) noexcept
-{return (n + (alignment-1)) & ~(alignment-1);}
-
-bool
-pointer_in_buffer(char* p) noexcept
-{return buf_ <= p && p <= buf_ + N;}
-
-public:
-arena() noexcept : ptr_(buf_) {}
-~arena() {ptr_ = nullptr;}
-arena(const arena&) = delete;
-arena& operator=(const arena&) = delete;
-
-char* allocate(std::size_t n);
-void deallocate(char* p, std::size_t n) noexcept;
-
-static constexpr std::size_t size() {return N;}
-std::size_t used() const {return static_cast(ptr_ - buf_);}
-void reset() {ptr_ = buf_;}
-};
-
-template 
-char*
-arena::allocate(std::size_t n)
-{
-n = align_up(n);
-if (static_cast(buf_ + N - ptr_) >= n)
-{
-char* r = ptr_;
-ptr_ += n;
-return r;
-}
-return static_cast(std::malloc(n));
-}
-
-template 
-void
-arena::deallocate(char* p, std::size_t n) noexcept
-{
-if (pointer_in_buffer(p))
-{
-n = align_up(n);
-if (p + n == ptr_)
-ptr_ = p;
-}
-else
-std::free(p);
-}
-
-template 
-class short_alloc
-{
-arena& a_;
-public:
-typedef T value_type;
-
-public:
-template  struct rebind {typedef short_alloc<_Up, N> other;};
-
-short_alloc(arena& a) noexcept : a_(a) {}
-template 
-short_alloc(const short_alloc& a) noexcept
-: a_(a.a_) {}
-short_alloc(const short_alloc&) = default;
-short_alloc& operator=(const short_alloc&) = delete;
-
-T* allocate(std::size_t n)
-{
-return reinterpret_cast(a_.allocate(n*sizeof(T)));
-}
-void deallocate(T* p, std::size_t n) noexcept
-{
-a_.deallocate(reinterpret_cast(p), n*sizeof(T));
-}
-
-template 
-friend
-bool
-operator==(const short_alloc& x, const short_alloc& y) noexcept;
-
-template  friend class short_alloc;
-};
-
-template 
-inline
-bool
-operator==(const short_alloc& x, const short_alloc& y) noexcept
-{
-return N == M && _ == _;
-}
-
-template 
-inline
-bool
-operator!=(const short_alloc& x, const short_alloc& y) noexcept
-{
-return !(x == y);
-}
-
-const size_t bs = 4 * 1024;
-template  using Alloc = short_alloc;
-template  using Vector = std::vector;
-
 class BumpPointerAllocator {
   struct BlockMeta {
 BlockMeta* Next;
@@ -1568,13 +1457,179 @@
   }
 };
 
+template 
+class PODSmallVector {
+  static_assert(std::is_pod::value, "");
+
+  T *First;
+  T *Last;
+  T *Cap;
+  T Inline[N];
+
+  bool isInline() const { return First == Inline; }
+
+public:
+  PODSmallVector() : First(Inline), Last(First), Cap(Inline + N) {}
+
+  PODSmallVector(const PODSmallVector &) = delete;
+  PODSmallVector& operator=(const PODSmallVector&) = delete;
+
+  PODSmallVector(PODSmallVector&& Other) {
+if (Other.isInline()) {
+  std::copy(Other.begin(), Other.end(), Inline);
+  First = Inline;
+  Last = First + Other.size();
+  Cap = Inline + N;
+  Other.clear();
+  return;
+}
+
+First = Other.First;
+Last = Other.Last;
+Cap = Other.Cap;
+Other.First = Other.Inline;
+Other.Last = Other.Inline;
+Other.Cap = Other.Inline + N;
+  }
+
+  PODSmallVector& operator=(PODSmallVector&& Other) {
+if (Other.isInline()) {
+  if (!isInline()) {
+std::free(First);
+First = Inline;
+Last = Inline;
+Cap = Inline + N;
+  }
+  std::copy(Other.begin(), Other.end(), begin());
+  Last = First + Other.size();
+  return *this;
+}
+
+if (!isInline())
+  std::free(First);
+
+First = Other.First;
+Last = Other.Last;
+Cap = Other.Cap;
+
+Other.First = Other.Inline;
+Other.Last = Other.Inline;
+Other.Cap = Other.Inline + N;
+return *this;
+  }
+
+  void push_back(const T ) {
+if (Last != Cap) {
+  *Last++ = Elem;
+  return;
+}
+
+size_t S = size();
+if (!isInline()) {
+  First = 

[PATCH] D27214: [ObjC] Encode type arguments in property information string constants

2017-08-07 Thread Greg Parker via Phabricator via cfe-commits
gparker42 added a comment.

This won't work. The property attribute string consists of comma-separated 
fields. The encoding used here embeds commas into the type value, which will 
break parsing of the attribute string. You'll need to use a separator other 
than a comma.


Repository:
  rL LLVM

https://reviews.llvm.org/D27214



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


r310299 - Mark static variables static; NFC.

2017-08-07 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Aug  7 13:26:33 2017
New Revision: 310299

URL: http://llvm.org/viewvc/llvm-project?rev=310299=rev
Log:
Mark static variables static; NFC.

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=310299=310298=310299=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Mon Aug  7 13:26:33 2017
@@ -99,8 +99,8 @@ TranslationUnitDecl::TranslationUnitDecl
 // and 'matcher' is a type only matters when looking for attributes
 // and settings from the immediate context.
 
-const unsigned IgnoreExplicitVisibilityBit = 2;
-const unsigned IgnoreAllVisibilityBit = 4;
+const static unsigned IgnoreExplicitVisibilityBit = 2;
+const static unsigned IgnoreAllVisibilityBit = 4;
 
 /// Kinds of LV computation.  The linkage side of the computation is
 /// always the same, but different things can change how visibility is


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


Re: r310191 - [X86] Enable isel to use the PAUSE instruction even when SSE2 is disabled. Clang part

2017-08-07 Thread Hans Wennborg via cfe-commits
On Sat, Aug 5, 2017 at 4:35 PM, Craig Topper via cfe-commits
 wrote:
> Author: ctopper
> Date: Sat Aug  5 16:35:54 2017
> New Revision: 310191
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310191=rev
> Log:
> [X86] Enable isel to use the PAUSE instruction even when SSE2 is disabled. 
> Clang part
>
> Summary:
> On older processors this instruction encoding is treated as a NOP.
>
> MSVC doesn't disable intrinsics based on features the way clang/gcc does. 
> Because the PAUSE instruction encoding doesn't crash older processors, some 
> software out there uses these intrinsics without checking for SSE2.
>
> This change also seems to also be consistent with gcc behavior.
>
> Fixes PR34079
>
> Reviewers: RKSimon, zvi
>
> Reviewed By: RKSimon
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D36362

Merged to 5.0 in r310294.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-07 Thread Yan Wang via Phabricator via cfe-commits
yawanng added a comment.

In https://reviews.llvm.org/D35372#834238, @hokein wrote:

> Looks good to me, a few nits. Thanks for improving it continuously.
>
> I'd hold it for a while to see whether @alexfh has further comments before 
> submitting it.


Thank you for the reviewing :-)


https://reviews.llvm.org/D35372



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


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-07 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110065.
yawanng marked 4 inline comments as done.

https://reviews.llvm.org/D35372

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecCheck.cpp
  clang-tidy/android/CloexecCheck.h
  clang-tidy/android/CloexecMemfdCreateCheck.cpp
  clang-tidy/android/CloexecMemfdCreateCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-memfd-create.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-memfd-create.cpp

Index: test/clang-tidy/android-cloexec-memfd-create.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-memfd-create.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s android-cloexec-memfd-create %t
+
+#define MFD_ALLOW_SEALING 1
+#define __O_CLOEXEC 3
+#define MFD_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int memfd_create(const char *name, unsigned int flags);
+
+void a() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: 'memfd_create' should use MFD_CLOEXEC where possible [android-cloexec-memfd-create]
+  // CHECK-FIXES: memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC))
+}
+
+void f() {
+  memfd_create(NULL, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'memfd_create'
+  // CHECK-FIXES: memfd_create(NULL, 3 | MFD_CLOEXEC)
+  TEMP_FAILURE_RETRY(memfd_create(NULL, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: 'memfd_create'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(memfd_create(NULL, 3 | MFD_CLOEXEC))
+
+  int flag = 3;
+  memfd_create(NULL, flag);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, flag));
+}
+
+namespace i {
+int memfd_create(const char *name, unsigned int flags);
+
+void d() {
+  memfd_create(NULL, MFD_ALLOW_SEALING);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+}
+
+} // namespace i
+
+void e() {
+  memfd_create(NULL, MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_CLOEXEC));
+  memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC);
+  TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING | MFD_CLOEXEC));
+}
+
+class G {
+public:
+  int memfd_create(const char *name, unsigned int flags);
+  void d() {
+memfd_create(NULL, MFD_ALLOW_SEALING);
+TEMP_FAILURE_RETRY(memfd_create(NULL, MFD_ALLOW_SEALING));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
android-cloexec-creat
android-cloexec-fopen
+   android-cloexec-memfd-create
android-cloexec-open
android-cloexec-socket
boost-use-to-string
Index: docs/clang-tidy/checks/android-cloexec-memfd-create.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-memfd-create.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-memfd-create
+
+android-cloexec-memfd-create
+
+
+``memfd_create()`` should include ``MFD_CLOEXEC`` in its type argument to avoid
+the file descriptor leakage. Without this flag, an opened sensitive file would
+remain open across a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  memfd_create(name, MFD_ALLOW_SEALING);
+
+  // becomes
+
+  memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
 
   Checks if the required mode ``e`` exists in the mode argument of ``fopen()``.
 
+- New `android-cloexec-memfd_create
+  `_ check
+
+  Checks if the required file flag ``MFD_CLOEXEC`` is present in the argument of
+  ``memfd_create()``.
+
 - New `android-cloexec-socket
   `_ check
 
Index: clang-tidy/android/CloexecMemfdCreateCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecMemfdCreateCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecMemfdCreateCheck.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.
+//

[libcxx] r310290 - [libc++] Don't hardcode namespace in manual mangling

2017-08-07 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Aug  7 12:59:58 2017
New Revision: 310290

URL: http://llvm.org/viewvc/llvm-project?rev=310290=rev
Log:
[libc++] Don't hardcode namespace in manual mangling

libc++'s inline namespace can change depending on the ABI version.
Instead of hardcoding __1 in the manual Microsoft ABI manglings for the
iostream globals, stringify _LIBCPP_NAMESPACE and use that instead, to
work across all ABI versions.

Modified:
libcxx/trunk/src/iostream.cpp

Modified: libcxx/trunk/src/iostream.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/iostream.cpp?rev=310290=310289=310290=diff
==
--- libcxx/trunk/src/iostream.cpp (original)
+++ libcxx/trunk/src/iostream.cpp Mon Aug  7 12:59:58 2017
@@ -11,19 +11,23 @@
 #include "string"
 #include "new"
 
+#define _str(s) #s
+#define str(s) _str(s)
+#define _LIBCPP_NAMESPACE_STR str(_LIBCPP_NAMESPACE)
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 #ifndef _LIBCPP_HAS_NO_STDIN
 _ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin[sizeof(istream)]
 #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?cin@__1@std@@3V?$basic_istream@DU?$char_traits@D@__1@std@@@12@A")
+__asm__("?cin@" _LIBCPP_NAMESPACE_STR 
"@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_NAMESPACE_STR 
"@std@@@12@A")
 #endif
 ;
 _ALIGNAS_TYPE (__stdinbuf ) static char __cin[sizeof(__stdinbuf )];
 static mbstate_t mb_cin;
 _ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin[sizeof(wistream)]
 #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?wcin@__1@std@@3V?$basic_istream@_WU?$char_traits@_W@__1@std@@@12@A")
+__asm__("?wcin@" _LIBCPP_NAMESPACE_STR 
"@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_NAMESPACE_STR 
"@std@@@12@A")
 #endif
 ;
 _ALIGNAS_TYPE (__stdinbuf ) static char __wcin[sizeof(__stdinbuf 
)];
@@ -33,14 +37,14 @@ static mbstate_t mb_wcin;
 #ifndef _LIBCPP_HAS_NO_STDOUT
 _ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]
 #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?cout@__1@std@@3V?$basic_ostream@DU?$char_traits@D@__1@std@@@12@A")
+__asm__("?cout@" _LIBCPP_NAMESPACE_STR 
"@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_NAMESPACE_STR 
"@std@@@12@A")
 #endif
 ;
 _ALIGNAS_TYPE (__stdoutbuf) static char 
__cout[sizeof(__stdoutbuf)];
 static mbstate_t mb_cout;
 _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)]
 #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?wcout@__1@std@@3V?$basic_ostream@_WU?$char_traits@_W@__1@std@@@12@A")
+__asm__("?wcout@" _LIBCPP_NAMESPACE_STR 
"@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_NAMESPACE_STR 
"@std@@@12@A")
 #endif
 ;
 _ALIGNAS_TYPE (__stdoutbuf) static char 
__wcout[sizeof(__stdoutbuf)];
@@ -49,14 +53,14 @@ static mbstate_t mb_wcout;
 
 _ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]
 #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?cerr@__1@std@@3V?$basic_ostream@DU?$char_traits@D@__1@std@@@12@A")
+__asm__("?cerr@" _LIBCPP_NAMESPACE_STR 
"@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_NAMESPACE_STR 
"@std@@@12@A")
 #endif
 ;
 _ALIGNAS_TYPE (__stdoutbuf) static char 
__cerr[sizeof(__stdoutbuf)];
 static mbstate_t mb_cerr;
 _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)]
 #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?wcerr@__1@std@@3V?$basic_ostream@_WU?$char_traits@_W@__1@std@@@12@A")
+__asm__("?wcerr@" _LIBCPP_NAMESPACE_STR 
"@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_NAMESPACE_STR 
"@std@@@12@A")
 #endif
 ;
 _ALIGNAS_TYPE (__stdoutbuf) static char 
__wcerr[sizeof(__stdoutbuf)];
@@ -64,12 +68,12 @@ static mbstate_t mb_wcerr;
 
 _ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]
 #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?clog@__1@std@@3V?$basic_ostream@DU?$char_traits@D@__1@std@@@12@A")
+__asm__("?clog@" _LIBCPP_NAMESPACE_STR 
"@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_NAMESPACE_STR 
"@std@@@12@A")
 #endif
 ;
 _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)]
 #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?wclog@__1@std@@3V?$basic_ostream@_WU?$char_traits@_W@__1@std@@@12@A")
+__asm__("?wclog@" _LIBCPP_NAMESPACE_STR 
"@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_NAMESPACE_STR 
"@std@@@12@A")
 #endif
 ;
 


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


[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-07 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:7555
+  if (NumRegsLeft > 0)
+NumRegsLeft -= (Size + 31) / 32;
+

Won't NumRegsLeft wrap if size==64 and NumRegsLeft == 1 potentially causing an 
assert later?


https://reviews.llvm.org/D36171



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


[PATCH] D34624: extra test modifications for D34158

2017-08-07 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 110059.
mibintc added a comment.

Updating this patch to latest revision of tools/extra


https://reviews.llvm.org/D34624

Files:
  test/clang-tidy/llvm-include-order.cpp
  test/pp-trace/pp-trace-conditional.cpp
  test/pp-trace/pp-trace-ident.cpp
  test/pp-trace/pp-trace-include.cpp
  test/pp-trace/pp-trace-macro.cpp
  test/pp-trace/pp-trace-modules.cpp
  test/pp-trace/pp-trace-pragma-general.cpp
  test/pp-trace/pp-trace-pragma-ms.cpp
  test/pp-trace/pp-trace-pragma-opencl.cpp


Index: test/pp-trace/pp-trace-pragma-ms.cpp
===
--- test/pp-trace/pp-trace-pragma-ms.cpp
+++ test/pp-trace/pp-trace-pragma-ms.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -target x86_64 
-fms-extensions -w | FileCheck --strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -target x86_64 
-fms-extensions -w -ffreestanding | FileCheck --strict-whitespace %s
 
 #pragma comment(compiler, "compiler comment")
 #pragma comment(exestr, "exestr comment")
Index: test/pp-trace/pp-trace-include.cpp
===
--- test/pp-trace/pp-trace-include.cpp
+++ test/pp-trace/pp-trace-include.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace %s -undef -target x86_64 -std=c++11 | FileCheck 
--strict-whitespace %s
+// RUN: pp-trace %s -undef -ffreestanding -target x86_64 -std=c++11 | 
FileCheck --strict-whitespace %s
 
 #include "Inputs/Level1A.h"
 #include "Inputs/Level1B.h"
Index: test/pp-trace/pp-trace-ident.cpp
===
--- test/pp-trace/pp-trace-ident.cpp
+++ test/pp-trace/pp-trace-ident.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -undef -target x86_64 
-std=c++11 | FileCheck --strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -undef -ffreestanding 
-target x86_64 -std=c++11 | FileCheck --strict-whitespace %s
 
 #ident "$Id$"
 
Index: test/pp-trace/pp-trace-conditional.cpp
===
--- test/pp-trace/pp-trace-conditional.cpp
+++ test/pp-trace/pp-trace-conditional.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged %s -undef -target x86_64 -std=c++11 | 
FileCheck --strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged %s -ffreestanding -undef -target x86_64 
-std=c++11 | FileCheck --strict-whitespace %s
 
 #if 1
 #endif
Index: test/pp-trace/pp-trace-pragma-general.cpp
===
--- test/pp-trace/pp-trace-pragma-general.cpp
+++ test/pp-trace/pp-trace-pragma-general.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s | FileCheck 
--strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding | 
FileCheck --strict-whitespace %s
 
 #pragma clang diagnostic push
 #pragma clang diagnostic pop
Index: test/pp-trace/pp-trace-macro.cpp
===
--- test/pp-trace/pp-trace-macro.cpp
+++ test/pp-trace/pp-trace-macro.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged %s -undef -target x86_64 -std=c++11 | 
FileCheck --strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged %s -undef -ffreestanding -target x86_64 
-std=c++11 | FileCheck --strict-whitespace %s
 
 #define MACRO 1
 int i = MACRO;
Index: test/pp-trace/pp-trace-modules.cpp
===
--- test/pp-trace/pp-trace-modules.cpp
+++ test/pp-trace/pp-trace-modules.cpp
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -x objective-c++ -undef 
-target x86_64 -std=c++11 -fmodules -fcxx-modules -fmodules-cache-path=%t -I%S 
-I%S/Input | FileCheck --strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -x objective-c++ -undef 
-ffreestanding -target x86_64 -std=c++11 -fmodules -fcxx-modules 
-fmodules-cache-path=%t -I%S -I%S/Input | FileCheck --strict-whitespace %s
 
 // CHECK: ---
 
Index: test/pp-trace/pp-trace-pragma-opencl.cpp
===
--- test/pp-trace/pp-trace-pragma-opencl.cpp
+++ test/pp-trace/pp-trace-pragma-opencl.cpp
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -x cl | FileCheck 
--strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding -x cl | 
FileCheck --strict-whitespace %s
 
 #pragma OPENCL EXTENSION all : disable
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
Index: test/clang-tidy/llvm-include-order.cpp
===
--- test/clang-tidy/llvm-include-order.cpp
+++ test/clang-tidy/llvm-include-order.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem 
%S/Inputs/Headers
+// RUN: %check_clang_tidy %s llvm-include-order %t 

[PATCH] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-07 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 110055.
mibintc added a comment.

In the last review, it was deemed less controversial if I move these updates 
back into the gnu/Linux tool chain. This revision is responding to that 
feedback.  I also simplified the test case. I tested on Linux with check-all 
and check-clang and found no unexpected failures.

The other test case modifications are to fix tests which are broken with this 
change due to unexpected changes to the preprocessing. I changed all these to 
pass -ffreestanding which inhibits the new behavior.

In fact I did have trouble writing the new test case to pass with the gnu/Linux 
toolchain. In the file lib/Driver/ToolChains/Linux.cpp function 
AddGnuIncludeArgs checks if GCCInstallation.isValid(). I don't know how to set 
up a Driver/Inputs sysroot tree so that the isValid check passes. (Does anyone 
know?) I experimented with various existing trees and had success with 
basic_cross_linux_tree, so I used that one in the test case. However 
basic_cross_linux_tree doesn't contain stdc-predef.h.  Would it be OK to add an 
include file to that tree? (I don't know if it's acceptable to add a new 
sysroot tree: it is a lot of new files and directories. On the other hand, I 
don't know if it's OK to co-opt a tree which was added by a different test 
case)  Perhaps you want me to another test case which verifies that 
fsystem-include-if-exists works generally. Currently I've added an affirmative 
test to see that -fsystem-include-if-exists is on the command line, and a test 
that -ffreestanding inhibits, and a negative test that when given a sysroot 
without the file, that the preprocessed output shows no indication of 
stdc-predef.h.


https://reviews.llvm.org/D34158

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Lex/PreprocessorOptions.h
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/clang_cpp.c
  test/Driver/crash-report-header.h
  test/Driver/crash-report-spaces.c
  test/Driver/crash-report.c
  test/Driver/rewrite-legacy-objc.m
  test/Driver/rewrite-map-in-diagnostics.c
  test/Driver/rewrite-objc.m
  test/Driver/stdc-predef.c
  test/Index/IBOutletCollection.m
  test/Index/annotate-macro-args.m
  test/Index/annotate-tokens-pp.c
  test/Index/annotate-tokens.c
  test/Index/c-index-getCursor-test.m
  test/Index/get-cursor-macro-args.m
  test/Index/get-cursor.cpp
  test/Preprocessor/ignore-pragmas.c
  unittests/Tooling/TestVisitor.h

Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -31,6 +31,8 @@
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
+  void AddGnuIncludeArgs(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const;
   void AddCudaIncludeArgs(const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList ,
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -705,6 +705,8 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
 
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
+
+  AddGnuIncludeArgs(DriverArgs, CC1Args);
 }
 
 static std::string DetectLibcxxIncludePath(StringRef base) {
@@ -743,6 +745,19 @@
   return "";
 }
 
+void Linux::AddGnuIncludeArgs(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const {
+  if (GCCInstallation.isValid()) {
+if (!DriverArgs.hasArg(options::OPT_ffreestanding)) {
+  // For gcc compatibility, clang will preinclude 
+  // -ffreestanding suppresses this behavior.
+  CC1Args.push_back("-fsystem-include-if-exists");
+  CC1Args.push_back("stdc-predef.h");
+}
+  }
+}
+
+
 void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const {
   // We need a detected GCC installation on Linux to provide libstdc++'s
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2503,6 +2503,10 @@
   for (const Arg *A : Args.filtered(OPT_chain_include))
 Opts.ChainedIncludes.emplace_back(A->getValue());
 
+  // Add the ordered list of -fsystem-include-if-exists.
+  for (const Arg *A : Args.filtered(OPT_fsystem_include_if_exists))
+Opts.FSystemIncludeIfExists.emplace_back(A->getValue());
+
   for (const Arg *A : Args.filtered(OPT_remap_file)) {
 std::pair Split = StringRef(A->getValue()).split(';');
 
Index: 

Re: [libcxx] r309838 - Fix PR33727: std::basic_stringbuf only works with DefaultConstructible allocators. Thanks to Jonathan Wakely for the report and suggested fix

2017-08-07 Thread Hans Wennborg via cfe-commits
On Wed, Aug 2, 2017 at 10:31 AM, Marshall Clow via cfe-commits
 wrote:
> Author: marshall
> Date: Wed Aug  2 10:31:09 2017
> New Revision: 309838
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309838=rev
> Log:
> Fix PR33727: std::basic_stringbuf only works with DefaultConstructible 
> allocators. Thanks to Jonathan Wakely for the report and suggested fix
>
> Modified:
> libcxx/trunk/include/sstream
> 
> libcxx/trunk/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp

Merged to 5.0 in r310287.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r309851 - Fix shadowing warning

2017-08-07 Thread Hans Wennborg via cfe-commits
On Wed, Aug 2, 2017 at 11:21 AM, Marshall Clow via cfe-commits
 wrote:
> Author: marshall
> Date: Wed Aug  2 11:21:34 2017
> New Revision: 309851
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309851=rev
> Log:
> Fix shadowing warning

Merged to 5.0 in r310288.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r309296 - Implement P0739R0: 'Some improvements to class template argument deduction integration into the standard library' This is an API change (not ABI change) due to a late change in

2017-08-07 Thread Hans Wennborg via cfe-commits
On Thu, Jul 27, 2017 at 10:44 AM, Marshall Clow via cfe-commits
 wrote:
> Author: marshall
> Date: Thu Jul 27 10:44:03 2017
> New Revision: 309296
>
> URL: http://llvm.org/viewvc/llvm-project?rev=309296=rev
> Log:
> Implement P0739R0: 'Some improvements to class template argument deduction 
> integration into the standard library' This is an API change (not ABI change) 
> due to a late change in the c++17 standard
>
> Modified:
> libcxx/trunk/include/mutex
> 
> libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp
> 
> libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
> libcxx/trunk/www/cxx1z_status.html
> libcxx/trunk/www/cxx2a_status.html

Merged together with r309307 to 5.0 in r310286.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r310288 - Merging r309851:

2017-08-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Aug  7 12:49:31 2017
New Revision: 310288

URL: http://llvm.org/viewvc/llvm-project?rev=310288=rev
Log:
Merging r309851:

r309851 | marshall | 2017-08-02 11:21:34 -0700 (Wed, 02 Aug 2017) | 1 line

Fix shadowing warning


Modified:
libcxx/branches/release_50/   (props changed)

libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp

Propchange: libcxx/branches/release_50/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  7 12:49:31 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:309296,309307,309838,309917,309920
+/libcxx/trunk:309296,309307,309838,309851,309917,309920

Modified: 
libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp?rev=310288=310287=310288=diff
==
--- 
libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
 (original)
+++ 
libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
 Mon Aug  7 12:49:31 2017
@@ -22,7 +22,7 @@ template
 struct NoDefaultAllocator : std::allocator
 {
   template struct rebind { using other = NoDefaultAllocator; };
-  NoDefaultAllocator(int id) : id(id) { }
+  NoDefaultAllocator(int id_) : id(id_) { }
   template NoDefaultAllocator(const NoDefaultAllocator& a) : 
id(a.id) { }
   int id;
 };


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


[libcxx] r310287 - Merging r309838:

2017-08-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Aug  7 12:49:04 2017
New Revision: 310287

URL: http://llvm.org/viewvc/llvm-project?rev=310287=rev
Log:
Merging r309838:

r309838 | marshall | 2017-08-02 10:31:09 -0700 (Wed, 02 Aug 2017) | 1 line

Fix PR33727: std::basic_stringbuf only works with DefaultConstructible 
allocators. Thanks to Jonathan Wakely for the report and suggested fix


Modified:
libcxx/branches/release_50/   (props changed)
libcxx/branches/release_50/include/sstream

libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp

Propchange: libcxx/branches/release_50/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  7 12:49:04 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:309296,309307,309917,309920
+/libcxx/trunk:309296,309307,309838,309917,309920

Modified: libcxx/branches/release_50/include/sstream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/sstream?rev=310287=310286=310287=diff
==
--- libcxx/branches/release_50/include/sstream (original)
+++ libcxx/branches/release_50/include/sstream Mon Aug  7 12:49:04 2017
@@ -249,7 +249,8 @@ basic_stringbuf<_CharT, _Traits, _Alloca
 template 
 basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const 
string_type& __s,
  ios_base::openmode __wch)
-: __hm_(0),
+: __str_(__s.get_allocator()),
+  __hm_(0),
   __mode_(__wch)
 {
 str(__s);

Modified: 
libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp?rev=310287=310286=310287=diff
==
--- 
libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
 (original)
+++ 
libcxx/branches/release_50/test/std/input.output/string.streams/stringstream.cons/string.pass.cpp
 Mon Aug  7 12:49:04 2017
@@ -18,6 +18,16 @@
 #include 
 #include 
 
+template
+struct NoDefaultAllocator : std::allocator
+{
+  template struct rebind { using other = NoDefaultAllocator; };
+  NoDefaultAllocator(int id) : id(id) { }
+  template NoDefaultAllocator(const NoDefaultAllocator& a) : 
id(a.id) { }
+  int id;
+};
+
+
 int main()
 {
 {
@@ -46,4 +56,13 @@ int main()
 ss << i << ' ' << 123;
 assert(ss.str() == L"456 1236 ");
 }
+{ // This is https://bugs.llvm.org/show_bug.cgi?id=33727
+   typedef std::basic_string    S;
+   typedef std::basic_stringbuf SB;
+
+   S s(NoDefaultAllocator(1));
+   SB sb(s);
+   //  This test is not required by the standard, but *where else* 
could it get the allocator?
+   assert(sb.str().get_allocator() == s.get_allocator());
+}
 }


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


[libcxx] r310286 - Merging r309296 and r309307:

2017-08-07 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Mon Aug  7 12:48:12 2017
New Revision: 310286

URL: http://llvm.org/viewvc/llvm-project?rev=310286=rev
Log:
Merging r309296 and r309307:

r309296 | marshall | 2017-07-27 10:44:03 -0700 (Thu, 27 Jul 2017) | 1 line

Implement P0739R0: 'Some improvements to class template argument deduction 
integration into the standard library' This is an API change (not ABI change) 
due to a late change in the c++17 standard



r309307 | marshall | 2017-07-27 11:47:35 -0700 (Thu, 27 Jul 2017) | 1 line

Disable the deduction guide test I added in 309296 for the moment, while I 
figure out which compilers don't support deduction guides


Modified:
libcxx/branches/release_50/   (props changed)
libcxx/branches/release_50/include/mutex

libcxx/branches/release_50/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp

libcxx/branches/release_50/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
libcxx/branches/release_50/www/cxx1z_status.html
libcxx/branches/release_50/www/cxx2a_status.html

Propchange: libcxx/branches/release_50/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug  7 12:48:12 2017
@@ -1,2 +1,2 @@
 /libcxx/branches/apple:136569-137939
-/libcxx/trunk:309917,309920
+/libcxx/trunk:309296,309307,309917,309920

Modified: libcxx/branches/release_50/include/mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/include/mutex?rev=310286=310285=310286=diff
==
--- libcxx/branches/release_50/include/mutex (original)
+++ libcxx/branches/release_50/include/mutex Mon Aug  7 12:48:12 2017
@@ -116,7 +116,7 @@ public:
 using mutex_type = Mutex;  // If MutexTypes... consists of the single type 
Mutex
 
 explicit scoped_lock(MutexTypes&... m);
-scoped_lock(MutexTypes&... m, adopt_lock_t);
+scoped_lock(adopt_lock_t, MutexTypes&... m);
 ~scoped_lock();
 scoped_lock(scoped_lock const&) = delete;
 scoped_lock& operator=(scoped_lock const&) = delete;
@@ -500,7 +500,7 @@ public:
 ~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) 
{__m_.unlock();}
 
 _LIBCPP_INLINE_VISIBILITY
-explicit scoped_lock(mutex_type& __m, adopt_lock_t) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
+explicit scoped_lock(adopt_lock_t, mutex_type& __m) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
 : __m_(__m) {}
 
 scoped_lock(scoped_lock const&) = delete;
@@ -522,7 +522,7 @@ public:
 }
 
 _LIBCPP_INLINE_VISIBILITY
-scoped_lock(_MArgs&... __margs, adopt_lock_t)
+scoped_lock(adopt_lock_t, _MArgs&... __margs)
 : __t_(__margs...)
 {
 }

Modified: 
libcxx/branches/release_50/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_50/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp?rev=310286=310285=310286=diff
==
--- 
libcxx/branches/release_50/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp
 (original)
+++ 
libcxx/branches/release_50/test/std/thread/thread.mutex/thread.lock/thread.lock.scoped/adopt_lock.pass.cpp
 Mon Aug  7 12:48:12 2017
@@ -14,7 +14,7 @@
 
 // template  class scoped_lock;
 
-// scoped_lock(Mutex&..., adopt_lock_t);
+// scoped_lock(adopt_lock_t, Mutex&...);
 
 #include 
 #include 
@@ -43,7 +43,7 @@ int main()
 using LG = std::scoped_lock;
 m1.lock();
 {
-LG lg(m1, std::adopt_lock);
+LG lg(std::adopt_lock, m1);
 assert(m1.locked);
 }
 assert(!m1.locked);
@@ -53,7 +53,7 @@ int main()
 using LG = std::scoped_lock;
 m1.lock(); m2.lock();
 {
-LG lg(m1, m2, std::adopt_lock);
+LG lg(std::adopt_lock, m1, m2);
 assert(m1.locked && m2.locked);
 }
 assert(!m1.locked && !m2.locked);
@@ -63,7 +63,7 @@ int main()
 using LG = std::scoped_lock;
 m1.lock(); m2.lock(); m3.lock();
 {
-LG lg(m1, m2, m3, std::adopt_lock);
+LG lg(std::adopt_lock, m1, m2, m3);
 assert(m1.locked && m2.locked && m3.locked);
 }
 assert(!m1.locked && !m2.locked && !m3.locked);

Modified: 
libcxx/branches/release_50/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
URL: 

[PATCH] D29654: [OpenMP] Integrate OpenMP target region cubin into host binary

2017-08-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 110056.
gtbercea added a comment.

Add -no-canonical-prefixes to tests.


https://reviews.llvm.org/D29654

Files:
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/CommonArgs.h
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -629,3 +629,43 @@
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR %s
 
 // CHK-FOPENMP-TARGET-NESTED-ERROR: clang{{.*}} error: invalid -Xopenmp-target argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are unsupported
+
+/// ###
+
+/// Check -Xopenmp-target uses one of the archs provided when several archs are used.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_35 -Xopenmp-target -march=sm_60 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-ARCHS %s
+
+// CHK-FOPENMP-TARGET-ARCHS: ptxas{{.*}}" "--gpu-name" "sm_60"
+// CHK-FOPENMP-TARGET-ARCHS: nvlink{{.*}}" "-arch" "sm_60"
+
+/// ###
+
+/// Check -Xopenmp-target -march=sm_35 works as expected when two triples are present.
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu,nvptx64-nvidia-cuda -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_35 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-COMPILATION %s
+
+// CHK-FOPENMP-TARGET-COMPILATION: ptxas{{.*}}" "--gpu-name" "sm_35"
+// CHK-FOPENMP-TARGET-COMPILATION: nvlink{{.*}}" "-arch" "sm_35"
+
+/// ###
+
+/// Check cubin file generation and usage by nvlink
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN %s
+
+// CHK-CUBIN: clang{{.*}}" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
+// CHK-CUBIN-NEXT: ptxas{{.*}}" "--output-file" "{{.*}}-openmp-nvptx64-nvidia-cuda.cubin" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
+// CHK-CUBIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" {{.*}} "openmp-offload-openmp-nvptx64-nvidia-cuda.cubin"
+
+/// ###
+
+/// Check cubin file generation and usage by nvlink
+// RUN:   touch %t1.o
+// RUN:   touch %t2.o
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %t1.o %t2.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
+
+// CHK-TWOCUBIN: clang-offload-bundler" "-type=o" "{{.*}}inputs={{.*}}tmp1.o" "-outputs={{.*}}.o,{{.*}}tmp1-openmp-nvptx64-nvidia-cuda.cubin" "-unbundle"
+// CHK-TWOCUBIN-NEXT: clang-offload-bundler" "-type=o" "{{.*}}inputs={{.*}}tmp2.o" "-outputs={{.*}}.o,{{.*}}tmp2-openmp-nvptx64-nvidia-cuda.cubin" "-unbundle"
+// CHK-TWOCUBIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" {{.*}} "openmp-offload.c.tmp1-openmp-nvptx64-nvidia-cuda.cubin" "openmp-offload.c.tmp2-openmp-nvptx64-nvidia-cuda.cubin"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -204,131 +204,6 @@
   // The types are (hopefully) good enough.
 }
 
-/// Add OpenMP linker script arguments at the end of the argument list so that
-/// the fat binary is built by embedding each of the device images into the
-/// host. The linker script also defines a few symbols required by the code
-/// generation so that the images can be easily retrieved at runtime by the
-/// offloading library. This should be used only in tool chains that support
-/// linker scripts.
-static void AddOpenMPLinkerScript(const ToolChain , Compilation ,
-  const InputInfo ,
-  const InputInfoList ,
-  const ArgList , ArgStringList ,
-  const JobAction ) {
-
-  // If this is not an OpenMP host toolchain, we don't need to do anything.
-  if (!JA.isHostOffloading(Action::OFK_OpenMP))
-return;
-
-  // Create temporary linker script. Keep it if save-temps is enabled.
-  const char *LKS;
-  SmallString<256> Name = llvm::sys::path::filename(Output.getFilename());
-  if (C.getDriver().isSaveTempsEnabled()) {
-llvm::sys::path::replace_extension(Name, "lk");
-LKS = C.getArgs().MakeArgString(Name.c_str());
-  } else {
-llvm::sys::path::replace_extension(Name, "");
-Name = 

[PATCH] D36423: [libc++] Introsort based sorting function

2017-08-07 Thread DIVYA SHANMUGHAN via Phabricator via cfe-commits
DIVYA created this revision.

The sorting algorithm currently employed in libc+ library uses quicksort with 
tail recursion elimination, as a result of which the worst case complexity 
turns out to be O(N^2).
This patch reduces the worst case time complexity, by employing Introsort 
algorithm. Introsort is a sorting technique, which begins with quicksort and 
when the recursion depth (or depth limit) goes beyond a threshold value, then 
it switches to Heapsort .As a result the worst case complexity reduces to 
O(NlogN)

Worked in collaboration with Aditya Kumar.


https://reviews.llvm.org/D36423

Files:
  include/algorithm


Index: include/algorithm
===
--- include/algorithm
+++ include/algorithm
@@ -642,6 +642,7 @@
 #include  // needed to provide swap_ranges.
 #include 
 #include 
+#include 
 #include 
 
 #if defined(__IBMCPP__)
@@ -3994,7 +3995,14 @@
 
 template 
 void
-__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare 
__comp)
+__partial_sort(_RandomAccessIterator, _RandomAccessIterator, 
_RandomAccessIterator,
+_Compare);
+
+// Using introsort algorithm for sorting
+template 
+void
+__intro_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, 
_Compare __comp, 
+   typename iterator_traits<_RandomAccessIterator>::difference_type 
__depth_limit)
 {
 // _Compare is known to be a reference type
 typedef typename iterator_traits<_RandomAccessIterator>::difference_type 
difference_type;
@@ -4029,6 +4037,12 @@
 _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
 return;
 }
+if (__depth_limit == 0)
+{
+__partial_sort<_Compare>(__first,__last,__last,__comp);
+return;
+}
+
 // __len > 5
 _RandomAccessIterator __m = __first;
 _RandomAccessIterator __lm1 = __last;
@@ -4172,19 +4186,33 @@
 // sort smaller range with recursive call and larger with tail 
recursion elimination
 if (__i - __first < __last - __i)
 {
-_VSTD::__sort<_Compare>(__first, __i, __comp);
-// _VSTD::__sort<_Compare>(__i+1, __last, __comp);
+_VSTD::__intro_sort<_Compare>(__first, __i, __comp, __depth_limit);
+// _VSTD::__intro_sort<_Compare>(__i+1, __last, __comp, 
__depth_limit);
 __first = ++__i;
 }
 else
 {
-_VSTD::__sort<_Compare>(__i+1, __last, __comp);
-// _VSTD::__sort<_Compare>(__first, __i, __comp);
+_VSTD::__intro_sort<_Compare>(__i+1, __last, __comp, 
__depth_limit);
+// _VSTD::__intro_sort<_Compare>(__first, __i, __comp, 
__depth_limit);
 __last = __i;
 }
+--__depth_limit;
 }
 }
 
+template 
+void
+__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare 
__comp)
+{
+
+  // Threshold(or depth limit) for introsort is taken to be 2*log2(size)
+  typedef typename iterator_traits<_RandomAccessIterator>::difference_type 
difference_type;
+  const difference_type __dp = __last - __first;
+  difference_type __depth_limit = __last == __first ? 0 : _VSTD::log2(__dp);
+  __depth_limit *=2;
+  __intro_sort<_Compare>(__first, __last, __comp, __depth_limit);
+}
+
 // This forwarder keeps the top call and the recursive calls using the same 
instantiation, forcing a reference _Compare
 template 
 inline _LIBCPP_INLINE_VISIBILITY


Index: include/algorithm
===
--- include/algorithm
+++ include/algorithm
@@ -642,6 +642,7 @@
 #include  // needed to provide swap_ranges.
 #include 
 #include 
+#include 
 #include 
 
 #if defined(__IBMCPP__)
@@ -3994,7 +3995,14 @@
 
 template 
 void
-__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator,
+_Compare);
+
+// Using introsort algorithm for sorting
+template 
+void
+__intro_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, 
+   typename iterator_traits<_RandomAccessIterator>::difference_type __depth_limit)
 {
 // _Compare is known to be a reference type
 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -4029,6 +4037,12 @@
 _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp);
 return;
 }
+if (__depth_limit == 0)
+{
+__partial_sort<_Compare>(__first,__last,__last,__comp);
+return;
+}
+
 // __len > 5
 _RandomAccessIterator __m = __first;
 _RandomAccessIterator __lm1 = __last;
@@ -4172,19 +4186,33 @@
 // sort smaller range with recursive call and larger with tail recursion elimination
 if (__i - __first < __last - __i)
 {
-

[PATCH] D36105: [AArch64] Ignore stdcall and similar on aarch64/windows

2017-08-07 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


https://reviews.llvm.org/D36105



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


[PATCH] D36237: Reland "Thread Safety Analysis: fix assert_capability.", add warnings

2017-08-07 Thread Josh Gao via Phabricator via cfe-commits
jmgao updated this revision to Diff 110054.
jmgao added a comment.

Reword warnings.


https://reviews.llvm.org/D36237

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Analysis/ThreadSafety.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-capabilities.c
  test/SemaCXX/warn-thread-safety-analysis.cpp
  test/SemaCXX/warn-thread-safety-parsing.cpp

Index: test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- test/SemaCXX/warn-thread-safety-parsing.cpp
+++ test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -571,11 +571,11 @@
 
 // takes zero or more arguments, all locks (vars/fields)
 
-void elf_function() EXCLUSIVE_LOCK_FUNCTION();
+void elf_function() EXCLUSIVE_LOCK_FUNCTION(); // expected-warning {{'exclusive_lock_function' attribute without arguments can only be applied to a method of a class}}
 
 void elf_function_args() EXCLUSIVE_LOCK_FUNCTION(mu1, mu2);
 
-int elf_testfn(int y) EXCLUSIVE_LOCK_FUNCTION();
+int elf_testfn(int y) EXCLUSIVE_LOCK_FUNCTION(); // expected-warning {{'exclusive_lock_function' attribute without arguments can only be applied to a method of a class}}
 
 int elf_testfn(int y) {
   int x EXCLUSIVE_LOCK_FUNCTION() = y; // \
@@ -590,7 +590,7 @@
  private:
   int test_field EXCLUSIVE_LOCK_FUNCTION(); // \
 // expected-warning {{'exclusive_lock_function' attribute only applies to functions}}
-  void test_method() EXCLUSIVE_LOCK_FUNCTION();
+  void test_method() EXCLUSIVE_LOCK_FUNCTION(); // expected-warning {{'exclusive_lock_function' attribute requires type annotated with 'capability' attribute; type here is 'ElfFoo *'}}
 };
 
 class EXCLUSIVE_LOCK_FUNCTION() ElfTestClass { // \
@@ -643,11 +643,11 @@
 
 // takes zero or more arguments, all locks (vars/fields)
 
-void slf_function() SHARED_LOCK_FUNCTION();
+void slf_function() SHARED_LOCK_FUNCTION(); // expected-warning {{'shared_lock_function' attribute without arguments can only be applied to a method of a class}}
 
 void slf_function_args() SHARED_LOCK_FUNCTION(mu1, mu2);
 
-int slf_testfn(int y) SHARED_LOCK_FUNCTION();
+int slf_testfn(int y) SHARED_LOCK_FUNCTION(); // expected-warning {{'shared_lock_function' attribute without arguments can only be applied to a method of a class}}
 
 int slf_testfn(int y) {
   int x SHARED_LOCK_FUNCTION() = y; // \
@@ -665,7 +665,8 @@
  private:
   int test_field SHARED_LOCK_FUNCTION(); // \
 // expected-warning {{'shared_lock_function' attribute only applies to functions}}
-  void test_method() SHARED_LOCK_FUNCTION();
+  void test_method() SHARED_LOCK_FUNCTION(); // \
+// expected-warning {{'shared_lock_function' attribute requires type annotated with 'capability' attribute; type here is 'SlfFoo *'}}
 };
 
 class SHARED_LOCK_FUNCTION() SlfTestClass { // \
@@ -716,29 +717,32 @@
 // takes a mandatory boolean or integer argument specifying the retval
 // plus an optional list of locks (vars/fields)
 
-void etf_function() __attribute__((exclusive_trylock_function));  // \
-  // expected-error {{'exclusive_trylock_function' attribute takes at least 1 argument}}
+void etf_function() __attribute__((exclusive_trylock_function)); // \
+  // expected-error {{'exclusive_trylock_function' attribute takes at least 1 argument}} \
 
 void etf_function_args() EXCLUSIVE_TRYLOCK_FUNCTION(1, mu2);
 
-void etf_function_arg() EXCLUSIVE_TRYLOCK_FUNCTION(1);
+void etf_function_arg() EXCLUSIVE_TRYLOCK_FUNCTION(1); // \
+  // expected-warning {{'exclusive_trylock_function' attribute without arguments can only be applied to a method of a class}}
 
-int etf_testfn(int y) EXCLUSIVE_TRYLOCK_FUNCTION(1);
+int etf_testfn(int y) EXCLUSIVE_TRYLOCK_FUNCTION(1); // \
+  // expected-warning {{'exclusive_trylock_function' attribute without arguments can only be applied to a method of a class}}
 
 int etf_testfn(int y) {
   int x EXCLUSIVE_TRYLOCK_FUNCTION(1) = y; // \
 // expected-warning {{'exclusive_trylock_function' attribute only applies to functions}}
   return x;
 };
 
 int etf_test_var EXCLUSIVE_TRYLOCK_FUNCTION(1); // \
-  // expected-warning {{'exclusive_trylock_function' attribute only applies to functions}}
+  // expected-warning {{'exclusive_trylock_function' attribute only applies to functions}} \
 
 class EtfFoo {
  private:
   int test_field EXCLUSIVE_TRYLOCK_FUNCTION(1); // \
 // expected-warning {{'exclusive_trylock_function' attribute only applies to functions}}
-  void test_method() EXCLUSIVE_TRYLOCK_FUNCTION(1);
+  void test_method() EXCLUSIVE_TRYLOCK_FUNCTION(1); // \
+// expected-warning {{'exclusive_trylock_function' attribute requires type annotated with 'capability' attribute; type here is 'EtfFoo *'}}
 };
 
 class EXCLUSIVE_TRYLOCK_FUNCTION(1) EtfTestClass { // \
@@ -759,7 +763,8 @@
 int etf_function_6() EXCLUSIVE_TRYLOCK_FUNCTION(1, muRef);
 int etf_function_7() EXCLUSIVE_TRYLOCK_FUNCTION(1, muDoubleWrapper.getWrapper()->getMu());
 int etf_functetfn_8() EXCLUSIVE_TRYLOCK_FUNCTION(1, 

r310282 - Non-functional change. Fix previous patch D34784.

2017-08-07 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Mon Aug  7 11:43:37 2017
New Revision: 310282

URL: http://llvm.org/viewvc/llvm-project?rev=310282=rev
Log:
Non-functional change. Fix previous patch D34784.

Modified:
cfe/trunk/lib/Driver/Compilation.cpp

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=310282=310281=310282=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Mon Aug  7 11:43:37 2017
@@ -60,11 +60,15 @@ Compilation::getArgsForToolChain(const T
   DerivedArgList * = TCArgs[{TC, BoundArch, DeviceOffloadKind}];
   if (!Entry) {
 // Translate OpenMP toolchain arguments provided via the -Xopenmp-target 
flags.
-Entry = TC->TranslateOpenMPTargetArgs(*TranslatedArgs, DeviceOffloadKind);
-if (!Entry)
-  Entry = TranslatedArgs;
+DerivedArgList *OpenMPArgs = TC->TranslateOpenMPTargetArgs(*TranslatedArgs,
+DeviceOffloadKind);
+if (!OpenMPArgs) {
+  Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
+} else {
+  Entry = TC->TranslateArgs(*OpenMPArgs, BoundArch, DeviceOffloadKind);
+  delete OpenMPArgs;
+}
 
-Entry = TC->TranslateArgs(*Entry, BoundArch, DeviceOffloadKind);
 if (!Entry)
   Entry = TranslatedArgs;
   }


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


[PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-07 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

This patch does 3 things:

1. Get rid of the unit test objc-modern-metadata-visibility2.mm because this 
test check uses flag -reverse-iterate. This flag will be removed in 
https://reviews.llvm.org/D35043.

2. https://reviews.llvm.org/D35043 gets rid of the empty base definition for 
PointerLikeTypeTraits. This results in a compiler warning because 
PointerLikeTypeTrait has been defined as struct here while in the header it is 
a class. So I have changed struct to class.

3. Since I changed struct PointerLikeTypeTrait to class PointerLikeTypeTrait 
here, the member functions are no longer public now. This results in a compiler 
error. So I explicitly marked them as public here.


https://reviews.llvm.org/D36386



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


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.

Looks good to me, a few nits. Thanks for improving it continuously.

I'd hold it for a while to see whether @alexfh has further comments before 
submitting it.




Comment at: clang-tidy/android/CloexecCheck.h:28
+/// prevent the file descriptor leakage on fork+exec and this class provides
+/// utilities to identify  and fix these C functions.
+class CloexecCheck : public ClangTidyCheck {

remove an extra blank before `and`.



Comment at: clang-tidy/android/CloexecCheck.h:45
+  ///   open(file, O_RDONLY | O_CLOEXE);
+  /// \endcode
+  void insertMacroFlag(const ast_matchers::MatchFinder::MatchResult ,

Nit: you are missing the parameter part in the comment, the same below.

```
/// \param Result XXX
/// \param MacroFlag XXX
/// \param ArgPos
```



Comment at: clang-tidy/android/CloexecCheck.h:47
+  void insertMacroFlag(const ast_matchers::MatchFinder::MatchResult ,
+   const StringRef MarcoFlag, const int ArgPos);
+

Is the `ArgPos` 0-based or 1-based? I know it is 0-based, but we'd better 
mention in the document part.



Comment at: clang-tidy/android/CloexecCheck.h:116
+  template 
+  void registerMatchersImpl(ast_matchers::MatchFinder *Finder,
+Types... Params) {

nit: I'd put this method as the first protected method.


https://reviews.llvm.org/D35372



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


Re: [PATCH] D24933: Enable configuration files in clang

2017-08-07 Thread Serge Pavlov via cfe-commits
2017-08-07 1:46 GMT+07:00 Richard Smith :

> On 6 August 2017 at 11:15, Serge Pavlov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> 2017-08-06 6:43 GMT+07:00 Hal Finkel :
>>
>>> On 07/24/2017 10:18 AM, Serge Pavlov wrote:
>>>
>>> I am thinking about reducing the patch further to leave only the ability
>>> to include config file when clang is called as `target-clang-drivermode`.
>>> It is still useful for cross compilation tasks because:
>>> - It is a convenient way to switch between supported targets,
>>> - SDK producer can ship compiler with a set of appropriate options or
>>> prepare them during installation.
>>> In this case if clang is called as `target-clang-drivermode`, it first
>>> tries to find file `target-drivermode.cfg` or `target.cfg` in a set of
>>> well-known directories, which in minimal case includes the directory where
>>> clang executable resides. If such file is found, options are  read from it,
>>> otherwise only option --target is added as clang does it now.
>>>
>>> This solution has obvious drawbacks:
>>> - User cannot specify config file in command line in the same way as he
>>> can choose a target: `clang --target `,
>>> - On Windows symlinks are implemented as file copy, the solution looks
>>> awkward.
>>> So more or less complete solution needs to allow specifying config file
>>> in command line.
>>>
>>>
>>> I'd rather not reduce the patch in this way, and you didn't describe why
>>> you're considering reducing the patch. Can you please elaborate?
>>>
>>
>> The only intent was to facilitate review process.
>>
>>>
>>> Using `@file` has some problems. Config file is merely a set of options,
>>> just as file included by `@file`. Different include file search is only a
>>> convenience and could be sacrificed. Comments and unused option warning
>>> suppression could be extended for all files included with `@file`. The real
>>> problem is the search path. To be useful, config files must be searched for
>>> in well-known directories, so that meaning of `clang @config_fille` does
>>> not depend on the current directory. So clang must have some rule to
>>> distinguish between config file and traditional use of `@file`. For
>>> instance, if file name ends with `.cfg` and there is a file with this name
>>> in config search directories, this is a config file and it is interpreted a
>>> bit differently. Of course, the file may be specified with full path, but
>>> this way is inconvenient.
>>>
>>>
>>> I see no reason why we can't unify the processing but have different
>>> search-path rules for @file vs. --config file.
>>>
>>
>> Now I think we can use @file without breaking compatibility.
>>
>> libiberty resolves `file` in `@file` always relative to current
>> directory. If such file is not found, it tries to open file with name
>> `@file`. We must keep this behavior for the sake of compatibility.
>>
>
> Do you know of actual software that depends on the fallback working this
> way? That seems very fragile to me, since a command line that uses @foo to
> name the file ./@foo would change meaning if a file named foo were created.
> Perhaps we should consider the fallback to be a mistake, and require files
> whose name starts with @ to be named as ./@filename, just like we do for
> files whose name starts with a hyphen.
>

Most likely if `@foo` is specified and `foo` is not found this is an error.
And indeed, it just `@foo` is needed, it still can be specified using
slightly modified file name.


>
> If after these steps `file` is not found and `file` does not contain
>> directory separator, clang could try to treat `file` as config file and
>> search it using special search path. If such solution is acceptable, we can
>> get rid of `--config`.
>>
>
> If we go this way, I think we should also deprecate the @file -> "open
> file with name ./@file" (warn on it for now, with the intent to remove it
> in a future version).
>

 This is https://reviews.llvm.org/D36420

But... I think the concern about @ vs --config is principally around having
> two different file formats, not about having two different command-line
> syntaxes to specify a file, so this may be addressing a non-issue. And I
> think the different use cases provide a decent argument for using different
> search paths (compiler configs should live with the compiler, @-files are
> expected to be generated by the user or the build system so should be found
> relative to the current directory). Keeping the two separate but with a
> unified format and internal mechanism seems like a good approach to me.
>

Format of both files is very simple. Features like comments and line
concatenation are not specific to config files and can be extended for all
@-file, as you proposed earlier (potential implementaion is in
https://reviews.llvm.org/D36045). In this case the only difference is
nested `@file`, in which `file` is resolved relative to containing config
file, not current directory.And yes, 

[PATCH] D36105: [AArch64] Ignore stdcall and similar on aarch64/windows

2017-08-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D36105#834225, @mgrang wrote:

> In https://reviews.llvm.org/D36105#834007, @mstorsjo wrote:
>
> > Ping @mgrang, can you check the above with MSVC? I'd like to move forward 
> > with this in one form or another.
>
>
> Yes, I checked with MSVC for ARM64 and it compiles without any warnings.


Thanks! @rnk - is this ok then?


https://reviews.llvm.org/D36105



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


[PATCH] D36237: Reland "Thread Safety Analysis: fix assert_capability.", add warnings

2017-08-07 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley added a comment.

Overall looks good.  However, I would change the wording on the warning to the 
following.  The terms "free function" and "instance method" may be confusing to 
some people.  Also, warn_thread_attribute_noargs_static_method should not 
mention the capability attribute, which is checked separately in 
warn_thread_attribute_noargs_not_lockable.

def warn_thread_attribute_noargs_not_method: ... "%0 attribute without 
arguments can only be applied to a method of a class." ...
def warn_thread_attribute_noargs_static_method: ... "%0 attribute without 
arguments cannot be applied a static method." ...


https://reviews.llvm.org/D36237



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


[PATCH] D36105: [AArch64] Ignore stdcall and similar on aarch64/windows

2017-08-07 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In https://reviews.llvm.org/D36105#834007, @mstorsjo wrote:

> Ping @mgrang, can you check the above with MSVC? I'd like to move forward 
> with this in one form or another.


Yes, I checked with MSVC for ARM64 and it compiles without any warnings.

  cl foo.c -c /W3
  Microsoft (R) C/C++ Optimizing Compiler for ARM64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  foo.c


https://reviews.llvm.org/D36105



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


Re: [PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-08-07 Thread Gheorghe-Teod Bercea via cfe-commits
I am aware of the failure, I am attempting
to push a fix as we speak!Thanks for the patience.--DoruFrom:      
 Aleksey Shlyapnikov
via Phabricator To:      
 gheorghe-teod.ber...@ibm.com,
hfin...@anl.gov, hahnf...@itc.rwth-aachen.de, cber...@us.ibm.com, caom...@us.ibm.com,
a.bat...@hotmail.comCc:      
 aleks...@google.com,
guansong.zh...@amd.com, cfe-commits@lists.llvm.org, lil...@gmail.com, acja...@us.ibm.comDate:      
 08/07/2017 01:58 PMSubject:    
   [PATCH] D34784:
[OpenMP] Add flag for specifying the target device architecture for OpenMP
device offloadingalekseyshl added a comment.http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7010is unhappy about this change, please fix.https://reviews.llvm.org/D34784

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


r310278 - Add some missing -no-canonical-prefixes.

2017-08-07 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Aug  7 11:31:01 2017
New Revision: 310278

URL: http://llvm.org/viewvc/llvm-project?rev=310278=rev
Log:
Add some missing -no-canonical-prefixes.

Modified:
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/test/Driver/openmp-offload.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload.c?rev=310278=310277=310278=diff
==
--- cfe/trunk/test/Driver/openmp-offload.c (original)
+++ cfe/trunk/test/Driver/openmp-offload.c Mon Aug  7 11:31:01 2017
@@ -601,7 +601,7 @@
 /// ###
 
 /// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr7 is passed when 
compiling for the device.
-// RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu 
-Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu 
-Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
 
 // CHK-FOPENMP-EQ-TARGET: clang{{.*}} "-target-cpu" "pwr7"
@@ -609,7 +609,7 @@
 /// ###
 
 /// Check -Xopenmp-target -march=pwr7 is passed when compiling for the device.
-// RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr7 %s 2>&1 \
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr7 %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s
 
 // CHK-FOPENMP-TARGET: clang{{.*}} "-target-cpu" "pwr7"
@@ -617,7 +617,7 @@
 /// ###
 
 /// Check -Xopenmp-target triggers error when multiple triples are used.
-// RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-unknown-linux-gnu 
-Xopenmp-target -mcpu=pwr8 %s 2>&1 \
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-unknown-linux-gnu 
-Xopenmp-target -mcpu=pwr8 %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR %s
 
 // CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR: clang{{.*}} error: cannot deduce 
implicit triple value for -Xopenmp-target, specify triple using 
-Xopenmp-target=
@@ -625,7 +625,7 @@
 /// ###
 
 /// Check -Xopenmp-target triggers error when an option requiring arguments is 
passed to it.
-// RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -Xopenmp-target 
-mcpu=pwr8 %s 2>&1 \
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -Xopenmp-target 
-mcpu=pwr8 %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR %s
 
 // CHK-FOPENMP-TARGET-NESTED-ERROR: clang{{.*}} error: invalid -Xopenmp-target 
argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are 
unsupported


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


[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-07 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann marked 2 inline comments as done.
euhlmann added a comment.

I resolved the formatting issues. I apologize for not paying closer attention 
to formatting earlier.

I don't have commit access, so if this change looks good now, could someone 
with access please commit?


https://reviews.llvm.org/D35847



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


[PATCH] D35847: clang-format: Fix left pointer alignment after delctype/typeof

2017-08-07 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 110032.
euhlmann added a comment.

Ran clang-format over changes and corrected formatting


https://reviews.llvm.org/D35847

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5422,6 +5422,10 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
+  verifyFormat("typedef typeof /*comment*/ (int(int, int))* MyFuncPtr;", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5468,9 +5472,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1397,11 +1397,13 @@
 if (NextToken->isOneOf(tok::comma, tok::semi))
   return TT_PointerOrReference;
 
-if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen &&
-PrevToken->MatchingParen->Previous &&
-PrevToken->MatchingParen->Previous->isOneOf(tok::kw_typeof,
-tok::kw_decltype))
-  return TT_PointerOrReference;
+if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen) {
+  FormatToken *TokenBeforeMatchingParen =
+  PrevToken->MatchingParen->getPreviousNonComment();
+  if (TokenBeforeMatchingParen &&
+  TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+return TT_PointerOrReference;
+}
 
 if (PrevToken->Tok.isLiteral() ||
 PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
@@ -2205,15 +2207,25 @@
 Left.Previous->is(tok::kw_case));
   if (Left.is(tok::l_square) && Right.is(tok::amp))
 return false;
-  if (Right.is(TT_PointerOrReference))
-return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
-   (Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
- Left.Previous->is(tok::r_paren)) ||
+  if (Right.is(TT_PointerOrReference)) {
+if (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) {
+  if (!Left.MatchingParen)
+return true;
+  FormatToken *TokenBeforeMatchingParen =
+  Left.MatchingParen->getPreviousNonComment();
+  if (!TokenBeforeMatchingParen ||
+  !TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+return true;
+}
+return (Left.Tok.isLiteral() ||
+(Left.is(tok::kw_const) && Left.Previous &&
+ Left.Previous->is(tok::r_paren)) ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (Style.PointerAlignment != FormatStyle::PAS_Left ||
   (Line.IsMultiVariableDeclStmt &&
(Left.NestingLevel == 0 ||
 (Left.NestingLevel == 1 && Line.First->is(tok::kw_for)));
+  }
   if (Right.is(TT_FunctionTypeLParen) && Left.isNot(tok::l_paren) &&
   (!Left.is(TT_PointerOrReference) ||
(Style.PointerAlignment != FormatStyle::PAS_Right &&


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5422,6 +5422,10 @@
   verifyFormat("for (;; *a = b) {\n}", Left);
   verifyFormat("return *this += 1;", Left);
   verifyFormat("throw *x;", Left);
+  verifyFormat("delete *x;", Left);
+  verifyFormat("typedef typeof(int(int, int))* MyFuncPtr;", Left);
+  verifyFormat("[](const decltype(*a)* ptr) {}", Left);
+  verifyFormat("typedef typeof /*comment*/ (int(int, int))* MyFuncPtr;", Left);
 
   verifyIndependentOfContext("a = *(x + y);");
   verifyIndependentOfContext("a = &(x + y);");
@@ -5468,9 +5472,6 @@
   verifyGoogleFormat("T** t = new T*;");
   verifyGoogleFormat("T** t = new T*();");
 
-  FormatStyle PointerLeft = getLLVMStyle();
-  PointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  verifyFormat("delete *x;", PointerLeft);
   verifyFormat("STATIC_ASSERT((a & b) == 0);");
   verifyFormat("STATIC_ASSERT(0 == (a & b));");
   verifyFormat("template  "
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ 

[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-08-07 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7010 is 
unhappy about this change, please fix.


https://reviews.llvm.org/D34784



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


[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-08-07 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode added a comment.

I don't have commit rights yet so I would be grateful for help in this matter :)




Comment at: lib/Lex/Lexer.cpp:469-477
+if (!isVerticalWhitespace(LexStart[0]))
+  continue;
 
-  const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-if (LexStart[0] == '\n' || LexStart[0] == '\r') {
-  ++LexStart;
-  break;
-}
+if (Lexer::isNewLineEscaped(BufStart, LexStart))
+  continue;
 
+// LexStart should point at first character of logical line.

alexfh wrote:
> The logic is hard to get here. I'd use a single `if` and reverse the 
> condition to get rid of the `continue`s:
> 
>   if (isVerticalWhitespace(*LexStart) && !Lexer::isNewLineEscaped(BufStart, 
> LexStart)) {
> ++LexStart;
> break;
>   }
Yes, I know - I thought that more vertical code composition would help


https://reviews.llvm.org/D30748



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


[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-08-07 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode updated this revision to Diff 110029.
idlecode added a comment.

Redability fix in `findBeginningOfLine`


https://reviews.llvm.org/D30748

Files:
  include/clang/Lex/Lexer.h
  lib/Lex/Lexer.cpp
  unittests/Lex/LexerTest.cpp

Index: unittests/Lex/LexerTest.cpp
===
--- unittests/Lex/LexerTest.cpp
+++ unittests/Lex/LexerTest.cpp
@@ -420,4 +420,57 @@
 #endif
 }
 
+TEST_F(LexerTest, IsNewLineEscapedValid) {
+  auto hasNewLineEscaped = [](const char *S) {
+return Lexer::isNewLineEscaped(S, S + strlen(S) - 1);
+  };
+
+  EXPECT_TRUE(hasNewLineEscaped("\\\r"));
+  EXPECT_TRUE(hasNewLineEscaped("\\\n"));
+  EXPECT_TRUE(hasNewLineEscaped("\\\r\n"));
+  EXPECT_TRUE(hasNewLineEscaped("\\\n\r"));
+  EXPECT_TRUE(hasNewLineEscaped("\\ \t\v\f\r"));
+  EXPECT_TRUE(hasNewLineEscaped("\\ \t\v\f\r\n"));
+
+  EXPECT_FALSE(hasNewLineEscaped("\\\r\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\\\r\r\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\\\n\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\r\n"));
+  EXPECT_FALSE(hasNewLineEscaped("\n\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\r\r"));
+  EXPECT_FALSE(hasNewLineEscaped("\n\n"));
+}
+
+TEST_F(LexerTest, GetBeginningOfTokenWithEscapedNewLine) {
+  // Each line should have the same length for
+  // further offset calculation to be more straightforward.
+  const unsigned IdentifierLength = 8;
+  std::string TextToLex = "rabarbar\n"
+  "foo\\\nbar\n"
+  "foo\\\rbar\n"
+  "fo\\\r\nbar\n"
+  "foo\\\n\rba\n";
+  std::vector ExpectedTokens{5, tok::identifier};
+  std::vector LexedTokens = CheckLex(TextToLex, ExpectedTokens);
+
+  for (const Token  : LexedTokens) {
+std::pair OriginalLocation =
+SourceMgr.getDecomposedLoc(Tok.getLocation());
+for (unsigned Offset = 0; Offset < IdentifierLength; ++Offset) {
+  SourceLocation LookupLocation =
+  Tok.getLocation().getLocWithOffset(Offset);
+
+  std::pair FoundLocation =
+  SourceMgr.getDecomposedExpansionLoc(
+  Lexer::GetBeginningOfToken(LookupLocation, SourceMgr, LangOpts));
+
+  // Check that location returned by the GetBeginningOfToken
+  // is the same as original token location reported by Lexer.
+  EXPECT_EQ(FoundLocation.second, OriginalLocation.second);
+}
+  }
+}
+
 } // anonymous namespace
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -463,19 +463,15 @@
   const char *BufStart = Buffer.data();
   if (Offset >= Buffer.size())
 return nullptr;
-  const char *StrData = BufStart + Offset;
 
-  if (StrData[0] == '\n' || StrData[0] == '\r')
-return StrData;
-
-  const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-if (LexStart[0] == '\n' || LexStart[0] == '\r') {
+  const char *LexStart = BufStart + Offset;
+  for (; LexStart != BufStart; --LexStart) {
+if (isVerticalWhitespace(LexStart[0]) &&
+!Lexer::isNewLineEscaped(BufStart, LexStart)) {
+  // LexStart should point at first character of logical line.
   ++LexStart;
   break;
 }
-
---LexStart;
   }
   return LexStart;
 }
@@ -487,7 +483,7 @@
   std::pair LocInfo = SM.getDecomposedLoc(Loc);
   if (LocInfo.first.isInvalid())
 return Loc;
-  
+
   bool Invalid = false;
   StringRef Buffer = SM.getBufferData(LocInfo.first, );
   if (Invalid)
@@ -499,52 +495,52 @@
   const char *LexStart = findBeginningOfLine(Buffer, LocInfo.second);
   if (!LexStart || LexStart == StrData)
 return Loc;
-  
+
   // Create a lexer starting at the beginning of this token.
   SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
   Lexer TheLexer(LexerStartLoc, LangOpts, Buffer.data(), LexStart,
  Buffer.end());
   TheLexer.SetCommentRetentionState(true);
-  
+
   // Lex tokens until we find the token that contains the source location.
   Token TheTok;
   do {
 TheLexer.LexFromRawLexer(TheTok);
-
+
 if (TheLexer.getBufferLocation() > StrData) {
   // Lexing this token has taken the lexer past the source location we're
   // looking for. If the current token encompasses our source location,
   // return the beginning of that token.
   if (TheLexer.getBufferLocation() - TheTok.getLength() <= StrData)
 return TheTok.getLocation();
-  
+
   // We ended up skipping over the source location entirely, which means
   // that it points into whitespace. We're done here.
   break;
 }
   } while (TheTok.getKind() != tok::eof);
-  
+
   // We've passed our source location; just return the original source location.
   return Loc;
 }
 
 SourceLocation Lexer::GetBeginningOfToken(SourceLocation Loc,
 

[PATCH] D36413: Use "foo-12345.o.tmp" instead of "foo.o-12345" as temporary file name.

2017-08-07 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.

This helps some tools that do things based on the output's extension.

For example, we got reports from users on Windows that have a tool that scan a 
build output dir (but skip .obj files). The tool would keep the "foo.obj-12345" 
file open, and then when clang tried to rename the temp file to the final 
output filename, that would fail. By making the tempfile end in ".obj.tmp", 
tools like this could now have a rule to ignore .tmp files.

This is a less ambitious reland of https://reviews.llvm.org/D36238


https://reviews.llvm.org/D36413

Files:
  lib/Frontend/CompilerInstance.cpp


Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -759,9 +759,15 @@
 
   if (UseTemporary) {
 // Create a temporary file.
-SmallString<128> TempPath;
-TempPath = OutFile;
+// Insert - before the extension (if any), and because some tools
+// (noticeable, clang's own GlobalModuleIndex.cpp) glob for build
+// artifacts, also append .tmp.
+StringRef OutputExtension = llvm::sys::path::extension(OutFile);
+SmallString<128> TempPath =
+StringRef(OutFile).drop_back(OutputExtension.size());
 TempPath += "-";
+TempPath += OutputExtension;
+TempPath += ".tmp";
 int fd;
 std::error_code EC =
 llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath);


Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -759,9 +759,15 @@
 
   if (UseTemporary) {
 // Create a temporary file.
-SmallString<128> TempPath;
-TempPath = OutFile;
+// Insert - before the extension (if any), and because some tools
+// (noticeable, clang's own GlobalModuleIndex.cpp) glob for build
+// artifacts, also append .tmp.
+StringRef OutputExtension = llvm::sys::path::extension(OutFile);
+SmallString<128> TempPath =
+StringRef(OutFile).drop_back(OutputExtension.size());
 TempPath += "-";
+TempPath += OutputExtension;
+TempPath += ".tmp";
 int fd;
 std::error_code EC =
 llvm::sys::fs::createUniqueFile(TempPath, fd, TempPath);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36327: [OpenCL] Allow targets emit optimized pipe functions for power of 2 type sizes

2017-08-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D36327#833891, @yaxunl wrote:

> In https://reviews.llvm.org/D36327#833653, @bader wrote:
>
> > Hi Sam,
> >
> > What do you think about implementing this optimization in target specific 
> > optimization pass? Since size/alignment is saved as function parameter in 
> > LLVM IR, the optimization can be done in target specific components w/o 
> > adding additional conditions to generic library.
> >
> > Thanks,
> > Alexey
>
>
> Hi Alexey,
>
> The optimization of the power-of-2 type size is implemented as a library 
> function. Our backend lacks the capability to link in library code at ISA 
> level, so linking of the optimized library function has to be done before any 
> target-specific passes. It seems the only place to do this is Clang codegen 
> since Clang/llvm does not support target-specific pre-linking passes.


My general feeling is that it doesn't look like a generic enough change for the 
frontend. Even though it is implemented in a generic way, not every target 
might have a special support for the power of 2 size and also if there is such 
a support not every implementation would handle it as a library function. But I 
can see that perhaps LLVM is missing flexibility in the flow to accommodate 
these needs. Any change we could try to extend the compilation flow such that 
this target specific optimization could happen before the IR linking?


https://reviews.llvm.org/D36327



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


Re: [PATCH] D36386: [clang] Remove unit test which uses reverse-iterate and fix a PointerLikeTypeTrait specialization

2017-08-07 Thread David Blaikie via cfe-commits
Not sure I understand the context for these changes - could you describe
the motivation(s) in more detail?

On Sun, Aug 6, 2017 at 10:39 PM Mandeep Singh Grang via Phabricator <
revi...@reviews.llvm.org> wrote:

> mgrang created this revision.
>
> This patch is in response to https://reviews.llvm.org/D35043 which
> removed -reverse-iterate flag
> and the base definition for PointerLikeTypeTrait.
>
>
> https://reviews.llvm.org/D36386
>
> Files:
>   include/clang/AST/ExternalASTSource.h
>   test/Rewriter/objc-modern-metadata-visibility2.mm
>
>
> Index: test/Rewriter/objc-modern-metadata-visibility2.mm
> ===
> --- test/Rewriter/objc-modern-metadata-visibility2.mm
> +++ /dev/null
> @@ -1,45 +0,0 @@
> -// REQUIRES: abi-breaking-checks
> -// NOTE: This test has been split from objc-modern-metadata-visibility.mm
> in
> -// order to test with -reverse-iterate as this flag is only present with
> -// ABI_BREAKING_CHECKS.
> -
> -// RUN: %clang_cc1 -E %s -o %t.mm -mllvm -reverse-iterate
> -// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions
> -rewrite-objc %t.mm -mllvm -reverse-iterate -o - | FileCheck %s
> -// rdar://11144048
> -
> -@class NSString;
> -
> -@interface NSObject {
> -Class isa;
> -}
> -@end
> -
> -@interface Sub : NSObject {
> -int subIvar;
> -NSString *nsstring;
> -@private
> -id PrivateIvar;
> -}
> -@end
> -
> -@implementation Sub
> -- (id) MyNSString { return subIvar ? PrivateIvar : nsstring; }
> -@end
> -
> -@interface NSString @end
> -@implementation NSString @end
> -
> -// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C"
> __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$subIvar;
> -// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long
> OBJC_IVAR_$_Sub$PrivateIvar;
> -// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C"
> __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$nsstring;
> -// CHECK: #pragma warning(disable:4273)
> -// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C"
> __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$subIvar
> -// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C"
> __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$nsstring
> -// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long
> int OBJC_IVAR_$_Sub$PrivateIvar
> -// CHECK: extern "C" __declspec(dllimport) struct _class_t
> OBJC_METACLASS_$_NSObject;
> -// CHECK: extern "C" __declspec(dllexport) struct _class_t
> OBJC_METACLASS_$_Sub
> -// CHECK: extern "C" __declspec(dllimport) struct _class_t
> OBJC_CLASS_$_NSObject;
> -// CHECK: extern "C" __declspec(dllexport) struct _class_t
> OBJC_CLASS_$_Sub
> -// CHECK: extern "C" __declspec(dllexport) struct _class_t
> OBJC_CLASS_$_NSString;
> -// CHECK: extern "C" __declspec(dllexport) struct _class_t
> OBJC_METACLASS_$_NSString
> -// CHECK: extern "C" __declspec(dllexport) struct _class_t
> OBJC_CLASS_$_NSString
> Index: include/clang/AST/ExternalASTSource.h
> ===
> --- include/clang/AST/ExternalASTSource.h
> +++ include/clang/AST/ExternalASTSource.h
> @@ -466,9 +466,10 @@
>  namespace llvm {
>  template   void (clang::ExternalASTSource::*Update)(Owner)>
> -struct PointerLikeTypeTraits<
> +class PointerLikeTypeTraits<
>  clang::LazyGenerationalUpdatePtr> {
>typedef clang::LazyGenerationalUpdatePtr Ptr;
> +public:
>static void *getAsVoidPointer(Ptr P) { return P.getOpaqueValue(); }
>static Ptr getFromVoidPointer(void *P) { return
> Ptr::getFromOpaqueValue(P); }
>enum {
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36171: AMDGPU: Use direct struct returns

2017-08-07 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


https://reviews.llvm.org/D36171



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


[PATCH] D36105: [AArch64] Ignore stdcall and similar on aarch64/windows

2017-08-07 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Ping @mgrang, can you check the above with MSVC? I'd like to move forward with 
this in one form or another.


https://reviews.llvm.org/D36105



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


[PATCH] D36410: [OpenCL] Handle taking address of block captures

2017-08-07 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.

There is an issue with taking an address of captured variables, because 
captures can be put in different locations depending on the vendor 
implementation (and therefore they are passed as generic AS pointer to the 
block).

The physical location for the captures can be:
(a) in case the block is called as a lambda function the captures are put on 
the stack - in the private AS.
(b) in case the block is used in enqueue it depends on the vendor 
implementation to put the captured content in the memory accessible for the 
enqueued kernels. In general case global memory can be used which is accessible 
everywhere.

Example:

  void foo(){
int a;
void (^bl)(void) = ^(void) {
  private int* b =  // a here is not the same object as a in foo
}

Currently Clang hits `unreachable` due to `bitcast` of generic to private AS 
pointer because the original location of `a` is on the stack but the location 
of the captures is in generic AS.

This patch disallows taking address of captures because the physical address 
space can be different depending on the block use cases and vendor 
implementations.

An alternative approached could be (in case we want to allow this code) to 
assume captures are located in the generic AS implicitly. However, in this case 
programmers should be advised that erroneous AS casts can occur further that 
can't be diagnosed by the frontend (i.e. if capture address is used further in 
the operations of a different address space to where the captures physical 
location is).

Example:

  void foo(){
int a;
void (^bl)(void) = ^(void) {
  local int* b = (local int*) //valid cast of implicitly generic to 
local but  will be located in private or global AS for the 2 uses below
}
b();
enqueue_kernel(..., b)
  }

@Sam, @Alexey, does it make sense taking this route?


https://reviews.llvm.org/D36410

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaOpenCL/invalid-block.cl


Index: test/SemaOpenCL/invalid-block.cl
===
--- test/SemaOpenCL/invalid-block.cl
+++ test/SemaOpenCL/invalid-block.cl
@@ -78,3 +78,14 @@
   };
   return;
 }
+
+// Taking address of a capture is not allowed
+int g;
+kernel void f7(int a1) {
+  int a2;
+  void (^bl)(void) = ^(void) {
+ //expected-warning{{expression result unused}}
+ //expected-error{{taking address of a capture is not allowed}}
+ //expected-error{{taking address of a capture is not allowed}}
+  };
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -526,14 +526,6 @@
   assert(!Ty.isNull() && "DefaultFunctionArrayConversion - missing type");
 
   if (Ty->isFunctionType()) {
-// If we are here, we are not calling a function but taking
-// its address (which is not allowed in OpenCL v1.0 s6.8.a.3).
-if (getLangOpts().OpenCL) {
-  if (Diagnose)
-Diag(E->getExprLoc(), diag::err_opencl_taking_function_address);
-  return ExprError();
-}
-
 if (auto *DRE = dyn_cast(E->IgnoreParenCasts()))
   if (auto *FD = dyn_cast(DRE->getDecl()))
 if (!checkAddressOfFunctionIsAvailable(FD, Diagnose, E->getExprLoc()))
@@ -10690,10 +10682,17 @@
   // Make sure to ignore parentheses in subsequent checks
   Expr *op = OrigOp.get()->IgnoreParens();
 
-  // OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed.
-  if (LangOpts.OpenCL && op->getType()->isFunctionType()) {
-Diag(op->getExprLoc(), diag::err_opencl_taking_function_address);
-return QualType();
+  // In OpenCL captures for blocks called as lambda functions
+  // are located in the private address space. Blocks used in
+  // enqueue_kernel can be located in a different address space
+  // depending on a vendor implementation. Thus preventing
+  // taking an address of the capture to avoid invalid AS casts.
+  if (LangOpts.OpenCL) {
+auto* VarRef = dyn_cast(op);
+if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
+  Diag(op->getExprLoc(), diag::err_opencl_taking_address_capture);
+  return QualType();
+}
   }
 
   if (getLangOpts().C99) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6948,8 +6948,8 @@
 def err_opencl_function_pointer_variable : Error<
   "pointers to functions are not allowed">;
 
-def err_opencl_taking_function_address : Error<
-  "taking address of function is not allowed">;
+def err_opencl_taking_address_capture : Error<
+  "taking address of a capture is not allowed">;
 
 def err_invalid_conversion_between_vector_and_scalar : Error<
   "invalid conversion between vector type %0 and scalar type %1">;


Index: test/SemaOpenCL/invalid-block.cl

[PATCH] D36407: [Sema] Extend -Wenum-compare to handle mixed enum comparisons in switch statements

2017-08-07 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs created this revision.

`-Wenum-compare` warns if two values with different enumeration types are 
compared in expressions with binary operators. This patch extends this 
diagnostic so that comparisons of mixed enumeration types are recognized in 
switch statements as well.

Example:

  enum MixedA { A1, A2, A3 };
  enum MixedB { B1, B2, B3 };
  
  void MixedEnums(MixedA a) {
switch (a) {
  case A1: break; // OK, same enum types.
  case B1: break; // Warn, different enum types.
}
  }


https://reviews.llvm.org/D36407

Files:
  lib/Sema/SemaStmt.cpp
  test/Sema/switch.c
  test/SemaCXX/warn-enum-compare.cpp


Index: test/SemaCXX/warn-enum-compare.cpp
===
--- test/SemaCXX/warn-enum-compare.cpp
+++ test/SemaCXX/warn-enum-compare.cpp
@@ -209,4 +209,21 @@
   while (getBar() > x); // expected-warning  {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
   while (getBar() < x); // expected-warning  {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
 
+  switch (a) {
+case name1::F1: break;
+case name1::F3: break;
+case name2::B2: break; // expected-warning {{comparison of two values with 
different enumeration types ('name1::Foo' and 'name2::Baz')}}
+  }
+
+  switch (x) {
+case FooB: break;
+case FooC: break;
+case BarD: break; // expected-warning {{comparison of two values with 
different enumeration types ('Foo' and 'Bar')}}
+  }
+
+  switch(getBar()) {
+case BarE: break;
+case BarF: break;
+case FooA: break; // expected-warning {{comparison of two values with 
different enumeration types ('Bar' and 'Foo')}}
+  }
 }
Index: test/Sema/switch.c
===
--- test/Sema/switch.c
+++ test/Sema/switch.c
@@ -372,6 +372,7 @@
   case EE1_b: break;
   case EE1_c: break; // no-warning
   case EE1_d: break; // expected-warning {{case value not in enumerated type 
'enum ExtendedEnum1'}}
+  // expected-warning@-1 {{comparison of two values with different enumeration 
types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
   }
 }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -743,6 +743,24 @@
   return true;
 }
 
+static void checkEnumTypesInSwitchStmt(Sema , Expr *Cond, Expr *Case) {
+  QualType CondType = GetTypeBeforeIntegralPromotion(Cond);
+  QualType CaseType = Case->getType();
+
+  const EnumType *CondEnumType = CondType->getAs();
+  const EnumType *CaseEnumType = CaseType->getAs();
+  if (!CondEnumType || !CaseEnumType)
+return;
+
+  if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
+return;
+
+  SourceLocation Loc = Case->getExprLoc();
+  S.Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
+  << CondType << CaseType << Cond->getSourceRange()
+  << Case->getSourceRange();
+}
+
 StmtResult
 Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
 Stmt *BodyStmt) {
@@ -843,6 +861,8 @@
 break;
   }
 
+  checkEnumTypesInSwitchStmt(*this, CondExpr, Lo);
+
   llvm::APSInt LoVal;
 
   if (getLangOpts().CPlusPlus11) {


Index: test/SemaCXX/warn-enum-compare.cpp
===
--- test/SemaCXX/warn-enum-compare.cpp
+++ test/SemaCXX/warn-enum-compare.cpp
@@ -209,4 +209,21 @@
   while (getBar() > x); // expected-warning  {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
   while (getBar() < x); // expected-warning  {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
 
+  switch (a) {
+case name1::F1: break;
+case name1::F3: break;
+case name2::B2: break; // expected-warning {{comparison of two values with different enumeration types ('name1::Foo' and 'name2::Baz')}}
+  }
+
+  switch (x) {
+case FooB: break;
+case FooC: break;
+case BarD: break; // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}}
+  }
+
+  switch(getBar()) {
+case BarE: break;
+case BarF: break;
+case FooA: break; // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
+  }
 }
Index: test/Sema/switch.c
===
--- test/Sema/switch.c
+++ test/Sema/switch.c
@@ -372,6 +372,7 @@
   case EE1_b: break;
   case EE1_c: break; // no-warning
   case EE1_d: break; // expected-warning {{case value not in enumerated type 'enum ExtendedEnum1'}}
+  // expected-warning@-1 {{comparison of two values with different enumeration types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}}
   }
 }
 
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ 

[PATCH] D36261: [clangd] Use multiple working threads in clangd.

2017-08-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.h:121-122
+public:
+  /// Returns the number of threads to use when shouldRunsynchronously() is
+  /// false. Must not be called if shouldRunsynchronously() is true.
+  unsigned getThreadsCount();

ilya-biryukov wrote:
> klimek wrote:
> > Why not: 1 -> run synchronously, > 1, run in parallel?
> Currently 1 means: start 1 worker thread to run async operations (that thread 
> is separate from the main thread).
> This makes sense for clangd, as if you do that, you still get code completion 
> that doesn't wait for diagnostics to finish.
> On the other hand, it's useful to have `-run-synchronously` for some tests.
As discussed, replaced with `unsigned AsyncThreadsCount`. Zero means run 
synchronously.


https://reviews.llvm.org/D36261



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


[PATCH] D36398: [clangd] Check if CompileCommand has changed on forceReparse.

2017-08-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdUnitStore.cpp:45
+ .first;
+Result.RemovedFile = nullptr;
+  } else if (!compileCommandsAreEqual(It->second->getCompileCommand(),

klimek wrote:
> Just say RemovedFile = nullptr in the struct?
I'd argue that having it in the code, rather than declaration makes it more 
readable. Besides, default ctor of shared_ptr gives us nullptr anyway, so we 
can also leave it as is and remove the assignments altogether.

I've moved `=nullptr` assignments out of the if/else bodies. Let me know if it 
still looks ugly.



Comment at: clangd/ClangdUnitStore.h:45-48
+  struct RecreateResult {
+std::shared_ptr FileInCollection;
+std::shared_ptr RemovedFile;
+  };

klimek wrote:
> Not obvious to me what things in there mean.
Added a comment. Hopefully makes sense now.


https://reviews.llvm.org/D36398



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


[PATCH] D36398: [clangd] Check if CompileCommand has changed on forceReparse.

2017-08-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 110016.
ilya-biryukov added a comment.

- Moved assignment `RemoveFile = nullptr` around a bit.
- Added a comment to recreateFileIfCompileCommandChanged.


https://reviews.llvm.org/D36398

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h

Index: clangd/ClangdUnitStore.h
===
--- clangd/ClangdUnitStore.h
+++ clangd/ClangdUnitStore.h
@@ -42,6 +42,25 @@
 return It->second;
   }
 
+  struct RecreateResult {
+/// A CppFile, stored in this CppFileCollection for the corresponding
+/// filepath after calling recreateFileIfCompileCommandChanged.
+std::shared_ptr FileInCollection;
+/// If a new CppFile had to be created to account for changed
+/// CompileCommand, a previous CppFile instance will be returned in this
+/// field.
+std::shared_ptr RemovedFile;
+  };
+
+  /// Similar to getOrCreateFile, but will replace a current CppFile for \p File
+  /// with a new one if CompileCommand, provided by \p CDB has changed.
+  /// If a currently stored CppFile had to be replaced, the previous instance
+  /// will be returned in RecreateResult.RemovedFile.
+  RecreateResult recreateFileIfCompileCommandChanged(
+  PathRef File, PathRef ResourceDir, GlobalCompilationDatabase ,
+  std::shared_ptr PCHs,
+  IntrusiveRefCntPtr VFS);
+
   std::shared_ptr getFile(PathRef File) {
 std::lock_guard Lock(Mutex);
 
@@ -59,6 +78,9 @@
   tooling::CompileCommand getCompileCommand(GlobalCompilationDatabase ,
 PathRef File, PathRef ResourceDir);
 
+  bool compileCommandsAreEqual(tooling::CompileCommand const ,
+   tooling::CompileCommand const );
+
   std::mutex Mutex;
   llvm::StringMap OpenedFiles;
 };
Index: clangd/ClangdUnitStore.cpp
===
--- clangd/ClangdUnitStore.cpp
+++ clangd/ClangdUnitStore.cpp
@@ -9,6 +9,7 @@
 
 #include "ClangdUnitStore.h"
 #include "llvm/Support/Path.h"
+#include 
 
 using namespace clang::clangd;
 using namespace clang;
@@ -25,6 +26,33 @@
   return Result;
 }
 
+CppFileCollection::RecreateResult
+CppFileCollection::recreateFileIfCompileCommandChanged(
+PathRef File, PathRef ResourceDir, GlobalCompilationDatabase ,
+std::shared_ptr PCHs,
+IntrusiveRefCntPtr VFS) {
+  auto NewCommand = getCompileCommand(CDB, File, ResourceDir);
+
+  std::lock_guard Lock(Mutex);
+
+  RecreateResult Result;
+  Result.RemovedFile = nullptr;
+
+  auto It = OpenedFiles.find(File);
+  if (It == OpenedFiles.end()) {
+It = OpenedFiles
+ .try_emplace(File, CppFile::Create(File, std::move(NewCommand),
+std::move(PCHs)))
+ .first;
+  } else if (!compileCommandsAreEqual(It->second->getCompileCommand(),
+  NewCommand)) {
+Result.RemovedFile = std::move(It->second);
+It->second = CppFile::Create(File, std::move(NewCommand), std::move(PCHs));
+  }
+  Result.FileInCollection = It->second;
+  return Result;
+}
+
 tooling::CompileCommand
 CppFileCollection::getCompileCommand(GlobalCompilationDatabase ,
  PathRef File, PathRef ResourceDir) {
@@ -39,3 +67,12 @@
  std::string(ResourceDir));
   return std::move(Commands.front());
 }
+
+bool CppFileCollection::compileCommandsAreEqual(
+tooling::CompileCommand const , tooling::CompileCommand const ) {
+  // tooling::CompileCommand.Output is ignored, it's not relevant for clangd.
+  return LHS.Directory == RHS.Directory &&
+ LHS.CommandLine.size() == RHS.CommandLine.size() &&
+ std::equal(LHS.CommandLine.begin(), LHS.CommandLine.end(),
+RHS.CommandLine.begin());
+}
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -192,10 +192,13 @@
   std::future addDocument(PathRef File, StringRef Contents);
   /// Remove \p File from list of tracked files, schedule a request to free
   /// resources associated with it.
-  /// \return A future that will become ready the file is removed and all
-  /// associated reosources are freed.
+  /// \return A future that will become ready when the file is removed and all
+  /// associated resources are freed.
   std::future removeDocument(PathRef File);
   /// Force \p File to be reparsed using the latest contents.
+  /// Will also check if CompileCommand, provided by GlobalCompilationDatabase
+  /// for \p File has changed. If it has, will remove currently stored Preamble
+  /// and AST and rebuild them from scratch.
   std::future forceReparse(PathRef File);
 
   /// Run code completion for \p File at \p Pos. If \p OverridenContents is not
Index: clangd/ClangdServer.cpp

[PATCH] D36397: [clangd] Fixed a data race.

2017-08-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D36397#833890, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D36397#833883, @klimek wrote:
>
> > Tests?
>
>
> TSAN does not catch this (as it's a logical error) and it requires a rather 
> bizarre timing of file reparses to trigger.
>  I couldn't come up with an example that would reproduce this.


Yea, we'll probably want to add a "smash it hard with parallel" requests kind 
of test to catch these things. You're right, there is probably not a better 
solution for this specific bug.


https://reviews.llvm.org/D36397



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


r310263 - [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-08-07 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Mon Aug  7 08:39:11 2017
New Revision: 310263

URL: http://llvm.org/viewvc/llvm-project?rev=310263=rev
Log:
[OpenMP] Add flag for specifying the target device architecture for OpenMP 
device offloading

Summary:
OpenMP has the ability to offload target regions to devices which may have 
different architectures.

A new -fopenmp-target-arch flag is introduced to specify the device 
architecture.

In this patch I use the new flag to specify the compute capability of the 
underlying NVIDIA architecture for the OpenMP offloading CUDA tool chain.

Only a host-offloading test is provided since full device offloading capability 
will only be available when [[ https://reviews.llvm.org/D29654 | D29654 ]] 
lands.

Reviewers: hfinkel, Hahnfeld, carlo.bertolli, caomhin, ABataev

Reviewed By: hfinkel

Subscribers: guansong, cfe-commits

Tags: #openmp

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Compilation.cpp
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=310263=310262=310263=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Aug  7 08:39:11 
2017
@@ -69,6 +69,10 @@ def err_drv_invalid_Xarch_argument_with_
   "invalid Xarch argument: '%0', options requiring arguments are unsupported">;
 def err_drv_invalid_Xarch_argument_isdriver : Error<
   "invalid Xarch argument: '%0', cannot change driver behavior inside Xarch 
argument">;
+def err_drv_Xopenmp_target_missing_triple : Error<
+  "cannot deduce implicit triple value for -Xopenmp-target, specify triple 
using -Xopenmp-target=">;
+def err_drv_invalid_Xopenmp_target_with_args : Error<
+  "invalid -Xopenmp-target argument: '%0', options requiring arguments are 
unsupported">;
 def err_drv_argument_only_allowed_with : Error<
   "invalid argument '%0' only allowed with '%1'">;
 def err_drv_argument_not_allowed_with : Error<

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=310263=310262=310263=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Aug  7 08:39:11 2017
@@ -459,6 +459,10 @@ def Xcuda_fatbinary : Separate<["-"], "X
   HelpText<"Pass  to fatbinary invocation">, MetaVarName<"">;
 def Xcuda_ptxas : Separate<["-"], "Xcuda-ptxas">,
   HelpText<"Pass  to the ptxas assembler">, MetaVarName<"">;
+def Xopenmp_target : Separate<["-"], "Xopenmp-target">,
+  HelpText<"Pass  to the target offloading toolchain.">, 
MetaVarName<"">;
+def Xopenmp_target_EQ : JoinedAndSeparate<["-"], "Xopenmp-target=">,
+  HelpText<"Pass  to the specified target offloading toolchain. The 
triple that identifies the toolchain must be provided after the equals sign.">, 
MetaVarName<"">;
 def z : Separate<["-"], "z">, Flags<[LinkerInput, RenderAsInput]>,
   HelpText<"Pass -z  to the linker">, MetaVarName<"">,
   Group;

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=310263=310262=310263=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Aug  7 08:39:11 2017
@@ -217,6 +217,17 @@ public:
 return nullptr;
   }
 
+  /// TranslateOpenMPTargetArgs - Create a new derived argument list for
+  /// that contains the OpenMP target specific flags passed via
+  /// -Xopenmp-target -opt=val OR -Xopenmp-target= -opt=val
+  /// Translation occurs only when the \p DeviceOffloadKind is specified.
+  ///
+  /// \param DeviceOffloadKind - The device offload kind used for the
+  /// translation.
+  virtual llvm::opt::DerivedArgList *
+  TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList ,
+  Action::OffloadKind DeviceOffloadKind) const;
+
   /// Choose a tool to use to handle the action \p JA.
   ///
   /// This can be overridden when a particular ToolChain needs to use

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=310263=310262=310263=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Mon Aug  7 08:39:11 2017
@@ 

[PATCH] D36327: [OpenCL] Allow targets emit optimized pipe functions for power of 2 type sizes

2017-08-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D36327#833653, @bader wrote:

> Hi Sam,
>
> What do you think about implementing this optimization in target specific 
> optimization pass? Since size/alignment is saved as function parameter in 
> LLVM IR, the optimization can be done in target specific components w/o 
> adding additional conditions to generic library.
>
> Thanks,
> Alexey


Hi Alexey,

The optimization of the power-of-2 type size is implemented as a library 
function. Our backend lacks the capability to link in library code at ISA 
level, so linking of the optimized library function has to be done before any 
target-specific passes. It seems the only place to do this is Clang codegen 
since Clang/llvm does not support target-specific pre-linking passes.


https://reviews.llvm.org/D36327



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


[PATCH] D36397: [clangd] Fixed a data race.

2017-08-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In https://reviews.llvm.org/D36397#833883, @klimek wrote:

> Tests?


TSAN does not catch this (as it's a logical error) and it requires a rather 
bizarre timing of file reparses to trigger.
I couldn't come up with an example that would reproduce this.


https://reviews.llvm.org/D36397



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


[PATCH] D34784: [OpenMP] Add flag for specifying the target device architecture for OpenMP device offloading

2017-08-07 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 110007.
gtbercea added a comment.

Fix test comments.


https://reviews.llvm.org/D34784

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Options.td
  include/clang/Driver/ToolChain.h
  lib/Driver/Compilation.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -597,3 +597,35 @@
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
 
 // CHK-FOPENMP-IS-DEVICE: clang{{.*}} "-aux-triple" "powerpc64le--linux" {{.*}}.c" "-fopenmp-is-device" "-fopenmp-host-ir-file-path"
+
+/// ###
+
+/// Check -Xopenmp-target=powerpc64le-ibm-linux-gnu -march=pwr7 is passed when compiling for the device.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target=powerpc64le-ibm-linux-gnu -mcpu=pwr7 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-EQ-TARGET %s
+
+// CHK-FOPENMP-EQ-TARGET: clang{{.*}} "-target-cpu" "pwr7"
+
+/// ###
+
+/// Check -Xopenmp-target -march=pwr7 is passed when compiling for the device.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -mcpu=pwr7 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET %s
+
+// CHK-FOPENMP-TARGET: clang{{.*}} "-target-cpu" "pwr7"
+
+/// ###
+
+/// Check -Xopenmp-target triggers error when multiple triples are used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-unknown-linux-gnu -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR %s
+
+// CHK-FOPENMP-TARGET-AMBIGUOUS-ERROR: clang{{.*}} error: cannot deduce implicit triple value for -Xopenmp-target, specify triple using -Xopenmp-target=
+
+/// ###
+
+/// Check -Xopenmp-target triggers error when an option requiring arguments is passed to it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -Xopenmp-target -Xopenmp-target -mcpu=pwr8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-NESTED-ERROR %s
+
+// CHK-FOPENMP-TARGET-NESTED-ERROR: clang{{.*}} error: invalid -Xopenmp-target argument: '-Xopenmp-target -Xopenmp-target', options requiring arguments are unsupported
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -212,8 +212,18 @@
   static_cast(getToolChain());
   assert(TC.getTriple().isNVPTX() && "Wrong platform");
 
+  StringRef GPUArchName;
+  // If this is an OpenMP action we need to extract the device architecture
+  // from the -march=arch option. This option may come from -Xopenmp-target
+  // flag or the default value.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP)) {
+GPUArchName = Args.getLastArgValue(options::OPT_march_EQ);
+assert(!GPUArchName.empty() && "Must have an architecture passed in.");
+  } else
+GPUArchName = JA.getOffloadingArch();
+
   // Obtain architecture from the action.
-  CudaArch gpu_arch = StringToCudaArch(JA.getOffloadingArch());
+  CudaArch gpu_arch = StringToCudaArch(GPUArchName);
   assert(gpu_arch != CudaArch::UNKNOWN &&
  "Device action expected to have an architecture.");
 
@@ -405,7 +415,7 @@
 
   // For OpenMP device offloading, append derived arguments. Make sure
   // flags are not duplicated.
-  // TODO: Append the compute capability.
+  // Also append the compute capability.
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 for (Arg *A : Args){
   bool IsDuplicate = false;
@@ -418,6 +428,13 @@
   if (!IsDuplicate)
 DAL->append(A);
 }
+
+StringRef Arch = DAL->getLastArgValue(options::OPT_march_EQ);
+if (Arch.empty())
+  // Default compute capability for CUDA toolchain is sm_20.
+  DAL->AddJoinedArg(nullptr,
+  Opts.getOption(options::OPT_march_EQ), "sm_20");
+
 return DAL;
   }
 
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -795,3 +795,65 @@
 
   return VersionTuple();
 }
+
+llvm::opt::DerivedArgList *
+ToolChain::TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList ,
+Action::OffloadKind DeviceOffloadKind) const {
+  if (DeviceOffloadKind == Action::OFK_OpenMP) {
+DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
+const OptTable  = getDriver().getOpts();
+
+// Handle -Xopenmp-target flags
+for (Arg 

[PATCH] D36397: [clangd] Fixed a data race.

2017-08-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Tests?


https://reviews.llvm.org/D36397



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


[PATCH] D36398: [clangd] Check if CompileCommand has changed on forceReparse.

2017-08-07 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clangd/ClangdUnitStore.cpp:45
+ .first;
+Result.RemovedFile = nullptr;
+  } else if (!compileCommandsAreEqual(It->second->getCompileCommand(),

Just say RemovedFile = nullptr in the struct?



Comment at: clangd/ClangdUnitStore.h:45-48
+  struct RecreateResult {
+std::shared_ptr FileInCollection;
+std::shared_ptr RemovedFile;
+  };

Not obvious to me what things in there mean.


https://reviews.llvm.org/D36398



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


[PATCH] D36398: [clangd] Check if CompileCommand has changed on forceReparse.

2017-08-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

https://reviews.llvm.org/D36398

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnitStore.cpp
  clangd/ClangdUnitStore.h

Index: clangd/ClangdUnitStore.h
===
--- clangd/ClangdUnitStore.h
+++ clangd/ClangdUnitStore.h
@@ -42,6 +42,16 @@
 return It->second;
   }
 
+  struct RecreateResult {
+std::shared_ptr FileInCollection;
+std::shared_ptr RemovedFile;
+  };
+
+  RecreateResult recreateFileIfCompileCommandChanged(
+  PathRef File, PathRef ResourceDir, GlobalCompilationDatabase ,
+  std::shared_ptr PCHs,
+  IntrusiveRefCntPtr VFS);
+
   std::shared_ptr getFile(PathRef File) {
 std::lock_guard Lock(Mutex);
 
@@ -59,6 +69,9 @@
   tooling::CompileCommand getCompileCommand(GlobalCompilationDatabase ,
 PathRef File, PathRef ResourceDir);
 
+  bool compileCommandsAreEqual(tooling::CompileCommand const ,
+   tooling::CompileCommand const );
+
   std::mutex Mutex;
   llvm::StringMap OpenedFiles;
 };
Index: clangd/ClangdUnitStore.cpp
===
--- clangd/ClangdUnitStore.cpp
+++ clangd/ClangdUnitStore.cpp
@@ -9,6 +9,7 @@
 
 #include "ClangdUnitStore.h"
 #include "llvm/Support/Path.h"
+#include 
 
 using namespace clang::clangd;
 using namespace clang;
@@ -25,6 +26,34 @@
   return Result;
 }
 
+CppFileCollection::RecreateResult
+CppFileCollection::recreateFileIfCompileCommandChanged(
+PathRef File, PathRef ResourceDir, GlobalCompilationDatabase ,
+std::shared_ptr PCHs,
+IntrusiveRefCntPtr VFS) {
+  auto NewCommand = getCompileCommand(CDB, File, ResourceDir);
+
+  std::lock_guard Lock(Mutex);
+
+  RecreateResult Result;
+  auto It = OpenedFiles.find(File);
+  if (It == OpenedFiles.end()) {
+It = OpenedFiles
+ .try_emplace(File, CppFile::Create(File, std::move(NewCommand),
+std::move(PCHs)))
+ .first;
+Result.RemovedFile = nullptr;
+  } else if (!compileCommandsAreEqual(It->second->getCompileCommand(),
+  NewCommand)) {
+Result.RemovedFile = std::move(It->second);
+It->second = CppFile::Create(File, std::move(NewCommand), std::move(PCHs));
+  } else {
+Result.RemovedFile = nullptr;
+  }
+  Result.FileInCollection = It->second;
+  return Result;
+}
+
 tooling::CompileCommand
 CppFileCollection::getCompileCommand(GlobalCompilationDatabase ,
  PathRef File, PathRef ResourceDir) {
@@ -39,3 +68,12 @@
  std::string(ResourceDir));
   return std::move(Commands.front());
 }
+
+bool CppFileCollection::compileCommandsAreEqual(
+tooling::CompileCommand const , tooling::CompileCommand const ) {
+  // tooling::CompileCommand.Output is ignored, it's not relevant for clangd.
+  return LHS.Directory == RHS.Directory &&
+ LHS.CommandLine.size() == RHS.CommandLine.size() &&
+ std::equal(LHS.CommandLine.begin(), LHS.CommandLine.end(),
+RHS.CommandLine.begin());
+}
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -192,10 +192,13 @@
   std::future addDocument(PathRef File, StringRef Contents);
   /// Remove \p File from list of tracked files, schedule a request to free
   /// resources associated with it.
-  /// \return A future that will become ready the file is removed and all
-  /// associated reosources are freed.
+  /// \return A future that will become ready when the file is removed and all
+  /// associated resources are freed.
   std::future removeDocument(PathRef File);
   /// Force \p File to be reparsed using the latest contents.
+  /// Will also check if CompileCommand, provided by GlobalCompilationDatabase
+  /// for \p File has changed. If it has, will remove currently stored Preamble
+  /// and AST and rebuild them from scratch.
   std::future forceReparse(PathRef File);
 
   /// Run code completion for \p File at \p Pos. If \p OverridenContents is not
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -154,9 +154,20 @@
 }
 
 std::future ClangdServer::forceReparse(PathRef File) {
-  // The addDocument schedules the reparse even if the contents of the file
-  // never changed, so we just call it here.
-  return addDocument(File, getDocument(File));
+  auto FileContents = DraftMgr.getDraft(File);
+  assert(FileContents.Draft &&
+ "forceReparse() was called for non-added document");
+
+  auto TaggedFS = FSProvider.getTaggedFileSystem(File);
+  auto Recreated = Units.recreateFileIfCompileCommandChanged(
+  File, ResourceDir, CDB, PCHs, TaggedFS.Value);
+
+  // Note 

[PATCH] D36397: [clangd] Fixed a data race.

2017-08-07 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

Calling addDocument after removeDocument could have resulted in an
invalid program state (AST and Preamble for the valid document could
have been incorrectly removed).
This commit also includes an improved CppFile::cancelRebuild
implementation that allows to cancel reparse without waiting for
ongoing rebuild to finish.


https://reviews.llvm.org/D36397

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h

Index: clangd/ClangdUnit.h
===
--- clangd/ClangdUnit.h
+++ clangd/ClangdUnit.h
@@ -151,9 +151,17 @@
   CppFile(CppFile const &) = delete;
   CppFile(CppFile &&) = delete;
 
-  /// Cancels all scheduled rebuilds and sets AST and Preamble to nulls.
+  /// Cancels a scheduled rebuild, if any, and sets AST and Preamble to nulls.
   /// If a rebuild is in progress, will wait for it to finish.
-  void cancelRebuilds();
+  void cancelRebuild();
+
+  /// Similar to deferRebuild, but sets both Preamble and AST to nulls instead
+  /// of doing an actual parsing. Returned future is a deferred computation that
+  /// will wait for any ongoing rebuilds to finish and actually set the AST and
+  /// Preamble to nulls. It can be run on a different thread.
+  /// This function is useful to cancel ongoing rebuilds, if any, before
+  /// removing CppFile.
+  std::future deferCancelRebuild();
 
   /// Rebuild AST and Preamble synchronously on the calling thread.
   /// Returns a list of diagnostics or a llvm::None, if another rebuild was
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -711,10 +711,12 @@
   ASTFuture = ASTPromise.get_future();
 }
 
-void CppFile::cancelRebuilds() {
+void CppFile::cancelRebuild() { deferCancelRebuild().get(); }
+
+std::future CppFile::deferCancelRebuild() {
   std::unique_lock Lock(Mutex);
   // Cancel an ongoing rebuild, if any, and wait for it to finish.
-  ++this->RebuildCounter;
+  unsigned RequestRebuildCounter = ++this->RebuildCounter;
   // Rebuild asserts that futures aren't ready if rebuild is cancelled.
   // We want to keep this invariant.
   if (futureIsReady(PreambleFuture)) {
@@ -725,12 +727,28 @@
 ASTPromise = std::promise();
 ASTFuture = ASTPromise.get_future();
   }
-  // Now wait for rebuild to finish.
-  RebuildCond.wait(Lock, [this]() { return !this->RebuildInProgress; });
 
-  // Return empty results for futures.
-  PreamblePromise.set_value(nullptr);
-  ASTPromise.set_value(std::make_shared(llvm::None));
+  Lock.unlock();
+  // Notify about changes to RebuildCounter.
+  RebuildCond.notify_all();
+
+  std::shared_ptr That = shared_from_this();
+  return std::async(std::launch::deferred, [That, RequestRebuildCounter]() {
+std::unique_lock Lock(That->Mutex);
+CppFile *This = &*That;
+This->RebuildCond.wait(Lock, [This, RequestRebuildCounter]() {
+  return !This->RebuildInProgress ||
+ This->RebuildCounter != RequestRebuildCounter;
+});
+
+// This computation got cancelled itself, do nothing.
+if (This->RebuildCounter != RequestRebuildCounter)
+  return;
+
+// Set empty results for Promises.
+That->PreamblePromise.set_value(nullptr);
+That->ASTPromise.set_value(std::make_shared(llvm::None));
+  });
 }
 
 llvm::Optional
@@ -767,6 +785,8 @@
   this->ASTFuture = this->ASTPromise.get_future();
 }
   } // unlock Mutex.
+  // Notify about changes to RebuildCounter.
+  RebuildCond.notify_all();
 
   // A helper to function to finish the rebuild. May be run on a different
   // thread.
@@ -916,7 +936,10 @@
   if (WasCancelledBeforeConstruction)
 return;
 
-  File.RebuildCond.wait(Lock, []() { return !File.RebuildInProgress; });
+  File.RebuildCond.wait(Lock, [, RequestRebuildCounter]() {
+return !File.RebuildInProgress ||
+   File.RebuildCounter != RequestRebuildCounter;
+  });
 
   WasCancelledBeforeConstruction = File.RebuildCounter != RequestRebuildCounter;
   if (WasCancelledBeforeConstruction)
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -233,6 +233,13 @@
   std::string dumpAST(PathRef File);
 
 private:
+  std::future
+  scheduleReparseAndDiags(PathRef File, VersionedDraft Contents,
+  std::shared_ptr Resources,
+  Tagged TaggedFS);
+
+  std::future scheduleCancelRebuild(std::shared_ptr Resources);
+
   GlobalCompilationDatabase 
   DiagnosticsConsumer 
   FileSystemProvider 
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -143,61 +143,14 @@
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
   std::shared_ptr Resources =
  

[PATCH] D36390: Fix overloaded static functions in SemaCodeComplete

2017-08-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

I've just found a regression in my change.
in case I have
std::string(/*complete here*/)

I need to investigate that case because I thought it's covered by 
!isa(FD) ...


https://reviews.llvm.org/D36390



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


[PATCH] D36390: Fix overloaded static functions in SemaCodeComplete

2017-08-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 109980.
yvvan added a comment.

Yes, I missed to include one file in this diff where it's used


https://reviews.llvm.org/D36390

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCodeComplete.cpp
  lib/Sema/SemaOverload.cpp
  test/Index/complete-call.cpp

Index: test/Index/complete-call.cpp
===
--- test/Index/complete-call.cpp
+++ test/Index/complete-call.cpp
@@ -94,6 +94,17 @@
   s.foo_7(42,);
 }
 
+struct Bar {
+  static void foo_1();
+  static void foo_1(int);
+};
+
+void test() {
+  Bar::foo_1();
+  Bar b;
+  b.foo_1();
+}
+
 // RUN: c-index-test -code-completion-at=%s:47:9 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1)
 // CHECK-CC1: Completion contexts:
@@ -803,3 +814,29 @@
 // CHECK-CC59-NEXT: Class name
 // CHECK-CC59-NEXT: Nested name specifier
 // CHECK-CC59-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:103:14 %s | FileCheck -check-prefix=CHECK-CC60 %s
+// CHECK-CC60: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1)
+// CHECK-CC60: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC60: Completion contexts:
+// CHECK-CC60-NEXT: Any type
+// CHECK-CC60-NEXT: Any value
+// CHECK-CC60-NEXT: Enum tag
+// CHECK-CC60-NEXT: Union tag
+// CHECK-CC60-NEXT: Struct tag
+// CHECK-CC60-NEXT: Class name
+// CHECK-CC60-NEXT: Nested name specifier
+// CHECK-CC60-NEXT: Objective-C interface
+
+// RUN: c-index-test -code-completion-at=%s:105:11 %s | FileCheck -check-prefix=CHECK-CC61 %s
+// CHECK-CC61: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{RightParen )} (1)
+// CHECK-CC61: OverloadCandidate:{ResultType void}{Text foo_1}{LeftParen (}{CurrentParameter int}{RightParen )} (1)
+// CHECK-CC61: Completion contexts:
+// CHECK-CC61-NEXT: Any type
+// CHECK-CC61-NEXT: Any value
+// CHECK-CC61-NEXT: Enum tag
+// CHECK-CC61-NEXT: Union tag
+// CHECK-CC61-NEXT: Struct tag
+// CHECK-CC61-NEXT: Class name
+// CHECK-CC61-NEXT: Nested name specifier
+// CHECK-CC61-NEXT: Objective-C interface
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -5868,6 +5868,7 @@
   // function, e.g., X::f(). We use an empty type for the implied
   // object argument (C++ [over.call.func]p3), and the acting context
   // is irrelevant.
+
   AddMethodCandidate(Method, FoundDecl, Method->getParent(), QualType(),
  Expr::Classification::makeSimpleLValue(), Args,
  CandidateSet, SuppressUserConversions,
@@ -6317,7 +6318,8 @@
  OverloadCandidateSet& CandidateSet,
  TemplateArgumentListInfo *ExplicitTemplateArgs,
  bool SuppressUserConversions,
- bool PartialOverloading) {
+ bool PartialOverloading,
+ bool ExtraFirstArgument) {
   for (UnresolvedSetIterator F = Fns.begin(), E = Fns.end(); F != E; ++F) {
 NamedDecl *D = F.getDecl()->getUnderlyingDecl();
 if (FunctionDecl *FD = dyn_cast(D)) {
@@ -6334,6 +6336,11 @@
ObjectClassification, Args.slice(1), CandidateSet,
SuppressUserConversions, PartialOverloading);
   } else {
+// Slice the first argument when we access static method as non-static
+if (Args.size() > 0 && ExtraFirstArgument && isa(FD)
+&& !isa(FD)) {
+  Args = Args.slice(1);
+}
 AddOverloadCandidate(FD, F.getPair(), Args, CandidateSet,
  SuppressUserConversions, PartialOverloading);
   }
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -4379,9 +4379,11 @@
 ArgExprs.append(Args.begin(), Args.end());
 UnresolvedSet<8> Decls;
 Decls.append(UME->decls_begin(), UME->decls_end());
+const bool extraArgument = !UME->isImplicitAccess() && UME->getBase();
 AddFunctionCandidates(Decls, ArgExprs, CandidateSet, TemplateArgs,
   /*SuppressUsedConversions=*/false,
-  /*PartialOverloading=*/true);
+  /*PartialOverloading=*/true,
+  extraArgument);
   } else {
 FunctionDecl *FD = nullptr;
 if (auto MCE = dyn_cast(NakedFn))
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -2677,7 +2677,8 @@
   OverloadCandidateSet ,
   

[PATCH] D36187: [clang-diff] Use the relative name for NamedDecls

2017-08-07 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added a comment.

There's some similar code in tools/clang/lib/Tooling/Core/Lookup.cpp, it might 
make sense to share it. Otherwise this looks good.




Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:391
+  if (!ContextPrefix.empty() &&
+  Val.substr(0, ContextPrefix.size()) == ContextPrefix)
+Val = Val.substr(ContextPrefix.size() + 1);

Val.startswith(ContextPrefix)


https://reviews.llvm.org/D36187



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


[PATCH] D36390: Fix overloaded static functions in SemaCodeComplete

2017-08-07 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added inline comments.



Comment at: include/clang/Sema/Sema.h:2681
+  bool PartialOverloading = false,
+  bool ExtraFirstArgument = false);
   void AddMethodCandidate(DeclAccessPair FoundDecl,

Shouldn't this be called with the new argument somehere? Otherwise it'll always 
be false.


https://reviews.llvm.org/D36390



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


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 109968.
yvvan added a comment.

Add unit-test for the case fixed in this review


https://reviews.llvm.org/D35355

Files:
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseTemplate.cpp
  test/Index/code-completion.cpp


Index: test/Index/code-completion.cpp
===
--- test/Index/code-completion.cpp
+++ test/Index/code-completion.cpp
@@ -37,6 +37,16 @@
   return 0;
 }
 
+template 
+struct Foo { T member; };
+
+template using Bar = Foo;
+
+void test_template_alias() {
+  // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s
+
+}
+
 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
@@ -88,3 +98,5 @@
 // CHECK-EXPR-NEXT: Class name
 // CHECK-EXPR-NEXT: Nested name specifier
 // CHECK-EXPR-NEXT: Objective-C interface
+
+// CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle 
<}{Placeholder typename T}{RightAngle >} (50)
Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -198,9 +198,11 @@
 
   if (Tok.is(tok::kw_using)) {
 // FIXME: We should return the DeclGroup to the caller.
-ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
- prefixAttrs);
-return nullptr;
+auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, 
TemplateInfo, DeclEnd,
+ prefixAttrs);
+if (!usingDeclPtr)
+  return nullptr;
+return usingDeclPtr.get().getSingleDecl();
   }
 
   // Parse the declaration specifiers, stealing any diagnostics from
@@ -1023,8 +1025,8 @@
 ? OO_None
 : TemplateName.OperatorFunctionId.Operator;
 
-TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
-  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
+TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
+  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
   LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds);
 
 Tok.setAnnotationValue(TemplateId);
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -243,7 +243,8 @@
   
   uint64_t Contexts = 0;
   if (isa(ND) || isa(ND) || 
-  isa(ND) || isa(ND)) {
+  isa(ND) || isa(ND) ||
+  isa(ND)) {
 // Types can appear in these contexts.
 if (LangOpts.CPlusPlus || !isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_TopLevel)


Index: test/Index/code-completion.cpp
===
--- test/Index/code-completion.cpp
+++ test/Index/code-completion.cpp
@@ -37,6 +37,16 @@
   return 0;
 }
 
+template 
+struct Foo { T member; };
+
+template using Bar = Foo;
+
+void test_template_alias() {
+  // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s
+
+}
+
 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
@@ -88,3 +98,5 @@
 // CHECK-EXPR-NEXT: Class name
 // CHECK-EXPR-NEXT: Nested name specifier
 // CHECK-EXPR-NEXT: Objective-C interface
+
+// CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -198,9 +198,11 @@
 
   if (Tok.is(tok::kw_using)) {
 // FIXME: We should return the DeclGroup to the caller.
-ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
- prefixAttrs);
-return nullptr;
+auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
+ prefixAttrs);
+if (!usingDeclPtr)
+  return nullptr;
+return usingDeclPtr.get().getSingleDecl();
   }
 
   // Parse the declaration specifiers, stealing any diagnostics from
@@ -1023,8 +1025,8 @@
 ? OO_None
 : TemplateName.OperatorFunctionId.Operator;
 
-TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
-  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
+TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
+  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
 

r310245 - Enable LLVM asan support for NetBSD/i386

2017-08-07 Thread Kamil Rytarowski via cfe-commits
Author: kamil
Date: Mon Aug  7 03:57:03 2017
New Revision: 310245

URL: http://llvm.org/viewvc/llvm-project?rev=310245=rev
Log:
Enable LLVM asan support for NetBSD/i386

Summary:
Verified to work and useful to run check-asan, as this target tests 32-bit and 
64-bit execution.

Sponsored by 

Reviewers: joerg, filcab, dim, vitalybuka

Reviewed By: vitalybuka

Subscribers: #sanitizers, cfe-commits

Tags: #sanitizers

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

Modified:
cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp?rev=310245=310244=310245=diff
==
--- cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp Mon Aug  7 03:57:03 2017
@@ -417,9 +417,10 @@ void NetBSD::addLibStdCxxIncludePaths(co
 }
 
 SanitizerMask NetBSD::getSupportedSanitizers() const {
+  const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
-  if (IsX86_64) {
+  if (IsX86 || IsX86_64) {
 Res |= SanitizerKind::Address;
   }
   return Res;


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


[PATCH] D36327: [OpenCL] Allow targets emit optimized pipe functions for power of 2 type sizes

2017-08-07 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

Hi Sam,

What do you think about implementing this optimization in target specific 
optimization pass? Since size/alignment is saved as function parameter in LLVM 
IR, the optimization can be done in target specific components w/o adding 
additional conditions to generic library.

Thanks,
Alexey


https://reviews.llvm.org/D36327



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


  1   2   >