r257989 - clang/test/Driver/darwin-multiarch-arm.c: Appease the case that "ld.exe" exists on %PATH% on win32.

2016-01-16 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sat Jan 16 02:35:53 2016
New Revision: 257989

URL: http://llvm.org/viewvc/llvm-project?rev=257989&view=rev
Log:
clang/test/Driver/darwin-multiarch-arm.c: Appease the case that "ld.exe" exists 
on %PATH% on win32.

Modified:
cfe/trunk/test/Driver/darwin-multiarch-arm.c

Modified: cfe/trunk/test/Driver/darwin-multiarch-arm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-multiarch-arm.c?rev=257989&r1=257988&r2=257989&view=diff
==
--- cfe/trunk/test/Driver/darwin-multiarch-arm.c (original)
+++ cfe/trunk/test/Driver/darwin-multiarch-arm.c Sat Jan 16 02:35:53 2016
@@ -5,10 +5,10 @@
 
 // CHECK: "-cc1" "-triple" "thumbv7-apple-ios5.0.0"
 // CHECK-SAME: "-o" "[[CC_OUT1:[^"]*]]"
-// CHECK:ld" {{.*}} "-o" "[[LD_OUT1:[^"]*]]" {{.*}} "[[CC_OUT1]]"
+// CHECK:ld{{(\.exe)?}}" {{.*}} "-o" "[[LD_OUT1:[^"]*]]" {{.*}} "[[CC_OUT1]]"
 // CHECK:"-cc1" "-triple" "thumbv7s-apple-ios5.0.0"
 // CHECK-SAME: "-o" "[[CC_OUT2:[^"]*]]"
-// CHECK:ld" {{.*}} "-o" "[[LD_OUT2:[^"]*]]" {{.*}} "[[CC_OUT2]]"
+// CHECK:ld{{(\.exe)?}}" {{.*}} "-o" "[[LD_OUT2:[^"]*]]" {{.*}} "[[CC_OUT2]]"
 // CHECK:lipo"
 // CHECK-DAG: "[[LD_OUT1]]"
 // CHECK-DAG: "[[LD_OUT2]]"


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


Re: r257982 - [libclang] Add missing CINDEX_LINKAGE from some new APIs in Index.h.

2016-01-16 Thread Ismail Donmez via cfe-commits
On Sat, Jan 16, 2016 at 5:01 AM, Argyrios Kyrtzidis via cfe-commits
 wrote:
> Author: akirtzidis
> Date: Fri Jan 15 21:01:20 2016
> New Revision: 257982
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257982&view=rev
> Log:
> [libclang] Add missing CINDEX_LINKAGE from some new APIs in Index.h.
>
> Modified:
> cfe/trunk/include/clang-c/Index.h

Should this be in 3.8 branch too?

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


Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-16 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45074.
arpith-jacob added a comment.

Created a distinct patch for 'target enter data'.
Added nesting test cases where the unstructured statement is nested in various 
regions.


http://reviews.llvm.org/D15989

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_device_messages.cpp
  test/OpenMP/target_enter_data_if_messages.cpp
  test/OpenMP/target_enter_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -600,6 +600,9 @@
   case Stmt::OMPTargetDataDirectiveClass:
 K = CXCursor_OMPTargetDataDirective;
 break;
+  case Stmt::OMPTargetEnterDataDirectiveClass:
+K = CXCursor_OMPTargetEnterDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1953,6 +1953,7 @@
   void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
