[PATCH] D36555: Move x86-specific sources to x86-specific source lists.

2017-08-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny requested changes to this revision.
mgorny added a comment.
This revision now requires changes to proceed.

Also, I think that if you're splitting them up, it'd also logical to move them 
into a subdirectory, `x86-common` maybe.




Comment at: compiler-rt/lib/builtins/CMakeLists.txt:223
+  cpu_model.c
+  divxc3.c
+  fixxfdi.c

This and the following files have only:

```
#if !_ARCH_PPC
```

so I suppose it's currently included on more targets than x86. If it's really 
not useful there, I think it'd be better to update the `#if`s first (and 
preferably get the author to review).


https://reviews.llvm.org/D36555



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


[PATCH] D35137: [Driver] Honor -isysroot for Linux targets

2017-08-11 Thread Yen Chi Hsuan via Phabricator via cfe-commits
yan12125 added a comment.

Bump. Anything missing on this patch?


Repository:
  rL LLVM

https://reviews.llvm.org/D35137



___
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-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Could you just implement this in SimplifyLibCalls?  I assume there's some way 
to fill in TargetLibraryInfo appropriately for a platform.  Is that too late 
for your linking requirements?


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] D36642: [Lexer] Report more precise skipped regions (PR34166)

2017-08-11 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.

This patch teaches the preprocessor to report more precise source ranges for 
code that is skipped due to conditional directives.

The new behavior includes the '#' from the opening directive and the full text 
of the line containing the closing directive in the skipped area. This matches 
up clang's behavior (we don't IRGen the code between the closing "endif" and 
the end of a line).

This also affects the code coverage implementation. See llvm.org/PR34166 (this 
also happens to be rdar://problem/23224058).


https://reviews.llvm.org/D36642

Files:
  lib/Lex/PPDirectives.cpp
  test/CoverageMapping/preprocessor.c
  test/Index/skipped-ranges.c


Index: test/Index/skipped-ranges.c
===
--- test/Index/skipped-ranges.c
+++ test/Index/skipped-ranges.c
@@ -20,6 +20,6 @@
 #endif // cool
 
 // RUN: env CINDEXTEST_SHOW_SKIPPED_RANGES=1 c-index-test 
-test-annotate-tokens=%s:1:1:16:1 %s | FileCheck %s
-// CHECK: Skipping: [5:2 - 6:7]
-// CHECK: Skipping: [8:2 - 12:7]
-// CHECK: Skipping: [14:2 - 20:7]
+// CHECK: Skipping: [5:1 - 6:22]
+// CHECK: Skipping: [8:1 - 12:27]
+// CHECK: Skipping: [14:1 - 20:15]
Index: test/CoverageMapping/preprocessor.c
===
--- test/CoverageMapping/preprocessor.c
+++ test/CoverageMapping/preprocessor.c
@@ -3,7 +3,7 @@
  // CHECK: func
 void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
   int i = 0;
-#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+2]]:2 = 0
+#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0
   int x = i;
 #endif
 }
@@ -17,18 +17,18 @@
  // CHECK: main
 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
   int i = 0;
-#if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+4]]:2 = 0
+#  if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> 
[[@LINE+4]]:29 = 0
   if(i == 0) {
 i = 1;
   }
-#endif
+#  endif // Mark me skipped!
 
 #if 1
  // CHECK-NEXT: File 0, [[@LINE+1]]:6 -> [[@LINE+1]]:12 = #0
   if(i == 0) {   // CHECK-NEXT: File 0, [[@LINE]]:14 -> [[@LINE+2]]:4 = #1
 i = 1;
   }
-#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+5]]:2 = 0
+#else// CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+5]]:7 = 0
   if(i == 1) {
 i = 0;
   }
Index: lib/Lex/PPDirectives.cpp
===
--- lib/Lex/PPDirectives.cpp
+++ lib/Lex/PPDirectives.cpp
@@ -559,8 +559,28 @@
   CurPPLexer->LexingRawMode = false;
 
   if (Callbacks) {
+const auto &SM = getSourceManager();
 SourceLocation BeginLoc = ElseLoc.isValid() ? ElseLoc : IfTokenLoc;
-Callbacks->SourceRangeSkipped(SourceRange(BeginLoc, Tok.getLocation()));
+
+// The begin loc tells us the start location of the directive, but we want
+// to include the hash ('#') at the start of the line.
+SourceLocation HashBeginLoc =
+BeginLoc.getLocWithOffset(-SM.getSpellingColumnNumber(BeginLoc) + 1);
+
+// We also want to skip the entire line containing the closing directive.
+const char *TokStart = SM.getCharacterData(Tok.getLocation());
+const char *EndOfLine = TokStart;
+while (true) {
+  char C = *EndOfLine;
+  // We'll warn about reaching the end of file later.
+  if (C == '\0' || C == '\r' || C == '\n')
+break;
+  ++EndOfLine;
+}
+SourceLocation DirectiveEndLoc =
+Tok.getLocation().getLocWithOffset(EndOfLine - TokStart);
+
+Callbacks->SourceRangeSkipped(SourceRange(HashBeginLoc, DirectiveEndLoc));
   }
 }
 


Index: test/Index/skipped-ranges.c
===
--- test/Index/skipped-ranges.c
+++ test/Index/skipped-ranges.c
@@ -20,6 +20,6 @@
 #endif // cool
 
 // RUN: env CINDEXTEST_SHOW_SKIPPED_RANGES=1 c-index-test -test-annotate-tokens=%s:1:1:16:1 %s | FileCheck %s
-// CHECK: Skipping: [5:2 - 6:7]
-// CHECK: Skipping: [8:2 - 12:7]
-// CHECK: Skipping: [14:2 - 20:7]
+// CHECK: Skipping: [5:1 - 6:22]
+// CHECK: Skipping: [8:1 - 12:27]
+// CHECK: Skipping: [14:1 - 20:15]
Index: test/CoverageMapping/preprocessor.c
===
--- test/CoverageMapping/preprocessor.c
+++ test/CoverageMapping/preprocessor.c
@@ -3,7 +3,7 @@
  // CHECK: func
 void func() {// CHECK: File 0, [[@LINE]]:13 -> [[@LINE+5]]:2 = #0
   int i = 0;
-#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+2]]:2 = 0
+#ifdef MACRO // CHECK-NEXT: Skipped,File 0, [[@LINE]]:1 -> [[@LINE+2]]:7 = 0
   int x = i;
 #endif
 }
@@ -17,18 +17,18 @@
  // CHECK: main
 int main() { // CHECK-NEXT: File 0, [[@LINE]]:12 -> {{[0-9]+}}:2 = #0
   int i = 0;
-#if 0// CHECK-NEXT: Skipped,File 0, [[@LINE]]:2 -> [[@LINE+4

[PATCH] D36641: [index] Update indexing to handle CXXDeductionGuideDecls properly

2017-08-11 Thread Nathan Hawes via Phabricator via cfe-commits
nathawes created this revision.

CXXDeductionGuideDecls can't be referenced so there's no need to output a 
symbol occurrence for them. Also handle DeducedTemplateSpecializationTypeLocs 
in the TypeIndexer so we don't miss the symbol occurrences of the corresponding 
template decls.


https://reviews.llvm.org/D36641

Files:
  lib/Index/IndexDecl.cpp
  lib/Index/IndexTypeSourceInfo.cpp
  lib/Index/IndexingContext.cpp
  test/Index/Core/index-source.cpp


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -497,6 +497,19 @@
 
 }
 
+template
+struct Guided { T t; };
+// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Def | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t | 
 | Def,RelChild | rel: 1
+// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
+Guided(double) -> Guided;
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Ref | rel: 0
+auto guided = Guided{1.0};
+// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | 
rel: 0
+// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | 
 | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | guided | c:@guided
+
 namespace rd33122110 {
 
 struct Outer {
Index: lib/Index/IndexingContext.cpp
===
--- lib/Index/IndexingContext.cpp
+++ lib/Index/IndexingContext.cpp
@@ -231,8 +231,8 @@
 
 /// Whether the given NamedDecl should be skipped because it has no name.
 static bool shouldSkipNamelessDecl(const NamedDecl *ND) {
-  return ND->getDeclName().isEmpty() && !isa(ND) &&
- !isa(ND);
+  return (ND->getDeclName().isEmpty() && !isa(ND) &&
+  !isa(ND)) || isa(ND);
 }
 
 static const Decl *adjustParent(const Decl *Parent) {
Index: lib/Index/IndexTypeSourceInfo.cpp
===
--- lib/Index/IndexTypeSourceInfo.cpp
+++ lib/Index/IndexTypeSourceInfo.cpp
@@ -126,8 +126,9 @@
 return true;
   }
 
-  bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
-if (const TemplateSpecializationType *T = TL.getTypePtr()) {
+  template
+  bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
+if (const auto *T = TL.getTypePtr()) {
   if (IndexCtx.shouldIndexImplicitTemplateInsts()) {
 if (CXXRecordDecl *RD = T->getAsCXXRecordDecl())
   IndexCtx.handleReference(RD, TL.getTemplateNameLoc(),
@@ -141,6 +142,14 @@
 return true;
   }
 
+  bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
+return HandleTemplateSpecializationTypeLoc(TL);
+  }
+
+  bool 
VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc 
TL) {
+return HandleTemplateSpecializationTypeLoc(TL);
+  }
+
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
 const DependentNameType *DNT = TL.getTypePtr();
 const NestedNameSpecifier *NNS = DNT->getQualifier();
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -267,6 +267,10 @@
  TypeNameInfo->getTypeLoc().getLocStart(),
  Dtor->getParent(), Dtor->getDeclContext());
   }
+} else if (const auto *Guide = dyn_cast(D)) {
+  IndexCtx.handleReference(Guide->getDeducedTemplate()->getTemplatedDecl(),
+   Guide->getLocation(), Guide,
+   Guide->getDeclContext());
 }
 // Template specialization arguments.
 if (const ASTTemplateArgumentListInfo *TemplateArgInfo =


Index: test/Index/Core/index-source.cpp
===
--- test/Index/Core/index-source.cpp
+++ test/Index/Core/index-source.cpp
@@ -497,6 +497,19 @@
 
 }
 