+  void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2628,6 +2629,11 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetEnterDataDirective(
+const OMPTargetEnterDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4510,6 +4516,8 @@
 return cxstring::createRef("OMPTargetDirective");
   case CXCursor_OMPTargetDataDirective:
 return cxstring::createRef("OMPTargetDataDirective");
+  case CXCursor_OMPTargetEnterDataDirective:
+return cxstring::createRef("OMPTargetEnterDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_enter_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target enter data // expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(always, to: r)
+  #pragma omp target enter data map(always, alloc: r)
+  #pragma omp target enter data map(always, from: r) // expected-error {{map type 'from' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(release: r) // expected-error {{map type 'release' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(delete: r) // expected-error {{map type 'delete' is not allowed for '#pragma omp target enter data'}}
+
+  return 0;
+}
Index: test/OpenMP/target_enter_data_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_if_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp target enter data map(to: i) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target enter data map(to: i) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp tar

Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-16 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45075.
arpith-jacob added a comment.

Created a distinct patch for 'target enter data'.
Added nesting test cases where the unstructured statement is nested in various 
regions.
Removed extraneous comments.


http://reviews.llvm.org/D15989

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_device_messages.cpp
  test/OpenMP/target_enter_data_if_messages.cpp
  test/OpenMP/target_enter_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -600,6 +600,9 @@
   case Stmt::OMPTargetDataDirectiveClass:
 K = CXCursor_OMPTargetDataDirective;
 break;
+  case Stmt::OMPTargetEnterDataDirectiveClass:
+K = CXCursor_OMPTargetEnterDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1953,6 +1953,7 @@
   void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
+  void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2628,6 +2629,11 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetEnterDataDirective(
+const OMPTargetEnterDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4510,6 +4516,8 @@
 return cxstring::createRef("OMPTargetDirective");
   case CXCursor_OMPTargetDataDirective:
 return cxstring::createRef("OMPTargetDataDirective");
+  case CXCursor_OMPTargetEnterDataDirective:
+return cxstring::createRef("OMPTargetEnterDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_enter_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target enter data // expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(always, to: r)
+  #pragma omp target enter data map(always, alloc: r)
+  #pragma omp target enter data map(always, from: r) // expected-error {{map type 'from' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(release: r) // expected-error {{map type 'release' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(delete: r) // expected-error {{map type 'delete' is not allowed for '#pragma omp target enter data'}}
+
+  return 0;
+}
Index: test/OpenMP/target_enter_data_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_if_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp target enter data map(to: i) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target enter data map(to: i) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match 

Re: [PATCH] D16179: [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.

2016-01-16 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:54-55
@@ -53,16 +53,4 @@
 
   // Both types must be pointers or references to classes.
-  if (const auto *DerivedPT = DerivedReturnTy->getAs()) {
-if (const auto *BasePT = BaseReturnTy->getAs()) {
-  DTy = DerivedPT->getPointeeType();
-  BTy = BasePT->getPointeeType();
-}
-  } else if (const auto *DerivedRT = DerivedReturnTy->getAs()) {
-if (const auto *BaseRT = BaseReturnTy->getAs()) {
-  DTy = DerivedRT->getPointeeType();
-  BTy = BaseRT->getPointeeType();
-}
-  }
-
-  // The return types aren't either both pointers or references to a class 
type.
-  if (DTy.isNull())
+  if ((!BaseReturnTy->isPointerType() || !DerivedReturnTy->isPointerType()) &&
+  (!BaseReturnTy->isReferenceType() || 
!DerivedReturnTy->isReferenceType()))

It takes a non-trivial effort to understand the equivalence of the comment and 
the condition. I think, pulling the negations one level up would make the 
condition read easier:
```
if (!(BaseReturnTy->isPointerType() && DerivedReturnTy->isPointerType()) &&
!(BaseReturnTy->isReferenceType() && DerivedReturnTy->isReferenceType()))
  return;
```

Also, please move the definitions of the variables `BTy`, `DTy`, `BRD`, `DRD` 
after this `if` and merge them with their initialization. 


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:240
@@ -247,2 +239,3 @@
 unsigned EditDistance =
-BaseMD->getName().edit_distance(DerivedMD->getName());
+StringRef(BaseMD->getNameAsString())
+.edit_distance(DerivedMD->getNameAsString());

xazax.hun wrote:
> congliu wrote:
> > NamedDecl::getName() directly returns a StringRef. Why using 
> > "getNameAsString()"? 
> Unfortunately getName will cause an assertion fail for methods that has a 
> non-identifier name, such as destructors and overloaded operators.
Should we maybe exclude operators and destructors from this check? A typo in 
destructor name won't compile. Do you have an example of a case where the check 
could be useful in detecting a typo in the name of an overloaded operator?

It would be nice to avoid using the (more expensive) `getNameAsString` here. 


http://reviews.llvm.org/D16179



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


Re: r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.

2016-01-16 Thread Joerg Sonnenberger via cfe-commits
Hello Richard,
can this be merged into 3.8? It creates some trivial noise under
valgrind.

Joerg

On Fri, Jan 15, 2016 at 10:29:34PM -, Joerg Sonnenberger via cfe-commits 
wrote:
> Author: joerg
> Date: Fri Jan 15 16:29:34 2016
> New Revision: 257947
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=257947&view=rev
> Log:
> Avoid self-assignment of SmallString, trigger UB behavior down the road.
> 
> Modified:
> cfe/trunk/tools/driver/driver.cpp
> 
> Modified: cfe/trunk/tools/driver/driver.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=257947&r1=257946&r2=257947&view=diff
> ==
> --- cfe/trunk/tools/driver/driver.cpp (original)
> +++ cfe/trunk/tools/driver/driver.cpp Fri Jan 15 16:29:34 2016
> @@ -290,9 +290,9 @@ static void SetInstallDir(SmallVectorImp
>if (CanonicalPrefixes)
>  llvm::sys::fs::make_absolute(InstalledPath);
>  
> -  InstalledPath = llvm::sys::path::parent_path(InstalledPath);
> -  if (llvm::sys::fs::exists(InstalledPath.c_str()))
> -TheDriver.setInstalledDir(InstalledPath);
> +  StringRef InstalledPathParent(llvm::sys::path::parent_path(InstalledPath));
> +  if (llvm::sys::fs::exists(InstalledPathParent))
> +TheDriver.setInstalledDir(InstalledPathParent);
>  }
>  
>  static int ExecuteCC1Tool(ArrayRef argv, StringRef Tool) {
> 
> 
> ___
> 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: [PATCH] D16179: [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss check.

2016-01-16 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:240
@@ -247,2 +239,3 @@
 unsigned EditDistance =
-BaseMD->getName().edit_distance(DerivedMD->getName());
+StringRef(BaseMD->getNameAsString())
+.edit_distance(DerivedMD->getNameAsString());

alexfh wrote:
> xazax.hun wrote:
> > congliu wrote:
> > > NamedDecl::getName() directly returns a StringRef. Why using 
> > > "getNameAsString()"? 
> > Unfortunately getName will cause an assertion fail for methods that has a 
> > non-identifier name, such as destructors and overloaded operators.
> Should we maybe exclude operators and destructors from this check? A typo in 
> destructor name won't compile. Do you have an example of a case where the 
> check could be useful in detecting a typo in the name of an overloaded 
> operator?
> 
> It would be nice to avoid using the (more expensive) `getNameAsString` here. 
Destructors can not be mispelled. Overloaded operators however might be 
virtual, and the user might forget the qualifier and miss the override. 
Although that might be a very rare case. Do you think it is worth to exclude 
that case for performance? Operators might be problematic anyways, the edit 
distance tend to be low there. 


http://reviews.llvm.org/D16179



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


Re: [PATCH] D16113: [clang-tdiy] Add header file extension configuration support.

2016-01-16 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 45077.
hokein marked an inline comment as done.
hokein added a comment.

Format code style.


http://reviews.llvm.org/D16113

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidy.h
  clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
  clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/HeaderFileExtensionsUtils.cpp
  clang-tidy/utils/HeaderFileExtensionsUtils.h

Index: clang-tidy/utils/HeaderFileExtensionsUtils.h
===
--- /dev/null
+++ clang-tidy/utils/HeaderFileExtensionsUtils.h
@@ -0,0 +1,50 @@
+//===--- HeaderFileExtensionsUtils.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_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
+
+#include 
+
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/Support/Path.h"
+
+namespace clang {
+namespace tidy {
+namespace header_file_extensions_utils {
+
+typedef llvm::SmallSet HeaderFileExtensionsSet;
+
+/// \brief Checks whether expansion location of Loc is in header file.
+bool isExpansionLocInHeaderFile(
+SourceLocation Loc, const SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions);
+
+/// \brief Checks whether presumed location of Loc is in header file.
+bool isPresumedLocInHeaderFile(
+SourceLocation Loc, SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions);
+
+/// \brief Checks whether spelling location of Loc is in header file.
+bool isSpellingLocInHeaderFile(
+SourceLocation Loc, SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions);
+
+/// \brief Parses header file extensions from a comma-separated list.
+bool parseHeaderFileExtensions(llvm::StringRef AllHeaderFileExtensions,
+   HeaderFileExtensionsSet &HeaderFileExtensions);
+
+} // namespace header_file_extensions_utils
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
Index: clang-tidy/utils/HeaderFileExtensionsUtils.cpp
===
--- /dev/null
+++ clang-tidy/utils/HeaderFileExtensionsUtils.cpp
@@ -0,0 +1,64 @@
+//===--- HeaderFileExtensionsUtils.cpp - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "HeaderFileExtensionsUtils.h"
+#include "clang/Basic/CharInfo.h"
+
+namespace clang {
+namespace tidy {
+namespace header_file_extensions_utils {
+
+bool isExpansionLocInHeaderFile(
+SourceLocation Loc, const SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions) {
+  SourceLocation ExpansionLoc = SM.getExpansionLoc(Loc);
+  StringRef FileExtension =
+  llvm::sys::path::extension(SM.getFilename(ExpansionLoc));
+  return HeaderFileExtensions.count(FileExtension.substr(1)) > 0;
+}
+
+bool isPresumedLocInHeaderFile(
+SourceLocation Loc, SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions) {
+  PresumedLoc PresumedLocation = SM.getPresumedLoc(Loc);
+  StringRef FileExtension =
+  llvm::sys::path::extension(PresumedLocation.getFilename());
+  return HeaderFileExtensions.count(FileExtension.substr(1)) > 0;
+}
+
+bool isSpellingLocInHeaderFile(
+SourceLocation Loc, SourceManager &SM,
+const HeaderFileExtensionsSet &HeaderFileExtensions) {
+  SourceLocation SpellingLoc = SM.getSpellingLoc(Loc);
+  StringRef FileExtension =
+  llvm::sys::path::extension(SM.getFilename(SpellingLoc));
+
+  return HeaderFileExtensions.count(FileExtension.substr(1)) > 0;
+}
+
+bool parseHeaderFileExtensions(llvm::StringRef AllHeaderFileExtensions,
+   HeaderFileExtensionsSet &HeaderFileExtensions) {
+  SmallVector Suffixes;
+  AllHeaderFileExtensions.split(Suffixes, ',');
+  HeaderFileExtensions.clear();
+  for (llvm::StringRef Suffix : Suffixes) {
+llvm::StringRef Extension = Suffix.trim();
+for (llvm::StringRef::const_iterator it = Extension.begin();
+ it != Extension.end(); ++it) {
+  if (!

Re: r257982 - [libclang] Add missing CINDEX_LINKAGE from some new APIs in Index.h.

2016-01-16 Thread Argyrios Kyrtzidis via cfe-commits
> On Jan 16, 2016, at 1:15 AM, Ismail Donmez  wrote:
> 
> On Sat, Jan 16, 2016 at 5:01 AM, Argyrios Kyrtzidis via cfe-commits
>  wrote:
>> Author: akirtzidis
>> Date: Fri Jan 15 21:01:20 2016
>> New Revision: 257982
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=257982&view=rev
>> Log:
>> [libclang] Add missing CINDEX_LINKAGE from some new APIs in Index.h.
>> 
>> Modified:
>>cfe/trunk/include/clang-c/Index.h
> 
> Should this be in 3.8 branch too?

I assume you mean both r257968 and r257982; it would be fine to add them, they 
are new functionality not disrupting existing functionality.

> 
> ismail

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


[PATCH] D16261: [CUDA] Only allow __global__ on free functions and static member functions.

2016-01-16 Thread Justin Lebar via cfe-commits
jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added subscribers: cfe-commits, echristo, jhen.

Warn for NVCC compatibility if you declare a static member function or
inline function as __global__.

http://reviews.llvm.org/D16261

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/SemaCUDA/bad-attributes.cu

Index: test/SemaCUDA/bad-attributes.cu
===
--- test/SemaCUDA/bad-attributes.cu
+++ test/SemaCUDA/bad-attributes.cu
@@ -47,3 +47,12 @@
 // expected-note@-1 {{conflicting attribute is here}}
 __global__ __host__ void z12();  // expected-error {{attributes are not 
compatible}}
 // expected-note@-1 {{conflicting attribute is here}}
+
+struct S {
+  __global__ void foo() {};  // expected-error {{must be a free function or 
static member function}}
+  __global__ static void bar(); // expected-warning {{kernel function 'bar' is 
a member function}}
+  __global__ static void baz() {}; // expected-warning {{kernel function 'baz' 
is a member function}}
+  // expected-warning@-1 {{kernel function 'baz' is inline}}
+};
+
+__global__ static inline void foobar() {};  // expected-warning {{kernel 
function 'foobar' is inline}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3617,11 +3617,23 @@
   : FixItHint());
 return;
   }
+  if (const auto *Method = dyn_cast(FD)) {
+if (Method->isInstance()) {
+  S.Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method)
+  << Method;
+  return;
+}
+S.Diag(Method->getLocStart(), diag::warn_nvcc_compat_kern_is_method)
+<< Method;
+  }
+  if (FD->isInlined()) {
+S.Diag(FD->getLocStart(), diag::warn_nvcc_compat_kern_is_inlined)
+<< FD;
+  }
 
   D->addAttr(::new (S.Context)
   CUDAGlobalAttr(Attr.getRange(), S.Context,
  Attr.getAttributeSpellingListIndex()));
-
 }
 
 static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) {
Index: lib/Sema/SemaCUDA.cpp
===
--- lib/Sema/SemaCUDA.cpp
+++ lib/Sema/SemaCUDA.cpp
@@ -273,12 +273,9 @@
 resolveCalleeCUDATargetConflict(Sema::CUDAFunctionTarget Target1,
 Sema::CUDAFunctionTarget Target2,
 Sema::CUDAFunctionTarget *ResolvedTarget) {
-  if (Target1 == Sema::CFT_Global && Target2 == Sema::CFT_Global) {
-// TODO: this shouldn't happen, really. Methods cannot be marked 
__global__.
-// Clang should detect this earlier and produce an error. Then this
-// condition can be changed to an assertion.
-return true;
-  }
+  // Only free functions and static member functions may be global.
+  assert(Target1 != Sema::CFT_Global);
+  assert(Target2 != Sema::CFT_Global);
 
   if (Target1 == Sema::CFT_HostDevice) {
 *ResolvedTarget = Target2;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6400,6 +6400,8 @@
 
 def err_kern_type_not_void_return : Error<
   "kernel function type %0 must have void return type">;
+def err_kern_is_nonstatic_method : Error<
+  "kernel function %0 must be a free function or static member function">;
 def err_config_scalar_return : Error<
   "CUDA special function 'cudaConfigureCall' must have scalar return type">;
 def err_kern_call_not_global_function : Error<
@@ -6412,6 +6414,12 @@
 def warn_host_calls_from_host_device : Warning<
   "calling __host__ function %0 from __host__ __device__ function %1 can lead 
to runtime errors">,
   InGroup;
+def warn_nvcc_compat_kern_is_method : Warning<
+  "kernel function %0 is a member function; this may not be accepted by nvcc">,
+  InGroup;
+def warn_nvcc_compat_kern_is_inlined : Warning<
+  "kernel function %0 is inlined; this may not be accepted by nvcc">,
+  InGroup;
 
 def warn_non_pod_vararg_with_format_string : Warning<
   "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic "


Index: test/SemaCUDA/bad-attributes.cu
===
--- test/SemaCUDA/bad-attributes.cu
+++ test/SemaCUDA/bad-attributes.cu
@@ -47,3 +47,12 @@
 // expected-note@-1 {{conflicting attribute is here}}
 __global__ __host__ void z12();  // expected-error {{attributes are not compatible}}
 // expected-note@-1 {{conflicting attribute is here}}
+
+struct S {
+  __global__ void foo() {};  // expected-error {{must be a free function or static member function}}
+  __global__ static void bar(); // expected-warning {{kernel function 'bar' is a member function}}
+  __global__ static void baz() {}; // expected-warning {{kernel function 'baz

Re: [PATCH] D16259: Add clang-tidy readability-redundant-return check

2016-01-16 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Thank you for this check! https://llvm.org/bugs/show_bug.cgi?id=21984 waited to 
be implemented for so looong time :-)

By the word, other return related readability check idea: 
https://llvm.org/bugs/show_bug.cgi?id=22416. May be both could be combined in 
single check?


http://reviews.llvm.org/D16259



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


Re: [PATCH] D16158: [CMake] Add clang's targets to LLVM's export set when not building standalone

2016-01-16 Thread don hinton via cfe-commits
hintonda added a comment.

Sorry the previous change caused this configuration to break.  However, I'm not 
sure about adding LLVMExports here.  Shouldn't that be handled in 
llvm/CMakeLists.txt?

In fact, this looks like a cmake bug (or feature) that won't let you export a 
target that depends on a static lib without also exporting that static lib.  
Since you've set LLVM_INSTALL_TOOLCHAIN_ONLY, you don't want to export those 
statics libs anyway, since they won't be available.

I'll play around with it and see if I can come up with something that works for 
all configurations.


http://reviews.llvm.org/D16158



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


[PATCH] D16264: For FreeBSD, use _p variants of libraries for linking C++ programs

2016-01-16 Thread Dimitry Andric via cfe-commits
dim created this revision.
dim added reviewers: compnerd, davide, dws, emaste.
dim added subscribers: rpokala, cfe-commits.
Herald added a subscriber: emaste.

As reported in https://llvm.org/bugs/show_bug.cgi?id=25496, on FreeBSD,
C++ programs compiled for profiling (using `-pg`) should be linked with
`-lc++_p` (or `-lstdc++_p`, depending on the `-stdlib=` setting), not
with the regular C++ libraries.

Add a `FreeBSD::AddCXXStdlibLibArgs()` override to handle this, and add
a test case for it.

This review is intended to replace D16102.

http://reviews.llvm.org/D16264

Files:
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  test/Driver/freebsd.cpp

Index: test/Driver/freebsd.cpp
===
--- test/Driver/freebsd.cpp
+++ test/Driver/freebsd.cpp
@@ -4,3 +4,10 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
 // CHECK-TEN: -lc++
 // CHECK-NINE: -lstdc++
+
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-TEN: -lc++_p
+// CHECK-PG-NINE: -lstdc++_p
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -725,6 +725,8 @@
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
 
   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3116,6 +3116,22 @@
   }
 }
 
+void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
+  ArgStringList &CmdArgs) const {
+  CXXStdlibType Type = GetCXXStdlibType(Args);
+  bool Profiling = Args.hasArg(options::OPT_pg);
+
+  switch (Type) {
+  case ToolChain::CST_Libcxx:
+CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
+break;
+
+  case ToolChain::CST_Libstdcxx:
+CmdArgs.push_back(Profiling ? "-lstdc++_p" : "-lstdc++");
+break;
+  }
+}
+
 Tool *FreeBSD::buildAssembler() const {
   return new tools::freebsd::Assembler(*this);
 }