+template
+struct Guided { T t; };
+// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Def | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t |  | Def,RelChild | rel: 1
+// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided
+Guided(double) -> Guided;
+// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref | rel: 0
+auto guided = Guided{1.0};
+// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0
+// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided |  | Ref,RelCont | rel: 1
+// CHECK-NEXT: RelCont | guided | c:@guided
+
 namespace rd33122110 {
 
 struct Outer {
Index: lib/Index/IndexingContext.cpp
===

Re: r310776 - PR34163: Don't cache an incorrect key function for a class if queried between

2017-08-11 Thread Richard Smith via cfe-commits
Hi Hans,

I'd like to get this into Clang 5, but it's not entirely risk-free. Perhaps
we could leave it in the tree for a little while and then merge if it seems
OK?

On 11 August 2017 at 18:46, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Fri Aug 11 18:46:03 2017
> New Revision: 310776
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310776&view=rev
> Log:
> PR34163: Don't cache an incorrect key function for a class if queried
> between
> the class becoming complete and its inline methods being parsed.
>
> This replaces the hack of using the "late parsed template" flag to track
> member
> functions with bodies we've not parsed yet; instead we now use the "will
> have
> body" flag, which carries the desired implication that the function
> declaration
> *is* a definition, and that we've just not parsed its body yet.
>
> Added:
> cfe/trunk/test/CodeGenCXX/pr34163.cpp
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/test/SemaCUDA/function-overload.cu
> cfe/trunk/test/SemaCUDA/no-destructor-overload.cu
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Decl.h?rev=310776&r1=310775&r2=310776&view=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Fri Aug 11 18:46:03 2017
> @@ -1666,8 +1666,7 @@ private:
>unsigned HasSkippedBody : 1;
>
>/// Indicates if the function declaration will have a body, once we're
> done
> -  /// parsing it.  (We don't set it to false when we're done parsing, in
> the
> -  /// hopes this is simpler.)
> +  /// parsing it.
>unsigned WillHaveBody : 1;
>
>/// \brief End part of this FunctionDecl's source range.
>
> Modified: cfe/trunk/lib/AST/DeclCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> DeclCXX.cpp?rev=310776&r1=310775&r2=310776&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/DeclCXX.cpp (original)
> +++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Aug 11 18:46:03 2017
> @@ -1837,9 +1837,10 @@ bool CXXMethodDecl::hasInlineBody() cons
>const FunctionDecl *CheckFn = getTemplateInstantiationPattern();
>if (!CheckFn)
>  CheckFn = this;
> -
> +
>const FunctionDecl *fn;
> -  return CheckFn->hasBody(fn) && !fn->isOutOfLine();
> +  return CheckFn->isDefined(fn) && !fn->isOutOfLine() &&
> + (fn->doesThisDeclarationHaveABody() || fn->willHaveBody());
>  }
>
>  bool CXXMethodDecl::isLambdaStaticInvoker() const {
>
> Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/
> ParseCXXInlineMethods.cpp?rev=310776&r1=310775&r2=310776&view=diff
> 
> ==
> --- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Fri Aug 11 18:46:03 2017
> @@ -166,20 +166,11 @@ NamedDecl *Parser::ParseCXXInlineMethodD
>}
>
>if (FnD) {
> -// If this is a friend function, mark that it's late-parsed so that
> -// it's still known to be a definition even before we attach the
> -// parsed body.  Sema needs to treat friend function definitions
> -// differently during template instantiation, and it's possible for
> -// the containing class to be instantiated before all its member
> -// function definitions are parsed.
> -//
> -// If you remove this, you can remove the code that clears the flag
> -// after parsing the member.
> -if (D.getDeclSpec().isFriendSpecified()) {
> -  FunctionDecl *FD = FnD->getAsFunction();
> -  Actions.CheckForFunctionRedefinition(FD);
> -  FD->setLateTemplateParsed(true);
> -}
> +FunctionDecl *FD = FnD->getAsFunction();
> +// Track that this function will eventually have a body; Sema needs
> +// to know this.
> +Actions.CheckForFunctionRedefinition(FD);
> +FD->setWillHaveBody(true);
>} else {
>  // If semantic analysis could not build a function declaration,
>  // just throw away the late-parsed declaration.
> @@ -559,10 +550,6 @@ void Parser::ParseLexedMethodDef(LexedMe
>
>ParseFunctionStatementBody(LM.D, FnScope);
>
> -  // Clear the late-template-parsed bit if we set it before.
> -  if (LM.D)
> -LM.D->getAsFunction()->setLateTemplateParsed(false);
> -
>while (Tok.isNot(tok::eof))
>  ConsumeAnyToken();
>
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDecl.cpp?rev=310776&r1=310775&r2=310776&view=diff
> ===

r310776 - PR34163: Don't cache an incorrect key function for a class if queried between

2017-08-11 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Aug 11 18:46:03 2017
New Revision: 310776

URL: http://llvm.org/viewvc/llvm-project?rev=310776&view=rev
Log:
PR34163: Don't cache an incorrect key function for a class if queried between
the class becoming complete and its inline methods being parsed.

This replaces the hack of using the "late parsed template" flag to track member
functions with bodies we've not parsed yet; instead we now use the "will have
body" flag, which carries the desired implication that the function declaration
*is* a definition, and that we've just not parsed its body yet.

Added:
cfe/trunk/test/CodeGenCXX/pr34163.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCUDA/function-overload.cu
cfe/trunk/test/SemaCUDA/no-destructor-overload.cu

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=310776&r1=310775&r2=310776&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Aug 11 18:46:03 2017
@@ -1666,8 +1666,7 @@ private:
   unsigned HasSkippedBody : 1;
 
   /// Indicates if the function declaration will have a body, once we're done
-  /// parsing it.  (We don't set it to false when we're done parsing, in the
-  /// hopes this is simpler.)
+  /// parsing it.
   unsigned WillHaveBody : 1;
 
   /// \brief End part of this FunctionDecl's source range.

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=310776&r1=310775&r2=310776&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri Aug 11 18:46:03 2017
@@ -1837,9 +1837,10 @@ bool CXXMethodDecl::hasInlineBody() cons
   const FunctionDecl *CheckFn = getTemplateInstantiationPattern();
   if (!CheckFn)
 CheckFn = this;
-  
+
   const FunctionDecl *fn;
-  return CheckFn->hasBody(fn) && !fn->isOutOfLine();
+  return CheckFn->isDefined(fn) && !fn->isOutOfLine() &&
+ (fn->doesThisDeclarationHaveABody() || fn->willHaveBody());
 }
 
 bool CXXMethodDecl::isLambdaStaticInvoker() const {

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=310776&r1=310775&r2=310776&view=diff
==
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Fri Aug 11 18:46:03 2017
@@ -166,20 +166,11 @@ NamedDecl *Parser::ParseCXXInlineMethodD
   }
 
   if (FnD) {
-// If this is a friend function, mark that it's late-parsed so that
-// it's still known to be a definition even before we attach the
-// parsed body.  Sema needs to treat friend function definitions
-// differently during template instantiation, and it's possible for
-// the containing class to be instantiated before all its member
-// function definitions are parsed.
-//
-// If you remove this, you can remove the code that clears the flag
-// after parsing the member.
-if (D.getDeclSpec().isFriendSpecified()) {
-  FunctionDecl *FD = FnD->getAsFunction();
-  Actions.CheckForFunctionRedefinition(FD);
-  FD->setLateTemplateParsed(true);
-}
+FunctionDecl *FD = FnD->getAsFunction();
+// Track that this function will eventually have a body; Sema needs
+// to know this.
+Actions.CheckForFunctionRedefinition(FD);
+FD->setWillHaveBody(true);
   } else {
 // If semantic analysis could not build a function declaration,
 // just throw away the late-parsed declaration.
@@ -559,10 +550,6 @@ void Parser::ParseLexedMethodDef(LexedMe
 
   ParseFunctionStatementBody(LM.D, FnScope);
 
-  // Clear the late-template-parsed bit if we set it before.
-  if (LM.D)
-LM.D->getAsFunction()->setLateTemplateParsed(false);
-
   while (Tok.isNot(tok::eof))
 ConsumeAnyToken();
 

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=310776&r1=310775&r2=310776&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 11 18:46:03 2017
@@ -12090,8 +12090,9 @@ Decl *Sema::ActOnStartOfFunctionDef(Scop
 FD->setInvalidDecl();
   }
 
-  // See if this is a redefinition.
-  if (!FD->isLateTemplateParsed()) {
+  // See if this is a redefinition. If 'will have body' is already set, then
+  // these checks were already performed when it was set.
+  if (!FD->willHaveBody() && !FD->isL

Re: r310605 - [Modules] Prevent #import to reenter header if not building a module.

2017-08-11 Thread Bruno Cardoso Lopes via cfe-commits
On Fri, Aug 11, 2017 at 9:27 PM, Richard Smith  wrote:
> On 11 August 2017 at 16:51, Bruno Cardoso Lopes via cfe-commits
>  wrote:
>>
>> On Thu, Aug 10, 2017 at 5:36 PM, Richard Smith 
>> wrote:
>> > On 10 August 2017 at 10:42, Hans Wennborg via cfe-commits
>> >  wrote:
>> >>
>> >> Sounds good to me.
>> >>
>> >> Richard, what do you think?
>> >>
>> >> On Thu, Aug 10, 2017 at 9:38 AM, Bruno Cardoso Lopes
>> >>  wrote:
>> >> > Hi Hans, can we please get this merged into 5.0?
>> >> >
>> >> > Thanks,
>> >> >
>> >> > On Thu, Aug 10, 2017 at 12:16 PM, Bruno Cardoso Lopes via cfe-commits
>> >> >  wrote:
>> >> >> Author: bruno
>> >> >> Date: Thu Aug 10 08:16:24 2017
>> >> >> New Revision: 310605
>> >> >>
>> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=310605&view=rev
>> >> >> Log:
>> >> >> [Modules] Prevent #import to reenter header if not building a
>> >> >> module.
>> >> >>
>> >> >> When non-modular headers are imported while not building a module
>> >> >> but
>> >> >> in -fmodules mode, be conservative and preserve the default #import
>> >> >> semantic: do not reenter headers.
>> >
>> >
>> > This comment doesn't appear to describe what this patch does: even when
>> > building a module it does not re-enter headers except for ones declared
>> > 'textual header' within the module being built. (isCompilingModuleHeader
>> > doesn't mean "are we compiling a module header right now?", it means "is
>> > this file declared as some kind of header within the current
>> > CompilingModule?".)
>>
>> What I'm trying to achieve here is: do not try to enter headers that
>> are not described as part of any module (textual) unless while
>> building a module. AFAIU, FileInfo.isCompilingModuleHeader is
>> basically LangOpts.isCompilingModule() && Mod->getTopLevelModule() ==
>> SourceModule, shouldn't it account for a more restrictive way to say
>> "are we compiling a textual header while building a module"?
>
>
> The "more restrictive" part is the problem: this also changes the behavior
> when we *are* building a module. Consider:
>
> // once.h
> #ifndef ONCE_H
> #define ONCE_H
> #pragma once
> extern int once;
> #endif
>
> // a.h
> #include "once.h"
>
> // b.h
> #include "once.h"
>
> // module.map
> module X { module A { header "a.h" } module B { header "b.h" } }
>
> This change appears to break the above module (when built with local
> submodule visibility enabled): module X.B no longer includes "once.h" and so
> no longer exports the "once" variable.

Nice testcase. I'll add it soon.

>> Checking for FileInfo.isCompilingModuleHeader has the additional
>> advantage that it would track previous attempts to import that header
>> while building a module, in which case it's going to try to re-enter.
>> It won't try to re-enter only in cases where that header was never
>> imported while building a header -> the same behavior #import has
>> without modules.
>>
>> Prior to r291644, clang would always avoid to re-enter a header. After
>> r291644 clang has a relaxed version of that, which I now proposing to
>> be less relaxed for #imports.
>>
>> > I'm nervous about taking this change: it will presumably break some
>> > cases
>> > (particularly with local submodule visibility enabled) where a #pragma
>> > once
>> > header is #included into multiple headers in the same module, by
>> > refusing to
>> > re-enter such headers -- and it will fix other such cases, depending on
>> > what
>> > exactly the header does and the structure of the module.
>>
>> I'd be interested in a such testcase to make sure we don't regress here!
>>
>> > If this were restricted to the case where we're not building a module
>> > (!LangOpts.isCompilingModule()), then I'd be OK putting it on the
>> > branch.
>>
>> Ok. It might not be a good idea to have this in 5.0 anyway, better
>> bake this for a while. But thinking forward, am I missing something
>> here? What about:
>>
>> if ((LangOpts.isCompilingModule() || !isImport) &&
>> !FileInfo.isModuleHeader &&
>> FileInfo.getControllingMacro(ExternalLookup))
>>   TryEnterHdr = true;
>
>
> I think perhaps what we want is this:
>
> if (FileInfo.getControllingMacro(ExternalLookup) &&
> FileInfo.DefinesControllingMacro)
>   TryEnterHdr = true;
>
> ... where DefinesControllingMacro is set to false if we ever included the
> header and found that it did not actually define its controlling macro (as
> happens in the testcase for your patch).
>
> Justification: we have no idea if the file has actually already been
> included in our current preprocessing context if we're compiling a module.
> If the file *also* has an include guard that it defines, we should just use
> the include guard logic to figure out whether it has been or needs to be
> included, since it handles module visibility issues correctly. (I think the
> only case where this is going to go wrong is if someone #imports the header,
> then #undef's the include guard macro and #imports the header again, but
> that seems like a fringe case.)

I see, that would sol

r310775 - Revert "[Modules] Prevent #import to reenter header if not building a module."

2017-08-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Aug 11 18:38:26 2017
New Revision: 310775

URL: http://llvm.org/viewvc/llvm-project?rev=310775&view=rev
Log:
Revert "[Modules] Prevent #import to reenter header if not building a module."

This reverts commit r310605. Richard pointed out a better way to achieve
this, which I'll post a patch for soon.

Removed:
cfe/trunk/test/Modules/Inputs/import-textual/x.h
cfe/trunk/test/Modules/import-textual-nomodules.m
Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=310775&r1=310774&r2=310775&view=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Fri Aug 11 18:38:26 2017
@@ -1143,7 +1143,7 @@ bool HeaderSearch::ShouldEnterIncludeFil
 // headers find in the wild might rely only on #import and do not contain
 // controlling macros, be conservative and only try to enter textual 
headers
 // if such macro is present.
-if (FileInfo.isCompilingModuleHeader && !FileInfo.isModuleHeader &&
+if (!FileInfo.isModuleHeader &&
 FileInfo.getControllingMacro(ExternalLookup))
   TryEnterHdr = true;
 return TryEnterHdr;

Removed: cfe/trunk/test/Modules/Inputs/import-textual/x.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/import-textual/x.h?rev=310774&view=auto
==
--- cfe/trunk/test/Modules/Inputs/import-textual/x.h (original)
+++ cfe/trunk/test/Modules/Inputs/import-textual/x.h (removed)
@@ -1,6 +0,0 @@
-#ifndef RANDOM_DEP
-
-@interface X
-@end
-
-#endif // RANDOM_DEP

Removed: cfe/trunk/test/Modules/import-textual-nomodules.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/import-textual-nomodules.m?rev=310774&view=auto
==
--- cfe/trunk/test/Modules/import-textual-nomodules.m (original)
+++ cfe/trunk/test/Modules/import-textual-nomodules.m (removed)
@@ -1,8 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps 
-I%S/Inputs/import-textual -fmodules-cache-path=%t %s -verify
-
-// expected-no-diagnostics
-
-#import "x.h"
-#import "x.h"
-


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


r310774 - Add a Dockerfile for clang-proto-fuzzer

2017-08-11 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Fri Aug 11 18:27:10 2017
New Revision: 310774

URL: http://llvm.org/viewvc/llvm-project?rev=310774&view=rev
Log:
Add a Dockerfile for clang-proto-fuzzer

Summary: Add a Dockerfile for clang-proto-fuzzer

Reviewers: morehouse, vitalybuka

Reviewed By: morehouse

Subscribers: hintonda, cfe-commits

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

Added:
cfe/trunk/tools/clang-fuzzer/Dockerfile
Modified:
cfe/trunk/tools/clang-fuzzer/README.txt

Added: cfe/trunk/tools/clang-fuzzer/Dockerfile
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/Dockerfile?rev=310774&view=auto
==
--- cfe/trunk/tools/clang-fuzzer/Dockerfile (added)
+++ cfe/trunk/tools/clang-fuzzer/Dockerfile Fri Aug 11 18:27:10 2017
@@ -0,0 +1,37 @@
+#===- llvm/tools/clang/tools/clang-fuzzer 
-===//
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===--===//
+# Produces an image that builds clang-proto-fuzzer
+FROM ubuntu:16.04
+RUN apt-get update -y
+RUN apt-get install -y autoconf automake libtool curl make g++ unzip wget git \
+binutils liblzma-dev libz-dev python-all cmake ninja-build subversion \
+pkg-config docbook2x
+
+WORKDIR /root
+
+# Get protobuf
+RUN wget -qO- 
https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz
 | tar zxf -
+RUN cd protobuf-3.3.0 && ./autogen.sh && ./configure && make -j $(nproc) && 
make check -j $(nproc) && make install && ldconfig
+# Get LLVM
+RUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
+RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang 
-r $(cd ../ && svn info | grep Revision | awk '{print $2}')
+RUN cd llvm/projects && svn co 
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt -r $(cd ../ && 
svn info | grep Revision | awk '{print $2}')
+# Build plain LLVM (stage 0)
+RUN mkdir build0 && cd build0 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release 
../llvm && ninja
+# Configure instrumented LLVM (stage 1)
+RUN mkdir build1 && cd build1 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release 
../llvm \
+-DLLVM_ENABLE_ASSERTIONS=ON \
+-DCMAKE_C_COMPILER=`pwd`/../build0/bin/clang \
+-DCMAKE_CXX_COMPILER=`pwd`/../build0/bin/clang++ \
+-DLLVM_USE_SANITIZE_COVERAGE=YES \
+-DLLVM_USE_SANITIZER=Address -DCLANG_ENABLE_PROTO_FUZZER=ON
+# Build the fuzzers
+RUN cd build1 && ninja clang-fuzzer
+RUN cd build1 && ninja clang-proto-fuzzer
+RUN cd build1 && ninja clang-proto-to-cxx

Modified: cfe/trunk/tools/clang-fuzzer/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/README.txt?rev=310774&r1=310773&r2=310774&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/README.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/README.txt Fri Aug 11 18:27:10 2017
@@ -59,6 +59,8 @@ Example:
 -DCLANG_ENABLE_PROTO_FUZZER=ON
   ninja clang-proto-fuzzer clang-proto-to-cxx
 
+This directory also contains a Dockerfile which sets up all required
+dependencies and builds the fuzzers.
 
 =
  Running the fuzzers


___
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-11 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw added a comment.

Daniel's right. We need need substantially more tests!




Comment at: docs/ClangFormatStyleOptions.rst:1199
+  * ``PPDIS_AfterHash`` (in configuration: ``AfterHash``)
+Indents directives after the hash, counting the hash as a column.
+

delete outdated bit of description: ", counting the hash as a column"



Comment at: include/clang/Format/Format.h:1038
+PPDIS_None,
+/// Indents directives after the hash, counting the hash as a column.
+/// \code

ditto



Comment at: lib/Format/UnwrappedLineParser.cpp:707
 void UnwrappedLineParser::parsePPElse() {
+  // If a potential include guard has a #else, it's not an include guard.
+  if (FoundIncludeGuardStart && PPBranchLevel == 0)

... has an #else ...



Comment at: lib/Format/UnwrappedLineParser.cpp:728
+  if (FoundIncludeGuardStart && PPBranchLevel == -1 && PeekNext->is(tok::eof)) 
{
+for (auto it = Lines.begin(); it != Lines.end(); ++it) {
+  if (it->InPPDirective && it->Level > 0)

You can use a range based for loop here. Also locals begin with upper case:

   for (auto& Line : Lines)  {



Comment at: lib/Format/UnwrappedLineParser.cpp:742-744
+  if (PPMaybeIncludeGuard &&
+  PPMaybeIncludeGuard->TokenText == FormatTok->TokenText &&
+  Lines.size() == 1) {

Lines.size() == 1 is problematic. We must at least support comments before the 
include guard. I'll comment on the tests and point out a couple of important 
cases that currently fail.



Comment at: unittests/Format/FormatTest.cpp:2281
 
 TEST_F(FormatTest, LayoutMacroDefinitionsStatementsSpanningBlocks) {
   verifyFormat("#define A \\\n"

Experimenting with the patch locally I found that comment indentation is broken 
in some cases. Please add tests that cover comments. For example:

comment indented at code level as expected:
  void f() {
  #if 0
// Comment
code();
  #  define FOO 0
  #endif
  }
comment not indented at code level when there's a guard:
  #ifndef _SOMEFILE_H
  #define _SOMEFILE_H
  void f() {
  #if 0
  // Comment
code();
  #  define FOO 0
  #endif
  }
  #endif

The `#define FOO 0` is required to trigger this behavior.



Comment at: unittests/Format/FormatTest.cpp:2322-2331
+  // Test with include guards.
+  EXPECT_EQ("#ifndef _SOMEFILE_H\n"
+"#define _SOMEFILE_H\n"
+"code();\n"
+"#endif",
+format("#ifndef _SOMEFILE_H\n"
+   "#define _SOMEFILE_H\n"

A DRY-er way to say this is:
  auto WithGuard = "#ifndef _SOMEFILE_H\n"
   "#define _SOMEFILE_H\n"
   "code();\n"
   "#endif";
  ASSERT_EQ(WithGuards, format(WithGuards, Style));




Comment at: unittests/Format/FormatTest.cpp:2334
+  // after #ifndef.
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define FOO\n"


It would be nice to have a comment that explains why you cannot use 
verifyFormat.



Comment at: unittests/Format/FormatTest.cpp:2394
+  // previous code line yet, so we can't detect it.
+  EXPECT_NE("#ifndef NOT_GUARD\n"
+"code();\n"

The two "Defect:" cases would be more precise and more self-documenting if they 
used EXPECT_EQ where the "expected" text showed the incorrect results.



Comment at: unittests/Format/FormatTest.cpp:2405-2408
+  // Defect: We currently do not deal with cases where legitimate lines may be
+  // outside an include guard. Examples are #pragma once and
+  // #pragma GCC diagnostic, or anything else that does not change the meaning
+  // of the file if it's included multiple times.

We need to handle comments (like copyrights) before the include guard. There is 
an analogous problem with trailing blank lines, or trailing comments.

I think we need a small state machine: Init, Start, Open, Closed, NotGuard 
(terminal). `FoundIncludeGuardStart` should change from a bool to an enum to 
track this state. `PPMaybeIncludeGuard` can then drop it's "mabye". Whether or 
not it is null depends directly on the state. It does not determine state 
itself. While parsing, each line updates the state. If we get to `eof` in the 
Closed state then we have detected an include guard. ... Or similar logic

Note that support for comments before the guard opens the door to support for 
#pragma once. It is tempting to add that, but that is a slippery slope. I would 
recommend leaving that as a defect that can be addressed later.


https://reviews.llvm.org/D35955



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


Re: r310706 - [modules] Set the lexical DC for dummy tag decls that refer to hidden

2017-08-11 Thread Richard Smith via cfe-commits
On 11 August 2017 at 17:20, Bruno Cardoso Lopes via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Alex,
>
> On Fri, Aug 11, 2017 at 9:06 AM, Alex Lorenz via cfe-commits
>  wrote:
> > Author: arphaman
> > Date: Fri Aug 11 05:06:52 2017
> > New Revision: 310706
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=310706&view=rev
> > Log:
> > [modules] Set the lexical DC for dummy tag decls that refer to hidden
> > declarations that are made visible after the dummy is parsed and ODR
> verified
> >
> > Prior to this commit the
> > "(getContainingDC(DC) == CurContext && "The next DeclContext should be
> lexically contained in the current one."),"
> > assertion failure was triggered during semantic analysis of the dummy
> > tag declaration that was declared in another tag declaration because its
> > lexical context did not point to the outer tag decl.
> >
> > rdar://32292196
> >
> > Added:
> > cfe/trunk/test/Modules/Inputs/innerstructredef.h
> > cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
> > Modified:
> > cfe/trunk/lib/Sema/SemaDecl.cpp
> > cfe/trunk/test/Modules/Inputs/module.map
> >
> > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDecl.cpp?rev=310706&r1=310705&r2=310706&view=diff
> > 
> ==
> > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 11 05:06:52 2017
> > @@ -13722,6 +13722,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
> >// comparison.
> >SkipBody->CheckSameAsPrevious = true;
> >SkipBody->New = createTagFromNewDecl();
> > +  SkipBody->New->setLexicalDeclContext(CurContext);
>
> I think it would be cleaner to do this inside "createTagFromNewDecl" than
> here.


I agree. Either before or after that change, this seems sufficiently
isolated and low-risk that it makes sense to take it for Clang 5.


> >SkipBody->Previous = Hidden;
> >  } else {
> >SkipBody->ShouldSkip = true;
> >
> > Added: cfe/trunk/test/Modules/Inputs/innerstructredef.h
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/
> innerstructredef.h?rev=310706&view=auto
> > 
> ==
> > --- cfe/trunk/test/Modules/Inputs/innerstructredef.h (added)
> > +++ cfe/trunk/test/Modules/Inputs/innerstructredef.h Fri Aug 11
> 05:06:52 2017
> > @@ -0,0 +1,6 @@
> > +struct Outer {
> > +// This definition is actually hidden since only submodule 'one' is
> imported.
> > +struct Inner {
> > +  int x;
> > +} field;
> > +};
> >
> > Modified: cfe/trunk/test/Modules/Inputs/module.map
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/Inputs/module.map?rev=310706&r1=310705&r2=310706&view=diff
> > 
> ==
> > --- cfe/trunk/test/Modules/Inputs/module.map (original)
> > +++ cfe/trunk/test/Modules/Inputs/module.map Fri Aug 11 05:06:52 2017
> > @@ -451,3 +451,12 @@ module DebugNestedB {
> >  module objcAtKeywordMissingEnd {
> >header "objcAtKeywordMissingEnd.h"
> >  }
> > +
> > +module innerstructredef {
> > +  module one {
> > +header "empty.h"
> > +  }
> > +  module two {
> > +   header "innerstructredef.h"
> > +  }
> > +}
> >
> > Added: cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/inner-struct-redefines-invisible.m?rev=310706&view=auto
> > 
> ==
> > --- cfe/trunk/test/Modules/inner-struct-redefines-invisible.m (added)
> > +++ cfe/trunk/test/Modules/inner-struct-redefines-invisible.m Fri Aug
> 11 05:06:52 2017
> > @@ -0,0 +1,12 @@
> > +// RUN: rm -rf %t
> > +// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -fmodules
> -fimplicit-module-maps -fmodules-cache-path=%t -verify %s
> > +// expected-no-diagnostics
> > +
> > +@import innerstructredef.one;
> > +
> > +struct Outer {
> > +// Should set lexical context when parsing 'Inner' here, otherwise
> there's a crash:
> > +struct Inner {
> > +  int x;
> > +} field;
> > +};
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r310605 - [Modules] Prevent #import to reenter header if not building a module.

2017-08-11 Thread Richard Smith via cfe-commits
On 11 August 2017 at 16:51, Bruno Cardoso Lopes via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Thu, Aug 10, 2017 at 5:36 PM, Richard Smith 
> wrote:
> > On 10 August 2017 at 10:42, Hans Wennborg via cfe-commits
> >  wrote:
> >>
> >> Sounds good to me.
> >>
> >> Richard, what do you think?
> >>
> >> On Thu, Aug 10, 2017 at 9:38 AM, Bruno Cardoso Lopes
> >>  wrote:
> >> > Hi Hans, can we please get this merged into 5.0?
> >> >
> >> > Thanks,
> >> >
> >> > On Thu, Aug 10, 2017 at 12:16 PM, Bruno Cardoso Lopes via cfe-commits
> >> >  wrote:
> >> >> Author: bruno
> >> >> Date: Thu Aug 10 08:16:24 2017
> >> >> New Revision: 310605
> >> >>
> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=310605&view=rev
> >> >> Log:
> >> >> [Modules] Prevent #import to reenter header if not building a module.
> >> >>
> >> >> When non-modular headers are imported while not building a module but
> >> >> in -fmodules mode, be conservative and preserve the default #import
> >> >> semantic: do not reenter headers.
> >
> >
> > This comment doesn't appear to describe what this patch does: even when
> > building a module it does not re-enter headers except for ones declared
> > 'textual header' within the module being built. (isCompilingModuleHeader
> > doesn't mean "are we compiling a module header right now?", it means "is
> > this file declared as some kind of header within the current
> > CompilingModule?".)
>
> What I'm trying to achieve here is: do not try to enter headers that
> are not described as part of any module (textual) unless while
> building a module. AFAIU, FileInfo.isCompilingModuleHeader is
> basically LangOpts.isCompilingModule() && Mod->getTopLevelModule() ==
> SourceModule, shouldn't it account for a more restrictive way to say
> "are we compiling a textual header while building a module"?
>

The "more restrictive" part is the problem: this also changes the behavior
when we *are* building a module. Consider:

// once.h
#ifndef ONCE_H
#define ONCE_H
#pragma once
extern int once;
#endif

// a.h
#include "once.h"

// b.h
#include "once.h"

// module.map
module X { module A { header "a.h" } module B { header "b.h" } }

This change appears to break the above module (when built with local
submodule visibility enabled): module X.B no longer includes "once.h" and
so no longer exports the "once" variable.

Checking for FileInfo.isCompilingModuleHeader has the additional
> advantage that it would track previous attempts to import that header
> while building a module, in which case it's going to try to re-enter.
> It won't try to re-enter only in cases where that header was never
> imported while building a header -> the same behavior #import has
> without modules.
>
> Prior to r291644, clang would always avoid to re-enter a header. After
> r291644 clang has a relaxed version of that, which I now proposing to
> be less relaxed for #imports.
>
> > I'm nervous about taking this change: it will presumably break some cases
> > (particularly with local submodule visibility enabled) where a #pragma
> once
> > header is #included into multiple headers in the same module, by
> refusing to
> > re-enter such headers -- and it will fix other such cases, depending on
> what
> > exactly the header does and the structure of the module.
>
> I'd be interested in a such testcase to make sure we don't regress here!
>
> > If this were restricted to the case where we're not building a module
> > (!LangOpts.isCompilingModule()), then I'd be OK putting it on the
> branch.
>
> Ok. It might not be a good idea to have this in 5.0 anyway, better
> bake this for a while. But thinking forward, am I missing something
> here? What about:
>
> if ((LangOpts.isCompilingModule() || !isImport) &&
> !FileInfo.isModuleHeader &&
> FileInfo.getControllingMacro(ExternalLookup))
>   TryEnterHdr = true;


I think perhaps what we want is this:

if (FileInfo.getControllingMacro(ExternalLookup) &&
FileInfo.DefinesControllingMacro)
  TryEnterHdr = true;

... where DefinesControllingMacro is set to false if we ever included the
header and found that it did not actually define its controlling macro (as
happens in the testcase for your patch).

Justification: we have no idea if the file has actually already been
included in our current preprocessing context if we're compiling a module.
If the file *also* has an include guard that it defines, we should just use
the include guard logic to figure out whether it has been or needs to be
included, since it handles module visibility issues correctly. (I think the
only case where this is going to go wrong is if someone #imports the
header, then #undef's the include guard macro and #imports the header
again, but that seems like a fringe case.)

Note that this justification applies any time modules is enabled, not just
when compiling a module. If you merely *load* a .pcm file whose compilation
#imported some header file (without even importing any modules from it),
then we will skip entering it with the current m

Re: r310706 - [modules] Set the lexical DC for dummy tag decls that refer to hidden

2017-08-11 Thread Bruno Cardoso Lopes via cfe-commits
Hi Alex,

On Fri, Aug 11, 2017 at 9:06 AM, Alex Lorenz via cfe-commits
 wrote:
> Author: arphaman
> Date: Fri Aug 11 05:06:52 2017
> New Revision: 310706
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310706&view=rev
> Log:
> [modules] Set the lexical DC for dummy tag decls that refer to hidden
> declarations that are made visible after the dummy is parsed and ODR verified
>
> Prior to this commit the
> "(getContainingDC(DC) == CurContext && "The next DeclContext should be 
> lexically contained in the current one."),"
> assertion failure was triggered during semantic analysis of the dummy
> tag declaration that was declared in another tag declaration because its
> lexical context did not point to the outer tag decl.
>
> rdar://32292196
>
> Added:
> cfe/trunk/test/Modules/Inputs/innerstructredef.h
> cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
> Modified:
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/test/Modules/Inputs/module.map
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=310706&r1=310705&r2=310706&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 11 05:06:52 2017
> @@ -13722,6 +13722,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
>// comparison.
>SkipBody->CheckSameAsPrevious = true;
>SkipBody->New = createTagFromNewDecl();
> +  SkipBody->New->setLexicalDeclContext(CurContext);

I think it would be cleaner to do this inside "createTagFromNewDecl" than here.

>SkipBody->Previous = Hidden;
>  } else {
>SkipBody->ShouldSkip = true;
>
> Added: cfe/trunk/test/Modules/Inputs/innerstructredef.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/innerstructredef.h?rev=310706&view=auto
> ==
> --- cfe/trunk/test/Modules/Inputs/innerstructredef.h (added)
> +++ cfe/trunk/test/Modules/Inputs/innerstructredef.h Fri Aug 11 05:06:52 2017
> @@ -0,0 +1,6 @@
> +struct Outer {
> +// This definition is actually hidden since only submodule 'one' is imported.
> +struct Inner {
> +  int x;
> +} field;
> +};
>
> Modified: cfe/trunk/test/Modules/Inputs/module.map
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=310706&r1=310705&r2=310706&view=diff
> ==
> --- cfe/trunk/test/Modules/Inputs/module.map (original)
> +++ cfe/trunk/test/Modules/Inputs/module.map Fri Aug 11 05:06:52 2017
> @@ -451,3 +451,12 @@ module DebugNestedB {
>  module objcAtKeywordMissingEnd {
>header "objcAtKeywordMissingEnd.h"
>  }
> +
> +module innerstructredef {
> +  module one {
> +header "empty.h"
> +  }
> +  module two {
> +   header "innerstructredef.h"
> +  }
> +}
>
> Added: cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/inner-struct-redefines-invisible.m?rev=310706&view=auto
> ==
> --- cfe/trunk/test/Modules/inner-struct-redefines-invisible.m (added)
> +++ cfe/trunk/test/Modules/inner-struct-redefines-invisible.m Fri Aug 11 
> 05:06:52 2017
> @@ -0,0 +1,12 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -fmodules 
> -fimplicit-module-maps -fmodules-cache-path=%t -verify %s
> +// expected-no-diagnostics
> +
> +@import innerstructredef.one;
> +
> +struct Outer {
> +// Should set lexical context when parsing 'Inner' here, otherwise there's a 
> crash:
> +struct Inner {
> +  int x;
> +} field;
> +};
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGAtomic.cpp:696
+if (S != Default)
+  SI->addCase(Builder.getInt32(static_cast(S)), B);
+

t-tye wrote:
> rjmccall wrote:
> > t-tye wrote:
> > > Is it documented in the SyncScope enum that the enumerator values are in 
> > > fact the values used for source language runtime values? Seems if other 
> > > languages want to use scopes they may may have a different ordering. That 
> > > would imply that there would be a function to map a SyncScope value to 
> > > the value used by the source language. For OpenCL the mapping is identity.
> > > 
> > > The memory ordering has the isValidAtomicOrderingCABI() that does a 
> > > similar thing.
> > The values in the SyncScope enum are the source language values.  We 
> > already have a step to translate them into LLVM values when we generate a 
> > native LLVM construct.  To the extent that we call into a runtime instead, 
> > none of that code has been written to be runtime-agnostic at all, and I've 
> > been assuming that we're basically okay with that, at least for now.
> That sounds reasonable to me. When/if another language comes along the task 
> of mapping the multiple ABIs can be done then. Still wanted to make sure it 
> is clear that the enum values in the SyncScope enum are documented as BEING 
> the OpenCL runtime ABI values and not some arbitrary list as in other enums 
> such as the address space enum. 
They are documented as being the values expected by the builtins, so they 
already can't be arbitrarily changed.

Now, the values expected by the builtin were chosen to match this specific 
runtime, but we had to choose something, and matching a runtime isn't the worst 
way of doing that.  But now that I think about it, those values seem to be 
rather sub-optimal because they don't start at 0, which means that things like 
this switch will be less efficient than they could be.  And I think the AST and 
IRGen would benefit from needing to renumber values; it will make the code 
clearer, and it'll help protect against people adding values to this enum just 
because those values are used by the runtime, i.e. without fully realizing that 
they're expanding a user-facing feature.  So let's go ahead and renumber the 
values in SyncScope to start at 0 and then re-map them in IRGen.


https://reviews.llvm.org/D36580



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


[PATCH] D36635: Add a Dockerfile for clang-proto-fuzzer

2017-08-11 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

> I'd avoid such extra complexity, after all this is just an example.

Understood...  LGTM

> BTW, my old svn (1.8.8, Ubuntu 14.04) does't have "info --show-item revision"

Guess my new macbook pro spoiled me...


https://reviews.llvm.org/D36635



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


Re: r310605 - [Modules] Prevent #import to reenter header if not building a module.

2017-08-11 Thread Bruno Cardoso Lopes via cfe-commits
On Thu, Aug 10, 2017 at 5:36 PM, Richard Smith  wrote:
> On 10 August 2017 at 10:42, Hans Wennborg via cfe-commits
>  wrote:
>>
>> Sounds good to me.
>>
>> Richard, what do you think?
>>
>> On Thu, Aug 10, 2017 at 9:38 AM, Bruno Cardoso Lopes
>>  wrote:
>> > Hi Hans, can we please get this merged into 5.0?
>> >
>> > Thanks,
>> >
>> > On Thu, Aug 10, 2017 at 12:16 PM, Bruno Cardoso Lopes via cfe-commits
>> >  wrote:
>> >> Author: bruno
>> >> Date: Thu Aug 10 08:16:24 2017
>> >> New Revision: 310605
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=310605&view=rev
>> >> Log:
>> >> [Modules] Prevent #import to reenter header if not building a module.
>> >>
>> >> When non-modular headers are imported while not building a module but
>> >> in -fmodules mode, be conservative and preserve the default #import
>> >> semantic: do not reenter headers.
>
>
> This comment doesn't appear to describe what this patch does: even when
> building a module it does not re-enter headers except for ones declared
> 'textual header' within the module being built. (isCompilingModuleHeader
> doesn't mean "are we compiling a module header right now?", it means "is
> this file declared as some kind of header within the current
> CompilingModule?".)

What I'm trying to achieve here is: do not try to enter headers that
are not described as part of any module (textual) unless while
building a module. AFAIU, FileInfo.isCompilingModuleHeader is
basically LangOpts.isCompilingModule() && Mod->getTopLevelModule() ==
SourceModule, shouldn't it account for a more restrictive way to say
"are we compiling a textual header while building a module"?

Checking for FileInfo.isCompilingModuleHeader has the additional
advantage that it would track previous attempts to import that header
while building a module, in which case it's going to try to re-enter.
It won't try to re-enter only in cases where that header was never
imported while building a header -> the same behavior #import has
without modules.

Prior to r291644, clang would always avoid to re-enter a header. After
r291644 clang has a relaxed version of that, which I now proposing to
be less relaxed for #imports.

> I'm nervous about taking this change: it will presumably break some cases
> (particularly with local submodule visibility enabled) where a #pragma once
> header is #included into multiple headers in the same module, by refusing to
> re-enter such headers -- and it will fix other such cases, depending on what
> exactly the header does and the structure of the module.

I'd be interested in a such testcase to make sure we don't regress here!

> If this were restricted to the case where we're not building a module
> (!LangOpts.isCompilingModule()), then I'd be OK putting it on the branch.

Ok. It might not be a good idea to have this in 5.0 anyway, better
bake this for a while. But thinking forward, am I missing something
here? What about:

if ((LangOpts.isCompilingModule() || !isImport) && !FileInfo.isModuleHeader &&
FileInfo.getControllingMacro(ExternalLookup))
  TryEnterHdr = true;

Thanks,

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

In https://reviews.llvm.org/D29660#839728, @alekseyshl wrote:

> In https://reviews.llvm.org/D29660#839550, @alekseyshl wrote:
>
> > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7109 
> > failed on r310718, please fix.
>
>
>
>
> In https://reviews.llvm.org/D29660#839647, @gtbercea wrote:
>
> > In https://reviews.llvm.org/D29660#839550, @alekseyshl wrote:
> >
> > > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7109 
> > > failed on r310718, please fix.
> >
> >
> > Couldn't fix/find the actual error so for now, just moving the flag patch 
> > tests to openmp-offload-gpu.c which is a disabled test.
> >
> > 310765
>
>
> Bad news, the bot is still red: 
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7114


Disabled openmp-offload.c on Linux again: https://reviews.llvm.org/rL310772


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36635: Add a Dockerfile for clang-proto-fuzzer

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

I'd avoid such extra complexity, after all this is just an example. 
One can force the full rebuild with --no-cache. It'll take just a bit more time 
since most of the time is consumed by the compiler builds. 
BTW, my old svn (1.8.8, Ubuntu 14.04) does't have "info --show-item revision"


https://reviews.llvm.org/D36635



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


r310772 - Disabling openmp-offload.c on linux until it is stabilized on all local configurations.

2017-08-11 Thread Alex Shlyapnikov via cfe-commits
Author: alekseyshl
Date: Fri Aug 11 16:10:39 2017
New Revision: 310772

URL: http://llvm.org/viewvc/llvm-project?rev=310772&view=rev
Log:
Disabling openmp-offload.c on linux until it is stabilized on all local 
configurations.

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

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=310772&r1=310771&r2=310772&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload.c (original)
+++ cfe/trunk/test/Driver/openmp-offload.c Fri Aug 11 16:10:39 2017
@@ -2,6 +2,9 @@
 /// Perform several driver tests for OpenMP offloading
 ///
 
+// Until this test is stabilized on all local configurations.
+// UNSUPPORTED: linux
+
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: powerpc-registered-target


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


[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-11 Thread Tony Tye via Phabricator via cfe-commits
t-tye accepted this revision.
t-tye added a comment.
This revision is now accepted and ready to land.

LGTM other than suggested documentation and static_assert/unreachable comments.




Comment at: lib/CodeGen/CGAtomic.cpp:696
+if (S != Default)
+  SI->addCase(Builder.getInt32(static_cast(S)), B);
+

rjmccall wrote:
> t-tye wrote:
> > Is it documented in the SyncScope enum that the enumerator values are in 
> > fact the values used for source language runtime values? Seems if other 
> > languages want to use scopes they may may have a different ordering. That 
> > would imply that there would be a function to map a SyncScope value to the 
> > value used by the source language. For OpenCL the mapping is identity.
> > 
> > The memory ordering has the isValidAtomicOrderingCABI() that does a similar 
> > thing.
> The values in the SyncScope enum are the source language values.  We already 
> have a step to translate them into LLVM values when we generate a native LLVM 
> construct.  To the extent that we call into a runtime instead, none of that 
> code has been written to be runtime-agnostic at all, and I've been assuming 
> that we're basically okay with that, at least for now.
That sounds reasonable to me. When/if another language comes along the task of 
mapping the multiple ABIs can be done then. Still wanted to make sure it is 
clear that the enum values in the SyncScope enum are documented as BEING the 
OpenCL runtime ABI values and not some arbitrary list as in other enums such as 
the address space enum. 


https://reviews.llvm.org/D36580



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

In https://reviews.llvm.org/D29660#839550, @alekseyshl wrote:

> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7109 
> failed on r310718, please fix.




In https://reviews.llvm.org/D29660#839647, @gtbercea wrote:

> In https://reviews.llvm.org/D29660#839550, @alekseyshl wrote:
>
> > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7109 
> > failed on r310718, please fix.
>
>
> Couldn't fix/find the actual error so for now, just moving the flag patch 
> tests to openmp-offload-gpu.c which is a disabled test.
>
> 310765


Bad news, the bot is still red: 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7114


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36635: Add a Dockerfile for clang-proto-fuzzer

2017-08-11 Thread don hinton via Phabricator via cfe-commits
hintonda added a comment.

You may want to add an ARG statement to force docker to rerun the svn commands 
each time you invoke `docker build`.  Otherwise it will reuse the cache since 
docker only looks at the RUN text, not it's result.

To get around that, you can add an `ARG REVISION` declaration before the first 
RUN command, and use $REVISION in your subsequent `svn co` commands.  The ARG 
declaration, will invalidate the cache for the subsequent RUN command, since 
docker passes ARG as an environment variable and can't know how it's used.

Then you could then invoke docker like this:

  docker build --build-arg REV=$(svn info --show-item revision 
http://llvm.org/svn/llvm-project/llvm/trunk) .


https://reviews.llvm.org/D36635



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


[PATCH] D36555: Move x86-specific sources to x86-specific source lists.

2017-08-11 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

Looks OK to me, but I haven't worked on this part of code either, so I think 
someone else should approve it.


https://reviews.llvm.org/D36555



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


[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/SyncScope.h:46
+  Scopes.push_back(SyncScope::OpenCLSubGroup);
+  return Scopes;
+}

t-tye wrote:
> Should there be an assert/static_assert in case SyncScope enum grows due to 
> other languages?
It makes sense to add a 'last' enumerator to SyncScope and do a static_assert 
here that last == OpenCLSubGroup.



Comment at: include/clang/Basic/SyncScope.h:59
+return "opencl_subgroup";
+  }
+}

t-tye wrote:
> Should there be a default/assert/static_assert to allow SyncScope enum to 
> grow due to other languages?
There will already be a warning from -Wswitch about this, which should be 
sufficient.

But we do often add llvm_unreachable after switches like this.



Comment at: lib/CodeGen/CGAtomic.cpp:696
+if (S != Default)
+  SI->addCase(Builder.getInt32(static_cast(S)), B);
+

t-tye wrote:
> Is it documented in the SyncScope enum that the enumerator values are in fact 
> the values used for source language runtime values? Seems if other languages 
> want to use scopes they may may have a different ordering. That would imply 
> that there would be a function to map a SyncScope value to the value used by 
> the source language. For OpenCL the mapping is identity.
> 
> The memory ordering has the isValidAtomicOrderingCABI() that does a similar 
> thing.
The values in the SyncScope enum are the source language values.  We already 
have a step to translate them into LLVM values when we generate a native LLVM 
construct.  To the extent that we call into a runtime instead, none of that 
code has been written to be runtime-agnostic at all, and I've been assuming 
that we're basically okay with that, at least for now.


https://reviews.llvm.org/D36580



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D29660#839550, @alekseyshl wrote:

> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7109 
> failed on r310718, please fix.


Couldn't fix/find the actual error so for now, just moving the flag patch tests 
to openmp-offload-gpu.c which is a disabled test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36635: Add a Dockerfile for clang-proto-fuzzer

2017-08-11 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added inline comments.



Comment at: tools/clang-fuzzer/Dockerfile:22
+# Get LLVM
+RUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
+RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang 
-r $(cd ../ && svn info | grep Revision | awk '{print $2}')

morehouse wrote:
> What if the latest revision breaks the build?
Then we will know that! 

I hope to have clang-proto-fuzzer on a bot of some kind at some point, maybe on 
oss-fuzz, so we will know if the TotT is broken



Comment at: tools/clang-fuzzer/Dockerfile:24
+RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang 
-r $(cd ../ && svn info | grep Revision | awk '{print $2}')
+RUN cd llvm/projects && svn co 
http://llvm.org/svn/llvm-project/compiler-rt/trunk clang -r $(cd ../ && svn 
info | grep Revision | awk '{print $2}')
+# Build plain LLVM (stage 0)

morehouse wrote:
> Should this be `svn co ... compiler-rt`?
Of course, fixed. !
Very surprisingly, this still worked!


https://reviews.llvm.org/D36635



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


[PATCH] D36635: Add a Dockerfile for clang-proto-fuzzer

2017-08-11 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc updated this revision to Diff 110810.
kcc added a comment.

fix 'svn co' command (apparently it did not matter though)


https://reviews.llvm.org/D36635

Files:
  tools/clang-fuzzer/Dockerfile
  tools/clang-fuzzer/README.txt


Index: tools/clang-fuzzer/README.txt
===
--- tools/clang-fuzzer/README.txt
+++ tools/clang-fuzzer/README.txt
@@ -59,6 +59,8 @@
 -DCLANG_ENABLE_PROTO_FUZZER=ON
   ninja clang-proto-fuzzer clang-proto-to-cxx
 
+This directory also contains a Dockerfile which sets up all required
+dependencies and builds the fuzzers.
 
 =
  Running the fuzzers
Index: tools/clang-fuzzer/Dockerfile
===
--- /dev/null
+++ tools/clang-fuzzer/Dockerfile
@@ -0,0 +1,37 @@
+#===- llvm/tools/clang/tools/clang-fuzzer 
-===//
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===--===//
+# Produces an image that builds clang-proto-fuzzer
+FROM ubuntu:16.04
+RUN apt-get update -y
+RUN apt-get install -y autoconf automake libtool curl make g++ unzip wget git \
+binutils liblzma-dev libz-dev python-all cmake ninja-build subversion \
+pkg-config docbook2x
+
+WORKDIR /root
+
+# Get protobuf
+RUN wget -qO- 
https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz
 | tar zxf -
+RUN cd protobuf-3.3.0 && ./autogen.sh && ./configure && make -j $(nproc) && 
make check -j $(nproc) && make install && ldconfig
+# Get LLVM
+RUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
+RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang 
-r $(cd ../ && svn info | grep Revision | awk '{print $2}')
+RUN cd llvm/projects && svn co 
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt -r $(cd ../ && 
svn info | grep Revision | awk '{print $2}')
+# Build plain LLVM (stage 0)
+RUN mkdir build0 && cd build0 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release 
../llvm && ninja
+# Configure instrumented LLVM (stage 1)
+RUN mkdir build1 && cd build1 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release 
../llvm \
+-DLLVM_ENABLE_ASSERTIONS=ON \
+-DCMAKE_C_COMPILER=`pwd`/../build0/bin/clang \
+-DCMAKE_CXX_COMPILER=`pwd`/../build0/bin/clang++ \
+-DLLVM_USE_SANITIZE_COVERAGE=YES \
+-DLLVM_USE_SANITIZER=Address -DCLANG_ENABLE_PROTO_FUZZER=ON
+# Build the fuzzers
+RUN cd build1 && ninja clang-fuzzer
+RUN cd build1 && ninja clang-proto-fuzzer
+RUN cd build1 && ninja clang-proto-to-cxx


Index: tools/clang-fuzzer/README.txt
===
--- tools/clang-fuzzer/README.txt
+++ tools/clang-fuzzer/README.txt
@@ -59,6 +59,8 @@
 -DCLANG_ENABLE_PROTO_FUZZER=ON
   ninja clang-proto-fuzzer clang-proto-to-cxx
 
+This directory also contains a Dockerfile which sets up all required
+dependencies and builds the fuzzers.
 
 =
  Running the fuzzers
Index: tools/clang-fuzzer/Dockerfile
===
--- /dev/null
+++ tools/clang-fuzzer/Dockerfile
@@ -0,0 +1,37 @@
+#===- llvm/tools/clang/tools/clang-fuzzer -===//
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===--===//
+# Produces an image that builds clang-proto-fuzzer
+FROM ubuntu:16.04
+RUN apt-get update -y
+RUN apt-get install -y autoconf automake libtool curl make g++ unzip wget git \
+binutils liblzma-dev libz-dev python-all cmake ninja-build subversion \
+pkg-config docbook2x
+
+WORKDIR /root
+
+# Get protobuf
+RUN wget -qO- https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz | tar zxf -
+RUN cd protobuf-3.3.0 && ./autogen.sh && ./configure && make -j $(nproc) && make check -j $(nproc) && make install && ldconfig
+# Get LLVM
+RUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
+RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang -r $(cd ../ && svn info | grep Revision | awk '{print $2}')
+RUN cd llvm/projects && svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt -r $(cd ../ && svn info | grep Revision | awk '{print $2}')
+# Build plain LLVM (stage 0)
+RUN mkdir build0 && cd build0 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm && ninja
+# Configure instrumented LLVM (stage 1)
+RUN mkdir build1 && cd build1 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm \
+-DLLVM_ENABLE_ASSERTIONS=ON \
+-DCMAKE_C_COMPILER=`pwd`/../build0/bin/clang \
+-DCMAKE_CXX_COMPILER=`pwd`/../build0/bin/clang++ \

[PATCH] D36635: Add a Dockerfile for clang-proto-fuzzer

2017-08-11 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: tools/clang-fuzzer/Dockerfile:22
+# Get LLVM
+RUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
+RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang 
-r $(cd ../ && svn info | grep Revision | awk '{print $2}')

What if the latest revision breaks the build?



Comment at: tools/clang-fuzzer/Dockerfile:24
+RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang 
-r $(cd ../ && svn info | grep Revision | awk '{print $2}')
+RUN cd llvm/projects && svn co 
http://llvm.org/svn/llvm-project/compiler-rt/trunk clang -r $(cd ../ && svn 
info | grep Revision | awk '{print $2}')
+# Build plain LLVM (stage 0)

Should this be `svn co ... compiler-rt`?


https://reviews.llvm.org/D36635



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


[libcxx] r310760 - [libcxx] [test] Rename __x to x. NFCI.

2017-08-11 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Aug 11 13:54:06 2017
New Revision: 310760

URL: http://llvm.org/viewvc/llvm-project?rev=310760&view=rev
Log:
[libcxx] [test] Rename __x to x. NFCI.

This improves readability and (theoretically) improves portability,
as __ugly names are reserved.

Modified:

libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp

Modified: 
libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp?rev=310760&r1=310759&r2=310760&view=diff
==
--- 
libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
 Fri Aug 11 13:54:06 2017
@@ -28,17 +28,17 @@
 template 
 struct identity : std::unary_function
 {
-constexpr const T& operator()(const T& __x) const { return __x;}
+constexpr const T& operator()(const T& x) const { return x;}
 };
 
 template <>
 struct identity
 {
 template 
-constexpr auto operator()(T&& __x) const
-_NOEXCEPT_(noexcept(_VSTD::forward(__x)))
--> decltype(_VSTD::forward(__x))
-{ return_VSTD::forward(__x); }
+constexpr auto operator()(T&& x) const
+_NOEXCEPT_(noexcept(_VSTD::forward(x)))
+-> decltype(_VSTD::forward(x))
+{ return_VSTD::forward(x); }
 };
 
 template 

Modified: 
libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp?rev=310760&r1=310759&r2=310760&view=diff
==
--- 
libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp
 Fri Aug 11 13:54:06 2017
@@ -1,3 +1,4 @@
+
 
//===--===//
 //
 // The LLVM Compiler Infrastructure
@@ -28,17 +29,17 @@
 template 
 struct identity : std::unary_function
 {
-constexpr const T& operator()(const T& __x) const { return __x;}
+constexpr const T& operator()(const T& x) const { return x;}
 };
 
 template <>
 struct identity
 {
 template 
-constexpr auto operator()(T&& __x) const
-_NOEXCEPT_(noexcept(_VSTD::forward(__x)))
--> decltype(_VSTD::forward(__x))
-{ return_VSTD::forward(__x); }
+constexpr auto operator()(T&& x) const
+_NOEXCEPT_(noexcept(_VSTD::forward(x)))
+-> decltype(_VSTD::forward(x))
+{ return_VSTD::forward(x); }
 };
 
 template 

Modified: 
libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp?rev=310760&r1=310759&r2=310760&view=diff
==
--- 
libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp
 Fri Aug 11 13:54:06 2017
@@ -28,17 +28,17 @@
 template 
 struct identity : std::unary_function
 {
-constexpr const T& operator()(const T& __x) const { return __x;}
+constexpr const T& operator()(const T& x) const { return x;}
 };
 
 template <>
 struct identity
 {
 template 
-constexpr auto operator()(T&& __x) const
-_NOEXCEPT_(noexcept(_VSTD::forward(__x)))
--> decltype(_VSTD::forward(__x))
-{ return_VSTD::forward(__x); }
+constexpr auto operator()(T&& x) const
+_NOEXCEPT_(noexcept(_VSTD::forward(x)))
+-> decltype(_VSTD::forward(x))
+{ return_VSTD::forward(x); }
 };
 
 template 

Modified: 
libcxx/trunk/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cp

[libcxx] r310761 - [libcxx] [test] Rename _Up to U, etc. NFCI.

2017-08-11 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Aug 11 13:54:09 2017
New Revision: 310761

URL: http://llvm.org/viewvc/llvm-project?rev=310761&view=rev
Log:
[libcxx] [test] Rename _Up to U, etc. NFCI.

This improves readability and (theoretically) improves portability,
as _Ugly names are reserved.

This performs additional de-uglification, so all of these tests
follow the example of iterator.traits/empty.pass.cpp.

Modified:

libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/logical.operations/transparent.pass.cpp

Modified: 
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp?rev=310761&r1=310760&r2=310761&view=diff
==
--- 
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
 Fri Aug 11 13:54:09 2017
@@ -25,8 +25,8 @@ struct has_value_type
 {
 private:
 struct two {char lx; char lxx;};
-template  static two test(...);
-template  static char test(typename _Up::value_type* = 0);
+template  static two test(...);
+template  static char test(typename U::value_type* = 0);
 public:
 static const bool value = sizeof(test(0)) == 1;
 };

Modified: 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp?rev=310761&r1=310760&r2=310761&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp
 Fri Aug 11 13:54:09 2017
@@ -15,11 +15,11 @@ template 
 struct is_transparent
 {
 private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename _Up::is_transparent* = 0);
+struct two {char lx; char lxx;};
+template  static two test(...);
+template  static char test(typename U::is_transparent* = 0);
 public:
-static const bool value = sizeof(__test(0)) == 1;
+static const bool value = sizeof(test(0)) == 1;
 };
 
 

Modified: 
libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp?rev=310761&r1=310760&r2=310761&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp
 Fri Aug 11 13:54:09 2017
@@ -15,11 +15,11 @@ template 
 struct is_transparent
 {
 private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename _Up::is_transparent* = 0);
+struct two {char lx; char lxx;};
+template  static two test(...);
+template  static char test(typename U::is_transparent* = 0);
 public:
-static const bool value = sizeof(__test(0)) == 1;
+static const bool value = sizeof(test(0)) == 1;
 };
 
 

Modified: 
libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp?rev=310761&r1=310760&r2=310761&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp
 Fri Aug 11 13:54:09 2017
@@ -15,11 +15,11 @@ template 
 struct is_transparent
 {
 private:
-struct __two {char __lx; char __lxx;};
-template  static __two __test(...);
-template  static char __test(typename _Up::is_transparent* = 0);
+struct two {char lx; char lxx;};
+template  static two test(...);
+template  static char test(typename U::is_transparent* = 0);
 public:
-static const bool value = sizeof(__test(0)) == 1;
+static const bool value = sizeof(test(0)) == 1;
 };
 
 

Modified: 
libcxx/trunk/test/std/utiliti

[libcxx] r310758 - [libcxx] [test] Rename _Tp to T. NFCI.

2017-08-11 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Aug 11 13:53:53 2017
New Revision: 310758

URL: http://llvm.org/viewvc/llvm-project?rev=310758&view=rev
Log:
[libcxx] [test] Rename _Tp to T. NFCI.

This improves readability and (theoretically) improves portability,
as _Ugly names are reserved.

Modified:

libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp

libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp

libcxx/trunk/test/std/localization/locale.categories/category.monetary/locale.moneypunct/types.pass.cpp

libcxx/trunk/test/std/localization/locales/locale/locale.types/locale.category/category.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp

libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.mers/values.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.eng/rand.eng.sub/values.pass.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.const/constants.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/transparent.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/comparisons/transparent.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/logical.operations/transparent.pass.cpp

libcxx/trunk/test/std/utilities/time/time.clock/time.clock.hires/consistency.pass.cpp

libcxx/trunk/test/std/utilities/time/time.clock/time.clock.steady/consistency.pass.cpp

libcxx/trunk/test/std/utilities/time/time.clock/time.clock.system/consistency.pass.cpp
libcxx/trunk/test/support/any_helpers.h
libcxx/trunk/test/support/experimental_any_helpers.h

Modified: 
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp?rev=310758&r1=310757&r2=310758&view=diff
==
--- 
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/iterator.primitives/iterator.traits/empty.pass.cpp
 Fri Aug 11 13:53:53 2017
@@ -20,7 +20,7 @@ struct not_an_iterator
 {
 };
 
-template 
+template 
 struct has_value_type
 {
 private:
@@ -28,7 +28,7 @@ private:
 template  static two test(...);
 template  static char test(typename _Up::value_type* = 0);
 public:
-static const bool value = sizeof(test<_Tp>(0)) == 1;
+static const bool value = sizeof(test(0)) == 1;
 };
 
 int main()

Modified: 
libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp?rev=310758&r1=310757&r2=310758&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/const_data_members.pass.cpp
 Fri Aug 11 13:53:53 2017
@@ -37,8 +37,8 @@
 round_style
 */
 
-template 
-void test(const _Tp &) {}
+template 
+void test(const T &) {}
 
 #define TEST_NUMERIC_LIMITS(type) \
   test(std::numeric_limits::is_specialized); \

Modified: 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp?rev=310758&r1=310757&r2=310758&view=diff
==
--- 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locale.categories/category.ctype/ctype_base.pass.cpp
 Fri Aug 11 13:53:53 2017
@@ -36,8 +36,8 @@
 #include 
 #include 
 
-template 
-void test(const _Tp &) {}
+template 
+void test(const T &) {}
 
 int main()
 {


[libcxx] r310759 - [libcxx] [test] Rename __c to ch. NFCI.

2017-08-11 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Fri Aug 11 13:54:01 2017
New Revision: 310759

URL: http://llvm.org/viewvc/llvm-project?rev=310759&view=rev
Log:
[libcxx] [test] Rename __c to ch. NFCI.

This improves readability and (theoretically) improves portability,
as __ugly names are reserved.

Modified:

libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_money.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.formatted/istream_extractors/streambuf.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/CharT_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_to_wide_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.unformatted/write.pa

[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-11 Thread Tony Tye via Phabricator via cfe-commits
t-tye added inline comments.



Comment at: include/clang/Basic/SyncScope.h:46
+  Scopes.push_back(SyncScope::OpenCLSubGroup);
+  return Scopes;
+}

Should there be an assert/static_assert in case SyncScope enum grows due to 
other languages?



Comment at: include/clang/Basic/SyncScope.h:59
+return "opencl_subgroup";
+  }
+}

Should there be a default/assert/static_assert to allow SyncScope enum to grow 
due to other languages?



Comment at: lib/CodeGen/CGAtomic.cpp:696
+if (S != Default)
+  SI->addCase(Builder.getInt32(static_cast(S)), B);
+

Is it documented in the SyncScope enum that the enumerator values are in fact 
the values used for source language runtime values? Seems if other languages 
want to use scopes they may may have a different ordering. That would imply 
that there would be a function to map a SyncScope value to the value used by 
the source language. For OpenCL the mapping is identity.

The memory ordering has the isValidAtomicOrderingCABI() that does a similar 
thing.


https://reviews.llvm.org/D36580



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D29660#839275, @alekseyshl wrote:

> In https://reviews.llvm.org/D29660#839209, @gtbercea wrote:
>
> > I have re-enabled the previous offloading tests and moved the new GPU 
> > offloading tests to a new file which is disabled for linux (for now).
> >
> > 310718
> >
> > Alex thanks so much for the logs, they have been very useful to understand 
> > what's going on.
> >
> > Aleksey, I have since tried to install a Clang version with the address 
> > sanitizer enabled but without much success. Apart from turning on the 
> > sanitizer in the cmake using the -DLLVM_USE_SANITIZER="Address" flag is 
> > there any other flag that I need to pass to cmake?
> >  I am trying to run this on my macbook x86_64 and OS X 10.11. I am getting 
> > the following error when building the compiler:
> >
> > [2966/4254] Linking CXX shared library lib/libc++abi.1.0.dylib
> >  FAILED: lib/libc++abi.1.0.dylib
> >  Undefined symbols for architecture x86_64:
> >
> >   "___asan_after_dynamic_init", referenced from:
> >   __GLOBAL__sub_I_cxa_default_handlers.cpp in cxa_default_handlers.cpp.o
> >   "___asan_before_dynamic_init", referenced from:
> >   __GLOBAL__sub_I_cxa_default_handlers.cpp in cxa_default_handlers.cpp.o
> >
> > [...]
> >  ld: symbol(s) not found for architecture x86_64
>
>
> Actually, you can run our bot, it is in zorg (http://llvm.org/git/zorg.git), 
> zorg/buildbot/builders/sanitizers/buildbot_fast.sh (the one I linked the last 
> time).
>
> Create a temp folder and from that folder run:
>  BUILDBOT_REVISION= BUILDBOT_CLOBBER= 
> $PATH_YOUR_PROJECTS$/zorg/zorg/buildbot/builders/sanitizers/buildbot_fast.sh


I can't seem to run this script since SVN keeps resetting the connection:

svn: E54: Error running context: Connection reset by peer


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 110799.
JonasToth marked an inline comment as done.
JonasToth added a comment.

address review comments from aaron


https://reviews.llvm.org/D36354

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.h
  clang-tidy/utils/Matchers.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-owning-memory.cpp

Index: test/clang-tidy/cppcoreguidelines-owning-memory.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-owning-memory.cpp
@@ -0,0 +1,347 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-owning-memory %t
+
+namespace gsl {
+template 
+using owner = T;
+} // namespace gsl
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(gsl::owner resource) : memory(resource) {}
+  unique_ptr(const unique_ptr &) = default;
+
+  ~unique_ptr() { delete memory; }
+
+private:
+  gsl::owner memory;
+};
+
+void takes_owner(gsl::owner owned_int) {
+}
+
+void takes_pointer(int *unowned_int) {
+}
+
+void takes_owner_and_more(int some_int, gsl::owner owned_int, float f) {
+}
+
+template 
+void takes_templated_owner(gsl::owner owned_T) {
+}
+
+gsl::owner returns_owner1() { return gsl::owner(new int(42)); } // Ok
+gsl::owner returns_owner2() { return new int(42); } // Ok
+
+int *returns_no_owner1() { return nullptr; }
+int *returns_no_owner2() {
+  return new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+int *returns_no_owner3() {
+  int *should_be_owner = new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  return should_be_owner;
+}
+int *returns_no_owner4() {
+  gsl::owner owner = new int(42);
+  return owner;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+
+unique_ptr returns_no_owner5() {
+  return unique_ptr(new int(42)); // Ok
+}
+
+/// FIXME CSA finds it, but the report is misleading.
+void csa_not_finding_leak() {
+  gsl::owner o1 = new int(42); // Ok
+
+  gsl::owner o2 = o1; // Ok
+  o2 = new int(45); // conceptual leak, the memory from o1 is now leaked, since its considered moved in the guideLINEs
+
+  delete o2;
+  // actual leak occurs here, its found, but mixed
+  delete o1;
+}
+
+void test_assignment_and_initialization() {
+  int stack_int1 = 15;
+  int stack_int2;
+
+  gsl::owner owned_int1 = &stack_int1; // BAD
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing neither with an owner nor a recognized resource
+
+  gsl::owner owned_int2;
+  owned_int2 = &stack_int2; // BAD since no owner, bad since uninitialized
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning neither an owner nor a recognized resource
+
+  gsl::owner owned_int3 = new int(42); // Good
+  owned_int3 = nullptr; // Good
+
+  gsl::owner owned_int4(nullptr); // Ok
+  owned_int4 = new int(42); // Good
+
+  gsl::owner owned_int5 = owned_int3; // Good
+
+  gsl::owner owned_int6{nullptr}; // Ok
+  owned_int6 = owned_int4; // Good
+
+  // FIXME, flow analysis for the case of reassignment. Value must be released before
+  owned_int6 = owned_int3; // BAD, because reassignment without resource release
+
+  auto owned_int7 = returns_owner1(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  const auto owned_int8 = returns_owner2(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  gsl::owner owned_int9 = returns_owner1(); // Ok
+  int *unowned_int3 = returns_owner1(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+
+  gsl::owner owned_int10;
+  owned_int10 = returns_owner1(); // Ok
+
+  int *unowned_int4;
+  unowned_int4 = returns_owner1(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning newly created owner/resource to non-owner
+
+  gsl::owner owned_int11 = returns_no_owner1(); // Bad since no owner
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing neither with an owner nor a recognized resource
+
+  gsl::owner owned_int12;
+  owned_int12 = returns_no_owner1(); // Bad since no owner
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning neither an owner nor a recognized resource
+
+  int *unowned_int5 = returns_no_owner1(); // Ok
+  int *unowned_int6;
+  unow

[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 5 inline comments as done.
JonasToth added inline comments.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:230
+<< BadOwnerInitialization->getSourceRange();
+// FIXME FixitHint to rewrite the type if possible
+

aaron.ballman wrote:
> Are you intending to address this in this patch?
> 
> Also, it should probably be "FIXME: " (with the colon).
no not in this patch directly, but i plan a follow up after getting this one 
done.


https://reviews.llvm.org/D36354



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


Re: r309226 - Headers: improve ARM EHABI coverage of unwind.h

2017-08-11 Thread Evgenii Stepanov via cfe-commits
Hi,

I've noticed that the code in
compiler-rt/lib/builtins/gcc_personality_v0.c refers to
_Unwind_Exception as "struct _Unwind_Exception". With this change, it
is not a struct anymore on ARM. Should that code be fixed, or is it a
problem in this change?

compiler-rt/lib/builtins/gcc_personality_v0.c:153:23: error:
declaration of 'struct _Unwind_Exception' will not be visible outside
of this function [-Werror,-Wvisibility]
continueUnwind(struct _Unwind_Exception *exceptionObject,

On Thu, Jul 27, 2017 at 9:46 AM, Hans Wennborg via cfe-commits
 wrote:
> Merged to 5.0 in r309290.
>
> On Wed, Jul 26, 2017 at 3:55 PM, Saleem Abdulrasool via cfe-commits
>  wrote:
>> Author: compnerd
>> Date: Wed Jul 26 15:55:23 2017
>> New Revision: 309226
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=309226&view=rev
>> Log:
>> Headers: improve ARM EHABI coverage of unwind.h
>>
>> Ensure that we define the `_Unwind_Control_Block` structure used on ARM
>> EHABI targets.  This is needed for building libc++abi with the unwind.h
>> from the resource dir.  A minor fallout of this is that we needed to
>> create a typedef for _Unwind_Exception to work across ARM EHABI and
>> non-EHABI targets.  The structure definitions here are based originally
>> on the documentation from ARM under the "Exception Handling ABI for the
>> ARM® Architecture" Section 7.2.  They are then adjusted to more closely
>> reflect the definition in libunwind from LLVM.  Those changes are
>> compatible in layout but permit easier use in libc++abi and help
>> maintain compatibility between libunwind and the compiler provided
>> definition.
>>
>> Modified:
>> cfe/trunk/lib/Headers/unwind.h
>>
>> Modified: cfe/trunk/lib/Headers/unwind.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/unwind.h?rev=309226&r1=309225&r2=309226&view=diff
>> ==
>> --- cfe/trunk/lib/Headers/unwind.h (original)
>> +++ cfe/trunk/lib/Headers/unwind.h Wed Jul 26 15:55:23 2017
>> @@ -76,7 +76,13 @@ typedef intptr_t _sleb128_t;
>>  typedef uintptr_t _uleb128_t;
>>
>>  struct _Unwind_Context;
>> +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || 
>> defined(__ARM_DWARF_EH___))
>> +struct _Unwind_Control_Block;
>> +typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */
>> +#else
>>  struct _Unwind_Exception;
>> +typedef struct _Unwind_Exception _Unwind_Exception;
>> +#endif
>>  typedef enum {
>>_URC_NO_REASON = 0,
>>  #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
>> @@ -109,8 +115,42 @@ typedef enum {
>>  } _Unwind_Action;
>>
>>  typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code,
>> - struct _Unwind_Exception *);
>> + _Unwind_Exception *);
>>
>> +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || 
>> defined(__ARM_DWARF_EH___))
>> +typedef struct _Unwind_Control_Block _Unwind_Control_Block;
>> +typedef uint32_t _Unwind_EHT_Header;
>> +
>> +struct _Unwind_Control_Block {
>> +  uint64_t exception_class;
>> +  void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
>> +  /* unwinder cache (private fields for the unwinder's use) */
>> +  struct {
>> +uint32_t reserved1; /* forced unwind stop function, 0 if not forced */
>> +uint32_t reserved2; /* personality routine */
>> +uint32_t reserved3; /* callsite */
>> +uint32_t reserved4; /* forced unwind stop argument */
>> +uint32_t reserved5;
>> +  } unwinder_cache;
>> +  /* propagation barrier cache (valid after phase 1) */
>> +  struct {
>> +uint32_t sp;
>> +uint32_t bitpattern[5];
>> +  } barrier_cache;
>> +  /* cleanup cache (preserved over cleanup) */
>> +  struct {
>> +uint32_t bitpattern[4];
>> +  } cleanup_cache;
>> +  /* personality cache (for personality's benefit) */
>> +  struct {
>> +uint32_t fnstart; /* function start address */
>> +_Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
>> +uint32_t additional;  /* additional data */
>> +uint32_t reserved1;
>> +  } pr_cache;
>> +  long long int : 0; /* force alignment of next item to 8-byte boundary */
>> +};
>> +#else
>>  struct _Unwind_Exception {
>>_Unwind_Exception_Class exception_class;
>>_Unwind_Exception_Cleanup_Fn exception_cleanup;
>> @@ -120,16 +160,18 @@ struct _Unwind_Exception {
>> * aligned".  GCC has interpreted this to mean "use the maximum useful
>> * alignment for the target"; so do we. */
>>  } __attribute__((__aligned__));
>> +#endif
>>
>>  typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(int, _Unwind_Action,
>> _Unwind_Exception_Class,
>> -   struct _Unwind_Exception *,
>> +   _Unwind_Exception *,
>> struct _Unwind_Context *

[PATCH] D36635: Add a Dockerfile for clang-proto-fuzzer

2017-08-11 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc created this revision.

Add a Dockerfile for clang-proto-fuzzer


https://reviews.llvm.org/D36635

Files:
  tools/clang-fuzzer/Dockerfile
  tools/clang-fuzzer/README.txt


Index: tools/clang-fuzzer/README.txt
===
--- tools/clang-fuzzer/README.txt
+++ tools/clang-fuzzer/README.txt
@@ -59,6 +59,8 @@
 -DCLANG_ENABLE_PROTO_FUZZER=ON
   ninja clang-proto-fuzzer clang-proto-to-cxx
 
+This directory also contains a Dockerfile which sets up all required
+dependencies and builds the fuzzers.
 
 =
  Running the fuzzers
Index: tools/clang-fuzzer/Dockerfile
===
--- /dev/null
+++ tools/clang-fuzzer/Dockerfile
@@ -0,0 +1,37 @@
+#===- llvm/tools/clang/tools/clang-fuzzer 
-===//
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===--===//
+# Produces an image that builds clang-proto-fuzzer
+FROM ubuntu:16.04
+RUN apt-get update -y
+RUN apt-get install -y autoconf automake libtool curl make g++ unzip wget git \
+binutils liblzma-dev libz-dev python-all cmake ninja-build subversion \
+pkg-config docbook2x
+
+WORKDIR /root
+
+# Get protobuf
+RUN wget -qO- 
https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz
 | tar zxf -
+RUN cd protobuf-3.3.0 && ./autogen.sh && ./configure && make -j $(nproc) && 
make check -j $(nproc) && make install && ldconfig
+# Get LLVM
+RUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
+RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang 
-r $(cd ../ && svn info | grep Revision | awk '{print $2}')
+RUN cd llvm/projects && svn co 
http://llvm.org/svn/llvm-project/compiler-rt/trunk clang -r $(cd ../ && svn 
info | grep Revision | awk '{print $2}')
+# Build plain LLVM (stage 0)
+RUN mkdir build0 && cd build0 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release 
../llvm && ninja
+# Configure instrumented LLVM (stage 1)
+RUN mkdir build1 && cd build1 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release 
../llvm \
+-DLLVM_ENABLE_ASSERTIONS=ON \
+-DCMAKE_C_COMPILER=`pwd`/../build0/bin/clang \
+-DCMAKE_CXX_COMPILER=`pwd`/../build0/bin/clang++ \
+-DLLVM_USE_SANITIZE_COVERAGE=YES \
+-DLLVM_USE_SANITIZER=Address -DCLANG_ENABLE_PROTO_FUZZER=ON
+# Build the fuzzers
+RUN cd build1 && ninja clang-fuzzer
+RUN cd build1 && ninja clang-proto-fuzzer
+RUN cd build1 && ninja clang-proto-to-cxx


Index: tools/clang-fuzzer/README.txt
===
--- tools/clang-fuzzer/README.txt
+++ tools/clang-fuzzer/README.txt
@@ -59,6 +59,8 @@
 -DCLANG_ENABLE_PROTO_FUZZER=ON
   ninja clang-proto-fuzzer clang-proto-to-cxx
 
+This directory also contains a Dockerfile which sets up all required
+dependencies and builds the fuzzers.
 
 =
  Running the fuzzers
Index: tools/clang-fuzzer/Dockerfile
===
--- /dev/null
+++ tools/clang-fuzzer/Dockerfile
@@ -0,0 +1,37 @@
+#===- llvm/tools/clang/tools/clang-fuzzer -===//
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===--===//
+# Produces an image that builds clang-proto-fuzzer
+FROM ubuntu:16.04
+RUN apt-get update -y
+RUN apt-get install -y autoconf automake libtool curl make g++ unzip wget git \
+binutils liblzma-dev libz-dev python-all cmake ninja-build subversion \
+pkg-config docbook2x
+
+WORKDIR /root
+
+# Get protobuf
+RUN wget -qO- https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz | tar zxf -
+RUN cd protobuf-3.3.0 && ./autogen.sh && ./configure && make -j $(nproc) && make check -j $(nproc) && make install && ldconfig
+# Get LLVM
+RUN svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
+RUN cd llvm/tools && svn co http://llvm.org/svn/llvm-project/cfe/trunk clang -r $(cd ../ && svn info | grep Revision | awk '{print $2}')
+RUN cd llvm/projects && svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk clang -r $(cd ../ && svn info | grep Revision | awk '{print $2}')
+# Build plain LLVM (stage 0)
+RUN mkdir build0 && cd build0 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm && ninja
+# Configure instrumented LLVM (stage 1)
+RUN mkdir build1 && cd build1 && cmake -GNinja -DCMAKE_BUILD_TYPE=Release ../llvm \
+-DLLVM_ENABLE_ASSERTIONS=ON \
+-DCMAKE_C_COMPILER=`pwd`/../build0/bin/clang \
+-DCMAKE_CXX_COMPILER=`pwd`/../build0/bin/clang++ \
+-DLLVM_USE_SANITIZE_COVERAGE=YES \
+-DLLVM_USE_SANITIZER=A

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7109 
failed on r310718, please fix.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:188
+diag(OwnerAssignment->getLocStart(),
+ "assigning neither an owner nor a recognized resource")
+<< SourceRange(OwnerAssignment->getLocStart(),

JonasToth wrote:
> aaron.ballman wrote:
> > Same comments here as above about "owner" and "recognized resource". I 
> > think you want to talk about `gsl::owner<>` where you use "owner" and drop 
> > "recognized resource" (because such a resource returns a 
> > `gsl::owner<>`-flagged type, if I understand properly).
> ideally every created resource would be flagged as `gsl::owner<>`, but for 
> example `fopen`, `malloc` and friends can't, but would benefit the most from 
> such a check (+ flow analysis if the owner gets consumed on every path)
The use case certainly makes sense, but that doesn't make the diagnostic any 
more clear to the user. Perhaps: "expected assignment source to be of type 
'gsl::owner<>'; got %0"? It's not perfect because it doesn't mention 
"recognized resource", but that can be improved in the follow-up patch that 
defines those resources.

The wording should be similar for the below cases as well.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:167
+ "expected argument of type 'gsl::owner<>'; got %0")
+<< ExpectedOwner->getType().getAsString()
+<< ExpectedOwner->getSourceRange();

You can pass the `QualType` directly instead of calling `getAsString()` on it.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:184
+  // Assignments to owners.
+  if (OwnerAssignment != nullptr) {
+diag(OwnerAssignment->getLocStart(),

No need to check against `nullptr` explicitly (here and elsewhere).



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:191
+  // Initialization of owners.
+  else if (OwnerInitialization != nullptr) {
+diag(OwnerInitialization->getLocStart(),

No else after a return. Same applies elsewhere.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:208
+
+bool OwningMemoryCheck::handleBadAssignmentAndInit(const BoundNodes &Nodes) {
+  // Problematic assignment and initializations, since the assigned value is a

It's hard to understand how this differs from `handleAssignmentAndInit()`; 
might need a more descriptive name.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:230
+<< BadOwnerInitialization->getSourceRange();
+// FIXME FixitHint to rewrite the type if possible
+

Are you intending to address this in this patch?

Also, it should probably be "FIXME: " (with the colon).


https://reviews.llvm.org/D36354



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


[PATCH] D36572: Implemented P0409R2 - Allow lambda capture [=, this]

2017-08-11 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 110776.
hamzasood added a comment.

@rjmccall The warning is emitted, but you're right that there's no test to 
ensure that actually happens; test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp 
used Wno-c++2a-extensions to suppress the warning.

I've changed it so that checking for the warning is now part of the test.


https://reviews.llvm.org/D36572

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaLambda.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
  test/FixIt/fixit-cxx0x.cpp
  test/SemaCXX/cxx2a-lambda-equals-this.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -808,7 +807,7 @@
 
   Allow lambda-capture [=, this]
   http://wg21.link/p0409r2";>P0409R2
-  No
+  SVN
 
 
   __VA_OPT__ for preprocessor comma elision
Index: test/SemaCXX/cxx2a-lambda-equals-this.cpp
===
--- test/SemaCXX/cxx2a-lambda-equals-this.cpp
+++ test/SemaCXX/cxx2a-lambda-equals-this.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+// expected-no-diagnostics
+
+// This test does two things.
+// Deleting the copy constructor ensures that an [=, this] capture doesn't copy the object.
+// Accessing a member variable from the lambda ensures that the capture actually works.
+class A {
+  A(const A &) = delete;
+  int i;
+
+  void func() {
+auto L = [=, this]() -> int { return i; };
+L();
+  }
+};
Index: test/FixIt/fixit-cxx0x.cpp
===
--- test/FixIt/fixit-cxx0x.cpp
+++ test/FixIt/fixit-cxx0x.cpp
@@ -54,7 +54,6 @@
 
 void S2::f(int i) {
   (void)[&, &i, &i]{}; // expected-error 2{{'&' cannot precede a capture when the capture default is '&'}}
-  (void)[=, this]{ this->g(5); }; // expected-error{{'this' cannot be explicitly captured}}
   (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[] mutable { }; // expected-error{{lambda requires '()' before 'mutable'}}
Index: test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
@@ -8,7 +8,7 @@
 (void)[this, this] () {}; // expected-error {{'this' can appear only once}}
 (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}}
 (void)[=, &foo] () {};
-(void)[=, this] () {}; // expected-error {{'this' cannot be explicitly captured}}
+(void)[=, this] () {}; // expected-warning {{C++2a extension}}
 (void)[&, foo] () {};
 (void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} 
 (void)[&, this] () {};
@@ -23,7 +23,7 @@
 void S2::f(int i) {
   (void)[&, i]{ };
   (void)[&, &i]{ }; // expected-error{{'&' cannot precede a capture when the capture default is '&'}}
-  (void)[=, this]{ }; // expected-error{{'this' cannot be explicitly captured}}
+  (void)[=, this]{ }; // expected-warning{{C++2a extension}}
   (void)[=]{ this->g(i); };
   (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[i(0), i(1)]{ }; // expected-error{{'i' can appear only once in a capture list}}
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -948,17 +948,15 @@
 continue;
   }
 
-  // C++1z [expr.prim.lambda]p8:
-  //  If a lambda-capture includes a capture-default that is =, each
-  //  simple-capture of that lambda-capture shall be of the form "&
-  //  identifier" or "* this". [ Note: The form [&,this] is redundant but
-  //  accepted for compatibility with ISO C++14. --end note ]
-  if (Intro.Default == LCD_ByCopy && C->Kind != LCK_StarThis) {
-Diag(C->Loc, diag::err_this_capture_with_copy_default)
-<< FixItHint::CreateRemoval(
-SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc));
-continue;
-  }
+  // C++2a [expr.prim.lambda]p8:
+  //  If a lambda-capture includes a capture-default that is =,
+  //  each simple-capture of that lambda-capture shall b

[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/SyncScope.h:47
+  return Scopes;
+}
+

You could just return an ArrayRef to a static const array.



Comment at: lib/CodeGen/CGAtomic.cpp:687
+
+  auto *SC = Builder.CreateIntCast(Scope, Builder.getInt32Ty(), false);
+  // If unsupported sync scope is encountered at run time, assume default sync

Does Sema not coerce the argument to int?  It really should, and then you can 
just rely on that here.  (You should use CGF.IntTy if you do this, though, in 
case you're on a target with a non-32-bit int.)


https://reviews.llvm.org/D36580



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


[PATCH] D36572: Implemented P0409R2 - Allow lambda capture [=, this]

2017-08-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: test/FixIt/fixit-cxx0x.cpp:57
   (void)[&, &i, &i]{}; // expected-error 2{{'&' cannot precede a capture when 
the capture default is '&'}}
-  (void)[=, this]{ this->g(5); }; // expected-error{{'this' cannot be 
explicitly captured}}
   (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture 
list}}

hamzasood wrote:
> rjmccall wrote:
> > hamzasood wrote:
> > > rjmccall wrote:
> > > > hamzasood wrote:
> > > > > rjmccall wrote:
> > > > > > Shouldn't you only be accepting this in C++2a mode?
> > > > > I'm not sure what the system is with allowing future language 
> > > > > features as extensions, but I noticed that [*this] capture is allowed 
> > > > > as an extension pre-C++17 so I figured it would make sense for [=, 
> > > > > this] to also be allowed as an extension (since the proposal mentions 
> > > > > how it's meant to increase code clarify in the presence of [*this]).
> > > > Surely there should at least be an on-by-default extension warning?  
> > > > The behavior we're using sounds a lot more like we're treating this as 
> > > > a bug-fix in the standard than a new feature.  Richard, can you weigh 
> > > > in here?
> > > The extension warning for this (ext_equals_this_lambda_capture_cxx2a) is 
> > > on by default.
> > Why did the diagnostic disappear from this file, then?
> That file is for FixIt hints, which I don't think make much sense for an 
> extension warning (and I couldn't find any other extension warnings that 
> offer FixIt hints)
Sure, it's reasonable for this specific test to not test the warning.  However, 
since I don't see anything in this test that actually turns off the warning, 
and since you have not in fact added any tests that verify that the warning is 
ever turned on, I suspect that it is actually not being emitted.


https://reviews.llvm.org/D36572



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


r310733 - Add -fsanitize=fuzzer-no-link flag to the driver.

2017-08-11 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Aug 11 10:22:58 2017
New Revision: 310733

URL: http://llvm.org/viewvc/llvm-project?rev=310733&view=rev
Log:
Add -fsanitize=fuzzer-no-link flag to the driver.

The flag will perform instrumentation necessary to the fuzzing,
but will NOT link libLLVMFuzzer.a library.
Necessary when modifying CFLAGS for projects which may produce
executables as well as a fuzzable target.

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

Modified:
cfe/trunk/include/clang/Basic/Sanitizers.def
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/test/Driver/fuzzer.c

Modified: cfe/trunk/include/clang/Basic/Sanitizers.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Sanitizers.def?rev=310733&r1=310732&r2=310733&view=diff
==
--- cfe/trunk/include/clang/Basic/Sanitizers.def (original)
+++ cfe/trunk/include/clang/Basic/Sanitizers.def Fri Aug 11 10:22:58 2017
@@ -50,6 +50,9 @@ SANITIZER("memory", Memory)
 // libFuzzer
 SANITIZER("fuzzer", Fuzzer)
 
+// libFuzzer-required instrumentation, no linking.
+SANITIZER("fuzzer-no-link", FuzzerNoLink)
+
 // ThreadSanitizer
 SANITIZER("thread", Thread)
 

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=310733&r1=310732&r2=310733&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Fri Aug 11 10:22:58 2017
@@ -32,7 +32,7 @@ enum : SanitizerMask {
   RequiresPIE = DataFlow,
   NeedsUnwindTables = Address | Thread | Memory | DataFlow,
   SupportsCoverage = Address | KernelAddress | Memory | Leak | Undefined |
- Integer | Nullability | DataFlow | Fuzzer,
+ Integer | Nullability | DataFlow | Fuzzer | FuzzerNoLink,
   RecoverableByDefault = Undefined | Integer | Nullability,
   Unrecoverable = Unreachable | Return,
   LegacyFsanitizeRecoverMask = Undefined | Integer,
@@ -286,8 +286,11 @@ SanitizerArgs::SanitizerArgs(const ToolC
   Add &= ~InvalidTrappingKinds;
   Add &= Supported;
 
-  // Enable coverage if the fuzzing flag is set.
   if (Add & Fuzzer)
+Add |= FuzzerNoLink;
+
+  // Enable coverage if the fuzzing flag is set.
+  if (Add & FuzzerNoLink)
 CoverageFeatures |= CoverageTracePCGuard | CoverageIndirCall |
 CoverageTraceCmp | CoveragePCTable;
 

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=310733&r1=310732&r2=310733&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Aug 11 10:22:58 2017
@@ -2018,6 +2018,7 @@ SanitizerMask Darwin::getSupportedSaniti
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Leak;
   Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   if (isTargetMacOS()) {
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=310733&r1=310732&r2=310733&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Fri Aug 11 10:22:58 2017
@@ -828,6 +828,7 @@ SanitizerMask Linux::getSupportedSanitiz
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::KernelAddress;
   Res |= SanitizerKind::Vptr;
   Res |= SanitizerKind::SafeStack;

Modified: cfe/trunk/test/Driver/fuzzer.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuzzer.c?rev=310733&r1=310732&r2=310733&view=diff
==
--- cfe/trunk/test/Driver/fuzzer.c (original)
+++ cfe/trunk/test/Driver/fuzzer.c Fri Aug 11 10:22:58 2017
@@ -21,6 +21,11 @@
 // RUN: %clang -fsanitize=fuzzer %s -shared -o %t.so -### 2>&1 | FileCheck 
--check-prefixes=CHECK-NOLIB-SO %s
 // CHECK-NOLIB-SO-NOT: libLLVMFuzzer.a
 
+// Check that we don't link in libFuzzer when compiling with 
-fsanitize=fuzzer-no-link.
+// RUN: %clang -fsanitize=fuzzer-no-link %s -target x86_64-apple-darwin14 -### 
2>&1 | FileCheck --check-prefixes=CHECK-NOLIB,CHECK-COV %s
+// CHECK-NOLIB-NOT: libLLVMFuzzer.a
+// CHECK-COV: -fsanitize-coverage-trace-pc-guard
+
 // RUN: %clang -fsanitize=fuzzer -fsanitize-coverage=trace-pc %s -### 2>&1 | 
FileCheck --c

[PATCH] D35362: [clang-tidy] Add a close-on-exec check on accept() in Android module.

2017-08-11 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110758.

https://reviews.llvm.org/D35362

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecAcceptCheck.cpp
  clang-tidy/android/CloexecAcceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-accept.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-accept.cpp

Index: test/clang-tidy/android-cloexec-accept.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-accept.cpp
@@ -0,0 +1,28 @@
+// RUN: %check_clang_tidy %s android-cloexec-accept %t
+
+struct sockaddr {};
+typedef int socklen_t;
+#define NULL 0
+
+extern "C" int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+
+void f() {
+  accept(0, NULL, NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC [android-cloexec-accept]
+  // CHECK-FIXES: accept4(0, NULL, NULL, SOCK_CLOEXEC);
+}
+
+namespace i {
+int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+void g() {
+  accept(0, NULL, NULL);
+}
+} // namespace i
+
+class C {
+public:
+  int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
+  void h() {
+accept(0, NULL, NULL);
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   android-cloexec-accept
android-cloexec-creat
android-cloexec-dup
android-cloexec-fopen
Index: docs/clang-tidy/checks/android-cloexec-accept.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-accept.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-accept
+
+android-cloexec-accept
+==
+
+The usage of ``accept()`` is not recommended, it's better to use ``accept4()``.
+Without this flag, an opened sensitive file descriptor would remain open across
+a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  accept(sockfd, addr, addrlen);
+
+  // becomes
+
+  accept4(sockfd, addr, addrlen, SOCK_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -70,6 +70,11 @@
   ``AllowConditionalIntegerCasts`` -> ``AllowIntegerConditions``,
   ``AllowConditionalPointerCasts`` -> ``AllowPointerConditions``.
 
+- New `android-cloexec-accept
+  `_ check
+
+  Detects usage of ``accept()``.
+
 - New `android-cloexec-dup
   `_ check
 
Index: clang-tidy/android/CloexecAcceptCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecAcceptCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecAcceptCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// accept() is better to be replaced by accept4().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-accept.html
+class CloexecAcceptCheck : public CloexecCheck {
+public:
+  CloexecAcceptCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_ACCEPT_H
Index: clang-tidy/android/CloexecAcceptCheck.cpp
===
--- /dev/null
+++ clang-tidy/android/CloexecAcceptCheck.cpp
@@ -0,0 +1,47 @@
+//===--- CloexecAcceptCheck.cpp - clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecAcceptCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::

[PATCH] D35363: [clang-tidy] Add a close-on-exec check on accept4() in Android module.

2017-08-11 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110755.

https://reviews.llvm.org/D35363

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecAccept4Check.cpp
  clang-tidy/android/CloexecAccept4Check.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-accept4.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-accept4.cpp

Index: test/clang-tidy/android-cloexec-accept4.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-accept4.cpp
@@ -0,0 +1,66 @@
+// RUN: %check_clang_tidy %s android-cloexec-accept4 %t
+
+typedef int socklen_t;
+struct sockaddr {};
+
+#define SOCK_NONBLOCK 1
+#define __O_CLOEXEC 3
+#define SOCK_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
+
+void a() {
+  accept4(0, NULL, NULL, SOCK_NONBLOCK);
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: 'accept4' should use SOCK_CLOEXEC where possible [android-cloexec-accept4]
+  // CHECK-FIXES: accept4(0, NULL, NULL, SOCK_NONBLOCK | SOCK_CLOEXEC);
+  TEMP_FAILURE_RETRY(accept4(0, NULL, NULL, SOCK_NONBLOCK));
+  // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: 'accept4'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(accept4(0, NULL, NULL, SOCK_NONBLOCK | SOCK_CLOEXEC));
+}
+
+void f() {
+  accept4(0, NULL, NULL, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'accept4'
+  // CHECK-FIXES: accept4(0, NULL, NULL, 3 | SOCK_CLOEXEC);
+  TEMP_FAILURE_RETRY(accept4(0, NULL, NULL, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: 'accept4'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(accept4(0, NULL, NULL, 3 | SOCK_CLOEXEC));
+
+  int flag = SOCK_NONBLOCK;
+  accept4(0, NULL, NULL, flag);
+  TEMP_FAILURE_RETRY(accept4(0, NULL, NULL, flag));
+}
+
+namespace i {
+int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
+
+void d() {
+  accept4(0, NULL, NULL, SOCK_NONBLOCK);
+  TEMP_FAILURE_RETRY(accept4(0, NULL, NULL, SOCK_NONBLOCK));
+}
+
+} // namespace i
+
+void e() {
+  accept4(0, NULL, NULL, SOCK_CLOEXEC);
+  TEMP_FAILURE_RETRY(accept4(0, NULL, NULL, SOCK_CLOEXEC));
+  accept4(0, NULL, NULL, SOCK_NONBLOCK | SOCK_CLOEXEC);
+  TEMP_FAILURE_RETRY(accept4(0, NULL, NULL, SOCK_NONBLOCK | SOCK_CLOEXEC));
+}
+
+class G {
+public:
+  int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
+  void d() {
+accept4(0, NULL, NULL, SOCK_NONBLOCK);
+TEMP_FAILURE_RETRY(accept4(0, NULL, NULL, SOCK_NONBLOCK));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 =
 
 .. toctree::
+   android-cloexec-accept4
android-cloexec-creat
android-cloexec-dup
android-cloexec-fopen
Index: docs/clang-tidy/checks/android-cloexec-accept4.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-accept4.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-accept4
+
+android-cloexec-accept4
+===
+
+``accept4()`` should include ``SOCK_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++
+
+  accept4(sockfd, addr, addrlen, SOCK_NONBLOCK);
+
+  // becomes
+
+  accept4(sockfd, addr, addrlen, SOCK_NONBLOCK | SOCK_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -70,6 +70,12 @@
   ``AllowConditionalIntegerCasts`` -> ``AllowIntegerConditions``,
   ``AllowConditionalPointerCasts`` -> ``AllowPointerConditions``.
 
+- New `android-cloexec-accept4
+  `_ check
+
+  Checks if the required file flag ``SOCK_CLOEXEC`` is present in the argument of
+  ``accept4()``.
+
 - New `android-cloexec-dup
   `_ check
 
Index: clang-tidy/android/CloexecAccept4Check.h
===
--- /dev/null
+++ clang-tidy/android/CloexecAccept4Check.h
@@ -0,0 +1,35 @@
+//===--- CloexecAccept4Check.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.
+//
+//===---

[PATCH] D35364: [clang-tidy] Add a close-on-exec check on dup() in Android module.

2017-08-11 Thread Yan Wang via Phabricator via cfe-commits
yawanng added inline comments.



Comment at: clang-tidy/android/CloexecCheck.h:91
+  /// Helper function to get the spelling of a particular argument.
+  StringRef getSpellingArg(const ast_matchers::MatchFinder::MatchResult 
&Result,
+   int N) const;

hokein wrote:
> This method seems only be used in one check. Maybe move it to the 
> implementation of that specific check? And you can make the  private members 
> `FuncBindingStr` and `FuncDeclBindingStr` to protected member.
Actually, this  method will be used in three checks. 


https://reviews.llvm.org/D35364



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


[PATCH] D35364: [clang-tidy] Add a close-on-exec check on dup() in Android module.

2017-08-11 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110753.
yawanng marked an inline comment as done.

https://reviews.llvm.org/D35364

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

Index: test/clang-tidy/android-cloexec-dup.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-dup.cpp
@@ -0,0 +1,31 @@
+// RUN: %check_clang_tidy %s android-cloexec-dup %t
+
+extern "C" int dup(int oldfd);
+void f() {
+  dup(1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer fcntl() to dup() because fcntl() allows F_DUPFD_CLOEXEC [android-cloexec-dup]
+  // CHECK-FIXES: fcntl(1, F_DUPFD_CLOEXEC);
+  int oldfd = 0;
+  dup(oldfd);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer
+  // CHECK-FIXES: fcntl(oldfd, F_DUPFD_CLOEXEC);
+}
+
+namespace i {
+int dup(int oldfd);
+void g() {
+  dup(0);
+  int oldfd = 1;
+  dup(oldfd);
+}
+} // namespace i
+
+class C {
+public:
+  int dup(int oldfd);
+  void h() {
+dup(0);
+int oldfd = 1;
+dup(oldfd);
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
 
 .. toctree::
android-cloexec-creat
+   android-cloexec-dup
android-cloexec-fopen
android-cloexec-memfd-create
android-cloexec-open
Index: docs/clang-tidy/checks/android-cloexec-dup.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-dup.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-dup
+
+android-cloexec-dup
+===
+
+The usage of ``dup()`` is not recommended, it's better to use ``fcntl()``,
+which can set the close-on-exec flag. Otherwise, an opened sensitive file would
+remain open across a fork+exec to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  int fd = dup(oldfd);
+
+  // becomes
+
+  int fd = fcntl(oldfd, F_DUPFD_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -70,6 +70,11 @@
   ``AllowConditionalIntegerCasts`` -> ``AllowIntegerConditions``,
   ``AllowConditionalPointerCasts`` -> ``AllowPointerConditions``.
 
+- New `android-cloexec-dup
+  `_ check
+
+  Detects usage of ``dup()``.
+
 - New `android-cloexec-memfd_create
   `_ check
 
Index: clang-tidy/android/CloexecDupCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecDupCheck.h
@@ -0,0 +1,36 @@
+//===--- CloexecDupCheck.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_DUP_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_DUP_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// dup() is better to be replaced by fcntl(), which has close-on-exec flag.
+/// Find the usage of dup() and redirect user to use fcntl().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-dup.html
+class CloexecDupCheck : public CloexecCheck {
+public:
+  CloexecDupCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_DUP_H
Index: clang-tidy/android/CloexecDupCheck.cpp
===
--- /dev/null
+++ clang-tidy/android/CloexecDupCheck.cpp
@@ -0,0 +1,38 @@
+//===--- CloexecDupCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecDupCheck.h"
+#include "clang/

[PATCH] D35365: [clang-tidy] Add a close-on-exec check on epoll_create1() in Android module.

2017-08-11 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110752.

https://reviews.llvm.org/D35365

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecEpollCreate1Check.cpp
  clang-tidy/android/CloexecEpollCreate1Check.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-epoll-create1.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-epoll-create1.cpp

Index: test/clang-tidy/android-cloexec-epoll-create1.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-epoll-create1.cpp
@@ -0,0 +1,59 @@
+// RUN: %check_clang_tidy %s android-cloexec-epoll-create1 %t
+
+#define __O_CLOEXEC 3
+#define EPOLL_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+
+extern "C" int epoll_create1(int flags);
+
+void a() {
+  epoll_create1(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'epoll_create1' should use EPOLL_CLOEXEC where possible [android-cloexec-epoll-create1]
+  // CHECK-FIXES: epoll_create1(EPOLL_CLOEXEC);
+  TEMP_FAILURE_RETRY(epoll_create1(0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'epoll_create1'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC));
+}
+
+void f() {
+  epoll_create1(3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'epoll_create1'
+  // CHECK-FIXES: epoll_create1(EPOLL_CLOEXEC);
+  TEMP_FAILURE_RETRY(epoll_create1(3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'epoll_create1'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC));
+
+  int flag = 0;
+  epoll_create1(EPOLL_CLOEXEC);
+  TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC));
+}
+
+namespace i {
+int epoll_create1(int flags);
+
+void d() {
+  epoll_create1(0);
+  TEMP_FAILURE_RETRY(epoll_create1(0));
+}
+
+} // namespace i
+
+void e() {
+  epoll_create1(EPOLL_CLOEXEC);
+  TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC));
+}
+
+class G {
+public:
+  int epoll_create1(int flags);
+  void d() {
+epoll_create1(EPOLL_CLOEXEC);
+TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC));
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
 
 .. toctree::
android-cloexec-creat
+   android-cloexec-epoll-create1
android-cloexec-fopen
android-cloexec-memfd-create
android-cloexec-open
Index: docs/clang-tidy/checks/android-cloexec-epoll-create1.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-epoll-create1.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-epoll-create1
+
+android-cloexec-epoll-create1
+=
+
+``epoll_create1()`` should include ``EPOLL_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++
+
+  epoll_create1(0);
+
+  // becomes
+
+  epoll_create1(EPOLL_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -70,6 +70,12 @@
   ``AllowConditionalIntegerCasts`` -> ``AllowIntegerConditions``,
   ``AllowConditionalPointerCasts`` -> ``AllowPointerConditions``.
 
+- New `android-cloexec-epoll-create1
+  `_ check
+
+  Checks if the required file flag ``EPOLL_CLOEXEC`` is present in the argument of
+  ``epoll_create1()``.
+
 - New `android-cloexec-memfd_create
   `_ check
 
Index: clang-tidy/android/CloexecEpollCreate1Check.h
===
--- /dev/null
+++ clang-tidy/android/CloexecEpollCreate1Check.h
@@ -0,0 +1,35 @@
+//===--- CloexecEpollCreate1Check.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE1_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE1_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// Finds code that uses epoll_create1() without using the EPOLL_CLOEXEC flag.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-epoll

[PATCH] D35368: [clang-tidy] Add a close-on-exec check on inotify_init1() in Android module.

2017-08-11 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110750.
yawanng marked 2 inline comments as done.

https://reviews.llvm.org/D35368

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecInotifyInit1Check.cpp
  clang-tidy/android/CloexecInotifyInit1Check.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-inotify-init1.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-inotify-init1.cpp

Index: test/clang-tidy/android-cloexec-inotify-init1.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-inotify-init1.cpp
@@ -0,0 +1,64 @@
+// RUN: %check_clang_tidy %s android-cloexec-inotify-init1 %t
+
+#define IN_NONBLOCK 1
+#define __O_CLOEXEC 3
+#define IN_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+
+extern "C" int inotify_init1(int flags);
+
+void a() {
+  inotify_init1(IN_NONBLOCK);
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: 'inotify_init1' should use IN_CLOEXEC where possible [android-cloexec-inotify-init1]
+  // CHECK-FIXES: inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
+  TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK));
+  // CHECK-MESSAGES: :[[@LINE-1]]:47: warning: 'inotify_init1'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK | IN_CLOEXEC));
+}
+
+void f() {
+  inotify_init1(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'inotify_init1'
+  // CHECK-FIXES: inotify_init1(IN_CLOEXEC);
+  TEMP_FAILURE_RETRY(inotify_init1(0));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'inotify_init1'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(inotify_init1(IN_CLOEXEC));
+
+  int flag = 1;
+  inotify_init1(flag);
+  TEMP_FAILURE_RETRY(inotify_init1(flag));
+}
+
+namespace i {
+int inotify_init1(int flags);
+
+void d() {
+  inotify_init1(IN_NONBLOCK);
+  TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK));
+}
+
+} // namespace i
+
+void e() {
+  inotify_init1(IN_CLOEXEC);
+  TEMP_FAILURE_RETRY(inotify_init1(IN_CLOEXEC));
+  inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
+  TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK | IN_CLOEXEC));
+}
+
+class G {
+public:
+  int inotify_init1(int flags);
+  void d() {
+inotify_init1(IN_CLOEXEC);
+TEMP_FAILURE_RETRY(inotify_init1(IN_CLOEXEC));
+inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
+TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK | IN_CLOEXEC));
+  }
+};
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-inotify-init1
android-cloexec-memfd-create
android-cloexec-open
android-cloexec-socket
Index: docs/clang-tidy/checks/android-cloexec-inotify-init1.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-inotify-init1.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-inotify-init1
+
+android-cloexec-inotify-init1
+=
+
+``inotify_init1()`` should include ``IN_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++
+
+  inotify_init1(IN_NONBLOCK);
+
+  // becomes
+
+  inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -82,6 +82,12 @@
   Finds cases where integer division in a floating point context is likely to
   cause unintended loss of precision.
 
+- New `android-cloexec-inotify-init1
+  `_ check
+
+  Checks if the required file flag ``IN_CLOEXEC`` is present in the argument of
+  ``inotify_init1()``.
+
 - New `readability-static-accessed-through-instance
   `_ check
 
Index: clang-tidy/android/CloexecInotifyInit1Check.h
===
--- /dev/null
+++ clang-tidy/android/CloexecInotifyInit1Check.h
@@ -0,0 +1,35 @@
+//===--- CloexecInotifyInit1Check.h - clang-tidy-*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT1_H
+#define LLVM_

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

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

In https://reviews.llvm.org/D29660#839209, @gtbercea wrote:

> I have re-enabled the previous offloading tests and moved the new GPU 
> offloading tests to a new file which is disabled for linux (for now).
>
> 310718
>
> Alex thanks so much for the logs, they have been very useful to understand 
> what's going on.
>
> Aleksey, I have since tried to install a Clang version with the address 
> sanitizer enabled but without much success. Apart from turning on the 
> sanitizer in the cmake using the -DLLVM_USE_SANITIZER="Address" flag is there 
> any other flag that I need to pass to cmake?
>  I am trying to run this on my macbook x86_64 and OS X 10.11. I am getting 
> the following error when building the compiler:
>
> [2966/4254] Linking CXX shared library lib/libc++abi.1.0.dylib
>  FAILED: lib/libc++abi.1.0.dylib
>  Undefined symbols for architecture x86_64:
>
>   "___asan_after_dynamic_init", referenced from:
>   __GLOBAL__sub_I_cxa_default_handlers.cpp in cxa_default_handlers.cpp.o
>   "___asan_before_dynamic_init", referenced from:
>   __GLOBAL__sub_I_cxa_default_handlers.cpp in cxa_default_handlers.cpp.o
>
> [...]
>  ld: symbol(s) not found for architecture x86_64


Actually, you can run our bot, it is in zorg (http://llvm.org/git/zorg.git), 
zorg/buildbot/builders/sanitizers/buildbot_fast.sh (the one I linked the last 
time).


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D35367: [clang-tidy] Add a close-on-exec check on epoll_create() in Android module.

2017-08-11 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110751.

https://reviews.llvm.org/D35367

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

Index: test/clang-tidy/android-cloexec-epoll-create.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-epoll-create.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s android-cloexec-epoll-create %t
+
+extern "C" int epoll_create(int size);
+
+void f() {
+  epoll_create(0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer epoll_create() to epoll_create1() because epoll_create1() allows EPOLL_CLOEXEC [android-cloexec-epoll-create]
+  // CHECK-FIXES: epoll_create1(EPOLL_CLOEXEC);
+}
+
+namespace i {
+int epoll_create(int size);
+void g() {
+  epoll_create(0);
+}
+} // namespace i
+
+class C {
+public:
+  int epoll_create(int size);
+  void h() {
+epoll_create(0);
+  }
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -5,6 +5,7 @@
 
 .. toctree::
android-cloexec-creat
+   android-cloexec-epoll-create
android-cloexec-fopen
android-cloexec-memfd-create
android-cloexec-open
Index: docs/clang-tidy/checks/android-cloexec-epoll-create.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-epoll-create.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - android-cloexec-epoll-create
+
+android-cloexec-epoll-create
+
+
+The usage of ``epoll_create()`` is not recommended, it's better to use
+``epoll_create1()``, which allows close-on-exec.
+
+Examples:
+
+.. code-block:: c++
+
+  epoll_create(size);
+
+  // becomes
+
+  epoll_create1(EPOLL_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -70,6 +70,11 @@
   ``AllowConditionalIntegerCasts`` -> ``AllowIntegerConditions``,
   ``AllowConditionalPointerCasts`` -> ``AllowPointerConditions``.
 
+- New `android-cloexec-epoll-create
+  `_ check
+
+  Detects usage of ``epoll_create()``.
+
 - New `android-cloexec-memfd_create
   `_ check
 
Index: clang-tidy/android/CloexecEpollCreateCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecEpollCreateCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecEpollCreateCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// epoll_create() is better to be replaced by epoll_create1().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-epoll-create.html
+class CloexecEpollCreateCheck : public CloexecCheck {
+public:
+  CloexecEpollCreateCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_EPOLL_CREATE_H
Index: clang-tidy/android/CloexecEpollCreateCheck.cpp
===
--- /dev/null
+++ clang-tidy/android/CloexecEpollCreateCheck.cpp
@@ -0,0 +1,36 @@
+//===--- CloexecEpollCreateCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecEpollCreateCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecEpollCreateC

[PATCH] D35370: [clang-tidy] Add a close-on-exec check on inotify_init() in Android module.

2017-08-11 Thread Yan Wang via Phabricator via cfe-commits
yawanng updated this revision to Diff 110749.
yawanng marked an inline comment as done.

https://reviews.llvm.org/D35370

Files:
  clang-tidy/android/AndroidTidyModule.cpp
  clang-tidy/android/CMakeLists.txt
  clang-tidy/android/CloexecInotifyInitCheck.cpp
  clang-tidy/android/CloexecInotifyInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/android-cloexec-inotify-init.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/android-cloexec-inotify-init.cpp

Index: test/clang-tidy/android-cloexec-inotify-init.cpp
===
--- /dev/null
+++ test/clang-tidy/android-cloexec-inotify-init.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s android-cloexec-inotify-init %t
+
+extern "C" int inotify_init();
+
+void f() {
+  inotify_init();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer inotify_init() to inotify_init1() because inotify_init1() allows IN_CLOEXEC [android-cloexec-inotify-init]
+  // CHECK-FIXES: inotify_init1(IN_CLOEXEC);
+}
+
+namespace i {
+int inotify_init();
+void g() {
+  inotify_init();
+}
+} // namespace i
+
+class C {
+public:
+  int inotify_init();
+  void h() {
+inotify_init();
+  }
+};
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-inotify-init
android-cloexec-memfd-create
android-cloexec-open
android-cloexec-socket
Index: docs/clang-tidy/checks/android-cloexec-inotify-init.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/android-cloexec-inotify-init.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - android-cloexec-inotify-init
+
+android-cloexec-inotify-init
+
+
+The usage of ``inotify_init()`` is not recommended, it's better to use
+``inotify_init1()``.
+
+Examples:
+
+.. code-block:: c++
+
+  inotify_init();
+
+  // becomes
+
+  inotify_init1(IN_CLOEXEC);
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -70,6 +70,11 @@
   ``AllowConditionalIntegerCasts`` -> ``AllowIntegerConditions``,
   ``AllowConditionalPointerCasts`` -> ``AllowPointerConditions``.
 
+- New `android-cloexec-inotify-init
+  `_ check
+
+  Detects usage of ``inotify_init()``.
+
 - New `android-cloexec-memfd_create
   `_ check
 
Index: clang-tidy/android/CloexecInotifyInitCheck.h
===
--- /dev/null
+++ clang-tidy/android/CloexecInotifyInitCheck.h
@@ -0,0 +1,35 @@
+//===--- CloexecInotifyInitCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// inotify_init() is better to be replaced by inotify_init1().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-inotify-init.html
+class CloexecInotifyInitCheck : public CloexecCheck {
+public:
+  CloexecInotifyInitCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_INOTIFY_INIT_H
Index: clang-tidy/android/CloexecInotifyInitCheck.cpp
===
--- /dev/null
+++ clang-tidy/android/CloexecInotifyInitCheck.cpp
@@ -0,0 +1,34 @@
+//===--- CloexecInotifyInitCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "CloexecInotifyInitCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecInotifyInitCh

[clang-tools-extra] r310732 - Enable exceptions for this test case to speculatively fix the build bots.

2017-08-11 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Aug 11 09:46:45 2017
New Revision: 310732

URL: http://llvm.org/viewvc/llvm-project?rev=310732&view=rev
Log:
Enable exceptions for this test case to speculatively fix the build bots.

Hopefully corrects: 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/15666

Modified:
clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp?rev=310732&r1=310731&r2=310732&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp Fri 
Aug 11 09:46:45 2017
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s hicpp-exception-baseclass %t
+// RUN: %check_clang_tidy %s hicpp-exception-baseclass %t -- -- 
-fcxx-exceptions
 
 namespace std {
 class exception {};
@@ -20,7 +20,7 @@ void problematic() {
 throw non_derived_exception(); // Some class is not allowed
 // CHECK-MESSAGES: [[@LINE-1]]:5: warning: throwing an exception whose type is 
not derived from 'std::exception'
 // CHECK-MESSAGES: 8:1: note: type defined here
-  } catch (non_derived_exception &e) { 
+  } catch (non_derived_exception &e) {
   }
   throw non_derived_exception(); // Bad
 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: throwing an exception whose type is 
not derived from 'std::exception'


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


Re: r310704 - Revert r302670 for the upcoming 5.0.0 release

2017-08-11 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r310728.

On Fri, Aug 11, 2017 at 4:39 AM, Stefan Maksimovic via cfe-commits
 wrote:
> Author: smaksimovic
> Date: Fri Aug 11 04:39:07 2017
> New Revision: 310704
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310704&view=rev
> Log:
> Revert r302670 for the upcoming 5.0.0 release
>
> This is causing failures when compiling clang with -O3
> as one of the structures used by clang is passed by
> value and uses the fastcc calling convention.
>
> Faliures manifest for stage2 mips build.
>
> Removed:
> cfe/trunk/test/CodeGen/mips-aggregate-arg.c
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=310704&r1=310703&r2=310704&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Aug 11 04:39:07 2017
> @@ -6821,14 +6821,6 @@ MipsABIInfo::classifyArgumentType(QualTy
>return getNaturalAlignIndirect(Ty, RAA == 
> CGCXXABI::RAA_DirectInMemory);
>  }
>
> -// Use indirect if the aggregate cannot fit into registers for
> -// passing arguments according to the ABI
> -unsigned Threshold = IsO32 ? 16 : 64;
> -
> -if(getContext().getTypeSizeInChars(Ty) > 
> CharUnits::fromQuantity(Threshold))
> -  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
> - getContext().getTypeAlign(Ty) / 8 > 
> Align);
> -
>  // If we have reached here, aggregates are passed directly by coercing to
>  // another structure type. Padding is inserted if the offset of the
>  // aggregate is unaligned.
>
> Removed: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=310703&view=auto
> ==
> --- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (original)
> +++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c (removed)
> @@ -1,38 +0,0 @@
> -// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
> FileCheck -check-prefix=O32 %s
> -// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
> -target-abi n32 | FileCheck -check-prefix=N32-N64 %s
> -// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
> -target-abi n64 | FileCheck -check-prefix=N32-N64 %s
> -
> -struct t1 {
> -  char t1[10];
> -};
> -
> -struct t2 {
> -  char t2[20];
> -};
> -
> -struct t3 {
> -  char t3[65];
> -};
> -
> -extern struct t1 g1;
> -extern struct t2 g2;
> -extern struct t3 g3;
> -extern void f1(struct t1);
> -extern void f2(struct t2);
> -extern void f3(struct t3);
> -
> -void f() {
> -
> -// O32:  call void @f1(i32 inreg %{{[0-9]+}}, i32 inreg %{{[0-9]+}}, i16 
> inreg %{{[0-9]+}})
> -// O32:  call void @f2(%struct.t2* byval align 4 %{{.*}})
> -// O32:  call void @f3(%struct.t3* byval align 4 %{{.*}})
> -
> -// N32-N64:  call void @f1(i64 inreg %{{[0-9]+}}, i16 inreg %{{[0-9]+}})
> -// N32-N64:  call void @f2(i64 inreg %{{[0-9]+}}, i64 inreg %{{[0-9]+}}, i32 
> inreg %{{[0-9]+}})
> -// N32-N64:  call void @f3(%struct.t3* byval align 8 %{{.*}})
> -
> -  f1(g1);
> -  f2(g2);
> -  f3(g3);
> -}
> -
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r310727 - Add hicpp-exception-baseclass to the HIC++ module.

2017-08-11 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Aug 11 09:31:51 2017
New Revision: 310727

URL: http://llvm.org/viewvc/llvm-project?rev=310727&view=rev
Log:
Add hicpp-exception-baseclass to the HIC++ module.

This enforces that throwing an exception in C++ requires that exception to 
inherit from std::exception.

Patch by Jonas Toth.

Added:
clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-exception-baseclass.rst
clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt?rev=310727&r1=310726&r2=310727&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt Fri Aug 11 09:31:51 
2017
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyHICPPModule
+  ExceptionBaseclassCheck.cpp
   NoAssemblerCheck.cpp
   HICPPTidyModule.cpp
 

Added: clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp?rev=310727&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp Fri 
Aug 11 09:31:51 2017
@@ -0,0 +1,49 @@
+//===--- ExceptionBaseclassCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ExceptionBaseclassCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace hicpp {
+
+void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  Finder->addMatcher(
+  cxxThrowExpr(
+  allOf(
+  has(expr(unless(hasType(cxxRecordDecl(
+  isSameOrDerivedFrom(hasName("std::exception"))),
+  eachOf(has(expr(hasType(namedDecl().bind("decl", 
anything(
+  .bind("bad_throw"),
+  this);
+}
+
+void ExceptionBaseclassCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *BadThrow = Result.Nodes.getNodeAs("bad_throw");
+  diag(BadThrow->getLocStart(),
+   "throwing an exception whose type is not derived from 'std::exception'")
+  << BadThrow->getSourceRange();
+
+  const auto *TypeDecl = Result.Nodes.getNodeAs("decl");
+  if (TypeDecl != nullptr)
+diag(TypeDecl->getLocStart(), "type defined here", DiagnosticIDs::Note);
+}
+
+} // namespace hicpp
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.h?rev=310727&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.h (added)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/ExceptionBaseclassCheck.h Fri Aug 
11 09:31:51 2017
@@ -0,0 +1,35 @@
+//===--- ExceptionBaseclassCheck.h - clang-tidy--*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTION_BASECLASS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_HICPP_EXCEPTION_BASECLASS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace hicpp {
+
+/// Check for thrown exceptions and enforce they are all derived from 
std::exception.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/hicpp-exception-baseclass.html
+class ExceptionBaseclassCheck : public ClangTidyCheck {
+public:
+  ExceptionBaseclassCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registe

[PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy

2017-08-11 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho added a comment.

Should I update the other tests in QualTypeNamesTest.cpp to use multiline 
strings as well?


https://reviews.llvm.org/D36610



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


[PATCH] D36567: [Bash-autocompletion] Add --autocomplete flag to 5.0 release notes

2017-08-11 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

Hans already merged it in r310723.


Repository:
  rL LLVM

https://reviews.llvm.org/D36567



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


[PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy

2017-08-11 Thread Sterling Augustine via Phabricator via cfe-commits
saugustine accepted this revision.
saugustine added a comment.
This revision is now accepted and ready to land.

This is a good change as far as functionality, but I defer to others on the 
style and other details.


https://reviews.llvm.org/D36610



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


[PATCH] D36567: [Bash-autocompletion] Add --autocomplete flag to 5.0 release notes

2017-08-11 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

Yuka,

You seem to have committed a release note for 5.0 to SVN trunk. What you 
should've done is to do that to the 5.0 branch. I'll correct the error for you.


Repository:
  rL LLVM

https://reviews.llvm.org/D36567



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


Re: r310700 - [Bash-autocompletion] Add --autocomplete flag to 5.0 release notes

2017-08-11 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r310723. Thanks!

On Fri, Aug 11, 2017 at 2:44 AM, Yuka Takahashi via cfe-commits
 wrote:
> Author: yamaguchi
> Date: Fri Aug 11 02:44:42 2017
> New Revision: 310700
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310700&view=rev
> Log:
> [Bash-autocompletion] Add --autocomplete flag to 5.0 release notes
>
> Summary:
> I thought we should add this information to release notes, because we
> added a new flag to clang driver.
>
> Reviewers: v.g.vassilev, teemperor, ruiu
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D36567
>
> Modified:
> cfe/trunk/docs/ReleaseNotes.rst
>
> Modified: cfe/trunk/docs/ReleaseNotes.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=310700&r1=310699&r2=310700&view=diff
> ==
> --- cfe/trunk/docs/ReleaseNotes.rst (original)
> +++ cfe/trunk/docs/ReleaseNotes.rst Fri Aug 11 02:44:42 2017
> @@ -75,7 +75,7 @@ Non-comprehensive list of changes in thi
>  New Compiler Flags
>  --
>
> -The option 
> +- --autocomplete was implemented to obtain a list of flags and its 
> arguments. This is used for shell autocompletion.
>
>  Deprecated Compiler Flags
>  -
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r310694 - Implement latest feature test macro recommendations, P0096R4.

2017-08-11 Thread Hans Wennborg via cfe-commits
Thanks! I've merged r309054 in r310721 to make it apply cleanly, and
this one in r310722.

On Thu, Aug 10, 2017 at 8:42 PM, Richard Smith  wrote:
> Hi Hans, this should go onto the Clang 5 branch. Thanks!
>
> On 10 August 2017 at 20:39, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Thu Aug 10 20:39:40 2017
>> New Revision: 310694
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310694&view=rev
>> Log:
>> Implement latest feature test macro recommendations, P0096R4.
>>
>> Modified:
>> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>> cfe/trunk/test/Lexer/cxx-features.cpp
>> cfe/trunk/www/cxx_status.html
>>
>> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=310694&r1=310693&r2=310694&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
>> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu Aug 10 20:39:40 2017
>> @@ -498,6 +498,8 @@ static void InitializeCPlusPlusFeatureTe
>>  Builder.defineMacro("__cpp_ref_qualifiers", "200710");
>>  Builder.defineMacro("__cpp_alias_templates", "200704");
>>}
>> +  if (LangOpts.ThreadsafeStatics)
>> +Builder.defineMacro("__cpp_threadsafe_static_init", "200806");
>>
>>// C++14 features.
>>if (LangOpts.CPlusPlus14) {
>> @@ -520,6 +522,7 @@ static void InitializeCPlusPlusFeatureTe
>>  Builder.defineMacro("__cpp_noexcept_function_type", "201510");
>>  Builder.defineMacro("__cpp_capture_star_this", "201603");
>>  Builder.defineMacro("__cpp_if_constexpr", "201606");
>> +Builder.defineMacro("__cpp_deduction_guides", "201611");
>>  Builder.defineMacro("__cpp_template_auto", "201606");
>>  Builder.defineMacro("__cpp_namespace_attributes", "201411");
>>  Builder.defineMacro("__cpp_enumerator_attributes", "201411");
>> @@ -529,8 +532,6 @@ static void InitializeCPlusPlusFeatureTe
>>  Builder.defineMacro("__cpp_structured_bindings", "201606");
>>  Builder.defineMacro("__cpp_nontype_template_args", "201411");
>>  Builder.defineMacro("__cpp_fold_expressions", "201603");
>> -// FIXME: This is not yet listed in SD-6.
>> -Builder.defineMacro("__cpp_deduction_guides", "201611");
>>}
>>if (LangOpts.AlignedAllocation)
>>  Builder.defineMacro("__cpp_aligned_new", "201606");
>>
>> Modified: cfe/trunk/test/Lexer/cxx-features.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/cxx-features.cpp?rev=310694&r1=310693&r2=310694&view=diff
>>
>> ==
>> --- cfe/trunk/test/Lexer/cxx-features.cpp (original)
>> +++ cfe/trunk/test/Lexer/cxx-features.cpp Thu Aug 10 20:39:40 2017
>> @@ -4,7 +4,7 @@
>>  // RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -fsized-deallocation
>> -verify %s
>>  // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation
>> -verify %s
>>  // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation
>> -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
>> -// RUN: %clang_cc1 -fno-rtti -verify %s -DNO_EXCEPTIONS -DNO_RTTI
>> +// RUN: %clang_cc1 -fno-rtti -fno-threadsafe-statics -verify %s
>> -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS
>>  // RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify
>> %s
>>
>>  // expected-no-diagnostics
>> @@ -26,11 +26,11 @@
>>  #error "wrong value for __cpp_hex_float"
>>  #endif
>>
>> -#if check(inline_variables, 0, 0, 0, 201606) // FIXME: provisional name
>> +#if check(inline_variables, 0, 0, 0, 201606)
>>  #error "wrong value for __cpp_inline_variables"
>>  #endif
>>
>> -#if check(aligned_new, 0, 0, 0, 201606) // FIXME: provisional name
>> +#if check(aligned_new, 0, 0, 0, 201606)
>>  #error "wrong value for __cpp_aligned_new"
>>  #endif
>>
>> @@ -48,7 +48,7 @@
>>
>>  // constexpr checked below
>>
>> -#if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name
>> +#if check(if_constexpr, 0, 0, 0, 201606)
>>  #error "wrong value for __cpp_if_constexpr"
>>  #endif
>>
>> @@ -56,11 +56,11 @@
>>
>>  // static_assert checked below
>>
>> -#if check(deduction_guides, 0, 0, 0, 201611) // FIXME: provisional name
>> +#if check(deduction_guides, 0, 0, 0, 201611)
>>  #error "wrong value for __cpp_deduction_guides"
>>  #endif
>>
>> -#if check(template_auto, 0, 0, 0, 201606) // FIXME: provisional name
>> +#if check(template_auto, 0, 0, 0, 201606)
>>  #error "wrong value for __cpp_template_auto"
>>  #endif
>>
>> @@ -80,7 +80,7 @@
>>
>>  // inheriting_constructors checked below
>>
>> -#if check(variadic_using, 0, 0, 0, 201611) // FIXME: provisional name
>> +#if check(variadic_using, 0, 0, 0, 201611)
>>  #error "wrong value for __cpp_variadic_using"
>>  #endif
>>
>> @@ -163,6 +163,10 @@
>>  #error "wrong value for __cpp_user_defined_literals"
>>  #endif
>>
>> +#if defined(NO_THREADSAFE_STATICS) ? check(threadsafe_static_init, 0,

Re: r310692 - PR33850: Update cxx_dr_status for Clang 5 branch.

2017-08-11 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r310720.

On Thu, Aug 10, 2017 at 8:14 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Thu Aug 10 20:14:20 2017
> New Revision: 310692
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310692&view=rev
> Log:
> PR33850: Update cxx_dr_status for Clang 5 branch.
>
> Modified:
> cfe/trunk/test/CXX/drs/dr20xx.cpp
> cfe/trunk/test/CXX/drs/dr4xx.cpp
> cfe/trunk/www/cxx_dr_status.html
> cfe/trunk/www/make_cxx_dr_status
>
> Modified: cfe/trunk/test/CXX/drs/dr20xx.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr20xx.cpp?rev=310692&r1=310691&r2=310692&view=diff
> ==
> --- cfe/trunk/test/CXX/drs/dr20xx.cpp (original)
> +++ cfe/trunk/test/CXX/drs/dr20xx.cpp Thu Aug 10 20:14:20 2017
> @@ -10,7 +10,7 @@
>  #define static_assert(...) _Static_assert(__VA_ARGS__)
>  #endif
>
> -namespace dr2094 { // dr2094: 5.0
> +namespace dr2094 { // dr2094: 5
>struct A { int n; };
>struct B { volatile int n; };
>static_assert(__is_trivially_copyable(volatile int), "");
>
> Modified: cfe/trunk/test/CXX/drs/dr4xx.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr4xx.cpp?rev=310692&r1=310691&r2=310692&view=diff
> ==
> --- cfe/trunk/test/CXX/drs/dr4xx.cpp (original)
> +++ cfe/trunk/test/CXX/drs/dr4xx.cpp Thu Aug 10 20:14:20 2017
> @@ -1202,7 +1202,7 @@ namespace dr495 { // dr495: 3.5
>long n2 = s2;
>  }
>
> -namespace dr496 { // dr496: sup dr2094
> +namespace dr496 { // dr496: sup 2094
>struct A { int n; };
>struct B { volatile int n; };
>int check1[ __is_trivially_copyable(const int) ? 1 : -1];
>
> Modified: cfe/trunk/www/cxx_dr_status.html
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=310692&r1=310691&r2=310692&view=diff
> ==
> --- cfe/trunk/www/cxx_dr_status.html (original)
> +++ cfe/trunk/www/cxx_dr_status.html Thu Aug 10 20:14:20 2017
> @@ -591,7 +591,7 @@
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#92";>92
>  CD4
>  Should exception-specifications be part of the type 
> system?
> -Clang 4 (C++17 onwards)
> +Clang 4 (C++17 onwards)
>
>
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#93";>93
> @@ -813,7 +813,7 @@
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#129";>129
>  CD3
>  Stability of uninitialized auto variables
> -Duplicate of 616
> +Duplicate of 616
>
>
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#130";>130
> @@ -1480,7 +1480,7 @@ accessible?
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#240";>240
>  CD3
>  Uninitialized values and undefined behavior
> -Duplicate of 616
> +Duplicate of 616
>
>
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#241";>241
> @@ -1594,7 +1594,7 @@ accessible?
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#259";>259
>  CD1
>  Restrictions on explicit specialization and instantiation
> -Clang 4
> +Clang 4
>
>
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#260";>260
> @@ -1913,7 +1913,7 @@ of class templates
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#312";>312
>  CD3
>  “use” of invalid pointer value not defined
> -Duplicate of 616
> +Duplicate of 616
>
>
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#313";>313
> @@ -2279,7 +2279,7 @@ of class templates
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373";>373
>  C++11
>  Lookup on namespace qualified name in using-directive
> -SVN
> +Clang 5
>
>
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374";>374
> @@ -3017,7 +3017,7 @@ of class templates
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#496";>496
>  CD3
>  Is a volatile-qualified type really a POD?
> -Superseded by  href="#dr2094">dr2094
> +Superseded by  href="#2094">2094
>
>
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#497";>497
> @@ -3541,7 +3541,7 @@ and POD class
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#583";>583
>  CD3
>  Relational pointer comparisons against the null pointer constant
> -Clang 4
> +Clang 4
>
>
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#584";>584
> @@ -3613,7 +3613,7 @@ and POD class
>   href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#595";>595
>  dup
>  Exception specifications in templates instantiated from class 
>

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

I have re-enabled the previous offloading tests and moved the new GPU 
offloading tests to a new file which is disabled for linux (for now).

310718

Alex thanks so much for the logs, they have been very useful to understand 
what's going on.

Aleksey, I have since tried to install a Clang version with the address 
sanitizer enabled but without much success. Apart from turning on the sanitizer 
in the cmake using the -DLLVM_USE_SANITIZER="Address" flag is there any other 
flag that I need to pass to cmake?
I am trying to run this on my macbook x86_64 and OS X 10.11. I am getting the 
following error when building the compiler:

[2966/4254] Linking CXX shared library lib/libc++abi.1.0.dylib
FAILED: lib/libc++abi.1.0.dylib
Undefined symbols for architecture x86_64:

  "___asan_after_dynamic_init", referenced from:
  __GLOBAL__sub_I_cxa_default_handlers.cpp in cxa_default_handlers.cpp.o
  "___asan_before_dynamic_init", referenced from:
  __GLOBAL__sub_I_cxa_default_handlers.cpp in cxa_default_handlers.cpp.o

[...]
ld: symbol(s) not found for architecture x86_64


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


Re: r310691 - PR33489: A function-style cast to a deduced class template specialization type is type-dependent if it can't be resolved due to a type-dependent argument.

2017-08-11 Thread Hans Wennborg via cfe-commits
Thanks! r310719.

On Thu, Aug 10, 2017 at 7:08 PM, Richard Smith  wrote:
> Hi Hans, this fixes a bug you wanted to treat as a 5.0 release blocker, so
> should be ported to the branch :)
>
> On 10 August 2017 at 19:04, Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Thu Aug 10 19:04:19 2017
>> New Revision: 310691
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310691&view=rev
>> Log:
>> PR33489: A function-style cast to a deduced class template specialization
>> type is type-dependent if it can't be resolved due to a type-dependent
>> argument.
>>
>> Modified:
>> cfe/trunk/lib/AST/ExprCXX.cpp
>> cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
>>
>> Modified: cfe/trunk/lib/AST/ExprCXX.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=310691&r1=310690&r2=310691&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ExprCXX.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprCXX.cpp Thu Aug 10 19:04:19 2017
>> @@ -1052,7 +1052,9 @@ CXXUnresolvedConstructExpr::CXXUnresolve
>>:Type->getType()->isRValueReferenceType()? VK_XValue
>>:VK_RValue),
>>   OK_Ordinary,
>> - Type->getType()->isDependentType(), true, true,
>> + Type->getType()->isDependentType() ||
>> + Type->getType()->getContainedDeducedType(),
>> + true, true,
>>   Type->getType()->containsUnexpandedParameterPack()),
>>  Type(Type),
>>  LParenLoc(LParenLoc),
>>
>> Modified:
>> cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=310691&r1=310690&r2=310691&view=diff
>>
>> ==
>> --- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
>> (original)
>> +++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Thu
>> Aug 10 19:04:19 2017
>> @@ -286,6 +286,29 @@ namespace tuple_tests {
>>}
>>  }
>>
>> +namespace dependent {
>> +  template struct X {
>> +X(T);
>> +  };
>> +  template int Var(T t) {
>> +X x(t);
>> +return X(x) + 1; // expected-error {{invalid operands}}
>> +  }
>> +  template int Cast(T t) {
>> +return X(X(t)) + 1; // expected-error {{invalid operands}}
>> +  }
>> +  template int New(T t) {
>> +return X(new X(t)) + 1; // expected-error {{invalid operands}}
>> +  };
>> +  template int Var(float); // expected-note {{instantiation of}}
>> +  template int Cast(float); // expected-note {{instantiation of}}
>> +  template int New(float); // expected-note {{instantiation of}}
>> +  template int operator+(X, int);
>> +  template int Var(int);
>> +  template int Cast(int);
>> +  template int New(int);
>> +}
>> +
>>  #else
>>
>>  // expected-no-diagnostics
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36186: [clang-diff] Improve and test getNodeValue

2017-08-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Tooling/ASTDiff/ASTDiff.cpp:428
+Value += getRelativeName(V) + "(" + V->getType().getAsString(TypePP) + ")";
+if (auto *C = dyn_cast(D)) {
+  for (auto *Init : C->inits()) {

It looks like you're doing a lot of work for constructors here, but I don't 
seem them tested in this patch.


https://reviews.llvm.org/D36186



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


[PATCH] D35948: [CommonOptionsParser] Expose ArgumentsAdjustingCompilationDatabase

2017-08-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a reviewer: klimek.
arphaman added a comment.

@klimek Ping.


https://reviews.llvm.org/D35948



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


[PATCH] D36184: [clang-diff] Filter AST nodes

2017-08-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: test/Tooling/clang-diff-ast.cpp:68
+// nodes from other files are excluded
+// CHECK-NOT {{.}}
+#include "clang-diff-ast.cpp"

johannes wrote:
> arphaman wrote:
> > 1) Missing ':'
> > 2) What exactly does this regex accomplish? Right now it will match any 
> > character which doesn't look correct
> I want to assert that there is no output here, because other files are 
> excluded, there may be a better way..
Ok, fair enough.


https://reviews.llvm.org/D36184



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


r310715 - [mips] Add missing mips-registered-target to mips test.

2017-08-11 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Fri Aug 11 08:23:23 2017
New Revision: 310715

URL: http://llvm.org/viewvc/llvm-project?rev=310715&view=rev
Log:
[mips] Add missing mips-registered-target to mips test.

Modified:
cfe/trunk/test/Driver/mips-abi.c

Modified: cfe/trunk/test/Driver/mips-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abi.c?rev=310715&r1=310714&r2=310715&view=diff
==
--- cfe/trunk/test/Driver/mips-abi.c (original)
+++ cfe/trunk/test/Driver/mips-abi.c Fri Aug 11 08:23:23 2017
@@ -1,5 +1,7 @@
 // Check passing Mips ABI options to the backend.
 //
+// REQUIRES: mips-registered-target
+//
 // RUN: %clang -target mips-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS32R2-O32 %s
 // RUN: %clang -target mips64-linux-gnu -mips32r2 -mabi=32 -### -c %s 2>&1 \


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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 110731.
JonasToth added a comment.

remove manual source range creation, where i forgot it before


https://reviews.llvm.org/D36354

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.h
  clang-tidy/utils/Matchers.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-owning-memory.cpp

Index: test/clang-tidy/cppcoreguidelines-owning-memory.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-owning-memory.cpp
@@ -0,0 +1,347 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-owning-memory %t
+
+namespace gsl {
+template 
+using owner = T;
+} // namespace gsl
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(gsl::owner resource) : memory(resource) {}
+  unique_ptr(const unique_ptr &) = default;
+
+  ~unique_ptr() { delete memory; }
+
+private:
+  gsl::owner memory;
+};
+
+void takes_owner(gsl::owner owned_int) {
+}
+
+void takes_pointer(int *unowned_int) {
+}
+
+void takes_owner_and_more(int some_int, gsl::owner owned_int, float f) {
+}
+
+template 
+void takes_templated_owner(gsl::owner owned_T) {
+}
+
+gsl::owner returns_owner1() { return gsl::owner(new int(42)); } // Ok
+gsl::owner returns_owner2() { return new int(42); } // Ok
+
+int *returns_no_owner1() { return nullptr; }
+int *returns_no_owner2() {
+  return new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+int *returns_no_owner3() {
+  int *should_be_owner = new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  return should_be_owner;
+}
+int *returns_no_owner4() {
+  gsl::owner owner = new int(42);
+  return owner;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+
+unique_ptr returns_no_owner5() {
+  return unique_ptr(new int(42)); // Ok
+}
+
+/// FIXME CSA finds it, but the report is misleading.
+void csa_not_finding_leak() {
+  gsl::owner o1 = new int(42); // Ok
+
+  gsl::owner o2 = o1; // Ok
+  o2 = new int(45); // conceptual leak, the memory from o1 is now leaked, since its considered moved in the guideLINEs
+
+  delete o2;
+  // actual leak occurs here, its found, but mixed
+  delete o1;
+}
+
+void test_assignment_and_initialization() {
+  int stack_int1 = 15;
+  int stack_int2;
+
+  gsl::owner owned_int1 = &stack_int1; // BAD
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing neither with an owner nor a recognized resource
+
+  gsl::owner owned_int2;
+  owned_int2 = &stack_int2; // BAD since no owner, bad since uninitialized
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning neither an owner nor a recognized resource
+
+  gsl::owner owned_int3 = new int(42); // Good
+  owned_int3 = nullptr; // Good
+
+  gsl::owner owned_int4(nullptr); // Ok
+  owned_int4 = new int(42); // Good
+
+  gsl::owner owned_int5 = owned_int3; // Good
+
+  gsl::owner owned_int6{nullptr}; // Ok
+  owned_int6 = owned_int4; // Good
+
+  // FIXME, flow analysis for the case of reassignment. Value must be released before
+  owned_int6 = owned_int3; // BAD, because reassignment without resource release
+
+  auto owned_int7 = returns_owner1(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  const auto owned_int8 = returns_owner2(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  gsl::owner owned_int9 = returns_owner1(); // Ok
+  int *unowned_int3 = returns_owner1(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+
+  gsl::owner owned_int10;
+  owned_int10 = returns_owner1(); // Ok
+
+  int *unowned_int4;
+  unowned_int4 = returns_owner1(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning newly created owner/resource to non-owner
+
+  gsl::owner owned_int11 = returns_no_owner1(); // Bad since no owner
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing neither with an owner nor a recognized resource
+
+  gsl::owner owned_int12;
+  owned_int12 = returns_no_owner1(); // Bad since no owner
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning neither an owner nor a recognized resource
+
+  int *unowned_int5 = returns_no_owner1(); // Ok
+  int *unowned_int6;
+  unowned_int6 = return

[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked an inline comment as done.
JonasToth added inline comments.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:188
+diag(OwnerAssignment->getLocStart(),
+ "assigning neither an owner nor a recognized resource")
+<< SourceRange(OwnerAssignment->getLocStart(),

aaron.ballman wrote:
> Same comments here as above about "owner" and "recognized resource". I think 
> you want to talk about `gsl::owner<>` where you use "owner" and drop 
> "recognized resource" (because such a resource returns a 
> `gsl::owner<>`-flagged type, if I understand properly).
ideally every created resource would be flagged as `gsl::owner<>`, but for 
example `fopen`, `malloc` and friends can't, but would benefit the most from 
such a check (+ flow analysis if the owner gets consumed on every path)


https://reviews.llvm.org/D36354



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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 110730.
JonasToth marked 6 inline comments as done.
JonasToth added a comment.

- order release notes
- address aarons comments
- adjust diagnostic for function arguments


https://reviews.llvm.org/D36354

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.h
  clang-tidy/utils/Matchers.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-owning-memory.cpp

Index: test/clang-tidy/cppcoreguidelines-owning-memory.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-owning-memory.cpp
@@ -0,0 +1,347 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-owning-memory %t
+
+namespace gsl {
+template 
+using owner = T;
+} // namespace gsl
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(gsl::owner resource) : memory(resource) {}
+  unique_ptr(const unique_ptr &) = default;
+
+  ~unique_ptr() { delete memory; }
+
+private:
+  gsl::owner memory;
+};
+
+void takes_owner(gsl::owner owned_int) {
+}
+
+void takes_pointer(int *unowned_int) {
+}
+
+void takes_owner_and_more(int some_int, gsl::owner owned_int, float f) {
+}
+
+template 
+void takes_templated_owner(gsl::owner owned_T) {
+}
+
+gsl::owner returns_owner1() { return gsl::owner(new int(42)); } // Ok
+gsl::owner returns_owner2() { return new int(42); } // Ok
+
+int *returns_no_owner1() { return nullptr; }
+int *returns_no_owner2() {
+  return new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+int *returns_no_owner3() {
+  int *should_be_owner = new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  return should_be_owner;
+}
+int *returns_no_owner4() {
+  gsl::owner owner = new int(42);
+  return owner;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+
+unique_ptr returns_no_owner5() {
+  return unique_ptr(new int(42)); // Ok
+}
+
+/// FIXME CSA finds it, but the report is misleading.
+void csa_not_finding_leak() {
+  gsl::owner o1 = new int(42); // Ok
+
+  gsl::owner o2 = o1; // Ok
+  o2 = new int(45); // conceptual leak, the memory from o1 is now leaked, since its considered moved in the guideLINEs
+
+  delete o2;
+  // actual leak occurs here, its found, but mixed
+  delete o1;
+}
+
+void test_assignment_and_initialization() {
+  int stack_int1 = 15;
+  int stack_int2;
+
+  gsl::owner owned_int1 = &stack_int1; // BAD
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing neither with an owner nor a recognized resource
+
+  gsl::owner owned_int2;
+  owned_int2 = &stack_int2; // BAD since no owner, bad since uninitialized
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning neither an owner nor a recognized resource
+
+  gsl::owner owned_int3 = new int(42); // Good
+  owned_int3 = nullptr; // Good
+
+  gsl::owner owned_int4(nullptr); // Ok
+  owned_int4 = new int(42); // Good
+
+  gsl::owner owned_int5 = owned_int3; // Good
+
+  gsl::owner owned_int6{nullptr}; // Ok
+  owned_int6 = owned_int4; // Good
+
+  // FIXME, flow analysis for the case of reassignment. Value must be released before
+  owned_int6 = owned_int3; // BAD, because reassignment without resource release
+
+  auto owned_int7 = returns_owner1(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  const auto owned_int8 = returns_owner2(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  gsl::owner owned_int9 = returns_owner1(); // Ok
+  int *unowned_int3 = returns_owner1(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+
+  gsl::owner owned_int10;
+  owned_int10 = returns_owner1(); // Ok
+
+  int *unowned_int4;
+  unowned_int4 = returns_owner1(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning newly created owner/resource to non-owner
+
+  gsl::owner owned_int11 = returns_no_owner1(); // Bad since no owner
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing neither with an owner nor a recognized resource
+
+  gsl::owner owned_int12;
+  owned_int12 = returns_no_owner1(); // Bad since no owner
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning neither an owner nor a recognized resource
+
+  int *unowned_int5 = 

[PATCH] D36315: [mips] Support implicit gpopt with N64 when using -fno-pic

2017-08-11 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Thanks for the review and spotting this bug that lead me to finding the other 
bug.


Repository:
  rL LLVM

https://reviews.llvm.org/D36315



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


[PATCH] D36315: [mips] Support implicit gpopt with N64 when using -fno-pic

2017-08-11 Thread Simon Dardis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310714: [mips] Support implicit gpopt with N64 when using 
-fno-pic (authored by sdardis).

Repository:
  rL LLVM

https://reviews.llvm.org/D36315

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/mips-features.c


Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -85,6 +85,24 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
 // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
 //
+// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-GPOPT %s
+// CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -fno-pic -mno-gpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
+// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -mgpopt (-fpic is implicit)
+// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s
+// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt"
+// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with 
the implicit usage of -mabicalls
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mips16 -mips16 2>&1 \
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1473,8 +1473,21 @@
   // NOTE: We need a warning here or in the backend to warn when -mgpopt is
   //   passed explicitly when compiling something with -mabicalls
   //   (implictly) in affect. Currently the warning is in the backend.
+  //
+  // When the ABI in use is  N64, we also need to determine the PIC mode that
+  // is in use, as -fno-pic for N64 implies -mno-abicalls.
   bool NoABICalls =
   ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
+
+  llvm::Reloc::Model RelocationModel;
+  unsigned PICLevel;
+  bool IsPIE;
+  std::tie(RelocationModel, PICLevel, IsPIE) =
+  ParsePICArgs(getToolChain(), Args);
+
+  NoABICalls = NoABICalls ||
+   (RelocationModel == llvm::Reloc::Static && ABIName == "n64");
+
   bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt);
   // We quietly ignore -mno-gpopt as the backend defaults to -mno-gpopt.
   if (NoABICalls && (!GPOpt || WantGPOpt)) {


Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -85,6 +85,24 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
 // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
 //
+// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-GPOPT %s
+// CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -fno-pic -mno-gpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
+// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -mgpopt (-fpic is implicit)
+// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s
+// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt"
+// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with the implicit usage of -mabicalls
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mips16 -mips16 2>&1 \
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1473,8 +1473,21 @@
   // NOTE: We need a warning here or in the backend to warn when -mgpopt is
   //   passed explicitly when compiling something with -mabicalls
   //   (implictly) in affect. Currently the warning is in the backend.
+  //
+  // When the ABI in use is  N64, we also need to determine the PIC mode that
+  // is in use, as -fno-pic for N64 implies -mno-abicalls.
   bool NoABICalls =
   ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
+
+  llvm::Reloc::Model RelocationModel;
+

r310714 - [mips] Support implicit gpopt with N64 when using -fno-pic

2017-08-11 Thread Simon Dardis via cfe-commits
Author: sdardis
Date: Fri Aug 11 08:01:34 2017
New Revision: 310714

URL: http://llvm.org/viewvc/llvm-project?rev=310714&view=rev
Log:
[mips] Support implicit gpopt with N64 when using -fno-pic

As clang defaults to -mno-abicalls when using -fno-pic for N64, implicitly use
-mgpopt in that case.

Reviewers: atanasyan

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=310714&r1=310713&r2=310714&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Aug 11 08:01:34 2017
@@ -1473,8 +1473,21 @@ void Clang::AddMIPSTargetArgs(const ArgL
   // NOTE: We need a warning here or in the backend to warn when -mgpopt is
   //   passed explicitly when compiling something with -mabicalls
   //   (implictly) in affect. Currently the warning is in the backend.
+  //
+  // When the ABI in use is  N64, we also need to determine the PIC mode that
+  // is in use, as -fno-pic for N64 implies -mno-abicalls.
   bool NoABICalls =
   ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
+
+  llvm::Reloc::Model RelocationModel;
+  unsigned PICLevel;
+  bool IsPIE;
+  std::tie(RelocationModel, PICLevel, IsPIE) =
+  ParsePICArgs(getToolChain(), Args);
+
+  NoABICalls = NoABICalls ||
+   (RelocationModel == llvm::Reloc::Static && ABIName == "n64");
+
   bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt);
   // We quietly ignore -mno-gpopt as the backend defaults to -mno-gpopt.
   if (NoABICalls && (!GPOpt || WantGPOpt)) {

Modified: cfe/trunk/test/Driver/mips-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-features.c?rev=310714&r1=310713&r2=310714&view=diff
==
--- cfe/trunk/test/Driver/mips-features.c (original)
+++ cfe/trunk/test/Driver/mips-features.c Fri Aug 11 08:01:34 2017
@@ -85,6 +85,24 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
 // CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
 //
+// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-GPOPT %s
+// CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -fno-pic -mno-gpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
+// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -mgpopt (-fpic is implicit)
+// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s
+// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt"
+// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with 
the implicit usage of -mabicalls
+//
 // -mips16
 // RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN: -mno-mips16 -mips16 2>&1 \


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


[PATCH] D35982: [mips] Introducing option -mabs=[legacy/2008]

2017-08-11 Thread Simon Dardis via Phabricator via cfe-commits
sdardis requested changes to this revision.
sdardis added a comment.
This revision now requires changes to proceed.

Follow @atanasyan 's suggestion and post a patch that renames that enum along 
with other changes.

One comment inlined.




Comment at: clang/Basic/DiagnosticDriverKinds.td:282-287
+def warn_target_unsupported_abslegacy : Warning<
+  "ignoring '-mabs=legacy' option because the '%0' architecture does not 
support it">,
+  InGroup;
+def warn_target_unsupported_abs2008 : Warning<
+  "ignoring '-mabs=2008' option because the '%0' architecture does not support 
it">,
+  InGroup;

These require tests. You should test that abs2008 is ignored pre-r2, legacy and 
abs2008 is accepted up to r5 and legacy is ignored for R6.


Repository:
  rL LLVM

https://reviews.llvm.org/D35982



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


[PATCH] D35624: Removal of microMIPS64R6

2017-08-11 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.

One nit inlined, you can address it when committing.




Comment at: Basic/Targets/Mips.cpp:206
 bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
+  if ((getTriple().getArch() == llvm::Triple::mips64 ||
+   getTriple().getArch() == llvm::Triple::mips64el) &&

Add a comment here stating that the microMIPS64R6 backend was removed.


Repository:
  rL LLVM

https://reviews.llvm.org/D35624



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


[PATCH] D32411: [libcxx] Provide #include_next alternative for MSVC

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

ping


https://reviews.llvm.org/D32411



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


[PATCH] D34170: [libcxx] Moving compiler specific test infrastructure to compiler.py

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

ping


https://reviews.llvm.org/D34170



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


[PATCH] D35364: [clang-tidy] Add a close-on-exec check on dup() in Android module.

2017-08-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/android/CloexecCheck.h:91
+  /// Helper function to get the spelling of a particular argument.
+  StringRef getSpellingArg(const ast_matchers::MatchFinder::MatchResult 
&Result,
+   int N) const;

This method seems only be used in one check. Maybe move it to the 
implementation of that specific check? And you can make the  private members 
`FuncBindingStr` and `FuncDeclBindingStr` to protected member.



Comment at: test/clang-tidy/android-cloexec-dup.cpp:7
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer fcntl() to dup() because 
fcntl() allows F_DUPFD_CLOEXEC [android-cloexec-dup]
+  // CHECK-FIXES: fcntl(1, F_DUPFD_CLOEXEC)
+  int oldfd = 0;

nit: trailing `;`, the same below. Please apply this to other patches as well.


https://reviews.llvm.org/D35364



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


[PATCH] D35368: [clang-tidy] Add a close-on-exec check on inotify_init1() in Android module.

2017-08-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/android/CloexecInotifyInit1Check.cpp:28
+void CloexecInotifyInit1Check::check(const MatchFinder::MatchResult &Result) {
+  insertMacroFlag(Result, "IN_CLOEXEC", /*ArgPos=*/0);
+}

nit: `/*MarcoFlag=*/`



Comment at: test/clang-tidy/android-cloexec-inotify-init1.cpp:19
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: 'inotify_init1' should use 
IN_CLOEXEC where possible [android-cloexec-inotify-init1]
+  // CHECK-FIXES: inotify_init1(IN_NONBLOCK | IN_CLOEXEC)
+  TEMP_FAILURE_RETRY(inotify_init1(IN_NONBLOCK));

The same, trailing `;`.


https://reviews.llvm.org/D35368



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


[PATCH] D35370: [clang-tidy] Add a close-on-exec check on inotify_init() in Android module.

2017-08-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tidy/android/CloexecInotifyInitCheck.cpp:27
+  replaceFunc(Result,
+  "prefer inotify_init() to inotify_init1() "
+  "because inotify_init1() allows IN_CLOEXEC",

The parameter 2 and 3 are not clear at the first glance. Maybe add 
`/*WarningMsg=*/`, and `/*FixMsg=*/`.



Comment at: test/clang-tidy/android-cloexec-inotify-init.cpp:8
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer inotify_init() to 
inotify_init1() because inotify_init1() allows IN_CLOEXEC 
[android-cloexec-inotify-init]
+  // CHECK-FIXES: inotify_init1(IN_CLOEXEC)
+}

nit: trailing `;`.


https://reviews.llvm.org/D35370



___
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-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

John, do you have any comments? Thanks.


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] D36614: [clang-format] Refine trailing comment detection

2017-08-11 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a subscriber: klimek.

This patch fixes an non-idempotency issue connected with detection of trailing
comments. Consider formatting the following code with column limit at `V`:

  V
  const /* comment comment */ A = B;

The comment is not a trailing comment, breaking before it doesn't bring it under
the column limit. The formatter breaks after it, resulting in:

  V
  const /* comment comment */
  A = B;

For a next reformat, the formatter considers the comment as a trailing comment,
so it is free to break it further, resulting in:

  V
  const /* comment
   comment */
  A = B;

This patch improves this by refining the trailing comment detection, so that
the comment in the second version is not considered trailing anymore.


https://reviews.llvm.org/D36614

Files:
  lib/Format/FormatToken.h
  unittests/Format/FormatTestComments.cpp


Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -451,6 +451,17 @@
   verifyFormat("f(/* aa = */\n"
"  );");
 
+  verifyFormat("const /** comment comment */ A = B;",
+   getLLVMStyleWithColumns(40));
+
+  verifyFormat("const /** comment comment comment */ A =\n"
+   "B;",
+   getLLVMStyleWithColumns(40));
+
+  verifyFormat("const /** comment comment comment comment */\n"
+   "A = B;",
+   getLLVMStyleWithColumns(40));
+
   FormatStyle NoBinPacking = getLLVMStyle();
   NoBinPacking.BinPackParameters = false;
   verifyFormat("(/* parameter 1 */ aa,\n"
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -391,7 +391,11 @@
 
   bool isTrailingComment() const {
 return is(tok::comment) &&
-   (is(TT_LineComment) || !Next || Next->NewlinesBefore > 0);
+   (is(TT_LineComment) || !Next ||
+(Next->NewlinesBefore > 0 &&
+ (!Previous ||
+  Previous->isOneOf(tok::comma, tok::equal, tok::l_brace) ||
+  Next->is(tok::r_brace;
   }
 
   /// \brief Returns \c true if this is a keyword that can be used


Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -451,6 +451,17 @@
   verifyFormat("f(/* aa = */\n"
"  );");
 
+  verifyFormat("const /** comment comment */ A = B;",
+   getLLVMStyleWithColumns(40));
+
+  verifyFormat("const /** comment comment comment */ A =\n"
+   "B;",
+   getLLVMStyleWithColumns(40));
+
+  verifyFormat("const /** comment comment comment comment */\n"
+   "A = B;",
+   getLLVMStyleWithColumns(40));
+
   FormatStyle NoBinPacking = getLLVMStyle();
   NoBinPacking.BinPackParameters = false;
   verifyFormat("(/* parameter 1 */ aa,\n"
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -391,7 +391,11 @@
 
   bool isTrailingComment() const {
 return is(tok::comment) &&
-   (is(TT_LineComment) || !Next || Next->NewlinesBefore > 0);
+   (is(TT_LineComment) || !Next ||
+(Next->NewlinesBefore > 0 &&
+ (!Previous ||
+  Previous->isOneOf(tok::comma, tok::equal, tok::l_brace) ||
+  Next->is(tok::r_brace;
   }
 
   /// \brief Returns \c true if this is a keyword that can be used
___
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-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

A follow-up after discussion offline: we should make an attempt to simplify the 
threading code in `ClangdUnit.h` by moving the async worker loop of `CppFile` 
into the class itself, rather than relying on external scheduling to do the 
right thing.
@klimek, are there any other issues we need to address in this specific patch 
or are we good to go with submitting it?


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] D34158: For Linux/gnu compatibility, preinclude if the file is available

2017-08-11 Thread Melanie Blower via Phabricator via cfe-commits
mibintc planned changes to this revision.
mibintc added a comment.

Need TO FIX: We should be stripping the new arg as well: add 
"-fsystem-include-if-exists" argument to the list of include things in the 
skipArgs() function in lib/Driver/Job.cpp


https://reviews.llvm.org/D34158



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


Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-11 Thread Diana Picus via cfe-commits
Well, these are ASAN tests, I'm not sure how that would interact with Valgrind.
Anyway, I'll try to reproduce the environment, I'm guessing it would
be best to catch this in gdb so I can actually see what's going on.

On 11 August 2017 at 15:21, Vassil Vassilev  wrote:
> That's really strange. It looks like some random behavior. Did you run some 
> memory checker like valgrind?
>
> Do the environment provided by the test runner and yours match?
>
> Sent from my phone. Please excuse my brevity.
>
>> On 11 Aug 2017, at 15:58, Diana Picus  wrote:
>>
>> Hi again,
>>
>> I finally got the debug build, but unfortunately the stack traces that
>> the tests print look the same. My suspicion is that this is because
>> the addresses printed by the tests are funny (i.e. odd numbers instead
>> of divisible by 4). I tried to follow those addresses in an objdump of
>> the executable, but I didn't have much success since most of them
>> weren't really pointing to call instructions.
>>
>> When I try to run the tests manually in the shell or in gdb, they pass.
>>
>> I'm not sure what else to try. Thoughts?
>>
>> Thanks,
>> Diana
>>
>>> On 11 August 2017 at 11:14, Diana Picus  wrote:
>>> Hi guys,
>>>
>>> I'm SO sorry about the delays. I've been having all sorts of trouble
>>> getting that debug build on the board (from ld running out of memory
>>> to the board just crashing on me, in which case I need to ask someone
>>> else to reboot it because I can't power cycle it remotely). I can
>>> assure you this is one of my top priorities, I'll get those stack
>>> traces as soon as I can.
>>>
>>> Thanks for your patience and sorry again,
>>> Diana
>>>
 On 10 August 2017 at 22:55, Richard Smith  wrote:
 Any news on this? We want this change in Clang 5, so the sooner we can
 understand and fix this regression the better...

 On 10 August 2017 at 01:28, Diana Picus via cfe-commits
  wrote:
>
> Hi Vassil,
>
> My build is in progress, but since it's a full build it's probably
> going to take another couple of hours to complete. I'll let you know
> when it's done.
>
> Thanks,
> Diana
>
> On 10 August 2017 at 10:09, Vassil Vassilev 
> wrote:
>> It looks like I can not reproduce it on osx (non-arm)... :(
>>> On 09/08/17 22:54, Diana Picus wrote:
>>>
>>> Reverting this also fixed the selfhost bots:
>>>
>>>
>>> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
>>>
>>>
>>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
>>>
>>>
>>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819
>>>
>>> I'm afraid the logs for those look even less helpful.
>>>
 On 9 August 2017 at 16:17, Diana Picus  wrote:

 Hi,

 See attached. FWIW, when I ran this on a very similar machine, I got
 194 failures, all of which went away after reverting. So there might
 be something fishy going on.

 Regards,
 Diana

 On 9 August 2017 at 15:02, Vassil Vassilev 
 wrote:
>
> Hi Diana,
>
>   It seems the service is down. Could you send us the details of the
> failures (incl stack traces if any)
>
> Many thanks,
> Vassil
>
>> On 09/08/17 15:27, Diana Picus via cfe-commits wrote:
>>
>> Hi Richard,
>>
>> I'm sorry but I've reverted this in r310464 because it was breaking
>> some ASAN tests on this bot:
>>
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452
>>
>> Please let me know if I can help debug this.
>>
>> Cheers,
>> Diana
>>
>> On 8 August 2017 at 21:14, Richard Smith via cfe-commits
>>  wrote:
>>>
>>> I forgot to say:
>>>
>>> Based on a patch by Vassil Vassilev, which was based on a patch by
>>> Bernd
>>> Schmidt, which was based on a patch by Reid Kleckner.
>>>
>>> On 8 August 2017 at 12:12, Richard Smith via cfe-commits
>>>  wrote:

 Author: rsmith
 Date: Tue Aug  8 12:12:28 2017
 New Revision: 310401

 URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
 Log:
 PR19668, PR23034: Fix handling of move constructors and deleted
 copy
 constructors when deciding whether classes should be passed
 indirectly.

 This fixes ABI differences between Clang and GCC:

   * Previously, Clang ignored the move constructor when making
 this
 determination. It now takes the move constructor into
 account,
 per
 htt

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-11 Thread Vassil Vassilev via cfe-commits
That's really strange. It looks like some random behavior. Did you run some 
memory checker like valgrind?

Do the environment provided by the test runner and yours match?

Sent from my phone. Please excuse my brevity.

> On 11 Aug 2017, at 15:58, Diana Picus  wrote:
> 
> Hi again,
> 
> I finally got the debug build, but unfortunately the stack traces that
> the tests print look the same. My suspicion is that this is because
> the addresses printed by the tests are funny (i.e. odd numbers instead
> of divisible by 4). I tried to follow those addresses in an objdump of
> the executable, but I didn't have much success since most of them
> weren't really pointing to call instructions.
> 
> When I try to run the tests manually in the shell or in gdb, they pass.
> 
> I'm not sure what else to try. Thoughts?
> 
> Thanks,
> Diana
> 
>> On 11 August 2017 at 11:14, Diana Picus  wrote:
>> Hi guys,
>> 
>> I'm SO sorry about the delays. I've been having all sorts of trouble
>> getting that debug build on the board (from ld running out of memory
>> to the board just crashing on me, in which case I need to ask someone
>> else to reboot it because I can't power cycle it remotely). I can
>> assure you this is one of my top priorities, I'll get those stack
>> traces as soon as I can.
>> 
>> Thanks for your patience and sorry again,
>> Diana
>> 
>>> On 10 August 2017 at 22:55, Richard Smith  wrote:
>>> Any news on this? We want this change in Clang 5, so the sooner we can
>>> understand and fix this regression the better...
>>> 
>>> On 10 August 2017 at 01:28, Diana Picus via cfe-commits
>>>  wrote:
 
 Hi Vassil,
 
 My build is in progress, but since it's a full build it's probably
 going to take another couple of hours to complete. I'll let you know
 when it's done.
 
 Thanks,
 Diana
 
 On 10 August 2017 at 10:09, Vassil Vassilev 
 wrote:
> It looks like I can not reproduce it on osx (non-arm)... :(
>> On 09/08/17 22:54, Diana Picus wrote:
>> 
>> Reverting this also fixed the selfhost bots:
>> 
>> 
>> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
>> 
>> 
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
>> 
>> 
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819
>> 
>> I'm afraid the logs for those look even less helpful.
>> 
>>> On 9 August 2017 at 16:17, Diana Picus  wrote:
>>> 
>>> Hi,
>>> 
>>> See attached. FWIW, when I ran this on a very similar machine, I got
>>> 194 failures, all of which went away after reverting. So there might
>>> be something fishy going on.
>>> 
>>> Regards,
>>> Diana
>>> 
>>> On 9 August 2017 at 15:02, Vassil Vassilev 
>>> wrote:
 
 Hi Diana,
 
   It seems the service is down. Could you send us the details of the
 failures (incl stack traces if any)
 
 Many thanks,
 Vassil
 
> On 09/08/17 15:27, Diana Picus via cfe-commits wrote:
> 
> Hi Richard,
> 
> I'm sorry but I've reverted this in r310464 because it was breaking
> some ASAN tests on this bot:
> 
> 
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452
> 
> Please let me know if I can help debug this.
> 
> Cheers,
> Diana
> 
> On 8 August 2017 at 21:14, Richard Smith via cfe-commits
>  wrote:
>> 
>> I forgot to say:
>> 
>> Based on a patch by Vassil Vassilev, which was based on a patch by
>> Bernd
>> Schmidt, which was based on a patch by Reid Kleckner.
>> 
>> On 8 August 2017 at 12:12, Richard Smith via cfe-commits
>>  wrote:
>>> 
>>> Author: rsmith
>>> Date: Tue Aug  8 12:12:28 2017
>>> New Revision: 310401
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
>>> Log:
>>> PR19668, PR23034: Fix handling of move constructors and deleted
>>> copy
>>> constructors when deciding whether classes should be passed
>>> indirectly.
>>> 
>>> This fixes ABI differences between Clang and GCC:
>>> 
>>>   * Previously, Clang ignored the move constructor when making
>>> this
>>> determination. It now takes the move constructor into
>>> account,
>>> per
>>> https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this
>>> change
>>> may
>>> seem recent, but the ABI change was agreed on the Itanium C++
>>> ABI
>>> list a long time ago).
>>> 
>>>   * Previously, Clang's behavior when the copy constructor was
>>> deleted
>>> was unstable -- dependi

[PATCH] D35941: Fix -Wshadow false positives with function-local classes.

2017-08-11 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D35941#838633, @rsmith wrote:

> In https://reviews.llvm.org/D35941#823524, @alexfh wrote:
>
> > IIUC, most cases where -Wshadow warnings are issued is when a declaration 
> > from an enclosing scope would be accessible if there was no declaration 
> > that shadows it. In this case the the local variable of a function would 
> > not be accessible inside the local class anyway
>
>
> That's not strictly true; the variable can be accessed in unevaluated 
> operands, and in code doing so, a `-Wshadow` warning might (theoretically) be 
> useful:
>
>   void f(SomeComplexType val) {
> struct A {
>   decltype(val) &ref;
>   void g(int val) {
> decltype(val) *p = &ref;
>   }
> } a = {val};
>   }
>


Good to know!

> That said, suppressing the warning seems like a good thing in the common 
> case. We've discussed the idea of deferring some `-Wshadow` warnings until we 
> see a use; if someone cares about this case, we could consider warning only 
> if the shadowed variable is actually used in an unevaluated operand.

Sounds reasonable.


Repository:
  rL LLVM

https://reviews.llvm.org/D35941



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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:149
+  // Deletion of non-owners, with `delete variable;`
+  if (DeletedVariable != nullptr) {
+assert(DeleteStmt != nullptr &&

aaron.ballman wrote:
> Can `DeletedVariable` ever be null if `DeleteStmt` is non-null? I don't think 
> it can, so perhaps the best approach is to gate on `DeleteStmt` and remove 
> the assert.
I think that both will be matched simultaneously, but i was unsure, therefor i 
programmed it defensive.
I can change it if you want.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:153
+diag(DeleteStmt->getLocStart(),
+ "deleting unowned memory; use RAII or gsl::owner")
+<< SourceRange(DeletedVariable->getLocStart(),

aaron.ballman wrote:
> "use RAII" is not particularly helpful. I think this means you should use a 
> smart pointer, no? If so, I'd recommend: `"deleting a pointer through a type 
> that is not marked 'gsl::owner'; consider using a smart pointer instead"` or 
> something along those lines.
in this case RAII means smartpointers, but in general `gsl::owner` could be 
file handles, sockets and whatever else.

i will adjust the warning to mention smartpointers.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:168
+diag(ExpectedOwner->getLocStart(),
+ "expected this argument to be an owner or a recognized resource")
+<< SourceRange(ExpectedOwner->getLocStart(),

aaron.ballman wrote:
> I'm having a bit of a hard time understanding the guidance in this warning. 
> How about: `"argument is expected to be of type 'gsl::owner<>'; got %0"` and 
> pass in the type of the argument?
> 
> I think something needs to be done to better-define "recognized resource" 
> before it's used as a term of art in the diagnostics; this applies elsewhere 
> as well.
I used the term 'recognized resource' since `FILE*` would be a resource as 
well, but the there is no way the C standard function could return an 
`gsl::owner<>`. 

I plan to enhance this check, to allow of lists of C/C++ functions that are 
known to create a resource, but can not be changed.
The effect would be like in the case of `new` - whenever such a function is 
called, the result must be assigned to an `gsl::owner`.
Furthermore the CppCoreGuidelines usually talk about 'resources', so the 
wording is somewhat similar.

same applies to next comment


https://reviews.llvm.org/D36354



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


[PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy

2017-08-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: unittests/Tooling/QualTypeNamesTest.cpp:247
+  "struct (anonymous struct at input.cc:1:1)";
+  PrintingPolicy.runOver(
+  "struct\n"

You should probably use multiline string here, i.e. R(" ... ")


https://reviews.llvm.org/D36610



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


[PATCH] D36611: Implemented P0683R1 - Default member initializers for bit-fields

2017-08-11 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.

This patch implements P0683R1 .

Member initialisers are allowed pre-C++11 as an extension. So I've also allowed 
bitfield member initialisers pre-C++2a as an extension (with appropriate 
warnings) for consistency.


https://reviews.llvm.org/D36611

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticParseKinds.td
  lib/AST/Decl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Parser/cxx2a-bitfield-member-init.cpp
  test/SemaCXX/member-init.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -798,7 +797,7 @@
 
   Default member initializers for bit-fields
   http://wg21.link/p0683r1";>P0683R1
-  No
+  SVN
 
 
   const&-qualified pointers to members
Index: test/SemaCXX/member-init.cpp
===
--- test/SemaCXX/member-init.cpp
+++ test/SemaCXX/member-init.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify -std=c++11 -Wall %s
 
 struct Bitfield {
-  int n : 3 = 7; // expected-error {{bit-field member cannot have an in-class initializer}}
+  int n : 3 = 2; // expected-warning {{C++2a extension}}
 };
 
 int a;
Index: test/Parser/cxx2a-bitfield-member-init.cpp
===
--- test/Parser/cxx2a-bitfield-member-init.cpp
+++ test/Parser/cxx2a-bitfield-member-init.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+// expected-no-diagnostics
+
+// This is a slightly modified version of the example from C++2a [class.mem]p7.
+// It tests the resolution of parsing ambiguities.
+
+int a;
+struct S {
+  unsigned x1 : 8 = 42;
+  unsigned x2 : 8 {42};
+
+  unsigned y1 : true ? 8 : a = 42;
+  unsigned y2 : (true ? 8 : a) = 42;
+
+  unsigned z1 : 1 || new int { 1 };
+  unsigned z2 : (1 || new int) { 1 };
+};
+
+constexpr S s{};
+static_assert(s.x1 == 42 && s.x2 == 42);
+static_assert(s.y1 == 0  && s.y2 == 42);
+static_assert(s.z1 == 0  && s.z2 == 1);
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -849,8 +849,8 @@
 void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) {
   VisitDeclaratorDecl(D);
   Record.push_back(D->isMutable());
-  if (D->InitStorage.getInt() == FieldDecl::ISK_BitWidthOrNothing &&
-  D->InitStorage.getPointer() == nullptr) {
+  Record.AddStmt(D->getBitWidth());
+  if (D->InitStorage.getInt() == FieldDecl::ISK_Nothing) {
 Record.push_back(0);
   } else if (D->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
 Record.push_back(D->InitStorage.getInt() + 1);
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1219,9 +1219,10 @@
 void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) {
   VisitDeclaratorDecl(FD);
   FD->Mutable = Record.readInt();
-  if (int BitWidthOrInitializer = Record.readInt()) {
+  FD->BitWidth = Record.readExpr();
+  if (int Initializer = Record.readInt()) {
 FD->InitStorage.setInt(
-  static_cast(BitWidthOrInitializer - 1));
+  static_cast(Initializer - 1));
 if (FD->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
   // Read captured variable length array.
   FD->InitStorage.setPointer(Record.readType().getAsOpaquePtr());
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -2403,6 +2403,7 @@
 /// declarator constant-initializer[opt]
 /// [C++11] declarator brace-or-equal-initializer[opt]
 /// identifier[opt] ':' constant-expression
+/// brace-or-equal-initializer[opt][C++2a]
 ///
 ///   virt-specifier-seq:
 /// virt-specifier
@@ -2720,10 +2721,12 @@
 InClassInitStyle HasInClassInit = ICIS_NoInit;
 bool HasStaticInitializer = false;
 if (Tok.isOneOf(tok::equal, tok::l_brace) && PureSpecLoc.isInvalid()) {
-  if (BitfieldSize.get()) {
-Diag(Tok, diag::err_bitfield_member_init);
-SkipUntil(tok::comma, StopAtSemi | 

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-11 Thread Diana Picus via cfe-commits
Hi again,

I finally got the debug build, but unfortunately the stack traces that
the tests print look the same. My suspicion is that this is because
the addresses printed by the tests are funny (i.e. odd numbers instead
of divisible by 4). I tried to follow those addresses in an objdump of
the executable, but I didn't have much success since most of them
weren't really pointing to call instructions.

When I try to run the tests manually in the shell or in gdb, they pass.

I'm not sure what else to try. Thoughts?

Thanks,
Diana

On 11 August 2017 at 11:14, Diana Picus  wrote:
> Hi guys,
>
> I'm SO sorry about the delays. I've been having all sorts of trouble
> getting that debug build on the board (from ld running out of memory
> to the board just crashing on me, in which case I need to ask someone
> else to reboot it because I can't power cycle it remotely). I can
> assure you this is one of my top priorities, I'll get those stack
> traces as soon as I can.
>
> Thanks for your patience and sorry again,
> Diana
>
> On 10 August 2017 at 22:55, Richard Smith  wrote:
>> Any news on this? We want this change in Clang 5, so the sooner we can
>> understand and fix this regression the better...
>>
>> On 10 August 2017 at 01:28, Diana Picus via cfe-commits
>>  wrote:
>>>
>>> Hi Vassil,
>>>
>>> My build is in progress, but since it's a full build it's probably
>>> going to take another couple of hours to complete. I'll let you know
>>> when it's done.
>>>
>>> Thanks,
>>> Diana
>>>
>>> On 10 August 2017 at 10:09, Vassil Vassilev 
>>> wrote:
>>> > It looks like I can not reproduce it on osx (non-arm)... :(
>>> > On 09/08/17 22:54, Diana Picus wrote:
>>> >>
>>> >> Reverting this also fixed the selfhost bots:
>>> >>
>>> >>
>>> >> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
>>> >>
>>> >>
>>> >> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
>>> >>
>>> >>
>>> >> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819
>>> >>
>>> >> I'm afraid the logs for those look even less helpful.
>>> >>
>>> >> On 9 August 2017 at 16:17, Diana Picus  wrote:
>>> >>>
>>> >>> Hi,
>>> >>>
>>> >>> See attached. FWIW, when I ran this on a very similar machine, I got
>>> >>> 194 failures, all of which went away after reverting. So there might
>>> >>> be something fishy going on.
>>> >>>
>>> >>> Regards,
>>> >>> Diana
>>> >>>
>>> >>> On 9 August 2017 at 15:02, Vassil Vassilev 
>>> >>> wrote:
>>> 
>>>  Hi Diana,
>>> 
>>> It seems the service is down. Could you send us the details of the
>>>  failures (incl stack traces if any)
>>> 
>>>  Many thanks,
>>>  Vassil
>>> 
>>>  On 09/08/17 15:27, Diana Picus via cfe-commits wrote:
>>> >
>>> > Hi Richard,
>>> >
>>> > I'm sorry but I've reverted this in r310464 because it was breaking
>>> > some ASAN tests on this bot:
>>> >
>>> >
>>> > http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452
>>> >
>>> > Please let me know if I can help debug this.
>>> >
>>> > Cheers,
>>> > Diana
>>> >
>>> > On 8 August 2017 at 21:14, Richard Smith via cfe-commits
>>> >  wrote:
>>> >>
>>> >> I forgot to say:
>>> >>
>>> >> Based on a patch by Vassil Vassilev, which was based on a patch by
>>> >> Bernd
>>> >> Schmidt, which was based on a patch by Reid Kleckner.
>>> >>
>>> >> On 8 August 2017 at 12:12, Richard Smith via cfe-commits
>>> >>  wrote:
>>> >>>
>>> >>> Author: rsmith
>>> >>> Date: Tue Aug  8 12:12:28 2017
>>> >>> New Revision: 310401
>>> >>>
>>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
>>> >>> Log:
>>> >>> PR19668, PR23034: Fix handling of move constructors and deleted
>>> >>> copy
>>> >>> constructors when deciding whether classes should be passed
>>> >>> indirectly.
>>> >>>
>>> >>> This fixes ABI differences between Clang and GCC:
>>> >>>
>>> >>>* Previously, Clang ignored the move constructor when making
>>> >>> this
>>> >>>  determination. It now takes the move constructor into
>>> >>> account,
>>> >>> per
>>> >>>  https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this
>>> >>> change
>>> >>> may
>>> >>>  seem recent, but the ABI change was agreed on the Itanium C++
>>> >>> ABI
>>> >>>  list a long time ago).
>>> >>>
>>> >>>* Previously, Clang's behavior when the copy constructor was
>>> >>> deleted
>>> >>>  was unstable -- depending on whether the lazy declaration of
>>> >>> the
>>> >>>  copy constructor had been triggered, you might get different
>>> >>> behavior.
>>> >>>  We now eagerly declare the copy constructor whenever its
>>> >>> deletedness
>>> >>>  is unclear, and ignore deleted copy/move constructors when
>>> >>> looking
>>> >>> for
>>> 

[PATCH] D36610: [Tooling] Add option to getFullyQualifiedName using a custom PritingPolicy

2017-08-11 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho created this revision.
Herald added a subscriber: klimek.

In our user case, we need to generate unique names for every tag, including 
anonymous structs/unions.

This adds a custom PrintingPolicy option to getFullyQualifiedName and the test 
case shows that different names are generated for different anonymous 
unions/structs.


https://reviews.llvm.org/D36610

Files:
  include/clang/Tooling/Core/QualTypeNames.h
  lib/Tooling/Core/QualTypeNames.cpp
  unittests/Tooling/QualTypeNamesTest.cpp

Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -15,6 +15,7 @@
 struct TypeNameVisitor : TestVisitor {
   llvm::StringMap ExpectedQualTypeNames;
   bool WithGlobalNsPrefix = false;
+  bool CustomPrintingPolicy = false;
 
   // ValueDecls are the least-derived decl with both a qualtype and a
   // name.
@@ -26,9 +27,22 @@
 std::string ExpectedName =
 ExpectedQualTypeNames.lookup(VD->getNameAsString());
 if (ExpectedName != "") {
-  std::string ActualName =
-  TypeName::getFullyQualifiedName(VD->getType(), *Context,
-  WithGlobalNsPrefix);
+  std::string ActualName;
+  if (!CustomPrintingPolicy)
+ActualName =
+TypeName::getFullyQualifiedName(VD->getType(), *Context,
+WithGlobalNsPrefix);
+  else {
+PrintingPolicy Policy(Context->getPrintingPolicy());
+Policy.SuppressScope = false;
+Policy.AnonymousTagLocations = true;
+Policy.PolishForDeclaration = true;
+Policy.SuppressUnwrittenScope = true;
+ActualName =
+TypeName::getFullyQualifiedName(VD->getType(), *Context,
+Policy, WithGlobalNsPrefix);
+  }
+
   if (ExpectedName != ActualName) {
 // A custom message makes it much easier to see what declaration
 // failed compared to EXPECT_EQ.
@@ -217,6 +231,32 @@
   "  }\n"
   "}\n"
   );
+
+  TypeNameVisitor PrintingPolicy;
+  PrintingPolicy.CustomPrintingPolicy = true;
+  PrintingPolicy.ExpectedQualTypeNames["a"] = "short";
+  PrintingPolicy.ExpectedQualTypeNames["un_in_st_1"] =
+  "union (anonymous struct at input.cc:1:1)::(anonymous union at "
+  "input.cc:3:3)";
+  PrintingPolicy.ExpectedQualTypeNames["b"] = "short";
+  PrintingPolicy.ExpectedQualTypeNames["un_in_st_2"] =
+  "union (anonymous struct at input.cc:1:1)::(anonymous union at "
+  "input.cc:7:3)";
+  PrintingPolicy.ExpectedQualTypeNames["anon_st"] =
+  "struct (anonymous struct at input.cc:1:1)";
+  PrintingPolicy.runOver(
+  "struct\n"
+  "{\n"
+  "  union\n"
+  "  {\n"
+  "short a;\n"
+  "  } un_in_st_1;\n"
+  "  union\n"
+  "  {\n"
+  "short b;\n"
+  "  } un_in_st_2;\n"
+  "} anon_st;\n"
+  );
 }
 
 }  // end anonymous namespace
Index: lib/Tooling/Core/QualTypeNames.cpp
===
--- lib/Tooling/Core/QualTypeNames.cpp
+++ lib/Tooling/Core/QualTypeNames.cpp
@@ -463,14 +463,21 @@
 
 std::string getFullyQualifiedName(QualType QT,
   const ASTContext &Ctx,
+  const PrintingPolicy &Policy,
+  bool WithGlobalNsPrefix) {
+  QualType FQQT = getFullyQualifiedType(QT, Ctx, WithGlobalNsPrefix);
+  return FQQT.getAsString(Policy);
+}
+
+std::string getFullyQualifiedName(QualType QT,
+  const ASTContext &Ctx,
   bool WithGlobalNsPrefix) {
   PrintingPolicy Policy(Ctx.getPrintingPolicy());
   Policy.SuppressScope = false;
   Policy.AnonymousTagLocations = false;
   Policy.PolishForDeclaration = true;
   Policy.SuppressUnwrittenScope = true;
-  QualType FQQT = getFullyQualifiedType(QT, Ctx, WithGlobalNsPrefix);
-  return FQQT.getAsString(Policy);
+  return getFullyQualifiedName(QT, Ctx, Policy, WithGlobalNsPrefix);
 }
 
 }  // end namespace TypeName
Index: include/clang/Tooling/Core/QualTypeNames.h
===
--- include/clang/Tooling/Core/QualTypeNames.h
+++ include/clang/Tooling/Core/QualTypeNames.h
@@ -74,6 +74,11 @@
 std::string getFullyQualifiedName(QualType QT,
   const ASTContext &Ctx,
   bool WithGlobalNsPrefix = false);
+
+std::string getFullyQualifiedName(QualType QT,
+  const ASTContext &Ctx,
+  const PrintingPolicy &Policy,
+  bool WithGlobalNsPrefix = false);
 }  // end namespace TypeName
 }  // end namespace clang
 #endif  // LLVM_CLANG_TOOLING_CORE_QUALTYPENAMES_H
___
cfe-com

[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:149
+  // Deletion of non-owners, with `delete variable;`
+  if (DeletedVariable != nullptr) {
+assert(DeleteStmt != nullptr &&

Can `DeletedVariable` ever be null if `DeleteStmt` is non-null? I don't think 
it can, so perhaps the best approach is to gate on `DeleteStmt` and remove the 
assert.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:153
+diag(DeleteStmt->getLocStart(),
+ "deleting unowned memory; use RAII or gsl::owner")
+<< SourceRange(DeletedVariable->getLocStart(),

"use RAII" is not particularly helpful. I think this means you should use a 
smart pointer, no? If so, I'd recommend: `"deleting a pointer through a type 
that is not marked 'gsl::owner'; consider using a smart pointer instead"` or 
something along those lines.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:154-155
+ "deleting unowned memory; use RAII or gsl::owner")
+<< SourceRange(DeletedVariable->getLocStart(),
+   DeletedVariable->getLocEnd());
+return true;

Can call `DeletedVariable->getSourceRange()` instead (same applies elsewhere).



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:157
+return true;
+  } else
+return false;

No `else` after a return (same applies elsewhere).



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:168
+diag(ExpectedOwner->getLocStart(),
+ "expected this argument to be an owner or a recognized resource")
+<< SourceRange(ExpectedOwner->getLocStart(),

I'm having a bit of a hard time understanding the guidance in this warning. How 
about: `"argument is expected to be of type 'gsl::owner<>'; got %0"` and pass 
in the type of the argument?

I think something needs to be done to better-define "recognized resource" 
before it's used as a term of art in the diagnostics; this applies elsewhere as 
well.



Comment at: clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp:188
+diag(OwnerAssignment->getLocStart(),
+ "assigning neither an owner nor a recognized resource")
+<< SourceRange(OwnerAssignment->getLocStart(),

Same comments here as above about "owner" and "recognized resource". I think 
you want to talk about `gsl::owner<>` where you use "owner" and drop 
"recognized resource" (because such a resource returns a `gsl::owner<>`-flagged 
type, if I understand properly).


https://reviews.llvm.org/D36354



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


[clang-tools-extra] r310707 - Implement hicpp-braces-around-statements as an alias to readability-braces-around-statements.

2017-08-11 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Aug 11 05:12:36 2017
New Revision: 310707

URL: http://llvm.org/viewvc/llvm-project?rev=310707&view=rev
Log:
Implement hicpp-braces-around-statements as an alias to 
readability-braces-around-statements.

Patch by Jonas Toth.

Added:

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-braces-around-statements.rst
Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp?rev=310707&r1=310706&r2=310707&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp Fri Aug 11 
05:12:36 2017
@@ -21,6 +21,7 @@
 #include "../modernize/UseEqualsDefaultCheck.h"
 #include "../modernize/UseEqualsDeleteCheck.h"
 #include "../modernize/UseOverrideCheck.h"
+#include "../readability/BracesAroundStatementsCheck.h"
 #include "../readability/FunctionSizeCheck.h"
 #include "../readability/IdentifierNamingCheck.h"
 #include "NoAssemblerCheck.h"
@@ -32,6 +33,8 @@ namespace hicpp {
 class HICPPModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"hicpp-braces-around-statements");
 CheckFactories.registerCheck(
 "hicpp-explicit-conversions");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=310707&r1=310706&r2=310707&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Fri Aug 11 05:12:36 2017
@@ -92,6 +92,8 @@ Improvements to clang-tidy
   
`_
   option.
 
+- Added alias `hicpp-braces-around-statements 
`_
 
+
 Improvements to include-fixer
 -
 

Added: 
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-braces-around-statements.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-braces-around-statements.rst?rev=310707&view=auto
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-braces-around-statements.rst
 (added)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-braces-around-statements.rst
 Fri Aug 11 05:12:36 2017
@@ -0,0 +1,11 @@
+.. title:: clang-tidy - hicpp-braces-around-statements
+.. meta::
+   :http-equiv=refresh: 5;URL=readability-braces-around-statements.html
+
+hicpp-braces-around-statements
+==
+
+The hicpp-braces-around-statements check is an alias, please see
+`readability-braces-around-statements 
`_
+for more information.
+It enforces the `rule 6.1.1 
`_.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=310707&r1=310706&r2=310707&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Fri Aug 11 05:12:36 
2017
@@ -62,6 +62,7 @@ Clang-Tidy Checks
google-runtime-member-string-references
google-runtime-operator
google-runtime-references
+   hicpp-braces-around-statements (redirects to 
readability-braces-around-statements) 
hicpp-explicit-conversions (redirects to google-explicit-constructor) 

hicpp-function-size (redirects to readability-function-size) 

hicpp-invalid-access-moved (redirects to misc-use-after-move) 



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


Re: r310706 - [modules] Set the lexical DC for dummy tag decls that refer to hidden

2017-08-11 Thread Alex L via cfe-commits
Hi Hans & Richard,

Is it possible to get this merged into LLVM 5.0?

Cheers,
Alex

On 11 August 2017 at 13:06, Alex Lorenz via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: arphaman
> Date: Fri Aug 11 05:06:52 2017
> New Revision: 310706
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310706&view=rev
> Log:
> [modules] Set the lexical DC for dummy tag decls that refer to hidden
> declarations that are made visible after the dummy is parsed and ODR
> verified
>
> Prior to this commit the
> "(getContainingDC(DC) == CurContext && "The next DeclContext should be
> lexically contained in the current one."),"
> assertion failure was triggered during semantic analysis of the dummy
> tag declaration that was declared in another tag declaration because its
> lexical context did not point to the outer tag decl.
>
> rdar://32292196
>
> Added:
> cfe/trunk/test/Modules/Inputs/innerstructredef.h
> cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
> Modified:
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/test/Modules/Inputs/module.map
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/
> SemaDecl.cpp?rev=310706&r1=310705&r2=310706&view=diff
> 
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 11 05:06:52 2017
> @@ -13722,6 +13722,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
>// comparison.
>SkipBody->CheckSameAsPrevious = true;
>SkipBody->New = createTagFromNewDecl();
> +  SkipBody->New->setLexicalDeclContext(CurContext);
>SkipBody->Previous = Hidden;
>  } else {
>SkipBody->ShouldSkip = true;
>
> Added: cfe/trunk/test/Modules/Inputs/innerstructredef.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/
> innerstructredef.h?rev=310706&view=auto
> 
> ==
> --- cfe/trunk/test/Modules/Inputs/innerstructredef.h (added)
> +++ cfe/trunk/test/Modules/Inputs/innerstructredef.h Fri Aug 11 05:06:52
> 2017
> @@ -0,0 +1,6 @@
> +struct Outer {
> +// This definition is actually hidden since only submodule 'one' is
> imported.
> +struct Inner {
> +  int x;
> +} field;
> +};
>
> Modified: cfe/trunk/test/Modules/Inputs/module.map
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/Inputs/module.map?rev=310706&r1=310705&r2=310706&view=diff
> 
> ==
> --- cfe/trunk/test/Modules/Inputs/module.map (original)
> +++ cfe/trunk/test/Modules/Inputs/module.map Fri Aug 11 05:06:52 2017
> @@ -451,3 +451,12 @@ module DebugNestedB {
>  module objcAtKeywordMissingEnd {
>header "objcAtKeywordMissingEnd.h"
>  }
> +
> +module innerstructredef {
> +  module one {
> +header "empty.h"
> +  }
> +  module two {
> +   header "innerstructredef.h"
> +  }
> +}
>
> Added: cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/inner-struct-redefines-invisible.m?rev=310706&view=auto
> 
> ==
> --- cfe/trunk/test/Modules/inner-struct-redefines-invisible.m (added)
> +++ cfe/trunk/test/Modules/inner-struct-redefines-invisible.m Fri Aug 11
> 05:06:52 2017
> @@ -0,0 +1,12 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -fmodules
> -fimplicit-module-maps -fmodules-cache-path=%t -verify %s
> +// expected-no-diagnostics
> +
> +@import innerstructredef.one;
> +
> +struct Outer {
> +// Should set lexical context when parsing 'Inner' here, otherwise
> there's a crash:
> +struct Inner {
> +  int x;
> +} field;
> +};
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310706 - [modules] Set the lexical DC for dummy tag decls that refer to hidden

2017-08-11 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Aug 11 05:06:52 2017
New Revision: 310706

URL: http://llvm.org/viewvc/llvm-project?rev=310706&view=rev
Log:
[modules] Set the lexical DC for dummy tag decls that refer to hidden
declarations that are made visible after the dummy is parsed and ODR verified

Prior to this commit the
"(getContainingDC(DC) == CurContext && "The next DeclContext should be 
lexically contained in the current one."),"
assertion failure was triggered during semantic analysis of the dummy
tag declaration that was declared in another tag declaration because its
lexical context did not point to the outer tag decl.

rdar://32292196

Added:
cfe/trunk/test/Modules/Inputs/innerstructredef.h
cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=310706&r1=310705&r2=310706&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 11 05:06:52 2017
@@ -13722,6 +13722,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
   // comparison.
   SkipBody->CheckSameAsPrevious = true;
   SkipBody->New = createTagFromNewDecl();
+  SkipBody->New->setLexicalDeclContext(CurContext);
   SkipBody->Previous = Hidden;
 } else {
   SkipBody->ShouldSkip = true;

Added: cfe/trunk/test/Modules/Inputs/innerstructredef.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/innerstructredef.h?rev=310706&view=auto
==
--- cfe/trunk/test/Modules/Inputs/innerstructredef.h (added)
+++ cfe/trunk/test/Modules/Inputs/innerstructredef.h Fri Aug 11 05:06:52 2017
@@ -0,0 +1,6 @@
+struct Outer {
+// This definition is actually hidden since only submodule 'one' is imported.
+struct Inner {
+  int x;
+} field;
+};

Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=310706&r1=310705&r2=310706&view=diff
==
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Fri Aug 11 05:06:52 2017
@@ -451,3 +451,12 @@ module DebugNestedB {
 module objcAtKeywordMissingEnd {
   header "objcAtKeywordMissingEnd.h"
 }
+
+module innerstructredef {
+  module one {
+header "empty.h"
+  }
+  module two {
+   header "innerstructredef.h"
+  }
+}

Added: cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/inner-struct-redefines-invisible.m?rev=310706&view=auto
==
--- cfe/trunk/test/Modules/inner-struct-redefines-invisible.m (added)
+++ cfe/trunk/test/Modules/inner-struct-redefines-invisible.m Fri Aug 11 
05:06:52 2017
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -verify %s
+// expected-no-diagnostics
+
+@import innerstructredef.one;
+
+struct Outer {
+// Should set lexical context when parsing 'Inner' here, otherwise there's a 
crash:
+struct Inner {
+  int x;
+} field;
+};


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


r310704 - Revert r302670 for the upcoming 5.0.0 release

2017-08-11 Thread Stefan Maksimovic via cfe-commits
Author: smaksimovic
Date: Fri Aug 11 04:39:07 2017
New Revision: 310704

URL: http://llvm.org/viewvc/llvm-project?rev=310704&view=rev
Log:
Revert r302670 for the upcoming 5.0.0 release

This is causing failures when compiling clang with -O3
as one of the structures used by clang is passed by
value and uses the fastcc calling convention.

Faliures manifest for stage2 mips build.

Removed:
cfe/trunk/test/CodeGen/mips-aggregate-arg.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=310704&r1=310703&r2=310704&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Aug 11 04:39:07 2017
@@ -6821,14 +6821,6 @@ MipsABIInfo::classifyArgumentType(QualTy
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
-// Use indirect if the aggregate cannot fit into registers for
-// passing arguments according to the ABI
-unsigned Threshold = IsO32 ? 16 : 64;
-
-if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
-  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
- getContext().getTypeAlign(Ty) / 8 > 
Align);
-
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.

Removed: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=310703&view=auto
==
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (original)
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c (removed)
@@ -1,38 +0,0 @@
-// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
-
-struct t1 {
-  char t1[10];
-};
-
-struct t2 {
-  char t2[20];
-};
-
-struct t3 {
-  char t3[65];
-};
-
-extern struct t1 g1;
-extern struct t2 g2;
-extern struct t3 g3;
-extern void f1(struct t1);
-extern void f2(struct t2);
-extern void f3(struct t3);
-
-void f() {
-
-// O32:  call void @f1(i32 inreg %{{[0-9]+}}, i32 inreg %{{[0-9]+}}, i16 inreg 
%{{[0-9]+}})
-// O32:  call void @f2(%struct.t2* byval align 4 %{{.*}})
-// O32:  call void @f3(%struct.t3* byval align 4 %{{.*}})
-
-// N32-N64:  call void @f1(i64 inreg %{{[0-9]+}}, i16 inreg %{{[0-9]+}})
-// N32-N64:  call void @f2(i64 inreg %{{[0-9]+}}, i64 inreg %{{[0-9]+}}, i32 
inreg %{{[0-9]+}})
-// N32-N64:  call void @f3(%struct.t3* byval align 8 %{{.*}})
-
-  f1(g1);
-  f2(g2);
-  f3(g3);
-}
-


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


  1   2   >