Index: test/Driver/freebsd.cpp
===
--- test/Driver/freebsd.cpp
+++ test/Driver/freebsd.cpp
@@ -4,3 +4,10 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NINE %s
 // CHECK-TEN: -lc++
 // CHECK-NINE: -lstdc++
+
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd10.0 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-TEN %s
+// RUN: %clangxx %s -### -pg -o %t.o -target amd64-unknown-freebsd9.2 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG-NINE %s
+// CHECK-PG-TEN: -lc++_p
+// CHECK-PG-NINE: -lstdc++_p
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -725,6 +725,8 @@
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
 
   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3116,6 +3116,22 @@
   }
 }
 
+void FreeBSD::AddCXXStdlibLibArgs(const ArgList &Args,
+  ArgStringList &CmdArgs) const {
+  CXXStdlibType Type = GetCXXStdlibType(Args);
+  bool Profiling = Args.hasArg(options::OPT_pg);
+
+  switch (Type) {
+  case ToolChain::CST_Libcxx:
+CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
+break;
+
+  case ToolChain::CST_Libstdcxx:
+CmdArgs.push_back(Profiling ? "-lstdc++_p" : "-lstdc++");
+break;
+  }
+}
+
 Tool *FreeBSD::buildAssembler() const {
   return new tools::freebsd::Assembler(*this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16102: Bug 25496 - clang++ -pg links with -lc++ instead of -lc++_p

2016-01-16 Thread Dimitry Andric via cfe-commits
dim commandeered this revision.
dim added a reviewer: dws.
dim added a comment.

Going to abandon this review in favor of http://reviews.llvm.org/D16264.


http://reviews.llvm.org/D16102



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


r258003 - [MS ABI] Don't crash while mangling recursive lambdas

2016-01-16 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Sun Jan 17 01:09:24 2016
New Revision: 258003

URL: http://llvm.org/viewvc/llvm-project?rev=258003&view=rev
Log:
[MS ABI] Don't crash while mangling recursive lambdas

We might get into bad situations where we try to embed the signature of
an inner lambda into an outer lambda which cannot work: the inner lambda
wants to embed the name of the outer lambda!

Instead, omit the return type for lambdas.

This fixes PR26105.

N.B.  While we are here, make lambdas nested within functions use an
artificial scope so that they can get demangled.

Modified:
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx14.cpp
cfe/trunk/test/CodeGenCXX/pr20719.cpp

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=258003&r1=258002&r2=258003&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Sun Jan 17 01:09:24 2016
@@ -160,14 +160,17 @@ public:
  raw_ostream &Out) override;
   void mangleStringLiteral(const StringLiteral *SL, raw_ostream &Out) override;
   bool getNextDiscriminator(const NamedDecl *ND, unsigned &disc) {
-// Lambda closure types are already numbered.
-if (isLambda(ND))
-  return false;
-
 const DeclContext *DC = getEffectiveDeclContext(ND);
 if (!DC->isFunctionOrMethod())
   return false;
 
+// Lambda closure types are already numbered, give out a phony number so
+// that they demangle nicely.
+if (isLambda(ND)) {
+  disc = 1;
+  return true;
+}
+
 // Use the canonical number for externally visible decls.
 if (ND->isExternallyVisible()) {
   disc = getASTContext().getManglingNumber(ND);
@@ -1799,9 +1802,12 @@ void MicrosoftCXXNameMangler::mangleFunc
   SourceRange Range;
   if (D) Range = D->getSourceRange();
 
+  bool IsInLambda = false;
   bool IsStructor = false, HasThisQuals = ForceThisQuals, IsCtorClosure = 
false;
   CallingConv CC = T->getCallConv();
   if (const CXXMethodDecl *MD = dyn_cast_or_null(D)) {
+if (MD->getParent()->isLambda())
+  IsInLambda = true;
 if (MD->isInstance())
   HasThisQuals = true;
 if (isa(MD)) {
@@ -1875,6 +1881,8 @@ void MicrosoftCXXNameMangler::mangleFunc
  "shouldn't need to mangle __auto_type!");
   mangleSourceName(AT->isDecltypeAuto() ? "" : "");
   Out << '@';
+} else if (IsInLambda) {
+  Out << '@';
 } else {
   if (ResultType->isVoidType())
 ResultType = ResultType.getUnqualifiedType();

Modified: cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp?rev=258003&r1=258002&r2=258003&view=diff
==
--- cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-seh-filter-captures.cpp Sun Jan 17 
01:09:24 2016
@@ -70,14 +70,14 @@ void test_lambda() {
   lambda();
 }
 
-// CHECK-LABEL: define internal void 
@"\01??R@?test_lambda@@YAXXZ@QEBAXXZ"(%class.anon* %this)
+// CHECK-LABEL: define internal void 
@"\01??R@?0??test_lambda@@YAXXZ@QEBA@XZ"(%class.anon* %this)
 // CHECK: @llvm.localescape(i32* %[[l2_addr:[^, ]*]])
 // CHECK: store i32 42, i32* %[[l2_addr]], align 4
 // CHECK: invoke void @might_crash()
 
-// CHECK-LABEL: define internal i32 
@"\01?filt$0@0@?R@?test_lambda@@YAXXZ@"(i8* %exception_pointers, i8* 
%frame_pointer)
-// CHECK: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void 
(%class.anon*)* @"\01??R@?test_lambda@@YAXXZ@QEBAXXZ" to i8*), i8* 
%frame_pointer)
-// CHECK: %[[l2_i8:[^ ]*]] = call i8* @llvm.localrecover(i8* bitcast (void 
(%class.anon*)* @"\01??R@?test_lambda@@YAXXZ@QEBAXXZ" to i8*), i8* 
%[[fp]], i32 0)
+// CHECK-LABEL: define internal i32 
@"\01?filt$0@0@?R@?0??test_lambda@@YAXXZ@"(i8* %exception_pointers, 
i8* %frame_pointer)
+// CHECK: %[[fp:[^ ]*]] = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void 
(%class.anon*)* @"\01??R@?0??test_lambda@@YAXXZ@QEBA@XZ" to i8*), i8* 
%frame_pointer)
+// CHECK: %[[l2_i8:[^ ]*]] = call i8* @llvm.localrecover(i8* bitcast (void 
(%class.anon*)* @"\01??R@?0??test_lambda@@YAXXZ@QEBA@XZ" to i8*), i8* 
%[[fp]], i32 0)
 // CHECK: %[[l2_ptr:[^ ]*]] = bitcast i8* %[[l2_i8]] to i32*
 // CHECK: %[[l2:[^ ]*]] = load i32, i32* %[[l2_ptr]]
 // CHECK: call i32 (i32, ...) @basic_filter(i32 %[[l2]])

Modified: cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp?rev=258003&r1=258002&r2=258003&view=diff
==