[libcxx] r249372 - Add comments for LWG issues 2219 and 2367

2015-10-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Oct  5 23:12:30 2015
New Revision: 249372

URL: http://llvm.org/viewvc/llvm-project?rev=249372&view=rev
Log:
Add comments for LWG issues 2219 and 2367

Modified:
libcxx/trunk/www/kona.html

Modified: libcxx/trunk/www/kona.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/kona.html?rev=249372&r1=249371&r2=249372&view=diff
==
--- libcxx/trunk/www/kona.html (original)
+++ libcxx/trunk/www/kona.html Mon Oct  5 23:12:30 2015
@@ -113,13 +113,13 @@
 2156 - check and make sure that we already do this. Write a test.
 2181 - I suspect that this will not require any code changes, but will 
need to be read carefully.
 2218 - Shouldn't require any code changes.
-2219 - Punt to Eric
+2219 - Sizable changes required. INVOKE needs 2 additional overloads and 
plenty of tests. I'm not going to back port this to C++03. (Eric)
 2244 - We don't do this; easy fix; think about how to test it.
 2250 - Looks like wording cleanup. Need to check more closely, but I think 
there's no code changes here.
 2259 - No code changes needed here.
 2336 - Check later
 2353 - Simple change, needs a test. (test probably used to exist)
-2367 - Ask Eric to do it. Tests.
+2367 - Already done in tuple, pair needs to be done. Tests. (Eric)
 2380 - No code changes here; we already do this.
 2384 - Wording cleanup; no code change required
 2385 - Removing broken signatures. Only question is "how far back"?


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


Re: [PATCH] D13408: Skip NonNull sema checks in unevaluated contexts.

2015-10-05 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

`DiagRuntimeBehavior` seems like a better way to do this. I'll commit that 
change.


http://reviews.llvm.org/D13408



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


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-05 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I think thing change will help us close a number out outstanding bugs. I  don't 
have any fundamental objections to this approach.  However the size of this 
patch scares me.  I understand the changes are mostly mechanical but their size 
can hide things. For example has anybody noticed that your internal changes to 
`` are in this patch? It would be nice to break this down into more 
digestible pieces that could be quickly spot checked.


Repository:
  rL LLVM

http://reviews.llvm.org/D12747



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


Re: [PATCH] D13408: Skip NonNull sema checks in unevaluated contexts.

2015-10-05 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

This seems reasonable.

I wonder if it might be better to also suppress warnings for 
dynamically-unreachable code (you can do this by changing the `Diag` calls 
inside `CheckNonNullArguments` to `DiagRuntimeBehavior` instead of the current 
patch). That would help for a case like:

  #define SAFE_FOO(x) if (x) foo(x)
  SAFE_FOO(0);

... but admittedly that's pretty contrived.

Anyway, this looks fine as far as it goes.


http://reviews.llvm.org/D13408



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


Re: [PATCH] D11182: [OPENMP 4.0] Initial support for 'omp declare reduction' construct.

2015-10-05 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/AST/DeclOpenMP.h:95
@@ +94,3 @@
+/// #pragma omp declare reduction (foo : int,float : omp_out += omp_in)
+/// initializer (omp_priv = 0)
+/// \endcode

I think automatic formatting has messed up your example. Maybe indent this line 
a bit more to show it's a continuation of the previous line.


Comment at: include/clang/AST/DeclOpenMP.h:99
@@ +98,3 @@
+/// Here 'omp_out += omp_in' is a combiner and 'omp_priv = 0' is an 
initializer.
+class OMPDeclareReductionDecl : public DeclaratorDecl, public DeclContext {
+private:

OK, then you need to update some parts of class `DeclContext` for this. At 
least the comment on that class needs to be updated, and possibly other parts 
too.


Comment at: include/clang/AST/DeclOpenMP.h:99
@@ +98,3 @@
+/// Here 'omp_out += omp_in' is a combiner and 'omp_priv = 0' is an 
initializer.
+class OMPDeclareReductionDecl : public DeclaratorDecl, public DeclContext {
+private:

rsmith wrote:
> OK, then you need to update some parts of class `DeclContext` for this. At 
> least the comment on that class needs to be updated, and possibly other parts 
> too.
Why is this a `DeclaratorDecl` rather than merely a `NamedDecl`? It doesn't 
have a declarator, or even a type.


Comment at: include/clang/AST/DeclOpenMP.h:103-105
@@ +102,5 @@
+  /// \brief Combiner for declare reduction construct.
+  Stmt *Combiner;
+  /// \brief Initializer for declare reduction construct.
+  Stmt *Initializer;
+  /// \brief Reference to the previous declare reduction construct in the same

Store these as `Expr*`s. We use `Stmt*` arrays in `Expr` nodes to support 
`StmtIterator`, which is not a concern here.


Comment at: include/clang/AST/DeclOpenMP.h:106
@@ +105,3 @@
+  Stmt *Initializer;
+  /// \brief Reference to the previous declare reduction construct in the same
+  /// scope with the same name. Required for proper templates instantiation if

The comment doesn't match the name. Does this point to the next or previous 
declaration? The previous decl would make more sense, since AST nodes are 
intended to be immutable once created. Storing them in this order will also 
create problems for template instantiation.


Comment at: include/clang/AST/DeclOpenMP.h:109
@@ +108,3 @@
+  /// the declare reduction construct is declared inside compound statement.
+  Decl *NextDeclInScope;
+

Store this as an `OMPDeclareReductionDecl*`.


Comment at: include/clang/AST/DeclOpenMP.h:130
@@ +129,3 @@
+  /// \brief Get combiner expression of the declare reduction construct.
+  Expr *getCombiner() { return cast(Combiner); }
+  Expr *getCombiner() const { return cast(Combiner); }

This is redundant with the next function. If you keep both, this should return 
`const Expr*`.


Comment at: include/clang/AST/DeclOpenMP.h:137
@@ +136,3 @@
+  /// construct.
+  Expr *getInitializer() { return cast_or_null(Initializer); }
+  Expr *getInitializer() const { return cast_or_null(Initializer); }

Likewise.


Comment at: include/clang/AST/DeclOpenMP.h:144-146
@@ +143,5 @@
+  /// scope with the same name.
+  OMPDeclareReductionDecl *getNextDeclInScope() {
+return cast_or_null(NextDeclInScope);
+  }
+  OMPDeclareReductionDecl *getNextDeclInScope() const {

Likewise.


Comment at: lib/AST/ASTContext.cpp:8321-8322
@@ -8320,4 +8320,4 @@
   return false;
-  } else if (isa(D))
+  } else if (isa(D) || isa(D))
 return true;
   else

Can these be forward-declared / used from a different translation unit than 
their definition? If not, it would seem better to emit them on use rather than 
emitting them eagerly.


Comment at: lib/AST/ItaniumMangle.cpp:70-73
@@ -68,4 +69,6 @@
   const DeclContext *DC = D->getDeclContext();
   if (const CapturedDecl *CD = dyn_cast(DC))
 return getEffectiveDeclContext(CD);
+  if (auto *DR = dyn_cast(DC))
+  return getEffectiveDeclContext(DR);
 

Use `isa(DC) || isa(DC)` then 
`cast(DC)` here.


Comment at: lib/AST/ItaniumMangle.cpp:73
@@ -71,1 +72,3 @@
+  if (auto *DR = dyn_cast(DC))
+  return getEffectiveDeclContext(DR);
 

Too much indentation here.


Comment at: lib/AST/MicrosoftMangle.cpp:63-64
@@ -61,2 +62,4 @@
 return getEffectiveDeclContext(CD);
+  if (auto *DR = dyn_cast(DC))
+return getEffectiveDeclContext(DR);
 

Likewise.


Comment at: lib/CodeGen/CodeGenModule.h:1131
@@ +1130,3 @@
+  /// \brief Emit a code for declare reduction construct.
+  ///
+  void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D);

Remove blank comment line.


Comment at: lib/Parse/Pars

[libcxx] r249363 - Mark 2259 and 2473 as complete. Add some more notes

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 18:27:10 2015
New Revision: 249363

URL: http://llvm.org/viewvc/llvm-project?rev=249363&view=rev
Log:
Mark 2259 and 2473 as complete. Add some more notes

Modified:
libcxx/trunk/www/kona.html

Modified: libcxx/trunk/www/kona.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/kona.html?rev=249363&r1=249362&r2=249363&view=diff
==
--- libcxx/trunk/www/kona.html (original)
+++ libcxx/trunk/www/kona.html Mon Oct  5 18:27:10 2015
@@ -71,7 +71,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2219";>2219INVOKE-ing
 a pointer to member with a reference_wrapper as the object 
expressionKona
http://cplusplus.github.io/LWG/lwg-defects.html#2244";>2244Issue
 on basic_istream::seekgKona
http://cplusplus.github.io/LWG/lwg-defects.html#2250";>2250Follow-up
 On Library Issue 2207Kona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2259";>2259Issues
 in 17.6.5.5 rules for member functionsKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2259";>2259Issues
 in 17.6.5.5 rules for member functionsKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2336";>2336is_trivially_constructible/is_trivially_assignable
 traits are always falseKona
http://cplusplus.github.io/LWG/lwg-defects.html#2353";>2353std::next
 is over-constrainedKona
http://cplusplus.github.io/LWG/lwg-defects.html#2367";>2367pair
 and tuple are not correctly implemented for is_constructible 
with no argsKona
@@ -83,7 +83,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2462";>2462std::ios_base::failure
 is overspecifiedKona
http://cplusplus.github.io/LWG/lwg-defects.html#2466";>2466allocator_traits::max_size()
 default behavior is incorrectKonaPatch Ready
http://cplusplus.github.io/LWG/lwg-defects.html#2469";>2469Wrong
 specification of Requires clause of operator[] for map and 
unordered_mapKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2473";>2473basic_filebuf's
 relation to C FILE semanticsKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2473";>2473basic_filebuf's
 relation to C FILE semanticsKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2476";>2476scoped_allocator_adaptor
 is not assignableKona
http://cplusplus.github.io/LWG/lwg-defects.html#2477";>2477Inconsistency
 of wordings in std::vector::erase() and 
std::deque::erase()Kona
http://cplusplus.github.io/LWG/lwg-defects.html#2483";>2483throw_with_nested()
 should use is_finalKonaComplete
@@ -108,7 +108,7 @@
 2101 - Need to write some careful test cases. In particular, need to check 
function types with/without const/ref qualifiers.  Currently we get this wrong. 
Installing metashell to play with these.
 2111 - Resolved an ambiguity by calling it out. No code change 
required.
 2119 - Hashes for all integral and enumeration types. Research needed
-2127 - Add a new member to raw_storage_iterator. Looks simple.
+2127 - Add a new member to raw_storage_iterator. Looks simple. 
Patch Available
 2133 - We do this already; thanks Eric.
 2156 - check and make sure that we already do this. Write a test.
 2181 - I suspect that this will not require any code changes, but will 
need to be read carefully.
@@ -116,7 +116,7 @@
 2219 - Punt to Eric
 2244 - We don't do this; easy fix; think about how to test it.
 2250 - Looks like wording cleanup. Need to check more closely, but I think 
there's no code changes here.
-2259 - I don't think that there's any code changes needed here.
+2259 - No code changes needed here.
 2336 - Check later
 2353 - Simple change, needs a test. (test probably used to exist)
 2367 - Ask Eric to do it. Tests.
@@ -125,10 +125,10 @@
 2385 - Removing broken signatures. Only question is "how far back"?
 2435 - Wording cleanup; no code change required
 2447 - I don't know if there's any work here.
-2462 - No code change necessary. Are there tests here? Should there 
be?
-2466 - Simple change; need a test.
-2469 - I suspect this is just wording cleanup, but it needs a closer 
look.
-2473 - I suspect this is just wording cleanup, but it needs a closer 
look.
+2462 - No code change necessary. I don't see any tests. I think that there 
should be
+2466 - Simple change; need a test. Patch Available
+2469 - This is a followon to 2464, which we're done. This restates a bunch 
of operations in terms of newer ops. Probably refactoring to do here, but tests 
shouldn't change.
+2473 - There are two changes here; one to filebuf::seekpos and 
the other to filebuf::sync. We do both of these already.
 2476 - Simple change; need tests.
 2477 - Definitely wording cleanup, but check the tests.
 2483 - We already do this.
@@ -136,7 +136,7 @@
 2485 - Ask Eric to do it. 
 2486 - Lots of code changes, all mechanical. Tests will be sizable.
 2487 - Don't know
-2489 - Looks easy. Just add some NOEXCEPT, and tests.
+2489 - Looks easy. J

[PATCH] D13453: Always generate cmake config files

2015-10-05 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added a reviewer: chapuni.
hintonda added a subscriber: cfe-commits.

Always generate and install cmake config files.

Currently, cmake config files are only generated and installed when 
CLANG_BUILD_STANDALONE set, which means config file will not be generated or 
installed when clang is built with llvm.  This change removes that restriction.

http://reviews.llvm.org/D13453

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -550,30 +550,28 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE)
-  # Generate a list of CMake library targets so that other CMake projects can
-  # link against them. LLVM calls its version of this file LLVMExports.cmake, 
but
-  # the usual CMake convention seems to be ${Project}Targets.cmake.
-  set(CLANG_INSTALL_PACKAGE_DIR share/clang/cmake)
-  set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
-  get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
-  export(TARGETS ${CLANG_EXPORTS} FILE 
${clang_cmake_builddir}/ClangTargets.cmake)
-
-  # Install a /share/clang/cmake/ClangConfig.cmake file so that
-  # find_package(Clang) works. Install the target list with it.
-  install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
-
-  install(FILES
-${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClangConfig.cmake
-DESTINATION share/clang/cmake)
-
-  # Also copy ClangConfig.cmake to the build directory so that dependent 
projects
-  # can build against a build directory of Clang more easily.
-  configure_file(
-${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClangConfig.cmake
-${CLANG_BINARY_DIR}/share/clang/cmake/ClangConfig.cmake
-COPYONLY)
-endif ()
+# Generate a list of CMake library targets so that other CMake projects can
+# link against them. LLVM calls its version of this file LLVMExports.cmake, but
+# the usual CMake convention seems to be ${Project}Targets.cmake.
+set(CLANG_INSTALL_PACKAGE_DIR share/clang/cmake)
+set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
+get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
+export(TARGETS ${CLANG_EXPORTS} FILE 
${clang_cmake_builddir}/ClangTargets.cmake)
+
+# Install a /share/clang/cmake/ClangConfig.cmake file so that
+# find_package(Clang) works. Install the target list with it.
+install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+
+install(FILES
+  ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClangConfig.cmake
+  DESTINATION share/clang/cmake)
+
+# Also copy ClangConfig.cmake to the build directory so that dependent projects
+# can build against a build directory of Clang more easily.
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClangConfig.cmake
+  ${CLANG_BINARY_DIR}/share/clang/cmake/ClangConfig.cmake
+  COPYONLY)
 
 if (CLANG_ENABLE_BOOTSTRAP)
   include(ExternalProject)


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -550,30 +550,28 @@
 set(CLANG_ORDER_FILE "" CACHE FILEPATH
   "Order file to use when compiling clang in order to improve startup time.")
 
-if (CLANG_BUILT_STANDALONE)
-  # Generate a list of CMake library targets so that other CMake projects can
-  # link against them. LLVM calls its version of this file LLVMExports.cmake, but
-  # the usual CMake convention seems to be ${Project}Targets.cmake.
-  set(CLANG_INSTALL_PACKAGE_DIR share/clang/cmake)
-  set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
-  get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
-  export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
-
-  # Install a /share/clang/cmake/ClangConfig.cmake file so that
-  # find_package(Clang) works. Install the target list with it.
-  install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
-
-  install(FILES
-${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClangConfig.cmake
-DESTINATION share/clang/cmake)
-
-  # Also copy ClangConfig.cmake to the build directory so that dependent projects
-  # can build against a build directory of Clang more easily.
-  configure_file(
-${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/ClangConfig.cmake
-${CLANG_BINARY_DIR}/share/clang/cmake/ClangConfig.cmake
-COPYONLY)
-endif ()
+# Generate a list of CMake library targets so that other CMake projects can
+# link against them. LLVM calls its version of this file LLVMExports.cmake, but
+# the usual CMake convention seems to be ${Project}Targets.cmake.
+set(CLANG_INSTALL_PACKAGE_DIR share/clang/cmake)
+set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/${CLANG_INSTALL_PACKAGE_DIR}")
+get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
+export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTarge

Re: [PATCH] D13368: [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast

2015-10-05 Thread Matthias Gehre via cfe-commits
mgehre added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp:33
@@ +32,3 @@
+  const auto *SourceDecl = SourceType->getPointeeCXXRecordDecl();
+  if(!SourceDecl)
+SourceDecl = SourceType->getAsCXXRecordDecl();

aaron.ballman wrote:
> In the event it's not a pointer or a reference, why are you getting the 
> source as a value type?
Source type could be no pointer nor ref like in:
   Base B0;
   auto R0 = static_cast(B0);
 


http://reviews.llvm.org/D13368



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


Re: [PATCH] D13368: [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast

2015-10-05 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 36567.
mgehre marked 2 inline comments as done.
mgehre added a comment.

Simplify logic to check for BaseToDerived cast. Add test for object to 
reference cast. Fixed comments


http://reviews.llvm.org/D13368

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-static-cast-downcast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-type-static-cast-downcast.cpp
@@ -0,0 +1,99 @@
+// RUN: %python %S/check_clang_tidy.py %s cppcoreguidelines-pro-type-static-cast-downcast %t
+
+class Base {
+};
+
+class Derived : public Base {
+};
+
+class Base2 {
+};
+
+class MultiDerived : public Base, public Base2 {
+};
+
+class PolymorphicBase {
+public:
+  virtual ~PolymorphicBase();
+};
+
+class PolymorphicDerived : public PolymorphicBase {
+};
+
+class PolymorphicMultiDerived : public Base, public PolymorphicBase {
+};
+
+void pointers() {
+
+  auto P0 = static_cast(new Base());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+
+  auto P1 = static_cast(new Derived()); // OK, upcast to a public base
+  auto P2 = static_cast(new MultiDerived()); // OK, upcast to a public base
+  auto P3 = static_cast(new MultiDerived()); // OK, upcast to a public base
+}
+
+void pointers_polymorphic() {
+
+  auto PP0 = static_cast(new PolymorphicBase());
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-static-cast-downcast]
+  // CHECK-FIXES: auto PP0 = dynamic_cast(new PolymorphicBase());
+
+  auto B1 = static_cast(new PolymorphicDerived()); // OK, upcast to a public base
+  auto B2 = static_cast(new PolymorphicMultiDerived()); // OK, upcast to a public base
+  auto B3 = static_cast(new PolymorphicMultiDerived()); // OK, upcast to a public base
+}
+
+void arrays() {
+  Base ArrayOfBase[10];
+  auto A0 = static_cast(ArrayOfBase);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+}
+
+void arrays_polymorphic() {
+  PolymorphicBase ArrayOfPolymorphicBase[10];
+  auto AP0 = static_cast(ArrayOfPolymorphicBase);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-static-cast-downcast]
+  // CHECK-FIXES: auto AP0 = dynamic_cast(ArrayOfPolymorphicBase);
+}
+
+void references() {
+  Base B0;
+  auto R0 = static_cast(B0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+  Base& RefToBase = B0;
+  auto R1 = static_cast(RefToBase);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use static_cast to downcast from a base to a derived class [cppcoreguidelines-pro-type-static-cast-downcast]
+
+  Derived RD1;
+  auto R2 = static_cast(RD1); // OK, upcast to a public base
+}
+
+void references_polymorphic() {
+  PolymorphicBase B0;
+  auto RP0 = static_cast(B0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-static-cast-downcast]
+  // CHECK-FIXES: auto RP0 = dynamic_cast(B0);
+
+
+  PolymorphicBase& RefToPolymorphicBase = B0;
+  auto RP1 = static_cast(RefToPolymorphicBase);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead [cppcoreguidelines-pro-type-static-cast-downcast]
+  // CHECK-FIXES: auto RP1 = dynamic_cast(RefToPolymorphicBase);
+
+  PolymorphicDerived d1;
+  auto RP2 = static_cast(d1); // OK, upcast to a public base
+}
+
+template
+void templ() {
+  auto B0 = static_cast(new D());
+}
+
+void templ_bad_call() {
+  templ(); //FIXME: this should trigger a warning
+}
+
+void templ_good_call() {
+  templ(); // OK, upcast to a public base
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -4,6 +4,7 @@
 .. toctree::
cert-variadic-function-def
cppcoreguidelines-pro-type-reinterpret-cast
+   cppcoreguidelines-pro-type-static-cast-downcast
google-build-explicit-make-pair
google-build-namespaces
  

Re: [PATCH] D13419: Fix several problems at the intersection of template instantiations and visibility

2015-10-05 Thread Keno Fischer via cfe-commits
loladiro updated this revision to Diff 36565.
loladiro added a comment.

Address review comment re loop structure. Reword comment that had a typo to 
both fix the typo and make the intent of the code more clear.


Repository:
  rL LLVM

http://reviews.llvm.org/D13419

Files:
  lib/AST/Decl.cpp
  lib/AST/DeclCXX.cpp
  test/CodeGenCXX/visibility.cpp

Index: test/CodeGenCXX/visibility.cpp
===
--- test/CodeGenCXX/visibility.cpp
+++ test/CodeGenCXX/visibility.cpp
@@ -1314,3 +1314,57 @@
   // CHECK-LABEL: define void @_ZN6test693foo1fEv
   // CHECK-HIDDEN-LABEL: define hidden void @_ZN6test693foo1fEv
 }
+
+namespace test70 {
+  template < typename T > class foo {
+  public:
+  T x;
+  template < typename S >
+  HIDDEN S AddS(S);
+  template < typename S > class HIDDEN barS {
+public:
+  static S AddS2(foo x, S);
+  };
+  template < typename S > class HIDDEN barZ {
+  public:
+template < typename Z >
+  static S AddSZ(foo x, S, Z);
+  };
+  };
+
+  // CHECK: define linkonce_odr hidden i64 @_ZN6test703fooIiE4AddSIxEET_S3_
+  // CHECK-NOT: define linkonce_odr i64 @_ZN6test703fooIiE4AddSIxEET_S3_
+  template < typename T >
+  template < typename S >
+  HIDDEN S foo::AddS(S y) {
+  return ((S) x) + y;
+  }
+
+  // CHECK: define linkonce_odr hidden i64 @_ZN6test703fooIiE4barSIxE5AddS2ES1_x
+  // CHECK-NOT: define linkonce_odr i64 @_ZN6test703fooIiE4barSIxE5AddS2ES1_x
+  template < typename T >
+  template < typename S >
+  HIDDEN S foo::barS::AddS2(foo x, S y) {
+  return ((S) x.x) + y;
+  }
+
+  // CHECK: define linkonce_odr hidden i64 @_ZN6test703fooIiE4barZIxE5AddSZIcEExS1_xT_
+  // CHECK-NOT: define linkonce_odr i64 @_ZN6test703fooIiE4barZIxE5AddSZIcEExS1_xT_
+  template < typename T >
+  template < typename S >
+  template < typename Z >
+  HIDDEN S foo::barZ::AddSZ(foo x, S y, Z z) {
+  return ((S) x.x) + y + ((S) z);
+  }
+
+  extern template struct foo;
+  template struct foo;
+
+  void f() {
+  auto var = foo{5};
+  auto bar = var.AddS((long long)3);
+  auto bar2 = decltype(var)::barS::AddS2(var,3);
+  auto bar3 = decltype(var)::barZ::AddSZ(var,3,(char)0);
+  }
+}
+
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1261,17 +1261,19 @@
   if (auto *TD = dyn_cast(this)) {
 auto From = TD->getInstantiatedFrom();
 if (auto *CTD = From.dyn_cast()) {
-  while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) {
-if (NewCTD->isMemberSpecialization())
+  while (!CTD->isMemberSpecialization()) {
+auto *NewCTD = CTD->getInstantiatedFromMemberTemplate();
+if (!NewCTD)
   break;
 CTD = NewCTD;
   }
   return CTD->getTemplatedDecl()->getDefinition();
 }
 if (auto *CTPSD =
 From.dyn_cast()) {
-  while (auto *NewCTPSD = CTPSD->getInstantiatedFromMember()) {
-if (NewCTPSD->isMemberSpecialization())
+  while (!CTPSD->isMemberSpecialization()) {
+auto *NewCTPSD = CTPSD->getInstantiatedFromMember();
+if (!NewCTPSD)
   break;
 CTPSD = NewCTPSD;
   }
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1049,7 +1049,9 @@
   // If this is a member class of a specialization of a class template
   // and the corresponding decl has explicit visibility, use that.
   if (const CXXRecordDecl *RD = dyn_cast(ND)) {
-CXXRecordDecl *InstantiatedFrom = RD->getInstantiatedFromMemberClass();
+const CXXRecordDecl *InstantiatedFrom = RD->getTemplateInstantiationPattern();
+if (!InstantiatedFrom)
+  InstantiatedFrom = RD->getInstantiatedFromMemberClass();
 if (InstantiatedFrom)
   return getVisibilityOf(InstantiatedFrom, kind);
   }
@@ -1084,16 +1086,12 @@
   }
   // Also handle function template specializations.
   if (const FunctionDecl *fn = dyn_cast(ND)) {
-// If the function is a specialization of a template with an
-// explicit visibility attribute, use that.
-if (FunctionTemplateSpecializationInfo *templateInfo
-  = fn->getTemplateSpecializationInfo())
-  return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
- kind);
-
-// If the function is a member of a specialization of a class template
-// and the corresponding decl has explicit visibility, use that.
-FunctionDecl *InstantiatedFrom = fn->getInstantiatedFromMemberFunction();
+// If the function is a template specialization or a member of
+// a specialized class template and the corresponding decl has
+// explicit visibility, use that.
+FunctionDecl *InstantiatedFrom = fn->getTemplateInstantiationPattern();
+if (!InstantiatedFrom)
+  InstantiatedFrom = fn->getInstantiatedFromMemberFunction();

Re: [PATCH] D13444: [clang-tidy] Clocky module and multiple check from my repository

2015-10-05 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

Will be good idea to review checks one by one.

Checks should be named after function, not after author. If existing categories 
too wide, new one could be introduced, like performance 
(clocky-inefficient-container-insert, clocky-inefficient-operator-use, 
misc-inefficient-algorithm, etc.)

Most likely clocky-unique-ptr-with-new is duplicating recently introduced 
modernize-make-unique.


Repository:
  rL LLVM

http://reviews.llvm.org/D13444



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


Re: [PATCH] D13368: [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast

2015-10-05 Thread Matthias Gehre via cfe-commits
mgehre marked an inline comment as done.


Comment at: clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp:53
@@ +52,3 @@
+  } else {
+diag(MatchedCast->getOperatorLoc(), "do not use static_cast to cast from 
base class to derived class.");
+  }

aaron.ballman wrote:
> What is the alternative the user should use in this instance?
The alternative is to either
1) change the program logic to not require and downcast of a non-polymorphic 
type
or
2) add NOLINT to notify your coworkers that this may be the spot where 
something goes wrong

In the end, these rules together should eliminate some classes of undefined 
behavior and crashes. If the application still crashes,
you should just need to look at the (hopefully few) places of NOLINT.

Anyway, I didn't make the rules. See Herb Sutters answer here: 
https://github.com/isocpp/CppCoreGuidelines/issues/270


http://reviews.llvm.org/D13368



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


Re: [PATCH] D13386: PR24115: Don't instantiate constexpr function templates in decltype

2015-10-05 Thread Richard Smith via cfe-commits
rsmith added a comment.

Sorry, this is not OK; we need to eagerly instantiate within a `decltype` 
expression in some cases, and we should not be treating `decltype` as being 
different from any other unevaluated operand here. Example:

  template constexpr T f() { return 0; }
  decltype(char{f()}) x;

... will be rejected due to a narrowing conversion unless `f()` is 
instantiated. As far as I'm aware, GCC gets around this by triggering 
instantiation from within the constant expression evaluator, but that is a 
significant layering / phases of translation violation, and we don't want to do 
that.

In discussion with Jason Merrill, the front-runner approach for handling this 
is to separate 'unevaluated contexts' into 'unevaluated contexts' and 
'constant-evaluated contexts' (clang already somewhat has this distinction -- 
see `Sema::ExpressionEvaluationContext`'s `Unevaluated` versus 
`ConstantEvaluated` -- but it doesn't quite line up with what we'd want here). 
The latter would cover things like:

- a template argument,
- an expression within a //braced-init-list//,
- an expression inside an array declarator

... and so on (these are the contexts that can occur within an unevaluated 
context, and where constant evaluation is necessary). We would then trigger 
instantiation of a `constexpr` function if it's either odr-used or referenced 
in a constant-evaluated context.


http://reviews.llvm.org/D13386



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


Re: [PATCH] D13311: [clang-tidy] Add check cppcoreguidelines-pro-bounds-pointer-arithmetic

2015-10-05 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 36564.
mgehre added a comment.

Fixed space after //


http://reviews.llvm.org/D13311

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
  clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
  docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-pointer-arithmetic.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp
@@ -0,0 +1,82 @@
+// RUN: %python %S/check_clang_tidy.py %s cppcoreguidelines-pro-bounds-pointer-arithmetic %t
+
+enum E {
+  ENUM_LITERAL = 1
+};
+
+int i = 4;
+int j = 1;
+int *p = 0;
+int *q = 0;
+
+void fail() {
+  q = p + 4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not use pointer arithmetic [cppcoreguidelines-pro-bounds-pointer-arithmetic]
+  p = q + i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not use pointer arithmetic
+  p = q + ENUM_LITERAL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not use pointer arithmetic
+
+  q = p - 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not use pointer arithmetic
+  p = q - i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not use pointer arithmetic
+  p = q - ENUM_LITERAL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not use pointer arithmetic
+
+  p += 4;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use pointer arithmetic
+  p += i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use pointer arithmetic
+  p += ENUM_LITERAL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use pointer arithmetic
+
+  q -= 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use pointer arithmetic
+  q -= i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use pointer arithmetic
+  q -= ENUM_LITERAL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use pointer arithmetic
+
+  p++;
+  // CHECK-MESSAGES: :[[@LINE-1]]:4: warning: do not use pointer arithmetic
+  ++p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use pointer arithmetic
+
+  p--;
+  // CHECK-MESSAGES: :[[@LINE-1]]:4: warning: do not use pointer arithmetic
+  --p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use pointer arithmetic
+
+  i = p[1];
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not use pointer arithmetic
+}
+
+struct S {
+  operator int() const;
+};
+
+void f(S &s) {
+  int *i;
+  i = i + s;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: do not use pointer arithmetic
+}
+
+void okay() {
+  int a[3];
+  i = a[2]; // OK, access to array
+
+  p = q;
+  p = &i;
+
+  i++;
+  ++i;
+  i--;
+  --i;
+  i += 1;
+  i -= 1;
+  i = j + 1;
+  i = j - 1;
+
+  auto diff = p - q; // OK, result is arithmetic
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -3,6 +3,7 @@
 
 .. toctree::
cert-variadic-function-def
+   cppcoreguidelines-pro-bounds-pointer-arithmetic
cppcoreguidelines-pro-type-reinterpret-cast
google-build-explicit-make-pair
google-build-namespaces
Index: docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-pointer-arithmetic.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-pointer-arithmetic.rst
@@ -0,0 +1,10 @@
+cppcoreguidelines-pro-bounds-pointer-arithmetic
+===
+
+This check flags all usage of pointer arithmetic, because it could lead to an invalid pointer.
+Subtraction of two pointers is not flagged by this check.
+
+Pointers should only refer to single objects, and pointer arithmetic is fragile and easy to get wrong. array_view is a bounds-checked, safe type for accessing arrays of data.
+
+This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-bounds1-dont-use-pointer-arithmetic-use-array_view-instead
Index: clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.h
@@ -0,0 +1,34 @@
+//===--- ProBoundsPointerArithmeticCheck.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_CPPCOREGUIDELINES_PRO_BOUNDS_POINTER_ARITH

Re: [PATCH] D13313: [clang-tidy] new check cppcoreguidelines-pro-type-reinterpret-cast

2015-10-05 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 36561.
mgehre added a comment.

"arc diff" produced a invalid patch file (due to some file being "moved"?)
This patch is manually generated by git format-patch. I checked that it applies 
cleanly against svn trunk.


http://reviews.llvm.org/D13313

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/Makefile
  clang-tidy/add_new_check.py
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/Makefile
  clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/tool/Makefile
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp
@@ -0,0 +1,6 @@
+// RUN: %python %S/check_clang_tidy.py %s cppcoreguidelines-pro-type-reinterpret-cast %t
+
+int i = 0;
+void* j;
+void f() { j = reinterpret_cast(i); }
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -3,6 +3,7 @@
 
 .. toctree::
cert-variadic-function-def
+   cppcoreguidelines-pro-type-reinterpret-cast
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst
@@ -0,0 +1,9 @@
+cppcoreguidelines-pro-type-reinterpret-cast
+===
+
+This check flags all uses of reinterpret_cast in C++ code.
+
+Use of these casts can violate type safety and cause the program to access a variable that is actually of type X to be accessed as if it were of an unrelated type Z.
+
+This rule is part of the "Type safety" profile of the C++ Core Guidelines, see
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type1-dont-use-reinterpret_cast.
Index: clang-tidy/tool/Makefile
===
--- clang-tidy/tool/Makefile
+++ clang-tidy/tool/Makefile
@@ -19,6 +19,7 @@
 USEDLIBS = clangTidy.a clangTidyLLVMModule.a clangTidyGoogleModule.a \
clangTidyMiscModule.a clangTidyModernizeModule.a clangTidyReadability.a \
 	   clangTidyUtils.a clangTidyCERTModule.a clangStaticAnalyzerFrontend.a \
+	   clangTidyCppCoreGuidelinesModule.a \
 	   clangStaticAnalyzerCheckers.a clangStaticAnalyzerCore.a \
 	   clangFormat.a clangASTMatchers.a clangTooling.a clangToolingCore.a \
 	   clangFrontend.a clangSerialization.a clangDriver.a clangParse.a \
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -357,6 +357,11 @@
 static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
 LLVMModuleAnchorSource;
 
+// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
+extern volatile int CppCoreGuidelinesModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
+CppCoreGuidelinesModuleAnchorSource;
+
 // This anchor is used to force the linker to link the GoogleModule.
 extern volatile int GoogleModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -11,6 +11,7 @@
   clangBasic
   clangTidy
   clangTidyCERTModule
+  clangTidyCppCoreGuidelinesModule
   clangTidyGoogleModule
   clangTidyLLVMModule
   clangTidyMiscModule
Index: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
@@ -0,0 +1,33 @@
+//===--- ProTypeReinterpretCast.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_CPPCOREGUIDELINES_PRO_TYPE_REINTERPRETCAST_C

Re: [PATCH] D13313: [clang-tidy] new check cppcoreguidelines-pro-type-reinterpret-cast

2015-10-05 Thread Matthias Gehre via cfe-commits
mgehre updated this revision to Diff 36557.
mgehre added a comment.

Rebased


http://reviews.llvm.org/D13313

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/Makefile
  clang-tidy/add_new_check.py
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/Makefile
  clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  clang-tidy/tool/Makefile
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-type-reinterpret-cast.cpp
@@ -0,0 +1,6 @@
+// RUN: %python %S/check_clang_tidy.py %s cppcoreguidelines-pro-type-reinterpret-cast %t
+
+int i = 0;
+void* j;
+void f() { j = reinterpret_cast(i); }
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: do not use reinterpret_cast [cppcoreguidelines-pro-type-reinterpret-cast]
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -2,6 +2,7 @@
 =
 
 .. toctree::
+   cppcoreguidelines-pro-type-reinterpret-cast
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-pro-type-reinterpret-cast.rst
@@ -0,0 +1,9 @@
+cppcoreguidelines-pro-type-reinterpret-cast
+===
+
+This check flags all uses of reinterpret_cast in C++ code.
+
+Use of these casts can violate type safety and cause the program to access a variable that is actually of type X to be accessed as if it were of an unrelated type Z.
+
+This rule is part of the "Type safety" profile of the C++ Core Guidelines, see
+https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#-type1-dont-use-reinterpret_cast.
Index: clang-tidy/tool/Makefile
===
--- clang-tidy/tool/Makefile
+++ clang-tidy/tool/Makefile
@@ -19,6 +19,7 @@
 USEDLIBS = clangTidy.a clangTidyLLVMModule.a clangTidyGoogleModule.a \
clangTidyMiscModule.a clangTidyModernizeModule.a clangTidyReadability.a \
 	   clangTidyUtils.a clangTidyCERTModule.a clangStaticAnalyzerFrontend.a \
+	   clangTidyCppCoreGuidelinesModule.a \
 	   clangStaticAnalyzerCheckers.a clangStaticAnalyzerCore.a \
 	   clangFormat.a clangASTMatchers.a clangTooling.a clangToolingCore.a \
 	   clangFrontend.a clangSerialization.a clangDriver.a clangParse.a \
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -357,6 +357,11 @@
 static int LLVM_ATTRIBUTE_UNUSED LLVMModuleAnchorDestination =
 LLVMModuleAnchorSource;
 
+// This anchor is used to force the linker to link the CppCoreGuidelinesModule.
+extern volatile int CppCoreGuidelinesModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
+CppCoreGuidelinesModuleAnchorSource;
+
 // This anchor is used to force the linker to link the GoogleModule.
 extern volatile int GoogleModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED GoogleModuleAnchorDestination =
Index: clang-tidy/tool/CMakeLists.txt
===
--- clang-tidy/tool/CMakeLists.txt
+++ clang-tidy/tool/CMakeLists.txt
@@ -11,6 +11,7 @@
   clangBasic
   clangTidy
   clangTidyCERTModule
+  clangTidyCppCoreGuidelinesModule
   clangTidyGoogleModule
   clangTidyLLVMModule
   clangTidyMiscModule
Index: clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
@@ -0,0 +1,33 @@
+//===--- ProTypeReinterpretCast.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_CPPCOREGUIDELINES_PRO_TYPE_REINTERPRETCAST_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_PRO_TYPE_REINTERPRETCAST_CHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Fla

Re: r249314 - [VFS] Move class out of method so it looks less like Java.

2015-10-05 Thread Benjamin Kramer via cfe-commits
On Mon, Oct 5, 2015 at 11:13 PM, Richard Smith 
wrote:

> On Mon, Oct 5, 2015 at 6:55 AM, Benjamin Kramer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: d0k
>> Date: Mon Oct  5 08:55:09 2015
>> New Revision: 249314
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=249314&view=rev
>> Log:
>> [VFS] Move class out of method so it looks less like Java.
>>
>> No functionality change.
>>
>> Modified:
>> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
>>
>> Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249314&r1=249313&r2=249314&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
>> +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 08:55:09 2015
>> @@ -942,6 +942,33 @@ ErrorOr VFSFromYAML::status(cons
>>return status(Path, *Result);
>>  }
>>
>> +namespace {
>> +/// Provide a file wrapper that returns the external name when asked.
>> +class NamedFileAdaptor : public File {
>> +  std::unique_ptr InnerFile;
>> +  std::string NewName;
>> +
>> +public:
>> +  NamedFileAdaptor(std::unique_ptr InnerFile, std::string NewName)
>> +  : InnerFile(std::move(InnerFile)), NewName(std::move(NewName)) {}
>> +
>> +  llvm::ErrorOr status() override {
>> +auto InnerStatus = InnerFile->status();
>> +if (InnerStatus)
>> +  return Status::copyWithNewName(*InnerStatus, NewName);
>> +return InnerStatus.getError();
>> +  }
>> +  llvm::ErrorOr>
>> +  getBuffer(const Twine &Name, int64_t FileSize = -1,
>> +bool RequiresNullTerminator = true,
>> +bool IsVolatile = false) override {
>>
>
> Why are default arguments being specified here? This is only called
> virtually, right?
>

Copy&Paste is convenient ;)

Removed the duplicated defaults in r249355.

- Ben


>
>
>> +return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator,
>> +IsVolatile);
>> +  }
>> +  std::error_code close() override { return InnerFile->close(); }
>> +};
>> +} // end anonymous namespace
>> +
>>  ErrorOr> VFSFromYAML::openFileForRead(const Twine
>> &Path) {
>>ErrorOr E = lookupPath(Path);
>>if (!E)
>> @@ -955,34 +982,9 @@ ErrorOr> VFSFromYA
>>if (!Result)
>>  return Result;
>>
>> -  if (!F->useExternalName(UseExternalNames)) {
>> -// Provide a file wrapper that returns the external name when asked.
>> -class NamedFileAdaptor : public File {
>> -  std::unique_ptr InnerFile;
>> -  std::string NewName;
>> -
>> -public:
>> -  NamedFileAdaptor(std::unique_ptr InnerFile, std::string
>> NewName)
>> -  : InnerFile(std::move(InnerFile)), NewName(std::move(NewName))
>> {}
>> -
>> -  llvm::ErrorOr status() override {
>> -auto InnerStatus = InnerFile->status();
>> -if (InnerStatus)
>> -  return Status::copyWithNewName(*InnerStatus, NewName);
>> -return InnerStatus.getError();
>> -  }
>> -  llvm::ErrorOr>
>> -  getBuffer(const Twine &Name, int64_t FileSize = -1,
>> -bool RequiresNullTerminator = true,
>> -bool IsVolatile = false) override {
>> -return InnerFile->getBuffer(Name, FileSize,
>> RequiresNullTerminator,
>> -IsVolatile);
>> -  }
>> -  std::error_code close() override { return InnerFile->close(); }
>> -};
>> +  if (!F->useExternalName(UseExternalNames))
>>  return std::unique_ptr(
>>  new NamedFileAdaptor(std::move(*Result), Path.str()));
>> -  }
>>
>>return Result;
>>  }
>>
>>
>> ___
>> 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] D13304: Avoid inlining in throw statement

2015-10-05 Thread Jun Bum Lim via cfe-commits
junbuml updated this revision to Diff 36551.
junbuml added a comment.

Just minor cleaning. Please let me know any comment.


http://reviews.llvm.org/D13304

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/throw-expressions.cpp

Index: test/CodeGenCXX/throw-expressions.cpp
===
--- test/CodeGenCXX/throw-expressions.cpp
+++ test/CodeGenCXX/throw-expressions.cpp
@@ -112,3 +112,14 @@
   // CHECK: ret i32* @val
   return cond ? val : ((throw "foo"));
 }
+
+// CHECK-LABEL: _Z5test9v
+// CHECK: invoke void @_ZN2EHC1Ev(%class.EH* %0) [[ATTR_NUM:#[0-9]+]]
+// CHECK: attributes [[ATTR_NUM]] = { cold noinline }
+class EH {
+public :
+  EH();
+};
+void test9() {
+  throw EH();
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -283,6 +283,11 @@
   /// finally block or filter expression.
   bool IsOutlinedSEHHelper;
 
+  // True if the current insertion point is in cold regions (e.g., exception
+  // handling regions). As of now, this flag is true only when handling throw
+  // statements.
+  bool IsColdRegion;
+
   const CodeGen::CGBlockInfo *BlockInfo;
   llvm::Value *BlockPointer;
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -44,7 +44,7 @@
   CapturedStmtInfo(nullptr),
   SanOpts(CGM.getLangOpts().Sanitize), IsSanitizerScope(false),
   CurFuncIsThunk(false), AutoreleaseResult(false), SawAsmBlock(false),
-  IsOutlinedSEHHelper(false),
+  IsOutlinedSEHHelper(false), IsColdRegion(false),
   BlockInfo(nullptr), BlockPointer(nullptr),
   LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
   NextCleanupDestIndex(1), FirstBlockInfo(nullptr), EHResumeBlock(nullptr),
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -400,6 +400,11 @@
 
 void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E,
bool KeepInsertionPoint) {
+  // While handling the throw statement, inform that the insertion point is in
+  // cold regions so that we could perform cold region specific IR generation.
+  // For example, the NoInline attribute could be added in CallSites in throw
+  // statements.
+  IsColdRegion = true;
   if (const Expr *SubExpr = E->getSubExpr()) {
 QualType ThrowType = SubExpr->getType();
 if (ThrowType->isObjCObjectPointerType()) {
@@ -417,6 +422,10 @@
   // to leave ourselves at a valid insertion point.
   if (KeepInsertionPoint)
 EmitBlock(createBasicBlock("throw.cont"));
+
+  IsColdRegion = false;
+  // FIXME: Similarly, we could set IsColdRegion for catch blocks in
+  // ExitCXXTryStmt().
 }
 
 void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -3464,6 +3464,27 @@
 Attrs.addAttribute(getLLVMContext(), llvm::AttributeSet::FunctionIndex,
llvm::Attribute::NoInline);
 
+  // As of now, IsColdRegion is true only while handling throw statements.
+  // It might be reasonable to avoid inlining CallSites invoked in exception
+  // handling context so that we can reduce code size blow-up in EH regions
+  // as well as indirectly increase inline opportunities for unwinding
+  // functions containing exception handling code.
+  if (IsColdRegion) {
+// FIXME: We add both NoInline and Cold because the inline cold-threshold
+// is not tuned yet (r200898). As of now, considering that CallSites in
+// exception handling regions are very cold is not unreasonable even without
+// profiling, and avoiding inlining in exception handling region may not
+// have significant impacts on performance unless a program execution logic
+// really depends on exception handling flows. However, when the inline
+// cold-threshold is tuned, we may need to remove NoInline here so that we
+// can allow a trivial constructor to be inlined.
+Attrs =
+Attrs.addAttribute(getLLVMContext(), llvm::AttributeSet::FunctionIndex,
+   llvm::Attribute::NoInline);
+Attrs =
+Attrs.addAttribute(getLLVMContext(), llvm::AttributeSet::FunctionIndex,
+   llvm::Attribute::Cold);
+  }
   CS.setAttributes(Attrs);
   CS.setCallingConv(static_cast(CallingConv));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249355 - Remove duplicated default arguments. NFC.

2015-10-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct  5 16:20:19 2015
New Revision: 249355

URL: http://llvm.org/viewvc/llvm-project?rev=249355&view=rev
Log:
Remove duplicated default arguments. NFC.

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249355&r1=249354&r2=249355&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 16:20:19 2015
@@ -124,10 +124,10 @@ class RealFile : public File {
 public:
   ~RealFile() override;
   ErrorOr status() override;
-  ErrorOr>
-  getBuffer(const Twine &Name, int64_t FileSize = -1,
-bool RequiresNullTerminator = true,
-bool IsVolatile = false) override;
+  ErrorOr> getBuffer(const Twine &Name,
+   int64_t FileSize,
+   bool RequiresNullTerminator,
+   bool IsVolatile) override;
   std::error_code close() override;
 };
 } // end anonymous namespace
@@ -424,9 +424,8 @@ public:
 
   llvm::ErrorOr status() override { return Node.getStatus(); }
   llvm::ErrorOr>
-  getBuffer(const Twine &Name, int64_t FileSize = -1,
-bool RequiresNullTerminator = true,
-bool IsVolatile = false) override {
+  getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator,
+bool IsVolatile) override {
 llvm::MemoryBuffer *Buf = Node.getBuffer();
 return llvm::MemoryBuffer::getMemBuffer(
 Buf->getBuffer(), Buf->getBufferIdentifier(), RequiresNullTerminator);
@@ -1270,9 +1269,8 @@ public:
 return InnerStatus.getError();
   }
   llvm::ErrorOr>
-  getBuffer(const Twine &Name, int64_t FileSize = -1,
-bool RequiresNullTerminator = true,
-bool IsVolatile = false) override {
+  getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator,
+bool IsVolatile) override {
 return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator,
 IsVolatile);
   }


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


Re: [PATCH] D12747: Implement [depr.c.headers]

2015-10-05 Thread Chandler Carruth via cfe-commits
Marshall, I think Richard has responded to your concerns. Anything left?
This is blocking some things on our end.

On Wed, Sep 16, 2015 at 2:04 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, Sep 14, 2015 at 7:07 AM, Marshall Clow 
> wrote:
>
>> mclow.lists added a comment.
>>
>> I have two concerns about this patch (w/o commenting on the actual code).
>>
>> 1. Until very recently, I was under the impression that C libraries
>> _either_ defined a macro, or had a function. I was quite surprised to find
>> that glibc did both.
>
>
> Yes, this is required by the C standard. C11 7.1.4/1 says:
>
> "Any function declared in a header may be additionally implemented as a
> function-like macro defined in the header [...]. Any macro definition of a
> function can be suppressed locally by enclosing the name of the function in
> parentheses, because the name is then not followed by the left parenthesis
> that indicates expansion of a macro function name. For the same syntactic
> reason, it is permitted to take the address of a library function even if
> it is also defined as a macro. [Footnote: This means that an implementation
> shall provide an actual function for each library function, even if it also
> provides a macro for that function.]"
>
> Have you checked other C libraries (Apple, FreeBSD, Android, Windows) to
>> see if they also define both?
>
>
> No, but libstdc++ does the same #undef thing, so any platform it supports
> must have a non-broken C standard library.
>
>
>> 2. This adds a lot of header files. Each header file slows down
>> compilation, and standard library header files get included *a lot*. We may
>> not be able to avoid this, but we should think about the costs here.
>
>
> I created a .cpp file that includes all of the <*.h> headers and does
> nothing else (which should maximize the performance difference), and built
> it with and without this change. I could not measure any difference (the
> average compile time with this change was slightly lower, but that is
> almost certainly noise).
> ___
> 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: r249314 - [VFS] Move class out of method so it looks less like Java.

2015-10-05 Thread Richard Smith via cfe-commits
On Mon, Oct 5, 2015 at 6:55 AM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Mon Oct  5 08:55:09 2015
> New Revision: 249314
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249314&view=rev
> Log:
> [VFS] Move class out of method so it looks less like Java.
>
> No functionality change.
>
> Modified:
> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
>
> Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249314&r1=249313&r2=249314&view=diff
>
> ==
> --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
> +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 08:55:09 2015
> @@ -942,6 +942,33 @@ ErrorOr VFSFromYAML::status(cons
>return status(Path, *Result);
>  }
>
> +namespace {
> +/// Provide a file wrapper that returns the external name when asked.
> +class NamedFileAdaptor : public File {
> +  std::unique_ptr InnerFile;
> +  std::string NewName;
> +
> +public:
> +  NamedFileAdaptor(std::unique_ptr InnerFile, std::string NewName)
> +  : InnerFile(std::move(InnerFile)), NewName(std::move(NewName)) {}
> +
> +  llvm::ErrorOr status() override {
> +auto InnerStatus = InnerFile->status();
> +if (InnerStatus)
> +  return Status::copyWithNewName(*InnerStatus, NewName);
> +return InnerStatus.getError();
> +  }
> +  llvm::ErrorOr>
> +  getBuffer(const Twine &Name, int64_t FileSize = -1,
> +bool RequiresNullTerminator = true,
> +bool IsVolatile = false) override {
>

Why are default arguments being specified here? This is only called
virtually, right?


> +return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator,
> +IsVolatile);
> +  }
> +  std::error_code close() override { return InnerFile->close(); }
> +};
> +} // end anonymous namespace
> +
>  ErrorOr> VFSFromYAML::openFileForRead(const Twine
> &Path) {
>ErrorOr E = lookupPath(Path);
>if (!E)
> @@ -955,34 +982,9 @@ ErrorOr> VFSFromYA
>if (!Result)
>  return Result;
>
> -  if (!F->useExternalName(UseExternalNames)) {
> -// Provide a file wrapper that returns the external name when asked.
> -class NamedFileAdaptor : public File {
> -  std::unique_ptr InnerFile;
> -  std::string NewName;
> -
> -public:
> -  NamedFileAdaptor(std::unique_ptr InnerFile, std::string
> NewName)
> -  : InnerFile(std::move(InnerFile)), NewName(std::move(NewName))
> {}
> -
> -  llvm::ErrorOr status() override {
> -auto InnerStatus = InnerFile->status();
> -if (InnerStatus)
> -  return Status::copyWithNewName(*InnerStatus, NewName);
> -return InnerStatus.getError();
> -  }
> -  llvm::ErrorOr>
> -  getBuffer(const Twine &Name, int64_t FileSize = -1,
> -bool RequiresNullTerminator = true,
> -bool IsVolatile = false) override {
> -return InnerFile->getBuffer(Name, FileSize,
> RequiresNullTerminator,
> -IsVolatile);
> -  }
> -  std::error_code close() override { return InnerFile->close(); }
> -};
> +  if (!F->useExternalName(UseExternalNames))
>  return std::unique_ptr(
>  new NamedFileAdaptor(std::move(*Result), Path.str()));
> -  }
>
>return Result;
>  }
>
>
> ___
> 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


[libcxx] r249354 - Mark 2380 and 2384 as complete; no changes needed

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 16:11:20 2015
New Revision: 249354

URL: http://llvm.org/viewvc/llvm-project?rev=249354&view=rev
Log:
Mark 2380 and 2384 as complete; no changes needed

Modified:
libcxx/trunk/www/kona.html

Modified: libcxx/trunk/www/kona.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/kona.html?rev=249354&r1=249353&r2=249354&view=diff
==
--- libcxx/trunk/www/kona.html (original)
+++ libcxx/trunk/www/kona.html Mon Oct  5 16:11:20 2015
@@ -75,8 +75,8 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2336";>2336is_trivially_constructible/is_trivially_assignable
 traits are always falseKona
http://cplusplus.github.io/LWG/lwg-defects.html#2353";>2353std::next
 is over-constrainedKona
http://cplusplus.github.io/LWG/lwg-defects.html#2367";>2367pair
 and tuple are not correctly implemented for is_constructible 
with no argsKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2380";>2380May
  provide long ::abs(long) and long long 
::abs(long long)?Kona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2384";>2384Allocator's
 deallocate function needs better 
specificationKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2380";>2380May
  provide long ::abs(long) and long long 
::abs(long long)?KonaComplete
+   http://cplusplus.github.io/LWG/lwg-defects.html#2384";>2384Allocator's
 deallocate function needs better 
specificationKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2385";>2385function::assign
 allocator argument doesn't make senseKona
http://cplusplus.github.io/LWG/lwg-defects.html#2435";>2435reference_wrapper::operator()'s
 Remark should be deletedKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2447";>2447Allocators
 and volatile-qualified value typesKona
@@ -120,8 +120,8 @@
 2336 - Check later
 2353 - Simple change, needs a test. (test probably used to exist)
 2367 - Ask Eric to do it. Tests.
-2380 - No code changes here; we already do this.
-2384 - Wording cleanup; no code change required
+2380 - No code changes here; we already do this.
+2384 - Wording cleanup; no code change required
 2385 - Removing broken signatures. Only question is "how far back"?
 2435 - Wording cleanup; no code change required
 2447 - I don't know if there's any work here.


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


[libcxx] r249352 - Patch for 2466 is ready

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 16:08:49 2015
New Revision: 249352

URL: http://llvm.org/viewvc/llvm-project?rev=249352&view=rev
Log:
Patch for 2466 is ready

Modified:
libcxx/trunk/www/kona.html

Modified: libcxx/trunk/www/kona.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/kona.html?rev=249352&r1=249351&r2=249352&view=diff
==
--- libcxx/trunk/www/kona.html (original)
+++ libcxx/trunk/www/kona.html Mon Oct  5 16:08:49 2015
@@ -81,7 +81,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2435";>2435reference_wrapper::operator()'s
 Remark should be deletedKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2447";>2447Allocators
 and volatile-qualified value typesKona
http://cplusplus.github.io/LWG/lwg-defects.html#2462";>2462std::ios_base::failure
 is overspecifiedKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2466";>2466allocator_traits::max_size()
 default behavior is incorrectKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2466";>2466allocator_traits::max_size()
 default behavior is incorrectKonaPatch Ready
http://cplusplus.github.io/LWG/lwg-defects.html#2469";>2469Wrong
 specification of Requires clause of operator[] for map and 
unordered_mapKona
http://cplusplus.github.io/LWG/lwg-defects.html#2473";>2473basic_filebuf's
 relation to C FILE semanticsKona
http://cplusplus.github.io/LWG/lwg-defects.html#2476";>2476scoped_allocator_adaptor
 is not assignableKona
@@ -126,7 +126,7 @@
 2435 - Wording cleanup; no code change required
 2447 - I don't know if there's any work here.
 2462 - No code change necessary. Are there tests here? Should there 
be?
-2466 - Simple change; need a test.
+2466 - Simple change; need a test.
 2469 - I suspect this is just wording cleanup, but it needs a closer 
look.
 2473 - I suspect this is just wording cleanup, but it needs a closer 
look.
 2476 - Simple change; need tests.


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


[libcxx] r249349 - Fixed a possible overflow in a test of allocator::max_size().

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 15:50:25 2015
New Revision: 249349

URL: http://llvm.org/viewvc/llvm-project?rev=249349&view=rev
Log:
Fixed a possible overflow in a test of allocator::max_size().

Modified:

libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp?rev=249349&r1=249348&r2=249349&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp
 Mon Oct  5 15:50:25 2015
@@ -22,6 +22,6 @@ int new_called = 0;
 int main()
 {
 const std::allocator a;
-std::size_t M = a.max_size() * sizeof(int);
-assert(M > 0x && M <= std::numeric_limits::max());
+std::size_t M = a.max_size();
+assert(M > 0x && M <= (std::numeric_limits::max() / 
sizeof(int)));
 }


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


Re: [PATCH] D13419: Fix several problems at the intersection of template instantiations and visibility

2015-10-05 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/AST/Decl.cpp:1089
@@ -1086,10 +1088,3 @@
   if (const FunctionDecl *fn = dyn_cast(ND)) {
-// If the function is a specialization of a template with an
-// explicit visibility attribute, use that.
-if (FunctionTemplateSpecializationInfo *templateInfo
-  = fn->getTemplateSpecializationInfo())
-  return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),
- kind);
-
-// If the function is a member of a specialization of a class template
+// If the function is a member of a specialization of a some template
 // and the corresponding decl has explicit visibility, use that.

typo "of a some"


Comment at: lib/AST/DeclCXX.cpp:1264-1269
@@ -1263,7 +1263,8 @@
 if (auto *CTD = From.dyn_cast()) {
-  while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) {
+  auto *NewCTD = CTD;
+  do {
+CTD = NewCTD;
 if (NewCTD->isMemberSpecialization())
   break;
-CTD = NewCTD;
-  }
+  } while ((NewCTD = CTD->getInstantiatedFromMemberTemplate()));
   return CTD->getTemplatedDecl()->getDefinition();

This loop structure is not very clear. How about:

  while (!CTD->isMemberSpecialization()) {
auto *NewCTD = CTD->getInstantiatedFromMemberTemplate();
if (!NewCTD)
  break;
CTD = NewCTD;
  }

... or

  while (auto *FromCTD = CTD->isMemberSpecialization()
 ? nullptr
 : CTD->getInstantiatedFromMemberTemplate())
CTD = FromCTD;


Repository:
  rL LLVM

http://reviews.llvm.org/D13419



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


[libcxx] r249348 - Mark a couple more issues 'ready'

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 15:35:30 2015
New Revision: 249348

URL: http://llvm.org/viewvc/llvm-project?rev=249348&view=rev
Log:
Mark a couple more issues 'ready'

Modified:
libcxx/trunk/www/kona.html

Modified: libcxx/trunk/www/kona.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/kona.html?rev=249348&r1=249347&r2=249348&view=diff
==
--- libcxx/trunk/www/kona.html (original)
+++ libcxx/trunk/www/kona.html Mon Oct  5 15:35:30 2015
@@ -86,12 +86,12 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2473";>2473basic_filebuf's
 relation to C FILE semanticsKona
http://cplusplus.github.io/LWG/lwg-defects.html#2476";>2476scoped_allocator_adaptor
 is not assignableKona
http://cplusplus.github.io/LWG/lwg-defects.html#2477";>2477Inconsistency
 of wordings in std::vector::erase() and 
std::deque::erase()Kona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2483";>2483throw_with_nested()
 should use is_finalKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2484";>2484rethrow_if_nested()
 is doubly unimplementableKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2483";>2483throw_with_nested()
 should use is_finalKonaComplete
+   http://cplusplus.github.io/LWG/lwg-defects.html#2484";>2484rethrow_if_nested()
 is doubly unimplementableKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2485";>2485get()
 should be overloaded for const 
tuple&&Kona
http://cplusplus.github.io/LWG/lwg-defects.html#2486";>2486mem_fn()
 should be required to use perfect forwardingKona
http://cplusplus.github.io/LWG/lwg-defects.html#2487";>2487bind()
 should be const-overloaded, not 
cv-overloadedKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2489";>2489mem_fn()
 should be noexceptKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2489";>2489mem_fn()
 should be noexceptKonaPatch Ready
http://cplusplus.github.io/LWG/lwg-defects.html#2492";>2492Clarify
 requirements for compKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2494";>2494[fund.ts.v2]
 ostream_joiner needs noexceptKona
 
@@ -131,12 +131,12 @@
 2473 - I suspect this is just wording cleanup, but it needs a closer 
look.
 2476 - Simple change; need tests.
 2477 - Definitely wording cleanup, but check the tests.
-2483 - We already do this.
-2484 - We already do this.
+2483 - We already do this.
+2484 - We already do this.
 2485 - Ask Eric to do it. 
 2486 - Lots of code changes, all mechanical. Tests will be sizable.
 2487 - Don't know
-2489 - Looks easy. Just add some NOEXCEPT, and tests.
+2489 - Looks easy. Just add some NOEXCEPT, and tests.
 2492 - Wording cleanup; no code changes needed.
 2494 - My implementation of this (not checked in) already has these.
 


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


Re: [libcxx] r249226 - [libcxx] Use newest supported language dialect when running the test suite.

2015-10-05 Thread Adrian Prantl via cfe-commits
Thanks for looking into this, the builder is green again!

http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/7586/

-- adrian

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


[libcxx] r249347 - Mark 2072 as complete; we already do this

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 15:21:54 2015
New Revision: 249347

URL: http://llvm.org/viewvc/llvm-project?rev=249347&view=rev
Log:
Mark 2072 as complete; we already do this

Modified:
libcxx/trunk/www/kona.html

Modified: libcxx/trunk/www/kona.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/kona.html?rev=249347&r1=249346&r2=249347&view=diff
==
--- libcxx/trunk/www/kona.html (original)
+++ libcxx/trunk/www/kona.html Mon Oct  5 15:21:54 2015
@@ -59,7 +59,7 @@
   
Issue #Issue 
NameMeetingStatus
http://cplusplus.github.io/LWG/lwg-defects.html#1169";>1169num_get
 not fully compatible with strto*Kona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2072";>2072Unclear
 wording about capacity of temporary buffersKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2072";>2072Unclear
 wording about capacity of temporary 
buffersKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2101";>2101Some
 transformation types can produce impossible 
typesKona
http://cplusplus.github.io/LWG/lwg-defects.html#2111";>2111Which
 unexpected/terminate handler is called from the 
exception handling runtime?KonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2119";>2119Missing
 hash specializations for extended integer 
typesKona
@@ -104,7 +104,7 @@
 Comments about the issues
 
 1169 - We currently have a single function __num_get_float that calls 
strtold_l, and then casts down to the appropriate floating point type.  That 
will have to change.
-2072 - I don't think there's anything to do here; this is just making the 
wording better.
+2072 - We already do this; this is just making the wording 
better.
 2101 - Need to write some careful test cases. In particular, need to check 
function types with/without const/ref qualifiers.  Currently we get this wrong. 
Installing metashell to play with these.
 2111 - Resolved an ambiguity by calling it out. No code change 
required.
 2119 - Hashes for all integral and enumeration types. Research needed


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


r249346 - Fix the MSVC build.

2015-10-05 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Mon Oct  5 15:20:50 2015
New Revision: 249346

URL: http://llvm.org/viewvc/llvm-project?rev=249346&view=rev
Log:
Fix the MSVC build.

No idea what asymmetry MSVC is findind.

Modified:
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=249346&r1=249345&r2=249346&view=diff
==
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Mon Oct  5 15:20:50 2015
@@ -528,9 +528,9 @@ protected:
 
 TEST_F(InMemoryFileSystemTest, IsEmpty) {
   auto Stat = FS.status("/a");
-  ASSERT_EQ(errc::no_such_file_or_directory, Stat.getError()) << FS.toString();
+  ASSERT_EQ(Stat.getError(),errc::no_such_file_or_directory) << FS.toString();
   Stat = FS.status("/");
-  ASSERT_EQ(errc::no_such_file_or_directory, Stat.getError()) << FS.toString();
+  ASSERT_EQ(Stat.getError(), errc::no_such_file_or_directory) << FS.toString();
 }
 
 TEST_F(InMemoryFileSystemTest, WindowsPath) {
@@ -560,9 +560,9 @@ TEST_F(InMemoryFileSystemTest, OpenFileF
   File = FS.openFileForRead("/a"); // Open again.
   ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
   File = FS.openFileForRead("/");
-  ASSERT_EQ(errc::invalid_argument, File.getError()) << FS.toString();
+  ASSERT_EQ(File.getError(), errc::invalid_argument) << FS.toString();
   File = FS.openFileForRead("/b");
-  ASSERT_EQ(errc::no_such_file_or_directory, File.getError()) << FS.toString();
+  ASSERT_EQ(File.getError(), errc::no_such_file_or_directory) << FS.toString();
 }
 
 TEST_F(InMemoryFileSystemTest, DirectoryIteration) {


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


[libcxx] r249345 - Patch ready for 2127

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 15:16:30 2015
New Revision: 249345

URL: http://llvm.org/viewvc/llvm-project?rev=249345&view=rev
Log:
Patch ready for 2127

Modified:
libcxx/trunk/www/kona.html

Modified: libcxx/trunk/www/kona.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/kona.html?rev=249345&r1=249344&r2=249345&view=diff
==
--- libcxx/trunk/www/kona.html (original)
+++ libcxx/trunk/www/kona.html Mon Oct  5 15:16:30 2015
@@ -63,7 +63,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2101";>2101Some
 transformation types can produce impossible 
typesKona
http://cplusplus.github.io/LWG/lwg-defects.html#2111";>2111Which
 unexpected/terminate handler is called from the 
exception handling runtime?KonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2119";>2119Missing
 hash specializations for extended integer 
typesKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2127";>2127Move-construction
 with raw_storage_iteratorKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2127";>2127Move-construction
 with raw_storage_iteratorKonaPatch Ready
http://cplusplus.github.io/LWG/lwg-defects.html#2133";>2133Attitude
 to overloaded comma for iteratorsKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2156";>2156Unordered
 containers' reserve(n) reserves for n-1 
elementsKona
http://cplusplus.github.io/LWG/lwg-defects.html#2181";>2181Exceptions
 from seed sequence operationsKona
@@ -108,7 +108,7 @@
 2101 - Need to write some careful test cases. In particular, need to check 
function types with/without const/ref qualifiers.  Currently we get this wrong. 
Installing metashell to play with these.
 2111 - Resolved an ambiguity by calling it out. No code change 
required.
 2119 - Hashes for all integral and enumeration types. Research needed
-2127 - Add a new member to raw_storage_iterator. Looks simple.
+2127 - Add a new member to raw_storage_iterator. Looks simple.
 2133 - We do this already; thanks Eric.
 2156 - check and make sure that we already do this. Write a test.
 2181 - I suspect that this will not require any code changes, but will 
need to be read carefully.


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


Re: [PATCH] D13446: [PATCH] Add checker discouraging definition of variadic function definitions in C++

2015-10-05 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Thank you for the note about checks -- I hadn't noticed that. I've fixed and 
committed in r249343.

Thank you for the quick review!

~Aaron


http://reviews.llvm.org/D13446



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


[clang-tools-extra] r249343 - Adding a checker (cert-dcl50-cpp) that detects the definition of a C-style variadic function in C++ code. Corresponds to the CERT C++ secure coding rule: https://www.secu

2015-10-05 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Oct  5 15:08:59 2015
New Revision: 249343

URL: http://llvm.org/viewvc/llvm-project?rev=249343&view=rev
Log:
Adding a checker (cert-dcl50-cpp) that detects the definition of a C-style 
variadic function in C++ code. Corresponds to the CERT C++ secure coding rule: 
https://www.securecoding.cert.org/confluence/display/cplusplus/DCL50-CPP.+Do+not+define+a+C-style+variadic+function

Added:
clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp
clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cert-variadic-function-def.rst
clang-tools-extra/trunk/test/clang-tidy/cert-variadic-function-def.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=249343&r1=249342&r2=249343&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Mon Oct  5 
15:08:59 2015
@@ -15,6 +15,7 @@
 #include "../misc/NewDeleteOverloadsCheck.h"
 #include "../misc/NonCopyableObjects.h"
 #include "../misc/StaticAssertCheck.h"
+#include "VariadicFunctionDefCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -25,6 +26,8 @@ public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 // C++ checkers
 // DCL
+CheckFactories.registerCheck(
+"cert-dcl50-cpp");
 CheckFactories.registerCheck(
 "cert-dcl54-cpp");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=249343&r1=249342&r2=249343&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt Mon Oct  5 15:08:59 
2015
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCERTModule
   CERTTidyModule.cpp
+  VariadicFunctionDefCheck.cpp
 
   LINK_LIBS
   clangAST

Added: clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp?rev=249343&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp Mon 
Oct  5 15:08:59 2015
@@ -0,0 +1,38 @@
+//===--- VariadicfunctiondefCheck.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 "VariadicFunctionDefCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+
+void VariadicFunctionDefCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+
+  // We only care about function *definitions* that are variadic.
+  Finder->addMatcher(functionDecl(isDefinition(), isVariadic()).bind("func"),
+ this);
+}
+
+void VariadicFunctionDefCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *FD = Result.Nodes.getNodeAs("func");
+
+  diag(FD->getLocation(),
+   "do not define a C-style variadic function; consider using a function "
+   "parameter pack or currying instead");
+}
+
+} // namespace tidy
+} // namespace clang
+

Added: clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h?rev=249343&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h (added)
+++ clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.h Mon Oct  
5 15:08:59 2015
@@ -0,0 +1,34 @@
+//===--- VariadicFunctionDefCheck.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.
+//
+//===--==

Re: [PATCH] D13446: [PATCH] Add checker discouraging definition of variadic function definitions in C++

2015-10-05 Thread Samuel Benzaquen via cfe-commits
sbenza accepted this revision.
sbenza added a comment.
This revision is now accepted and ready to land.

See comment regarding //CHECKs



Comment at: test/clang-tidy/cert-variadic-function-def.cpp:4
@@ +3,3 @@
+// Variadic function definitions are diagnosed.
+// CHECK-MESSAGES: :[[@LINE+1]]:6: warning: do not define a C-style variadic 
function; consider using a function parameter pack or currying instead 
[cert-dcl50-cpp]
+void f1(int, ...) {}

All other tests I've read/written put the //CHECK after the matched lines.
We should be consistent with that.


http://reviews.llvm.org/D13446



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


Re: r249336 - Re-introduce the unique_ptr removed in r249328 and just make

2015-10-05 Thread David Blaikie via cfe-commits
On Mon, Oct 5, 2015 at 11:54 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Mon Oct  5 13:54:30 2015
> New Revision: 249336
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249336&view=rev
> Log:
> Re-introduce the unique_ptr removed in r249328 and just make
> ~CodeGenABITypes out-of-line, which should have the same effect.
>
> Thanks to David Blaikie for pointing this out!
>
> Modified:
> cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
> cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
>
> Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=249336&r1=249335&r2=249336&view=diff
>
> ==
> --- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)
> +++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Mon Oct  5 13:54:30
> 2015
> @@ -80,7 +80,7 @@ private:
>std::unique_ptr PPO;
>
>/// The CodeGenModule we use get to the CodeGenTypes object.
> -  CodeGen::CodeGenModule *CGM;
> +  std::unique_ptr CGM;
>  };
>
>  }  // end namespace CodeGen
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=249336&r1=249335&r2=249336&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Mon Oct  5 13:54:30 2015
> @@ -33,10 +33,9 @@ CodeGenABITypes::CodeGenABITypes(ASTCont
>CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, M,
> C.getDiagnostics(),
>   CoverageInfo)) {}
>
> -CodeGenABITypes::~CodeGenABITypes()
> -{
> -  delete CGM;
> -}
> +// Explicitly out-of-line because ~CodeGenModule() is private but
>

Maybe "internal" might be a better term here. (if it were private, in the
C++ sense, it wouldn't be any more callable here than it would be in the
header) & probably just describe the whole type as internal, rather than
just the dtor. Maybe. Not sure.


> +// CodeGenABITypes.h is part of clang's API.
> +CodeGenABITypes::~CodeGenABITypes() = default;
>
>  const CGFunctionInfo &
>  CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
>
>
> ___
> 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


r249342 - Revert r107690 (for PR7417) and add a testcase that it breaks. The approach of

2015-10-05 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct  5 15:05:21 2015
New Revision: 249342

URL: http://llvm.org/viewvc/llvm-project?rev=249342&view=rev
Log:
Revert r107690 (for PR7417) and add a testcase that it breaks. The approach of
that change turns out to not be reasonable: mutating the AST of a parsed
template during instantiation is not a sound thing to do, does not work across
chained PCH / modules builds, and is in any case a special-case workaround to a
more general problem that should be solved centrally.

Added:
cfe/trunk/test/SemaTemplate/instantiate-expr-6.cpp
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/test/SemaTemplate/ms-lookup-template-base-classes.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=249342&r1=249341&r2=249342&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct  5 15:05:21 2015
@@ -6613,12 +6613,6 @@ public:
 
   friend class ArgumentPackSubstitutionRAII;
 
-  /// \brief The stack of calls expression undergoing template instantiation.
-  ///
-  /// The top of this stack is used by a fixit instantiating unresolved
-  /// function calls to fix the AST to match the textual change it prints.
-  SmallVector CallsUndergoingInstantiation;
-
   /// \brief For each declaration that involved template argument deduction, 
the
   /// set of diagnostics that were suppressed during that template argument
   /// deduction.

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=249342&r1=249341&r2=249342&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Oct  5 15:05:21 2015
@@ -1804,8 +1804,7 @@ Sema::DiagnoseEmptyLookup(Scope *S, CXXS
   // unqualified lookup.  This is useful when (for example) the
   // original lookup would not have found something because it was a
   // dependent name.
-  DeclContext *DC = (SS.isEmpty() && !CallsUndergoingInstantiation.empty())
-? CurContext : nullptr;
+  DeclContext *DC = SS.isEmpty() ? CurContext : nullptr;
   while (DC) {
 if (isa(DC)) {
   LookupQualifiedName(R, DC);
@@ -1833,47 +1832,7 @@ Sema::DiagnoseEmptyLookup(Scope *S, CXXS
 if (isInstance) {
   Diag(R.getNameLoc(), diagnostic) << Name
 << FixItHint::CreateInsertion(R.getNameLoc(), "this->");
-  UnresolvedLookupExpr *ULE = cast(
-  CallsUndergoingInstantiation.back()->getCallee());
-
-  CXXMethodDecl *DepMethod;
-  if (CurMethod->isDependentContext()) {
-DepMethod = CurMethod;
-  } else if (FunctionTemplateDecl *FTD =
- CurMethod->getPrimaryTemplate()) {
-// We have a member function template. It may be contained in a
-// class template. If so, get the original pattern for the member
-// function template. Otherwise, 'this' isn't dependent and we can
-// use CurMethod as is.
-if (FunctionTemplateDecl *MemberFTD =
-FTD->getInstantiatedFromMemberTemplate())
-  DepMethod = cast(MemberFTD->getTemplatedDecl());
-else
-  DepMethod = CurMethod;
-  } else {
-DepMethod = cast(
-CurMethod->getInstantiatedFromMemberFunction());
-  }
-  assert(DepMethod && "No template pattern found");
-
-  QualType DepThisType = DepMethod->getThisType(Context);
   CheckCXXThisCapture(R.getNameLoc());
-  CXXThisExpr *DepThis = new (Context) CXXThisExpr(
- R.getNameLoc(), DepThisType, false);
-  TemplateArgumentListInfo TList;
-  if (ULE->hasExplicitTemplateArgs())
-ULE->copyTemplateArgumentsInto(TList);
-
-  CXXScopeSpec SS;
-  SS.Adopt(ULE->getQualifierLoc());
-  CXXDependentScopeMemberExpr *DepExpr =
-  CXXDependentScopeMemberExpr::Create(
-  Context, DepThis, DepThisType, true, SourceLocation(),
-  SS.getWithLocInContext(Context),
-  ULE->getTemplateKeywordLoc(), nullptr,
-  R.getLookupNameInfo(),
-  ULE->hasExplicitTemplateArgs() ? &TList : nullptr);
-  CallsUndergoingInstantiation.back()->setCallee(DepExpr);
 } else {
   Diag(R.getNameLoc(), diagnostic) << Name;
 }

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=249342&r1=249341&r2=249342&view=diff
=

r249341 - Adding an AST node matcher for NonTypeTemplateParmDecl objects.

2015-10-05 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Oct  5 14:44:42 2015
New Revision: 249341

URL: http://llvm.org/viewvc/llvm-project?rev=249341&view=rev
Log:
Adding an AST node matcher for NonTypeTemplateParmDecl objects.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=249341&r1=249340&r2=249341&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct  5 14:44:42 2015
@@ -316,6 +316,16 @@ namespaceDecl()
 
 
 
+MatcherDecl>nonTypeTemplateParmDeclMatcherNonTypeTemplateParmDecl>...
+Matches 
non-type template parameter declarations.
+
+Given
+  template  struct C {};
+templateArgument()
+  matches 'N', but not 'T'.
+
+
+
 MatcherDecl>objcInterfaceDeclMatcherObjCInterfaceDecl>...
 Matches 
Objective-C interface declarations.
 
@@ -2213,7 +2223,7 @@ Usable as: MatcherFunctionDecl>isVariadic
 Matches if a function 
declaration is variadic.
 
-Example matches f, but not g or h. The function i will not match, event when
+Example matches f, but not g or h. The function i will not match, even when
 compiled in C mode.
   void f(...);
   void g(int);

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=249341&r1=249340&r2=249341&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Oct  5 14:44:42 2015
@@ -412,6 +412,18 @@ const internal::VariadicAllOfMatcher.
 const internal::VariadicAllOfMatcher templateArgument;
 
+/// \brief Matches non-type template parameter declarations.
+///
+/// Given
+/// \code
+///   template  struct C {};
+/// \endcode
+/// templateArgument()
+///   matches 'N', but not 'T'.
+const internal::VariadicDynCastAllOfMatcher<
+  Decl,
+  NonTypeTemplateParmDecl> nonTypeTemplateParmDecl;
+
 /// \brief Matches public C++ declarations.
 ///
 /// Given

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=249341&r1=249340&r2=249341&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Oct  5 14:44:42 2015
@@ -1172,6 +1172,13 @@ TEST(Matcher, SubstNonTypeTemplateParm)
   substNonTypeTemplateParmExpr()));
 }
 
+TEST(Matcher, NonTypeTemplateParmDecl) {
+  EXPECT_TRUE(matches("template  void f();",
+  nonTypeTemplateParmDecl(hasName("N";
+  EXPECT_TRUE(
+  notMatches("template  void f();", 
nonTypeTemplateParmDecl()));
+}
+
 TEST(Matcher, UserDefinedLiteral) {
   EXPECT_TRUE(matches("constexpr char operator \"\" _inc (const char i) {"
   "  return i + 1;"


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


[PATCH] D13446: [PATCH] Add checker discouraging definition of variadic function definitions in C++

2015-10-05 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: alexfh, sbenza.
aaron.ballman added a subscriber: cfe-commits.

C-style variadic functions (using an ellipsis) can be dangerous in C++ due to 
the inherit lack of type safety with argument passing. Better alternatives 
exist, such as function currying (like STL stream objects use), or function 
parameter packs. This patch adds a checker to diagnose definitions of variadic 
functions in C++ code, but still allows variadic function declarations, as 
those can be safely used to good effect for SFINAE patterns.

This patch corresponds to the CERT C++ Coding Standard rule: 
https://www.securecoding.cert.org/confluence/display/cplusplus/DCL50-CPP.+Do+not+define+a+C-style+variadic+function

http://reviews.llvm.org/D13446

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/VariadicFunctionDefCheck.cpp
  clang-tidy/cert/VariadicFunctionDefCheck.h
  docs/clang-tidy/checks/cert-variadic-function-def.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-variadic-function-def.cpp

Index: test/clang-tidy/cert-variadic-function-def.cpp
===
--- test/clang-tidy/cert-variadic-function-def.cpp
+++ test/clang-tidy/cert-variadic-function-def.cpp
@@ -0,0 +1,18 @@
+// RUN: %python %S/check_clang_tidy.py %s cert-dcl50-cpp %t
+
+// Variadic function definitions are diagnosed.
+// CHECK-MESSAGES: :[[@LINE+1]]:6: warning: do not define a C-style variadic function; consider using a function parameter pack or currying instead [cert-dcl50-cpp]
+void f1(int, ...) {}
+
+// Variadic function *declarations* are not diagnosed.
+void f2(int, ...); // ok
+
+// Function parameter packs are good, however.
+template 
+void f3(Arg F, Ts... Rest) {}
+
+struct S {
+  void f(int, ...); // ok
+  // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: do not define a C-style variadic function; consider using a function parameter pack or currying instead [cert-dcl50-cpp]
+  void f1(int, ...) {}
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -2,6 +2,7 @@
 =
 
 .. toctree::
+   cert-variadic-function-def
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/cert-variadic-function-def.rst
===
--- docs/clang-tidy/checks/cert-variadic-function-def.rst
+++ docs/clang-tidy/checks/cert-variadic-function-def.rst
@@ -0,0 +1,13 @@
+cert-dcl50-cpp
+
+
+A variadic function using an ellipsis has no mechanisms to check the type safety
+of arguments being passed to the function or to check that the number of
+arguments being passed matches the semantics of the function definition.
+Consequently, a runtime call to a C-style variadic function that passes
+inappropriate arguments yields undefined behavior. Such undefined behavior could
+be exploited to run arbitrary code.
+
+This check corresponds to the CERT C++ Coding Standard rule
+`DCL50-CPP. Do not define a C-style variadic function
+`_.
Index: clang-tidy/cert/VariadicFunctionDefCheck.h
===
--- clang-tidy/cert/VariadicFunctionDefCheck.h
+++ clang-tidy/cert/VariadicFunctionDefCheck.h
@@ -0,0 +1,34 @@
+//===--- VariadicFunctionDefCheck.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_CERT_VARIADICFUNCTIONDEF_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_VARIADICFUNCTIONDEF_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+
+/// Guards against any C-style variadic function definitions (not declarations).
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-variadic-function-def.html
+class VariadicFunctionDefCheck : public ClangTidyCheck {
+public:
+  VariadicFunctionDefCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CERT_VARIADICFUNCTIONDEF_H
+
Index: clang-tidy/cert/VariadicFunctionDefCheck.cpp
===
--- clang-tidy/cert/VariadicFunc

Re: [PATCH] D13445: [libcxx] Reexport std::bad_array_length symbols from libc++abi on OS X.

2015-10-05 Thread Eric Fiselier via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249339: [libcxx] Reexport std::bad_array_length symbols from 
libc++abi on OS X. (authored by EricWF).

Changed prior to commit:
  http://reviews.llvm.org/D13445?vs=36540&id=36541#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13445

Files:
  libcxx/trunk/lib/CMakeLists.txt
  libcxx/trunk/lib/libc++abi2.exp

Index: libcxx/trunk/lib/CMakeLists.txt
===
--- libcxx/trunk/lib/CMakeLists.txt
+++ libcxx/trunk/lib/CMakeLists.txt
@@ -107,7 +107,7 @@
   "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
   endif()
 else()
-  set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+  set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
 endif()
 
 add_link_flags(
Index: libcxx/trunk/lib/libc++abi2.exp
===
--- libcxx/trunk/lib/libc++abi2.exp
+++ libcxx/trunk/lib/libc++abi2.exp
@@ -290,6 +290,16 @@
 __ZTSSt16invalid_argument
 __ZTVSt16invalid_argument
 
+__ZNKSt16bad_array_length4whatEv
+__ZNSt16bad_array_lengthC1Ev
+__ZNSt16bad_array_lengthC2Ev
+__ZNSt16bad_array_lengthD0Ev
+__ZNSt16bad_array_lengthD1Ev
+__ZNSt16bad_array_lengthD2Ev
+__ZTISt16bad_array_length
+__ZTSSt16bad_array_length
+__ZTVSt16bad_array_length
+
 __ZTSDi
 __ZTSDn
 __ZTSDs


Index: libcxx/trunk/lib/CMakeLists.txt
===
--- libcxx/trunk/lib/CMakeLists.txt
+++ libcxx/trunk/lib/CMakeLists.txt
@@ -107,7 +107,7 @@
   "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
   endif()
 else()
-  set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+  set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
 endif()
 
 add_link_flags(
Index: libcxx/trunk/lib/libc++abi2.exp
===
--- libcxx/trunk/lib/libc++abi2.exp
+++ libcxx/trunk/lib/libc++abi2.exp
@@ -290,6 +290,16 @@
 __ZTSSt16invalid_argument
 __ZTVSt16invalid_argument
 
+__ZNKSt16bad_array_length4whatEv
+__ZNSt16bad_array_lengthC1Ev
+__ZNSt16bad_array_lengthC2Ev
+__ZNSt16bad_array_lengthD0Ev
+__ZNSt16bad_array_lengthD1Ev
+__ZNSt16bad_array_lengthD2Ev
+__ZTISt16bad_array_length
+__ZTSSt16bad_array_length
+__ZTVSt16bad_array_length
+
 __ZTSDi
 __ZTSDn
 __ZTSDs
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r249339 - [libcxx] Reexport std::bad_array_length symbols from libc++abi on OS X.

2015-10-05 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Oct  5 14:28:48 2015
New Revision: 249339

URL: http://llvm.org/viewvc/llvm-project?rev=249339&view=rev
Log:
[libcxx] Reexport std::bad_array_length symbols from libc++abi on OS X.

Summary:
On OS X libc++ needs to reexport libc++abi's symbols in order for them to be 
provided. We explicitly list the symbols to reexport it 
libcxx/lib/libc++abi2.exp. This patch adds the symbols required by 
std::bad_array_length which have been missing for some time.

However there is a problem. std::bad_array_length was add to libc++abi in 
September of 2013 by commit r190479, about a year after everything else. 
Therefore I think older OS X version  have libc++abi versions without 
std::bad_array_length. On those systems
libc++ won't build with this change because we will try and export undefined 
symbols.

The workaround I would write to support older systems depends on the amount of 
people who would need it.   If only a small number of developers are affected 
it might be sufficient to provide a CMake switch like 
`LIBCPP_LIBCPPABI_HAS_BAD_ARRAY_LENGTH` which is
ON by default and can be disabled by those who need it. Otherwise I think we 
should try to automatically detect if the symbols are present in 
`/usr/lib/libc++abi.dylib` and configure accordingly. I would prefer the first 
solution because writing CMake sucks.




Reviewers: mclow.lists, aprantl

Subscribers: aprantl, cfe-commits

Differential Revision: http://reviews.llvm.org/D13445

Modified:
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/lib/libc++abi2.exp

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=249339&r1=249338&r2=249339&view=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Mon Oct  5 14:28:48 2015
@@ -107,7 +107,7 @@ if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME S
   "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
   endif()
 else()
-  set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+  set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
 endif()
 
 add_link_flags(

Modified: libcxx/trunk/lib/libc++abi2.exp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/libc%2B%2Babi2.exp?rev=249339&r1=249338&r2=249339&view=diff
==
--- libcxx/trunk/lib/libc++abi2.exp (original)
+++ libcxx/trunk/lib/libc++abi2.exp Mon Oct  5 14:28:48 2015
@@ -290,6 +290,16 @@ __ZTISt16invalid_argument
 __ZTSSt16invalid_argument
 __ZTVSt16invalid_argument
 
+__ZNKSt16bad_array_length4whatEv
+__ZNSt16bad_array_lengthC1Ev
+__ZNSt16bad_array_lengthC2Ev
+__ZNSt16bad_array_lengthD0Ev
+__ZNSt16bad_array_lengthD1Ev
+__ZNSt16bad_array_lengthD2Ev
+__ZTISt16bad_array_length
+__ZTSSt16bad_array_length
+__ZTVSt16bad_array_length
+
 __ZTSDi
 __ZTSDn
 __ZTSDs


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


Re: [PATCH] D13445: [libcxx] Reexport std::bad_array_length symbols from libc++abi on OS X.

2015-10-05 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 36540.
EricWF added a comment.

I moved the symbols into `lib/libc++abi2.exp` since we didn't anticipate the 
need to exclude them.


http://reviews.llvm.org/D13445

Files:
  lib/CMakeLists.txt
  lib/libc++abi2.exp

Index: lib/libc++abi2.exp
===
--- lib/libc++abi2.exp
+++ lib/libc++abi2.exp
@@ -290,6 +290,16 @@
 __ZTSSt16invalid_argument
 __ZTVSt16invalid_argument
 
+__ZNKSt16bad_array_length4whatEv
+__ZNSt16bad_array_lengthC1Ev
+__ZNSt16bad_array_lengthC2Ev
+__ZNSt16bad_array_lengthD0Ev
+__ZNSt16bad_array_lengthD1Ev
+__ZNSt16bad_array_lengthD2Ev
+__ZTISt16bad_array_length
+__ZTSSt16bad_array_length
+__ZTVSt16bad_array_length
+
 __ZTSDi
 __ZTSDn
 __ZTSDs
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -107,7 +107,7 @@
   "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
   endif()
 else()
-  set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+  set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
 endif()
 
 add_link_flags(


Index: lib/libc++abi2.exp
===
--- lib/libc++abi2.exp
+++ lib/libc++abi2.exp
@@ -290,6 +290,16 @@
 __ZTSSt16invalid_argument
 __ZTVSt16invalid_argument
 
+__ZNKSt16bad_array_length4whatEv
+__ZNSt16bad_array_lengthC1Ev
+__ZNSt16bad_array_lengthC2Ev
+__ZNSt16bad_array_lengthD0Ev
+__ZNSt16bad_array_lengthD1Ev
+__ZNSt16bad_array_lengthD2Ev
+__ZTISt16bad_array_length
+__ZTSSt16bad_array_length
+__ZTVSt16bad_array_length
+
 __ZTSDi
 __ZTSDn
 __ZTSDs
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -107,7 +107,7 @@
   "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
   endif()
 else()
-  set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+  set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
 endif()
 
 add_link_flags(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13445: [libcxx] Reexport std::bad_array_length symbols from libc++abi on OS X.

2015-10-05 Thread Adrian Prantl via cfe-commits
aprantl accepted this revision.
aprantl added a reviewer: aprantl.
aprantl added a comment.
This revision is now accepted and ready to land.

Grepping through the nm output of libc++abi it looks like bad_array_length is 
included in Xcode 7 and Xcode 6.4, which is also what is installed on the 
lab.llvm.org:8080 machines and going further back it looks like it is even 
included in MacOSX10.9.sdk in Xcode 5.1.1.

I don't think there are any expectation that LLVM trunk can be built with older 
versions.

Thanks for investigating this!


http://reviews.llvm.org/D13445



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


r249338 - [sanitizer] Enable lsan for AArch64

2015-10-05 Thread Adhemerval Zanella via cfe-commits
Author: azanella
Date: Mon Oct  5 14:16:42 2015
New Revision: 249338

URL: http://llvm.org/viewvc/llvm-project?rev=249338&view=rev
Log:
[sanitizer] Enable lsan for AArch64

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=249338&r1=249337&r2=249338&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Oct  5 14:16:42 2015
@@ -3803,7 +3803,7 @@ SanitizerMask Linux::getSupportedSanitiz
   Res |= SanitizerKind::SafeStack;
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::DataFlow;
-  if (IsX86_64 || IsMIPS64)
+  if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::Leak;
   if (IsX86_64 || IsMIPS64 || IsAArch64)
 Res |= SanitizerKind::Thread;


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


r249336 - Re-introduce the unique_ptr removed in r249328 and just make

2015-10-05 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Oct  5 13:54:30 2015
New Revision: 249336

URL: http://llvm.org/viewvc/llvm-project?rev=249336&view=rev
Log:
Re-introduce the unique_ptr removed in r249328 and just make
~CodeGenABITypes out-of-line, which should have the same effect.

Thanks to David Blaikie for pointing this out!

Modified:
cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp

Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=249336&r1=249335&r2=249336&view=diff
==
--- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Mon Oct  5 13:54:30 2015
@@ -80,7 +80,7 @@ private:
   std::unique_ptr PPO;
 
   /// The CodeGenModule we use get to the CodeGenTypes object.
-  CodeGen::CodeGenModule *CGM;
+  std::unique_ptr CGM;
 };
 
 }  // end namespace CodeGen

Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=249336&r1=249335&r2=249336&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Mon Oct  5 13:54:30 2015
@@ -33,10 +33,9 @@ CodeGenABITypes::CodeGenABITypes(ASTCont
   CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, M, 
C.getDiagnostics(),
  CoverageInfo)) {}
 
-CodeGenABITypes::~CodeGenABITypes()
-{
-  delete CGM;
-}
+// Explicitly out-of-line because ~CodeGenModule() is private but
+// CodeGenABITypes.h is part of clang's API.
+CodeGenABITypes::~CodeGenABITypes() = default;
 
 const CGFunctionInfo &
 CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,


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


[PATCH] D13445: [libcxx] Reexport std::bad_array_length symbols from libc++abi on OS X.

2015-10-05 Thread Eric Fiselier via cfe-commits
EricWF created this revision.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.

On OS X libc++ needs to reexport libc++abi's symbols in order for them to be 
provided. We explicitly list the symbols to reexport it 
libcxx/lib/libc++abi2.exp. This patch adds the symbols required by 
std::bad_array_length which have been missing for some time.

However there is a problem. std::bad_array_length was add to libc++abi in 
September of 2013 by commit r190479, about a year after everything else. 
Therefore I think older OS X version  have libc++abi versions without 
std::bad_array_length. On those systems
libc++ won't build with this change because we will try and export undefined 
symbols.

The workaround I would write to support older systems depends on the amount of 
people who would need it.   If only a small number of developers are affected 
it might be sufficient to provide a CMake switch like 
`LIBCPP_LIBCPPABI_HAS_BAD_ARRAY_LENGTH` which is
ON by default and can be disabled by those who need it. Otherwise I think we 
should try to automatically detect if the symbols are present in 
`/usr/lib/libc++abi.dylib` and configure accordingly. I would prefer the first 
solution because writing CMake sucks.




http://reviews.llvm.org/D13445

Files:
  lib/CMakeLists.txt
  lib/libc++abi_bad_array_length.exp

Index: lib/libc++abi_bad_array_length.exp
===
--- /dev/null
+++ lib/libc++abi_bad_array_length.exp
@@ -0,0 +1,9 @@
+__ZNKSt16bad_array_length4whatEv
+__ZNSt16bad_array_lengthC1Ev
+__ZNSt16bad_array_lengthC2Ev
+__ZNSt16bad_array_lengthD0Ev
+__ZNSt16bad_array_lengthD1Ev
+__ZNSt16bad_array_lengthD2Ev
+__ZTISt16bad_array_length
+__ZTSSt16bad_array_length
+__ZTVSt16bad_array_length
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -107,7 +107,8 @@
   "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
   endif()
 else()
-  set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+  set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib 
-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+  set(OSX_RE_EXPORT_LINE "${OSX_RE_EXPORT_LINE} 
-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi_bad_array_length.exp")
 endif()
 
 add_link_flags(


Index: lib/libc++abi_bad_array_length.exp
===
--- /dev/null
+++ lib/libc++abi_bad_array_length.exp
@@ -0,0 +1,9 @@
+__ZNKSt16bad_array_length4whatEv
+__ZNSt16bad_array_lengthC1Ev
+__ZNSt16bad_array_lengthC2Ev
+__ZNSt16bad_array_lengthD0Ev
+__ZNSt16bad_array_lengthD1Ev
+__ZNSt16bad_array_lengthD2Ev
+__ZTISt16bad_array_length
+__ZTSSt16bad_array_length
+__ZTVSt16bad_array_length
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -107,7 +107,8 @@
   "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib")
   endif()
 else()
-  set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+  set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp")
+  set(OSX_RE_EXPORT_LINE "${OSX_RE_EXPORT_LINE} -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi_bad_array_length.exp")
 endif()
 
 add_link_flags(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r249334 - Add comments about the issues

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 13:48:10 2015
New Revision: 249334

URL: http://llvm.org/viewvc/llvm-project?rev=249334&view=rev
Log:
Add comments about the issues

Modified:
libcxx/trunk/www/kona.html

Modified: libcxx/trunk/www/kona.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/kona.html?rev=249334&r1=249333&r2=249334&view=diff
==
--- libcxx/trunk/www/kona.html (original)
+++ libcxx/trunk/www/kona.html Mon Oct  5 13:48:10 2015
@@ -61,10 +61,10 @@
http://cplusplus.github.io/LWG/lwg-defects.html#1169";>1169num_get
 not fully compatible with strto*Kona
http://cplusplus.github.io/LWG/lwg-defects.html#2072";>2072Unclear
 wording about capacity of temporary buffersKona
http://cplusplus.github.io/LWG/lwg-defects.html#2101";>2101Some
 transformation types can produce impossible 
typesKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2111";>2111Which
 unexpected/terminate handler is called from the 
exception handling runtime?Kona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2111";>2111Which
 unexpected/terminate handler is called from the 
exception handling runtime?KonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2119";>2119Missing
 hash specializations for extended integer 
typesKona
http://cplusplus.github.io/LWG/lwg-defects.html#2127";>2127Move-construction
 with raw_storage_iteratorKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2133";>2133Attitude
 to overloaded comma for iteratorsKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2133";>2133Attitude
 to overloaded comma for iteratorsKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2156";>2156Unordered
 containers' reserve(n) reserves for n-1 
elementsKona
http://cplusplus.github.io/LWG/lwg-defects.html#2181";>2181Exceptions
 from seed sequence operationsKona
http://cplusplus.github.io/LWG/lwg-defects.html#2218";>2218Unclear
 how containers use 
allocator_traits::construct()Kona
@@ -78,7 +78,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2380";>2380May
  provide long ::abs(long) and long long 
::abs(long long)?Kona
http://cplusplus.github.io/LWG/lwg-defects.html#2384";>2384Allocator's
 deallocate function needs better 
specificationKona
http://cplusplus.github.io/LWG/lwg-defects.html#2385";>2385function::assign
 allocator argument doesn't make senseKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2435";>2435reference_wrapper::operator()'s
 Remark should be deletedKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2435";>2435reference_wrapper::operator()'s
 Remark should be deletedKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2447";>2447Allocators
 and volatile-qualified value typesKona
http://cplusplus.github.io/LWG/lwg-defects.html#2462";>2462std::ios_base::failure
 is overspecifiedKona
http://cplusplus.github.io/LWG/lwg-defects.html#2466";>2466allocator_traits::max_size()
 default behavior is incorrectKona
@@ -92,7 +92,7 @@
http://cplusplus.github.io/LWG/lwg-defects.html#2486";>2486mem_fn()
 should be required to use perfect forwardingKona
http://cplusplus.github.io/LWG/lwg-defects.html#2487";>2487bind()
 should be const-overloaded, not 
cv-overloadedKona
http://cplusplus.github.io/LWG/lwg-defects.html#2489";>2489mem_fn()
 should be noexceptKona
-   http://cplusplus.github.io/LWG/lwg-defects.html#2492";>2492Clarify
 requirements for compKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2492";>2492Clarify
 requirements for compKonaComplete
http://cplusplus.github.io/LWG/lwg-defects.html#2494";>2494[fund.ts.v2]
 ostream_joiner needs noexceptKona
 
 

Fwd: r249328 - Undo the unique_ptr'fication of CodeGenABITypes::CGM introduced in r248762.

2015-10-05 Thread David Blaikie via cfe-commits
Oops, forgot to reply-all. Sorry Adrian.

-- Forwarded message --
From: David Blaikie 
Date: Mon, Oct 5, 2015 at 11:45 AM
Subject: Re: r249328 - Undo the unique_ptr'fication of CodeGenABITypes::CGM
introduced in r248762.
To: Adrian Prantl 




On Mon, Oct 5, 2015 at 11:43 AM, David Blaikie  wrote:

>
>
> On Mon, Oct 5, 2015 at 10:41 AM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Mon Oct  5 12:41:16 2015
>> New Revision: 249328
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=249328&view=rev
>> Log:
>> Undo the unique_ptr'fication of CodeGenABITypes::CGM introduced in
>> r248762.
>> include/clang/CodeGenABITypes.h is in meant to be included by external
>> users,
>
>
Oh, and it might be handy to have some kind of test coverage for this -
however that might happen. (I wonder if a "unit test" that didn't even have
any executable code/tests and just included the header, would've caught
this at compile-time rather than, presumably, when it was integrated into
another codebase with the actual external use of the header - though a more
fully fledged test would be nice, of course)


> but using a unique_ptr on the private CodeGenModule introduces a
>
> dependency on the type definition that prevents such a use.
>>
>
> If you just make the CodeGenABITypes dtor out of line (but still
> defaulted) this will address the issue without needing to use raw
> pointers/manual delete:
>
> foo.h:
>
> struct bar;
> struct foo {
>   unique_ptr b;
>   foo();
>   ~foo();
> };
>
> foo.cpp:
> struct bar {
> };
> foo::~foo() = default;
>
>
> We have similar code in a variety of parts of LLVM/Clang to cope with
> calling dtors of types that are implementation details, etc.
>
>
>>
>> NFC
>>
>> Modified:
>> cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
>> cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
>>
>> Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=249328&r1=249327&r2=249328&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)
>> +++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Mon Oct  5 12:41:16
>> 2015
>> @@ -52,6 +52,7 @@ class CodeGenABITypes
>>  public:
>>CodeGenABITypes(ASTContext &C, llvm::Module &M,
>>CoverageSourceInfo *CoverageInfo = nullptr);
>> +  ~CodeGenABITypes();
>>
>>/// These methods all forward to methods in the private implementation
>> class
>>/// CodeGenTypes.
>> @@ -79,7 +80,7 @@ private:
>>std::unique_ptr PPO;
>>
>>/// The CodeGenModule we use get to the CodeGenTypes object.
>> -  std::unique_ptr CGM;
>> +  CodeGen::CodeGenModule *CGM;
>>  };
>>
>>  }  // end namespace CodeGen
>>
>> Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=249328&r1=249327&r2=249328&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Mon Oct  5 12:41:16 2015
>> @@ -33,6 +33,11 @@ CodeGenABITypes::CodeGenABITypes(ASTCont
>>CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, M,
>> C.getDiagnostics(),
>>   CoverageInfo)) {}
>>
>> +CodeGenABITypes::~CodeGenABITypes()
>> +{
>> +  delete CGM;
>> +}
>> +
>>  const CGFunctionInfo &
>>  CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl
>> *MD,
>>   QualType receiverType) {
>>
>>
>> ___
>> 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: r249328 - Undo the unique_ptr'fication of CodeGenABITypes::CGM introduced in r248762.

2015-10-05 Thread David Blaikie via cfe-commits
On Mon, Oct 5, 2015 at 10:41 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Mon Oct  5 12:41:16 2015
> New Revision: 249328
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249328&view=rev
> Log:
> Undo the unique_ptr'fication of CodeGenABITypes::CGM introduced in r248762.
> include/clang/CodeGenABITypes.h is in meant to be included by external
> users, but using a unique_ptr on the private CodeGenModule introduces a

dependency on the type definition that prevents such a use.
>

If you just make the CodeGenABITypes dtor out of line (but still defaulted)
this will address the issue without needing to use raw pointers/manual
delete:

foo.h:

struct bar;
struct foo {
  unique_ptr b;
  foo();
  ~foo();
};

foo.cpp:
struct bar {
};
foo::~foo() = default;


We have similar code in a variety of parts of LLVM/Clang to cope with
calling dtors of types that are implementation details, etc.


>
> NFC
>
> Modified:
> cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
> cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
>
> Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=249328&r1=249327&r2=249328&view=diff
>
> ==
> --- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)
> +++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Mon Oct  5 12:41:16
> 2015
> @@ -52,6 +52,7 @@ class CodeGenABITypes
>  public:
>CodeGenABITypes(ASTContext &C, llvm::Module &M,
>CoverageSourceInfo *CoverageInfo = nullptr);
> +  ~CodeGenABITypes();
>
>/// These methods all forward to methods in the private implementation
> class
>/// CodeGenTypes.
> @@ -79,7 +80,7 @@ private:
>std::unique_ptr PPO;
>
>/// The CodeGenModule we use get to the CodeGenTypes object.
> -  std::unique_ptr CGM;
> +  CodeGen::CodeGenModule *CGM;
>  };
>
>  }  // end namespace CodeGen
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=249328&r1=249327&r2=249328&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Mon Oct  5 12:41:16 2015
> @@ -33,6 +33,11 @@ CodeGenABITypes::CodeGenABITypes(ASTCont
>CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, M,
> C.getDiagnostics(),
>   CoverageInfo)) {}
>
> +CodeGenABITypes::~CodeGenABITypes()
> +{
> +  delete CGM;
> +}
> +
>  const CGFunctionInfo &
>  CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
>   QualType receiverType) {
>
>
> ___
> 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


[libcxx] r249333 - Private page for status of Kona issues and papers. Will be deleted after the Kona meeting. Not to be linked to from other pages.

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 13:40:13 2015
New Revision: 249333

URL: http://llvm.org/viewvc/llvm-project?rev=249333&view=rev
Log:
Private page for status of Kona issues and papers. Will be deleted after the 
Kona meeting. Not to be linked to from other pages.

Added:
libcxx/trunk/www/kona.html

Added: libcxx/trunk/www/kona.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/kona.html?rev=249333&view=auto
==
--- libcxx/trunk/www/kona.html (added)
+++ libcxx/trunk/www/kona.html Mon Oct  5 13:40:13 2015
@@ -0,0 +1,109 @@
+http://www.w3.org/TR/html4/strict.dtd";>
+
+
+
+  
+  libc++ Kona Status
+  
+  
+
+
+
+
+  
+http://llvm.org/";>LLVM Home
+  
+
+  
+libc++ Info
+About
+  
+
+  
+Quick Links
+http://lists.llvm.org/mailman/listinfo/cfe-dev";>cfe-dev
+http://lists.llvm.org/mailman/listinfo/cfe-commits";>cfe-commits
+http://llvm.org/bugs/";>Bug Reports
+http://llvm.org/svn/llvm-project/libcxx/trunk/";>Browse SVN
+http://llvm.org/viewvc/llvm-project/libcxx/trunk/";>Browse 
ViewVC
+  
+
+
+
+  
+  libc++ Kona Status
+  
+
+  This is a temporary page; please check the c++1z status http://libcxx.llvm.org/cxx1z_status.html";>here
+  This page shows the status of the papers and issues that are expected to 
be adopted in Kona.
+
+  The groups that have contributed papers:
+  
+LWG - Library working group
+CWG - Core Language Working group
+SG1 - Study group #1 (Concurrency working group)
+  
+  
+  
+  Paper Status
+  
+   Paper #GroupPaper 
NameMeetingStatusFirst released version
+
+
+  
+
+  Library Working group Issues Status
+  
+   Issue #Issue 
NameMeetingStatus
+   http://cplusplus.github.io/LWG/lwg-defects.html#1169";>1169num_get
 not fully compatible with strto*Kona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2072";>2072Unclear
 wording about capacity of temporary buffersKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2101";>2101Some
 transformation types can produce impossible 
typesKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2111";>2111Which
 unexpected/terminate handler is called from the 
exception handling runtime?Kona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2119";>2119Missing
 hash specializations for extended integer 
typesKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2127";>2127Move-construction
 with raw_storage_iteratorKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2133";>2133Attitude
 to overloaded comma for iteratorsKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2156";>2156Unordered
 containers' reserve(n) reserves for n-1 
elementsKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2181";>2181Exceptions
 from seed sequence operationsKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2218";>2218Unclear
 how containers use 
allocator_traits::construct()Kona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2219";>2219INVOKE-ing
 a pointer to member with a reference_wrapper as the object 
expressionKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2244";>2244Issue
 on basic_istream::seekgKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2250";>2250Follow-up
 On Library Issue 2207Kona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2259";>2259Issues
 in 17.6.5.5 rules for member functionsKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2336";>2336is_trivially_constructible/is_trivially_assignable
 traits are always falseKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2353";>2353std::next
 is over-constrainedKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2367";>2367pair
 and tuple are not correctly implemented for is_constructible 
with no argsKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2380";>2380May
  provide long ::abs(long) and long long 
::abs(long long)?Kona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2384";>2384Allocator's
 deallocate function needs better 
specificationKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2385";>2385function::assign
 allocator argument doesn't make senseKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2435";>2435reference_wrapper::operator()'s
 Remark should be deletedKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2447";>2447Allocators
 and volatile-qualified value typesKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2462";>2462std::ios_base::failure
 is overspecifiedKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2466";>2466allocator_traits::max_size()
 default behavior is incorrectKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2469";>2469Wrong
 specification of Requires clause of operator[] for map and 
unordered_mapKona
+   http://cplusplus.github.io/LWG/lwg-defects.html#2473";>2473basic_filebuf'

Re: r249157 - Module debugging: Don't emit forward declarations in module scopes.

2015-10-05 Thread David Blaikie via cfe-commits
On Mon, Oct 5, 2015 at 11:37 AM, David Blaikie  wrote:

>
>
> On Mon, Oct 5, 2015 at 8:55 AM, Adrian Prantl  wrote:
>
>>
>> On Oct 2, 2015, at 3:24 PM, David Blaikie  wrote:
>>
>>
>>
>> On Fri, Oct 2, 2015 at 3:21 PM, Adrian Prantl  wrote:
>>
>>>
>>> On Oct 2, 2015, at 3:01 PM, David Blaikie  wrote:
>>>
>>>
>>>
>>> On Fri, Oct 2, 2015 at 3:00 PM, Adrian Prantl  wrote:
>>>

 On Oct 2, 2015, at 2:58 PM, David Blaikie  wrote:



 On Fri, Oct 2, 2015 at 2:40 PM, Adrian Prantl 
 wrote:

>
> On Oct 2, 2015, at 2:18 PM, David Blaikie  wrote:
>
> This seems a little curious, so you'll have code like this:
>
>   decl foo
>   module
> def bar
>member foo pointer (references the declaration of foo outside
> the module, in the CU?)
>
>
> Right.
>
> Why is that preferable to DWARF that looks more like the AST where the
> declaration of foo appears in the first module that references it, rather
> than, in a curiously circular situation, in the CU that references the
> module?
>
>
> The problem I had with this was that a forward declaration would end
> up in a DeclContext that is not the DeclContext of the definition. Looking
> at this through the dsymutil goggles, the different DeclContexts
> effectively prevent the forward declaration from being uniqued with the
> type's definition.
>

 Putting it in the CU doesn't seem to make the decl context match
 either, does it? In that case the decl context may still be "some other
 compile unit" (as with most declarations)

 Shouldn't dsymutil be treating modules more like CUs as "another top
 level scope”?


 The CU is not part of the DeclContext (for dsymutil’s interpretation of
 a DeclContext). Otherwise cross-CU type uniquing would never work.

>>>
>>> perhaps the module shouldn't be either, then?
>>>
>>>
>>> The module has to be, for correctness. (None of this applies to C++.
>>> Oversimplified: because of the ODR we can omit the parent DW_TAG_module
>>> from all CXXRecordDecls).
>>> For C and ObjC it is perfectly legal to have two modules with
>>> conflicting definitions for a type, so we need the DW_TAG_module as part of
>>> the DeclContext to differentiate them if we want to be able to resolve
>>> forward declarations to the correct definition.
>>>
>>
>> But you have to do the same thing for the things in the CU as well,
>> right? So you can't ignore the CU in the same way you can't ignore the
>> module, yes?
>>
>>
>> You’ve got a point there. In a non-ODR language, you still wouldn’t be
>> allowed to resolve a forward declaration to a specific type.
>> The one thing that I don’t like about emitting “real" forward
>> declarations into the DW_TAG_module is that they are indistinguishable from
>> the forward declarations that are emitted for external type references, for
>> which there is an actual definition in the module itself. This is more of
>> an aesthetic problem
>>
>
> Yeah, I agree it's a bit weird & not sure what the nicest solution is, but
> I think this is a bit more consistent with the way the modules actually
> work (that the type appears in the first module it's used from, even if
> it's just a declaration, then other modules do actually reference the type
> from the prior one)
>
> Remind me why we need these other types in the non-defining module anyway?
> Since it only contains type declarations, when does it need to contain
> types that aren't defined in the module? It just happens to be that its a
> type declaration that comes from the module, I guess? But the type will
> never be referenced from anything inside the non-defining DW_TAG_module?
>

(to clarify further - if nothing in the non-defining DW_TAG_module
references the type declaration, and the type definition won't be found in
the module, yeah - I think aesthetically, it makes sense to put the type
declaration in the CU - it's just the way the code to handle that falls out
that feels weird, I think)


>
> (& I know this is revisiting decisions we've made - but again, I wonder if
> this would all fall out more naturally if modularized types were treated
> more traditionally, but with an extra attribute in their declaration if
> they happen to be defined in a module we know about at the moment - so the
> code would look more like -flimit-debug-info just "if this definition is
> from a module, just emit a declaration" (& the "if we're building a
> declaration for a type defined in a module and we're targetting lldb, add
> the extra attribute) - it does seem a little (but not massively so) more
> complicated to be having to deal with these different context chains)
>
>
>> than a technical one, but it does make dsymutils job of resolving type
>> references in a single pass a little harder since dsymutil can no longer
>> assume that all forward declarations in a non-defining TAG_module can be
>> resolved.
>>

Re: r249157 - Module debugging: Don't emit forward declarations in module scopes.

2015-10-05 Thread David Blaikie via cfe-commits
On Mon, Oct 5, 2015 at 8:55 AM, Adrian Prantl  wrote:

>
> On Oct 2, 2015, at 3:24 PM, David Blaikie  wrote:
>
>
>
> On Fri, Oct 2, 2015 at 3:21 PM, Adrian Prantl  wrote:
>
>>
>> On Oct 2, 2015, at 3:01 PM, David Blaikie  wrote:
>>
>>
>>
>> On Fri, Oct 2, 2015 at 3:00 PM, Adrian Prantl  wrote:
>>
>>>
>>> On Oct 2, 2015, at 2:58 PM, David Blaikie  wrote:
>>>
>>>
>>>
>>> On Fri, Oct 2, 2015 at 2:40 PM, Adrian Prantl  wrote:
>>>

 On Oct 2, 2015, at 2:18 PM, David Blaikie  wrote:

 This seems a little curious, so you'll have code like this:

   decl foo
   module
 def bar
member foo pointer (references the declaration of foo outside
 the module, in the CU?)


 Right.

 Why is that preferable to DWARF that looks more like the AST where the
 declaration of foo appears in the first module that references it, rather
 than, in a curiously circular situation, in the CU that references the
 module?


 The problem I had with this was that a forward declaration would end up
 in a DeclContext that is not the DeclContext of the definition. Looking at
 this through the dsymutil goggles, the different DeclContexts effectively
 prevent the forward declaration from being uniqued with the type's
 definition.

>>>
>>> Putting it in the CU doesn't seem to make the decl context match either,
>>> does it? In that case the decl context may still be "some other compile
>>> unit" (as with most declarations)
>>>
>>> Shouldn't dsymutil be treating modules more like CUs as "another top
>>> level scope”?
>>>
>>>
>>> The CU is not part of the DeclContext (for dsymutil’s interpretation of
>>> a DeclContext). Otherwise cross-CU type uniquing would never work.
>>>
>>
>> perhaps the module shouldn't be either, then?
>>
>>
>> The module has to be, for correctness. (None of this applies to C++.
>> Oversimplified: because of the ODR we can omit the parent DW_TAG_module
>> from all CXXRecordDecls).
>> For C and ObjC it is perfectly legal to have two modules with conflicting
>> definitions for a type, so we need the DW_TAG_module as part of the
>> DeclContext to differentiate them if we want to be able to resolve forward
>> declarations to the correct definition.
>>
>
> But you have to do the same thing for the things in the CU as well, right?
> So you can't ignore the CU in the same way you can't ignore the module, yes?
>
>
> You’ve got a point there. In a non-ODR language, you still wouldn’t be
> allowed to resolve a forward declaration to a specific type.
> The one thing that I don’t like about emitting “real" forward declarations
> into the DW_TAG_module is that they are indistinguishable from the forward
> declarations that are emitted for external type references, for which there
> is an actual definition in the module itself. This is more of an aesthetic
> problem
>

Yeah, I agree it's a bit weird & not sure what the nicest solution is, but
I think this is a bit more consistent with the way the modules actually
work (that the type appears in the first module it's used from, even if
it's just a declaration, then other modules do actually reference the type
from the prior one)

Remind me why we need these other types in the non-defining module anyway?
Since it only contains type declarations, when does it need to contain
types that aren't defined in the module? It just happens to be that its a
type declaration that comes from the module, I guess? But the type will
never be referenced from anything inside the non-defining DW_TAG_module?

(& I know this is revisiting decisions we've made - but again, I wonder if
this would all fall out more naturally if modularized types were treated
more traditionally, but with an extra attribute in their declaration if
they happen to be defined in a module we know about at the moment - so the
code would look more like -flimit-debug-info just "if this definition is
from a module, just emit a declaration" (& the "if we're building a
declaration for a type defined in a module and we're targetting lldb, add
the extra attribute) - it does seem a little (but not massively so) more
complicated to be having to deal with these different context chains)


> than a technical one, but it does make dsymutils job of resolving type
> references in a single pass a little harder since dsymutil can no longer
> assume that all forward declarations in a non-defining TAG_module can be
> resolved.
>

Wouldn't dsymutil have a pretty generic algorithm for resolving
declarations to definitions that would have to cope with missing
definitions for declarations in CUs? So I would imagine this case would
just "fall out" of that resolution code without need for any special cases.
(so long as you visit modules in reverse order of dependencies - so you
visit the dependencies before the modules they depend on (or the other way
around, if that works best)).


>
> -- adrian
>
>
>
>>
>> -- adrian
>>
>>
>>
>>>
>>> -- adrian
>>>
>

Re: [PATCH] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-05 Thread Chris Bieneman via cfe-commits
beanz added a comment.

probinson,

Not by itself, but this could be used as a step in that direction. The 
`CLANG_COMPILER_RT_CMAKE_ARGS` variable can be used to configure how 
compiler-rt is built with a great deal of flexibility, but the goal of this 
patch is to try and closely match how compiler-rt builds in-tree today.

-Chris


http://reviews.llvm.org/D13399



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


Re: [PATCH] D13221: Make CompilerInvocation's use of the debug options more understandable.

2015-10-05 Thread David Blaikie via cfe-commits
On Mon, Oct 5, 2015 at 8:37 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> aprantl added a comment.
>
> Some bikeshedding about -di-kind={full|limited|line-tables}:
>
> 1. Is there a good reason not to spell out -debug-info-kind?
> 2. "full" is misleading as it will still only emit debug info for types
> actually used by the program. I think "standalone" would be more
> descriptive.
> 3. Why not "line-tables-only" like in -gline-tables-only?
>

All of that sounds reasonable to me, but I'm not too fussed in any
direction since it's just cc1.


>
>
> http://reviews.llvm.org/D13221
>
>
>
> ___
> 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] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-05 Thread Paul Robinson via cfe-commits
probinson added a subscriber: probinson.
probinson added a comment.

I'm a CMake ignoramus but functionally if I'm building a Clang cross-compiler, 
I'd want a cross-built compiler-rt but not run its tests even if 
LLVM_INCLUDE_TESTS is on.  Does that make sense?  If so, does this change make 
that work properly?
Thanks...


http://reviews.llvm.org/D13399



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


Re: [PATCH] D13134: [analyzer] Add keyboard shortcuts to report.html

2015-10-05 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

Thanks for the update. Unfortunately, we can't accept the mousetrap code. Any 
code contributed to clang needs to be under the UIUC license.  The original 
copyright owner would need to contribute the code under that license.

I think it would be fine to revert to your previous version -- but with a FIXME 
stating that this doesn't work on non-QWERTY keyboards.

Other than that, this LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D13134



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


Re: [PATCH] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-05 Thread Chris Bieneman via cfe-commits
beanz updated this revision to Diff 36532.
beanz added a comment.

- Cleanup based on feedback from samsonov


http://reviews.llvm.org/D13399

Files:
  runtime/CMakeLists.txt

Index: runtime/CMakeLists.txt
===
--- runtime/CMakeLists.txt
+++ runtime/CMakeLists.txt
@@ -24,85 +24,97 @@
 
 set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
 if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
-  if(CMAKE_GENERATOR MATCHES "Ninja")
-message(FATAL_ERROR
-"Ninja generator can't build compiler-rt as ExternalProject."
-"Unset LLVM_BUILD_EXTERNAL_COMPILER_RT, or don't use Ninja."
-"See http://www.cmake.org/Bug/view.php?id=14771";)
+  if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
+set(cmake_3_4_USES_TERMINAL_OPTIONS
+  USES_TERMINAL_CONFIGURE 1
+  USES_TERMINAL_BUILD 1
+  USES_TERMINAL_INSTALL 1
+  )
   endif()
 
   # Add compiler-rt as an external project.
   set(COMPILER_RT_PREFIX ${CMAKE_BINARY_DIR}/projects/compiler-rt)
+
+  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-stamps/)
+  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-bins/)
+
+  add_custom_target(compiler-rt-clear
+DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared
+)
+  add_custom_command(
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared
+DEPENDS clang llvm-config
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
+COMMAND ${CMAKE_COMMAND} -E make_directory ${BINARY_DIR}
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
+COMMAND ${CMAKE_COMMAND} -E make_directory ${STAMP_DIR}
+COMMENT "Clobberring compiler-rt build and stamp directories"
+)
   
   ExternalProject_Add(compiler-rt
+DEPENDS clang llvm-config
 PREFIX ${COMPILER_RT_PREFIX}
 SOURCE_DIR ${COMPILER_RT_SRC_ROOT}
-CMAKE_ARGS -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
+STAMP_DIR ${STAMP_DIR}
+BINARY_DIR ${BINARY_DIR}
+CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
+   -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
-   -DCMAKE_BUILD_TYPE=Release
+   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
-DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
-DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
-   -DCOMPILER_RT_INSTALL_PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
+   -DCOMPILER_RT_INSTALL_PATH=${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-   -DCOMPILER_RT_ENABLE_WERROR=ON
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build
+${cmake_3_4_USES_TERMINAL_OPTIONS}
 )
-  # Due to a bug, DEPENDS in ExternalProject_Add doesn't work
-  # in CMake 2.8.9 and 2.8.10.
-  add_dependencies(compiler-rt llvm-config clang)
 
-  # Add a custom step to always re-configure compiler-rt (in case some of its
-  # sources have changed).
-  ExternalProject_Add_Step(compiler-rt force-reconfigure
-DEPENDERS configure
-ALWAYS 1
-)
+  install(CODE "execute_process\(COMMAND ${CMAKE_COMMAND} -P ${BINARY_DIR}/cmake_install.cmake \)"
+COMPONENT compiler-rt)
 
-  ExternalProject_Add_Step(compiler-rt clobber
-COMMAND ${CMAKE_COMMAND} -E remove_directory 
-COMMAND ${CMAKE_COMMAND} -E make_directory 
-COMMENT "Clobberring compiler-rt build directory..."
-DEPENDERS configure
-DEPENDS ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-  )
-
-  ExternalProject_Get_Property(compiler-rt BINARY_DIR)
-  set(COMPILER_RT_BINARY_DIR ${BINARY_DIR})
+  add_custom_target(install-compiler-rt
+DEPENDS compiler-rt
+COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=compiler-rt
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
 
   # Add top-level targets that build specific compiler-rt runtimes.
   set(COMPILER_RT_RUNTIMES asan builtins dfsan lsan msan profile tsan ubsan)
   foreach(runtime ${COMPILER_RT_RUNTIMES})
 get_ext_project_build_command(build_runtime_cmd ${runtime})
 add_custom_target(${runtime}
   COMMAND ${build_runtime_cmd}
   DEPENDS compiler-rt-configure
-  WORKING_DIRECTORY ${COMPILER_RT_BINARY_DIR}
+  WORKING_DIRECTORY ${BINARY_DIR}
   VERBATIM)
   endforeach()
 
-  # Add binaries that compiler-rt tests depend on.
-  set(COMPILER_RT_TEST_DEPENDENCIES
-FileCheck count not llvm-nm llvm-symbolizer)
+  if(LLVM_INCLUDE_TESTS)
+# Add binaries that compiler-rt tests depend on.
+set(COMPILER_RT_TEST_DEPENDENCIES
+  FileCheck count not llvm-n

Re: [PATCH] D13318: Add a utility function to add target information to a command line

2015-10-05 Thread Luke Zarko via cfe-commits
zarko updated this revision to Diff 36529.
zarko added a comment.

Copy a dependency from a test Makefile to its CMakeLists.


http://reviews.llvm.org/D13318

Files:
  include/clang/Tooling/Tooling.h
  lib/Tooling/Tooling.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/ToolingTest.cpp

Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -18,6 +18,8 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TargetRegistry.h"
 #include "gtest/gtest.h"
 #include 
 #include 
@@ -291,6 +293,84 @@
   EXPECT_FALSE(Found);
 }
 
+namespace {
+/// Find a target name such that looking for it in TargetRegistry by that name
+/// returns the same target. We expect that there is at least one target
+/// configured with this property.
+std::string getAnyTarget() {
+  llvm::InitializeAllTargets();
+  for (const auto &Target : llvm::TargetRegistry::targets()) {
+std::string Error;
+if (llvm::TargetRegistry::lookupTarget(Target.getName(), Error) ==
+&Target) {
+  return Target.getName();
+}
+  }
+  return "";
+}
+}
+
+TEST(addTargetAndModeForProgramName, AddsTargetAndMode) {
+  std::string Target = getAnyTarget();
+  ASSERT_FALSE(Target.empty());
+
+  std::vector Args = {"clang", "-foo"};
+  addTargetAndModeForProgramName(Args, "");
+  EXPECT_EQ((std::vector{"clang", "-foo"}), Args);
+  addTargetAndModeForProgramName(Args, Target + "-g++");
+  EXPECT_EQ((std::vector{"clang", "-target", Target,
+  "--driver-mode=g++", "-foo"}),
+Args);
+}
+
+TEST(addTargetAndModeForProgramName, PathIgnored) {
+  std::string Target = getAnyTarget();
+  ASSERT_FALSE(Target.empty());
+
+  SmallString<32> ToolPath;
+  llvm::sys::path::append(ToolPath, "foo", "bar", Target + "-g++");
+
+  std::vector Args = {"clang", "-foo"};
+  addTargetAndModeForProgramName(Args, ToolPath);
+  EXPECT_EQ((std::vector{"clang", "-target", Target,
+  "--driver-mode=g++", "-foo"}),
+Args);
+}
+
+TEST(addTargetAndModeForProgramName, IgnoresExistingTarget) {
+  std::string Target = getAnyTarget();
+  ASSERT_FALSE(Target.empty());
+
+  std::vector Args = {"clang", "-foo", "-target", "something"};
+  addTargetAndModeForProgramName(Args, Target + "-g++");
+  EXPECT_EQ((std::vector{"clang", "--driver-mode=g++", "-foo",
+  "-target", "something"}),
+Args);
+
+  std::vector ArgsAlt = {"clang", "-foo", "-target=something"};
+  addTargetAndModeForProgramName(ArgsAlt, Target + "-g++");
+  EXPECT_EQ((std::vector{"clang", "--driver-mode=g++", "-foo",
+  "-target=something"}),
+ArgsAlt);
+}
+
+TEST(addTargetAndModeForProgramName, IgnoresExistingMode) {
+  std::string Target = getAnyTarget();
+  ASSERT_FALSE(Target.empty());
+
+  std::vector Args = {"clang", "-foo", "--driver-mode=abc"};
+  addTargetAndModeForProgramName(Args, Target + "-g++");
+  EXPECT_EQ((std::vector{"clang", "-target", Target, "-foo",
+  "--driver-mode=abc"}),
+Args);
+
+  std::vector ArgsAlt = {"clang", "-foo", "--driver-mode", "abc"};
+  addTargetAndModeForProgramName(ArgsAlt, Target + "-g++");
+  EXPECT_EQ((std::vector{"clang", "-target", Target, "-foo",
+  "--driver-mode", "abc"}),
+ArgsAlt);
+}
+
 #ifndef LLVM_ON_WIN32
 TEST(ClangToolTest, BuildASTs) {
   FixedCompilationDatabase Compilations("/", std::vector());
Index: unittests/Tooling/CMakeLists.txt
===
--- unittests/Tooling/CMakeLists.txt
+++ unittests/Tooling/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
   Support
   )
 
Index: lib/Tooling/Tooling.cpp
===
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -17,6 +17,7 @@
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -162,6 +163,31 @@
   return AbsolutePath.str();
 }
 
+void addTargetAndModeForProgramName(std::vector &CommandLine,
+StringRef InvokedAs) {
+  if (!CommandLine.empty() && !InvokedAs.empty()) {
+bool AlreadyHasTarget = false;
+bool AlreadyHasMode = false;
+// Skip CommandLine[0].
+for (auto Token = ++CommandLine.begin(); Token != CommandLine.end();
+ ++Token) {
+  StringRef TokenRef(*Token);
+  AlreadyHasTarget |=
+  (TokenRef == "-target" || TokenRef.star

Re: [PATCH] D13318: Add a utility function to add target information to a command line

2015-10-05 Thread Luke Zarko via cfe-commits
zarko added a comment.

I'd tested with the Makefile; it looks like CMakeLists for the unit tests isn't 
linking `${LLVM_TARGETS_TO_BUILD}`. I've updated the diff.


http://reviews.llvm.org/D13318



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


Re: [PATCH] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-05 Thread Chris Bieneman via cfe-commits
beanz added a comment.

I will send updated patches shortly.

Comments inline below.



Comment at: runtime/CMakeLists.txt:33
@@ -32,1 +32,3 @@
+  )
+set(cmake_3_4_USES_TERMINAL USES_TERMINAL 1)
   endif()

samsonov wrote:
> Should this also be named cmake_3_4_USES_TERMINAL_OPTIONS?
This was used in an earlier iteration to pass USES_TERMINAL into a call to 
`ExternalProject_Add_Step` I will remove it.


Comment at: runtime/CMakeLists.txt:40
@@ +39,3 @@
+  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-stamps/)
+  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-bins/)
+

samsonov wrote:
> This one is later re-defined from ExternalProject_Get_Property. Does it 
> provide the same value there?
Yep, it can be removed.


Comment at: runtime/CMakeLists.txt:42
@@ +41,3 @@
+
+  add_custom_target(compiler-rt-clear
+DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared

samsonov wrote:
> Where do you use this target?
That is a convenience target for clearing out the compiler-rt directory. It 
isn't strictly needed, but I have found it (and the bootstrap-clear) to be 
useful.

Particularly as I've been changing which files are generated by the compiler-rt 
build and where they end up it is nice to be able to nuke the build directory.


Comment at: runtime/CMakeLists.txt:47
@@ +46,3 @@
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared
+DEPENDS clang llvm-config
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}

samsonov wrote:
> Why do you need these deps?
Specifying those deps makes it so that if llvm-config or clang change 
compiler-rt gets cleaned out and rebuilt.


Comment at: runtime/CMakeLists.txt:71
@@ -49,2 +70,3 @@
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build

samsonov wrote:
> Why did you remove -DCOMPILER_RT_ENABLE_WERROR=ON? I think it's fine to keep 
> it enabled, as it's ok to ensure that ToT Clang builds ToT compiler-rt with 
> no warnings.
I'm trying to set the minimal set of options required to make compiler-rt 
build. Any additional options can be passed in via 
`CLANG_COMPILER_RT_CMAKE_ARGS`.

I think that if we expect `COMPILER_RT_ENABLE_WERROR` to be the way everyone is 
building, we should make that the default in compiler-rt, not pass it in here.


http://reviews.llvm.org/D13399



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


r249328 - Undo the unique_ptr'fication of CodeGenABITypes::CGM introduced in r248762.

2015-10-05 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Oct  5 12:41:16 2015
New Revision: 249328

URL: http://llvm.org/viewvc/llvm-project?rev=249328&view=rev
Log:
Undo the unique_ptr'fication of CodeGenABITypes::CGM introduced in r248762.
include/clang/CodeGenABITypes.h is in meant to be included by external
users, but using a unique_ptr on the private CodeGenModule introduces a
dependency on the type definition that prevents such a use.

NFC

Modified:
cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp

Modified: cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h?rev=249328&r1=249327&r2=249328&view=diff
==
--- cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h (original)
+++ cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h Mon Oct  5 12:41:16 2015
@@ -52,6 +52,7 @@ class CodeGenABITypes
 public:
   CodeGenABITypes(ASTContext &C, llvm::Module &M,
   CoverageSourceInfo *CoverageInfo = nullptr);
+  ~CodeGenABITypes();
 
   /// These methods all forward to methods in the private implementation class
   /// CodeGenTypes.
@@ -79,7 +80,7 @@ private:
   std::unique_ptr PPO;
 
   /// The CodeGenModule we use get to the CodeGenTypes object.
-  std::unique_ptr CGM;
+  CodeGen::CodeGenModule *CGM;
 };
 
 }  // end namespace CodeGen

Modified: cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp?rev=249328&r1=249327&r2=249328&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenABITypes.cpp Mon Oct  5 12:41:16 2015
@@ -33,6 +33,11 @@ CodeGenABITypes::CodeGenABITypes(ASTCont
   CGM(new CodeGen::CodeGenModule(C, *HSO, *PPO, *CGO, M, 
C.getDiagnostics(),
  CoverageInfo)) {}
 
+CodeGenABITypes::~CodeGenABITypes()
+{
+  delete CGM;
+}
+
 const CGFunctionInfo &
 CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
  QualType receiverType) {


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


Re: [PATCH] D13399: [CMake] Bug 14109 - CMake build for compiler-rt should use just-built clang

2015-10-05 Thread Alexey Samsonov via cfe-commits
samsonov added inline comments.


Comment at: runtime/CMakeLists.txt:33
@@ -32,1 +32,3 @@
+  )
+set(cmake_3_4_USES_TERMINAL USES_TERMINAL 1)
   endif()

Should this also be named cmake_3_4_USES_TERMINAL_OPTIONS?


Comment at: runtime/CMakeLists.txt:40
@@ +39,3 @@
+  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-stamps/)
+  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-bins/)
+

This one is later re-defined from ExternalProject_Get_Property. Does it provide 
the same value there?


Comment at: runtime/CMakeLists.txt:42
@@ +41,3 @@
+
+  add_custom_target(compiler-rt-clear
+DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared

Where do you use this target?


Comment at: runtime/CMakeLists.txt:47
@@ +46,3 @@
+OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-cleared
+DEPENDS clang llvm-config
+COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}

Why do you need these deps?


Comment at: runtime/CMakeLists.txt:71
@@ -49,2 +70,3 @@
+   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build

Why did you remove -DCOMPILER_RT_ENABLE_WERROR=ON? I think it's fine to keep it 
enabled, as it's ok to ensure that ToT Clang builds ToT compiler-rt with no 
warnings.


http://reviews.llvm.org/D13399



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


[libcxx] r249325 - Implement LWG#2063, and update the issues links to point to the github generated pages

2015-10-05 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Oct  5 11:17:34 2015
New Revision: 249325

URL: http://llvm.org/viewvc/llvm-project?rev=249325&view=rev
Log:
Implement LWG#2063, and update the issues links to point to the github 
generated pages

Modified:
libcxx/trunk/include/string

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
libcxx/trunk/www/cxx1y_status.html
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=249325&r1=249324&r2=249325&view=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Mon Oct  5 11:17:34 2015
@@ -1509,6 +1509,7 @@ public:
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 _LIBCPP_INLINE_VISIBILITY
 basic_string& assign(basic_string&& str)
+_NOEXCEPT_((__noexcept_move_assign_container<_Allocator, 
__alloc_traits>::value))
 {*this = _VSTD::move(str); return *this;}
 #endif
 basic_string& assign(const basic_string& __str, size_type __pos, size_type 
__n=npos);

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp?rev=249325&r1=249324&r2=249325&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
 Mon Oct  5 11:17:34 2015
@@ -76,4 +76,10 @@ int main()
  S("12345678901234567890"));
 }
 #endif
+#if __cplusplus > 201402L
+{
+typedef std::string S;
+static_assert(noexcept(S().assign(S())), "");  // LWG#2063
+}
+#endif
 }

Modified: libcxx/trunk/www/cxx1y_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1y_status.html?rev=249325&r1=249324&r2=249325&view=diff
==
--- libcxx/trunk/www/cxx1y_status.html (original)
+++ libcxx/trunk/www/cxx1y_status.html Mon Oct  5 11:17:34 2015
@@ -109,165 +109,165 @@
 
   
Issue #Issue 
NameMeetingStatus
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#1214";>1214Insufficient/inconsistent
 key immutability requirements for associative 
containersKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2009";>2009Reporting
 out-of-bound values on numeric string 
conversionsKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2010";>2010is_*
 traits for binding operations can't be meaningfully 
specializedKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2015";>2015Incorrect
 pre-conditions for some type traitsKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2021";>2021Further
 incorrect usages of result_ofKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2028";>2028messages_base::catalog
 overspecifiedKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2033";>2033Preconditions
 of reserve, shrink_to_fit, and resize 
functionsKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2039";>2039Issues
 with std::reverse and std::copy_ifKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2044";>2044No
 definition of "Stable" for copy 
algorithmsKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2045";>2045forward_list::merge
 and forward_list::splice_after with unequal 
allocatorsKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2047";>2047Incorrect
 "mixed" move-assignment semantics of 
unique_ptrKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2050";>2050Unordered
 associative containers do not use allocator_traits to define member 
typesKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2053";>2053Errors
 in regex bitmask typesKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2061";>2061make_move_iterator
 and arraysKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2064";>2064More
 noexcept issues in basic_stringKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2065";>2065Minimal
 allocator interfaceKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2067";>2067packaged_task
 should have deleted copy c'tor with const 
parameterKonaComplete
-   http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#2069";>2069Inconsistent
 exception spec for basic_st

Re: [PATCH] D13311: [clang-tidy] Add check cppcoreguidelines-pro-bounds-pointer-arithmetic

2015-10-05 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp:35
@@ +34,3 @@
+
+  //Array subscript on a pointer (not an array) is also pointer arithmetic
+  Finder->addMatcher(

Space after //


Comment at: 
test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp:68
@@ +67,3 @@
+  int a[3];
+  i = a[2]; //OK, access to array
+

Space after //


http://reviews.llvm.org/D13311



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


Re: r249157 - Module debugging: Don't emit forward declarations in module scopes.

2015-10-05 Thread Adrian Prantl via cfe-commits

> On Oct 2, 2015, at 3:24 PM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Oct 2, 2015 at 3:21 PM, Adrian Prantl  > wrote:
> 
>> On Oct 2, 2015, at 3:01 PM, David Blaikie > > wrote:
>> 
>> 
>> 
>> On Fri, Oct 2, 2015 at 3:00 PM, Adrian Prantl > > wrote:
>> 
>>> On Oct 2, 2015, at 2:58 PM, David Blaikie >> > wrote:
>>> 
>>> 
>>> 
>>> On Fri, Oct 2, 2015 at 2:40 PM, Adrian Prantl >> > wrote:
>>> 
 On Oct 2, 2015, at 2:18 PM, David Blaikie >>> > wrote:
 
 This seems a little curious, so you'll have code like this:
 
   decl foo
   module
 def bar
member foo pointer (references the declaration of foo outside the 
 module, in the CU?)
 
>>> 
>>> Right.
>>> 
 Why is that preferable to DWARF that looks more like the AST where the 
 declaration of foo appears in the first module that references it, rather 
 than, in a curiously circular situation, in the CU that references the 
 module?
>>> 
>>> The problem I had with this was that a forward declaration would end up in 
>>> a DeclContext that is not the DeclContext of the definition. Looking at 
>>> this through the dsymutil goggles, the different DeclContexts effectively 
>>> prevent the forward declaration from being uniqued with the type's 
>>> definition.
>>> 
>>> Putting it in the CU doesn't seem to make the decl context match either, 
>>> does it? In that case the decl context may still be "some other compile 
>>> unit" (as with most declarations)
>>> 
>>> Shouldn't dsymutil be treating modules more like CUs as "another top level 
>>> scope”?
>> 
>> The CU is not part of the DeclContext (for dsymutil’s interpretation of a 
>> DeclContext). Otherwise cross-CU type uniquing would never work.
>> 
>> perhaps the module shouldn't be either, then?
> 
> The module has to be, for correctness. (None of this applies to C++. 
> Oversimplified: because of the ODR we can omit the parent DW_TAG_module from 
> all CXXRecordDecls).
> For C and ObjC it is perfectly legal to have two modules with conflicting 
> definitions for a type, so we need the DW_TAG_module as part of the 
> DeclContext to differentiate them if we want to be able to resolve forward 
> declarations to the correct definition.
> 
> But you have to do the same thing for the things in the CU as well, right? So 
> you can't ignore the CU in the same way you can't ignore the module, yes?

You’ve got a point there. In a non-ODR language, you still wouldn’t be allowed 
to resolve a forward declaration to a specific type.
The one thing that I don’t like about emitting “real" forward declarations into 
the DW_TAG_module is that they are indistinguishable from the forward 
declarations that are emitted for external type references, for which there is 
an actual definition in the module itself. This is more of an aesthetic problem 
than a technical one, but it does make dsymutils job of resolving type 
references in a single pass a little harder since dsymutil can no longer assume 
that all forward declarations in a non-defining TAG_module can be resolved.

-- adrian

>  
> 
> -- adrian
> 
>>  
>> 
>> -- adrian
>> 
>>>  
>>> 
>>> -- adrian
>>> 
 On Fri, Oct 2, 2015 at 10:36 AM, Adrian Prantl via cfe-commits 
 mailto:cfe-commits@lists.llvm.org>> wrote:
 Author: adrian
 Date: Fri Oct  2 12:36:14 2015
 New Revision: 249157
 
 URL: http://llvm.org/viewvc/llvm-project?rev=249157&view=rev 
 
 Log:
 Module debugging: Don't emit forward declarations in module scopes.
 A forward declaration inside a module header does not belong to the module.
 
 Modified:
 cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
 cfe/trunk/test/Modules/Inputs/DebugObjC.h
 cfe/trunk/test/Modules/ModuleDebugInfo.m
 
 Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=249157&r1=249156&r2=249157&view=diff
  
 
 ==
 --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Oct  2 12:36:14 2015
 @@ -2172,6 +2172,9 @@ ObjCInterfaceDecl *CGDebugInfo::getObjCI
  }
 
  llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) {
 +  // A forward declaration inside a module header does not belong to the 
 module.
 +  if (isa(D) && !cast(D)->getDefinition())
 +return nullptr;
if (DebugTypeExtRefs && D->isFromASTFile()) {
  // Record a reference to an imported clang module or precompiled 
 header.
  auto *

Re: [PATCH] D13221: Make CompilerInvocation's use of the debug options more understandable.

2015-10-05 Thread Adrian Prantl via cfe-commits
aprantl added a comment.

Some bikeshedding about -di-kind={full|limited|line-tables}:

1. Is there a good reason not to spell out -debug-info-kind?
2. "full" is misleading as it will still only emit debug info for types 
actually used by the program. I think "standalone" would be more descriptive.
3. Why not "line-tables-only" like in -gline-tables-only?


http://reviews.llvm.org/D13221



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


Re: r249316 - [VFS] Add working directories to every virtual file system.

2015-10-05 Thread Diego Novillo via cfe-commits
Never mind.  My llvm and clang trees were out of sync.


Diego.

On Mon, Oct 5, 2015 at 11:15 AM, Diego Novillo  wrote:

>
>
> On Mon, Oct 5, 2015 at 9:55 AM, Benjamin Kramer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: d0k
>> Date: Mon Oct  5 08:55:20 2015
>> New Revision: 249316
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=249316&view=rev
>> Log:
>> [VFS] Add working directories to every virtual file system.
>>
>> For RealFileSystem this is getcwd()/chdir(), the synthetic file systems
>> can
>> make up one for themselves. OverlayFileSystem now synchronizes the working
>> directories when a new FS is added to the overlay or the overlay working
>> directory is set. This allows purely artificial file systems that have
>> zero
>> ties to the underlying disks.
>>
>> Differential Revision: http://reviews.llvm.org/D13430
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/VirtualFileSystem.h
>> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
>> cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=249316&r1=249315&r2=249316&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
>> +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Oct  5 08:55:20
>> 2015
>> @@ -199,6 +199,25 @@ public:
>>/// \note The 'end' iterator is directory_iterator().
>>virtual directory_iterator dir_begin(const Twine &Dir,
>> std::error_code &EC) = 0;
>> +
>> +  /// Set the working directory. This will affect all following
>> operations on
>> +  /// this file system and may propagate down for nested file systems.
>> +  virtual std::error_code setCurrentWorkingDirectory(const Twine &Path)
>> = 0;
>> +  /// Get the working directory of this file system.
>> +  virtual llvm::ErrorOr getCurrentWorkingDirectory() const
>> = 0;
>> +
>> +  /// Make \a Path an absolute path.
>> +  ///
>> +  /// Makes \a Path absolute using the current directory if it is not
>> already.
>> +  /// An empty \a Path will result in the current directory.
>> +  ///
>> +  /// /absolute/path   => /absolute/path
>> +  /// relative/../path => /relative/../path
>> +  ///
>> +  /// \param Path A path that is modified to be an absolute path.
>> +  /// \returns success if \a path has been made absolute, otherwise a
>> +  ///  platform-specific error_code.
>> +  std::error_code makeAbsolute(SmallVectorImpl &Path) const;
>>  };
>>
>>  /// \brief Gets an \p vfs::FileSystem for the 'real' file system, as
>> seen by
>> @@ -230,6 +249,8 @@ public:
>>llvm::ErrorOr>
>>openFileForRead(const Twine &Path) override;
>>directory_iterator dir_begin(const Twine &Dir, std::error_code &EC)
>> override;
>> +  llvm::ErrorOr getCurrentWorkingDirectory() const override;
>> +  std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
>>
>>typedef FileSystemList::reverse_iterator iterator;
>>
>> @@ -248,6 +269,7 @@ class InMemoryDirectory;
>>  /// An in-memory file system.
>>  class InMemoryFileSystem : public FileSystem {
>>std::unique_ptr Root;
>> +  std::string WorkingDirectory;
>>
>>  public:
>>InMemoryFileSystem();
>> @@ -260,6 +282,13 @@ public:
>>llvm::ErrorOr>
>>openFileForRead(const Twine &Path) override;
>>directory_iterator dir_begin(const Twine &Dir, std::error_code &EC)
>> override;
>> +  llvm::ErrorOr getCurrentWorkingDirectory() const override
>> {
>> +return WorkingDirectory;
>> +  }
>> +  std::error_code setCurrentWorkingDirectory(const Twine &Path) override
>> {
>> +WorkingDirectory = Path.str();
>> +return std::error_code();
>> +  }
>>  };
>>
>>  /// \brief Get a globally unique ID for a virtual file or directory.
>>
>> Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249316&r1=249315&r2=249316&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
>> +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 08:55:20 2015
>> @@ -89,6 +89,14 @@ FileSystem::getBufferForFile(const llvm:
>>return (*F)->getBuffer(Name, FileSize, RequiresNullTerminator,
>> IsVolatile);
>>  }
>>
>> +std::error_code FileSystem::makeAbsolute(SmallVectorImpl &Path)
>> const {
>> +  auto WorkingDir = getCurrentWorkingDirectory();
>> +  if (!WorkingDir)
>> +return WorkingDir.getError();
>> +
>> +  return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
>> +}
>>
>
> Ben,
>
> This is causing:
>
> tools/clang/lib/Basic/VirtualFileSystem.cpp:105:57: error: too many
> arguments to function call, expected single argument 'path', have 2
> arguments
>   return llvm::sys::fs::make_absolute(Wo

Re: r249316 - [VFS] Add working directories to every virtual file system.

2015-10-05 Thread Diego Novillo via cfe-commits
On Mon, Oct 5, 2015 at 9:55 AM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Mon Oct  5 08:55:20 2015
> New Revision: 249316
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249316&view=rev
> Log:
> [VFS] Add working directories to every virtual file system.
>
> For RealFileSystem this is getcwd()/chdir(), the synthetic file systems can
> make up one for themselves. OverlayFileSystem now synchronizes the working
> directories when a new FS is added to the overlay or the overlay working
> directory is set. This allows purely artificial file systems that have zero
> ties to the underlying disks.
>
> Differential Revision: http://reviews.llvm.org/D13430
>
> Modified:
> cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
>
> Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=249316&r1=249315&r2=249316&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
> +++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Oct  5 08:55:20
> 2015
> @@ -199,6 +199,25 @@ public:
>/// \note The 'end' iterator is directory_iterator().
>virtual directory_iterator dir_begin(const Twine &Dir,
> std::error_code &EC) = 0;
> +
> +  /// Set the working directory. This will affect all following
> operations on
> +  /// this file system and may propagate down for nested file systems.
> +  virtual std::error_code setCurrentWorkingDirectory(const Twine &Path) =
> 0;
> +  /// Get the working directory of this file system.
> +  virtual llvm::ErrorOr getCurrentWorkingDirectory() const =
> 0;
> +
> +  /// Make \a Path an absolute path.
> +  ///
> +  /// Makes \a Path absolute using the current directory if it is not
> already.
> +  /// An empty \a Path will result in the current directory.
> +  ///
> +  /// /absolute/path   => /absolute/path
> +  /// relative/../path => /relative/../path
> +  ///
> +  /// \param Path A path that is modified to be an absolute path.
> +  /// \returns success if \a path has been made absolute, otherwise a
> +  ///  platform-specific error_code.
> +  std::error_code makeAbsolute(SmallVectorImpl &Path) const;
>  };
>
>  /// \brief Gets an \p vfs::FileSystem for the 'real' file system, as seen
> by
> @@ -230,6 +249,8 @@ public:
>llvm::ErrorOr>
>openFileForRead(const Twine &Path) override;
>directory_iterator dir_begin(const Twine &Dir, std::error_code &EC)
> override;
> +  llvm::ErrorOr getCurrentWorkingDirectory() const override;
> +  std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
>
>typedef FileSystemList::reverse_iterator iterator;
>
> @@ -248,6 +269,7 @@ class InMemoryDirectory;
>  /// An in-memory file system.
>  class InMemoryFileSystem : public FileSystem {
>std::unique_ptr Root;
> +  std::string WorkingDirectory;
>
>  public:
>InMemoryFileSystem();
> @@ -260,6 +282,13 @@ public:
>llvm::ErrorOr>
>openFileForRead(const Twine &Path) override;
>directory_iterator dir_begin(const Twine &Dir, std::error_code &EC)
> override;
> +  llvm::ErrorOr getCurrentWorkingDirectory() const override {
> +return WorkingDirectory;
> +  }
> +  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
> +WorkingDirectory = Path.str();
> +return std::error_code();
> +  }
>  };
>
>  /// \brief Get a globally unique ID for a virtual file or directory.
>
> Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249316&r1=249315&r2=249316&view=diff
>
> ==
> --- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
> +++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 08:55:20 2015
> @@ -89,6 +89,14 @@ FileSystem::getBufferForFile(const llvm:
>return (*F)->getBuffer(Name, FileSize, RequiresNullTerminator,
> IsVolatile);
>  }
>
> +std::error_code FileSystem::makeAbsolute(SmallVectorImpl &Path)
> const {
> +  auto WorkingDir = getCurrentWorkingDirectory();
> +  if (!WorkingDir)
> +return WorkingDir.getError();
> +
> +  return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
> +}
>

Ben,

This is causing:

tools/clang/lib/Basic/VirtualFileSystem.cpp:105:57: error: too many
arguments to function call, expected single argument 'path', have 2
arguments
  return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
    ^~~~
[...]/llvm/llvm/include/llvm/Support/FileSystem.h:280:1: note:
'make_absolute' declared here
std::error_code make_absolute(SmallVectorImpl &path);
^
1 error generated.

Not sure which of t

Re: r249321 - Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests and documentation.

2015-10-05 Thread mats petersson via cfe-commits
On 5 October 2015 at 15:51, Aaron Ballman  wrote:

> On Mon, Oct 5, 2015 at 10:49 AM, mats petersson 
> wrote:
> >
> >
> > On 5 October 2015 at 15:41, Aaron Ballman via cfe-commits
> >  wrote:
> >>
> >> Author: aaronballman
> >> Date: Mon Oct  5 09:41:27 2015
> >> New Revision: 249321
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=249321&view=rev
> >> Log:
> >> Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus
> tests
> >> and documentation.
> >>
> >> Modified:
> >> cfe/trunk/docs/LibASTMatchersReference.html
> >> cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> >> cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> >> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> >> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
> >>
> >> Modified: cfe/trunk/docs/LibASTMatchersReference.html
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=249321&r1=249320&r2=249321&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/docs/LibASTMatchersReference.html (original)
> >> +++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct  5 09:41:27 2015
> >> @@ -2210,6 +2210,18 @@ Usable as: Matcher >>  
> >>
> >>
> >> +Matcher< >> href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
> ">FunctionDecl> >> class="name" onclick="toggle('isVariadic0')"> >> name="isVariadic0Anchor">isVariadic
> >> +Matches if a
> >> function declaration is variadic.
> >> +
> >> +Example matches f, but not g or h. The function i will not match, event
> >> when
> >> +compiled in C mode.
> >> +  void f(...);
> >> +  void g(int);
> >> +  template  void h(Ts...);
> >> +  void i();
> >> +
> >> +
> >> +
> >>  Matcher< >> href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
> ">FunctionDecl> >> class="name" onclick="toggle('parameterCountIs0')"> >> name="parameterCountIs0Anchor">parameterCountIsunsigned
> >> N
> >>  Matches
> >> FunctionDecls that have a specific parameter count.
> >>
> >>
> >> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=249321&r1=249320&r2=249321&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
> >> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Oct  5
> 09:41:27
> >> 2015
> >> @@ -3255,6 +3255,20 @@ AST_POLYMORPHIC_MATCHER(isDefinition,
> >>return Node.isThisDeclarationADefinition();
> >>  }
> >>
> >> +/// \brief Matches if a function declaration is variadic.
> >> +///
> >> +/// Example matches f, but not g or h. The function i will not match,
> >> even when
> >> +/// compiled in C mode.
> >> +/// \code
> >> +///   void f(...);
> >> +///   void g(int);
> >> +///   template  void h(Ts...);
> >> +///   void i();
> >> +/// \endcode
> >> +AST_MATCHER(FunctionDecl, isVariadic) {
> >> +  return Node.isVariadic();
> >> +}
> >> +
> >>  /// \brief Matches the class declaration that the given method
> >> declaration
> >>  /// belongs to.
> >>  ///
> >>
> >> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=249321&r1=249320&r2=249321&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
> >> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Oct  5 09:41:27
> >> 2015
> >> @@ -291,6 +291,7 @@ RegistryMaps::RegistryMaps() {
> >>REGISTER_MATCHER(isStruct);
> >>REGISTER_MATCHER(isTemplateInstantiation);
> >>REGISTER_MATCHER(isUnion);
> >> +  REGISTER_MATCHER(isVariadic);
> >>REGISTER_MATCHER(isVirtual);
> >>REGISTER_MATCHER(isWritten);
> >>REGISTER_MATCHER(labelStmt);
> >>
> >> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=249321&r1=249320&r2=249321&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
> >> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Oct  5
> >> 09:41:27 2015
> >> @@ -1511,6 +1511,13 @@ TEST(Function, MatchesFunctionDeclaratio
> >>notMatches("void f(int);"
> >>   "template  struct S { void g(T t) { f(t);
> }
> >> };",
> >>   CallFunctionF));
> >> +
> >> +  EXPECT_TRUE(matches("void f(...);", functionDecl(isVariadic(;
> >> +  EXPECT_TRUE(notMatches("void f(int);", functionDecl(isVariadic(;
> >
> > Am I missing something - surely this should be EXPECT_FALSE?
>
> EXPECT_TRUE is correct -- the test is using notMat

Re: r249321 - Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests and documentation.

2015-10-05 Thread Aaron Ballman via cfe-commits
On Mon, Oct 5, 2015 at 10:49 AM, mats petersson  wrote:
>
>
> On 5 October 2015 at 15:41, Aaron Ballman via cfe-commits
>  wrote:
>>
>> Author: aaronballman
>> Date: Mon Oct  5 09:41:27 2015
>> New Revision: 249321
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=249321&view=rev
>> Log:
>> Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests
>> and documentation.
>>
>> Modified:
>> cfe/trunk/docs/LibASTMatchersReference.html
>> cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
>> cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
>> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
>> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
>>
>> Modified: cfe/trunk/docs/LibASTMatchersReference.html
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=249321&r1=249320&r2=249321&view=diff
>>
>> ==
>> --- cfe/trunk/docs/LibASTMatchersReference.html (original)
>> +++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct  5 09:41:27 2015
>> @@ -2210,6 +2210,18 @@ Usable as: Matcher>  
>>
>>
>> +Matcher<> href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html";>FunctionDecl>> class="name" onclick="toggle('isVariadic0')">> name="isVariadic0Anchor">isVariadic
>> +Matches if a
>> function declaration is variadic.
>> +
>> +Example matches f, but not g or h. The function i will not match, event
>> when
>> +compiled in C mode.
>> +  void f(...);
>> +  void g(int);
>> +  template  void h(Ts...);
>> +  void i();
>> +
>> +
>> +
>>  Matcher<> href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html";>FunctionDecl>> class="name" onclick="toggle('parameterCountIs0')">> name="parameterCountIs0Anchor">parameterCountIsunsigned
>> N
>>  Matches
>> FunctionDecls that have a specific parameter count.
>>
>>
>> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=249321&r1=249320&r2=249321&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
>> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Oct  5 09:41:27
>> 2015
>> @@ -3255,6 +3255,20 @@ AST_POLYMORPHIC_MATCHER(isDefinition,
>>return Node.isThisDeclarationADefinition();
>>  }
>>
>> +/// \brief Matches if a function declaration is variadic.
>> +///
>> +/// Example matches f, but not g or h. The function i will not match,
>> even when
>> +/// compiled in C mode.
>> +/// \code
>> +///   void f(...);
>> +///   void g(int);
>> +///   template  void h(Ts...);
>> +///   void i();
>> +/// \endcode
>> +AST_MATCHER(FunctionDecl, isVariadic) {
>> +  return Node.isVariadic();
>> +}
>> +
>>  /// \brief Matches the class declaration that the given method
>> declaration
>>  /// belongs to.
>>  ///
>>
>> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=249321&r1=249320&r2=249321&view=diff
>>
>> ==
>> --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
>> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Oct  5 09:41:27
>> 2015
>> @@ -291,6 +291,7 @@ RegistryMaps::RegistryMaps() {
>>REGISTER_MATCHER(isStruct);
>>REGISTER_MATCHER(isTemplateInstantiation);
>>REGISTER_MATCHER(isUnion);
>> +  REGISTER_MATCHER(isVariadic);
>>REGISTER_MATCHER(isVirtual);
>>REGISTER_MATCHER(isWritten);
>>REGISTER_MATCHER(labelStmt);
>>
>> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=249321&r1=249320&r2=249321&view=diff
>>
>> ==
>> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
>> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Oct  5
>> 09:41:27 2015
>> @@ -1511,6 +1511,13 @@ TEST(Function, MatchesFunctionDeclaratio
>>notMatches("void f(int);"
>>   "template  struct S { void g(T t) { f(t); }
>> };",
>>   CallFunctionF));
>> +
>> +  EXPECT_TRUE(matches("void f(...);", functionDecl(isVariadic(;
>> +  EXPECT_TRUE(notMatches("void f(int);", functionDecl(isVariadic(;
>
> Am I missing something - surely this should be EXPECT_FALSE?

EXPECT_TRUE is correct -- the test is using notMatches() instead of matches().

~Aaron

>
> --
> Mats
>>
>> +  EXPECT_TRUE(notMatches("template  void f(Ts...);",
>> + functionDecl(isVariadic(;
>> +  EXPECT_TRUE(notMatches("void f();", functionDecl(isVariadic(;
>> +  EXPECT_TRUE(notMatchesC("void f();", functionDecl(isVariadic(;
>>  }
>>
>>  TEST(

Re: r249321 - Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests and documentation.

2015-10-05 Thread mats petersson via cfe-commits
On 5 October 2015 at 15:41, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: aaronballman
> Date: Mon Oct  5 09:41:27 2015
> New Revision: 249321
>
> URL: http://llvm.org/viewvc/llvm-project?rev=249321&view=rev
> Log:
> Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests
> and documentation.
>
> Modified:
> cfe/trunk/docs/LibASTMatchersReference.html
> cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
>
> Modified: cfe/trunk/docs/LibASTMatchersReference.html
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=249321&r1=249320&r2=249321&view=diff
>
> ==
> --- cfe/trunk/docs/LibASTMatchersReference.html (original)
> +++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct  5 09:41:27 2015
> @@ -2210,6 +2210,18 @@ Usable as: Matcher  
>
>
> +MatcherFunctionDecl> class="name" onclick="toggle('isVariadic0')"> name="isVariadic0Anchor">isVariadic
> +Matches if a
> function declaration is variadic.
> +
> +Example matches f, but not g or h. The function i will not match, event
> when
> +compiled in C mode.
> +  void f(...);
> +  void g(int);
> +  template  void h(Ts...);
> +  void i();
> +
> +
> +
>  MatcherFunctionDecl> class="name" onclick="toggle('parameterCountIs0')"> name="parameterCountIs0Anchor">parameterCountIsunsigned
> N
>  Matches
> FunctionDecls that have a specific parameter count.
>
>
> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=249321&r1=249320&r2=249321&view=diff
>
> ==
> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Oct  5 09:41:27
> 2015
> @@ -3255,6 +3255,20 @@ AST_POLYMORPHIC_MATCHER(isDefinition,
>return Node.isThisDeclarationADefinition();
>  }
>
> +/// \brief Matches if a function declaration is variadic.
> +///
> +/// Example matches f, but not g or h. The function i will not match,
> even when
> +/// compiled in C mode.
> +/// \code
> +///   void f(...);
> +///   void g(int);
> +///   template  void h(Ts...);
> +///   void i();
> +/// \endcode
> +AST_MATCHER(FunctionDecl, isVariadic) {
> +  return Node.isVariadic();
> +}
> +
>  /// \brief Matches the class declaration that the given method declaration
>  /// belongs to.
>  ///
>
> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=249321&r1=249320&r2=249321&view=diff
>
> ==
> --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Oct  5 09:41:27 2015
> @@ -291,6 +291,7 @@ RegistryMaps::RegistryMaps() {
>REGISTER_MATCHER(isStruct);
>REGISTER_MATCHER(isTemplateInstantiation);
>REGISTER_MATCHER(isUnion);
> +  REGISTER_MATCHER(isVariadic);
>REGISTER_MATCHER(isVirtual);
>REGISTER_MATCHER(isWritten);
>REGISTER_MATCHER(labelStmt);
>
> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=249321&r1=249320&r2=249321&view=diff
>
> ==
> --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
> +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Oct  5
> 09:41:27 2015
> @@ -1511,6 +1511,13 @@ TEST(Function, MatchesFunctionDeclaratio
>notMatches("void f(int);"
>   "template  struct S { void g(T t) { f(t); }
> };",
>   CallFunctionF));
> +
> +  EXPECT_TRUE(matches("void f(...);", functionDecl(isVariadic(;
> +  EXPECT_TRUE(notMatches("void f(int);", functionDecl(isVariadic(;
>
Am I missing something - surely this should be EXPECT_FALSE?

--
Mats

> +  EXPECT_TRUE(notMatches("template  void f(Ts...);",
> + functionDecl(isVariadic(;
> +  EXPECT_TRUE(notMatches("void f();", functionDecl(isVariadic(;
> +  EXPECT_TRUE(notMatchesC("void f();", functionDecl(isVariadic(;
>  }
>
>  TEST(FunctionTemplate, MatchesFunctionTemplateDeclarations) {
>
> Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h?rev=249321&r1=249320&r2=249321&view=diff
>
> =

r249321 - Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests and documentation.

2015-10-05 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Mon Oct  5 09:41:27 2015
New Revision: 249321

URL: http://llvm.org/viewvc/llvm-project?rev=249321&view=rev
Log:
Adding a narrowing AST matcher for FunctionDecl::isVariadic(), plus tests and 
documentation.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=249321&r1=249320&r2=249321&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Oct  5 09:41:27 2015
@@ -2210,6 +2210,18 @@ Usable as: MatcherFunctionDecl>isVariadic
+Matches if a function 
declaration is variadic.
+
+Example matches f, but not g or h. The function i will not match, event when
+compiled in C mode.
+  void f(...);
+  void g(int);
+  template  void h(Ts...);
+  void i();
+
+
+
 MatcherFunctionDecl>parameterCountIsunsigned N
 Matches 
FunctionDecls that have a specific parameter count.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=249321&r1=249320&r2=249321&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Oct  5 09:41:27 2015
@@ -3255,6 +3255,20 @@ AST_POLYMORPHIC_MATCHER(isDefinition,
   return Node.isThisDeclarationADefinition();
 }
 
+/// \brief Matches if a function declaration is variadic.
+///
+/// Example matches f, but not g or h. The function i will not match, even when
+/// compiled in C mode.
+/// \code
+///   void f(...);
+///   void g(int);
+///   template  void h(Ts...);
+///   void i();
+/// \endcode
+AST_MATCHER(FunctionDecl, isVariadic) {
+  return Node.isVariadic();
+}
+
 /// \brief Matches the class declaration that the given method declaration
 /// belongs to.
 ///

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=249321&r1=249320&r2=249321&view=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Mon Oct  5 09:41:27 2015
@@ -291,6 +291,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(isStruct);
   REGISTER_MATCHER(isTemplateInstantiation);
   REGISTER_MATCHER(isUnion);
+  REGISTER_MATCHER(isVariadic);
   REGISTER_MATCHER(isVirtual);
   REGISTER_MATCHER(isWritten);
   REGISTER_MATCHER(labelStmt);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=249321&r1=249320&r2=249321&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Mon Oct  5 09:41:27 2015
@@ -1511,6 +1511,13 @@ TEST(Function, MatchesFunctionDeclaratio
   notMatches("void f(int);"
  "template  struct S { void g(T t) { f(t); } };",
  CallFunctionF));
+
+  EXPECT_TRUE(matches("void f(...);", functionDecl(isVariadic(;
+  EXPECT_TRUE(notMatches("void f(int);", functionDecl(isVariadic(;
+  EXPECT_TRUE(notMatches("template  void f(Ts...);",
+ functionDecl(isVariadic(;
+  EXPECT_TRUE(notMatches("void f();", functionDecl(isVariadic(;
+  EXPECT_TRUE(notMatchesC("void f();", functionDecl(isVariadic(;
 }
 
 TEST(FunctionTemplate, MatchesFunctionTemplateDeclarations) {

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h?rev=249321&r1=249320&r2=249321&view=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h Mon Oct  5 09:41:27 2015
@@ -126,6 +126,13 @@ testing::AssertionResult matchesC(const
 }
 
 template 
+testing::AssertionResult notMatchesC(const std::string &Code,
+ const T &AMatcher) {
+  return matchesConditionally(Code, AMatcher, false, "", FileContentMappings(),
+  "input.c");
+}
+
+template 
 

Re: [PATCH] D13368: [clang-tidy] add check cppcoreguidelines-pro-type-static-cast-downcast

2015-10-05 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp:33
@@ +32,3 @@
+  const auto *SourceDecl = SourceType->getPointeeCXXRecordDecl();
+  if(!SourceDecl)
+SourceDecl = SourceType->getAsCXXRecordDecl();

In the event it's not a pointer or a reference, why are you getting the source 
as a value type?


Comment at: clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp:46
@@ +45,3 @@
+
+  if (SourceDecl->isPolymorphic()) {
+diag(MatchedCast->getOperatorLoc(), "do not use static_cast to cast from 
base class to derived class. "

You should elide the braces here and for the else statement.


Comment at: clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp:47
@@ +46,3 @@
+  if (SourceDecl->isPolymorphic()) {
+diag(MatchedCast->getOperatorLoc(), "do not use static_cast to cast from 
base class to derived class. "
+  "Use dynamic_cast instead.")

Punctuation nit -- we don't use complete sentences for diagnostics. This should 
be something like:

do not use static_cast to downcast from a base to a derived class; use 
dynamic_cast instead


Comment at: clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp:50
@@ +49,3 @@
+  << FixItHint::CreateReplacement(
+  {MatchedCast->getOperatorLoc(), MatchedCast->getOperatorLoc()},
+  "dynamic_cast");

I am pretty sure that you can create the replacement from a SourceLocation 
directly, because SourceRange has a nonexplicit constructor accepting a single 
SourceLocation.


Comment at: clang-tidy/cppcoreguidelines/ProTypeStaticCastDowncastCheck.cpp:53
@@ +52,3 @@
+  } else {
+diag(MatchedCast->getOperatorLoc(), "do not use static_cast to cast from 
base class to derived class.");
+  }

What is the alternative the user should use in this instance?


http://reviews.llvm.org/D13368



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


Re: [PATCH] D13317: clang_Cursor_getMangling shouldn't mangle if the declaration isn't mangled

2015-10-05 Thread Michael Wu via cfe-commits
michaelwu updated this revision to Diff 36518.
michaelwu added a comment.

This uses clang_isInvalid in PrintMangledName instead of checking for 
CXCursor_UnexposedDecl.


http://reviews.llvm.org/D13317

Files:
  test/Index/print-mangled-name.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3890,7 +3890,11 @@
 
   std::string FrontendBuf;
   llvm::raw_string_ostream FrontendBufOS(FrontendBuf);
-  MC->mangleName(ND, FrontendBufOS);
+  if (MC->shouldMangleDeclName(ND)) {
+MC->mangleName(ND, FrontendBufOS);
+  } else {
+ND->printName(FrontendBufOS);
+  }
 
   // Now apply backend mangling.
   std::unique_ptr DL(
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1429,6 +1429,8 @@
 
 static enum CXChildVisitResult PrintMangledName(CXCursor cursor, CXCursor p,
 CXClientData d) {
+  if (clang_isInvalid(clang_getCursorKind(cursor)))
+return CXChildVisit_Recurse;
   CXString MangledName;
   PrintCursor(cursor, NULL);
   MangledName = clang_Cursor_getMangling(cursor);
Index: test/Index/print-mangled-name.cpp
===
--- test/Index/print-mangled-name.cpp
+++ test/Index/print-mangled-name.cpp
@@ -29,3 +29,8 @@
 // ITANIUM: mangled=_Z3foo1SRS_
 // MACHO: mangled=__Z3foo1SRS_
 // MICROSOFT: mangled=?foo@@YAHUS
+
+extern "C" int foo(int);
+// ITANIUM: mangled=foo
+// MACHO: mangled=_foo
+// MICROSOFT: mangled=_foo


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3890,7 +3890,11 @@
 
   std::string FrontendBuf;
   llvm::raw_string_ostream FrontendBufOS(FrontendBuf);
-  MC->mangleName(ND, FrontendBufOS);
+  if (MC->shouldMangleDeclName(ND)) {
+MC->mangleName(ND, FrontendBufOS);
+  } else {
+ND->printName(FrontendBufOS);
+  }
 
   // Now apply backend mangling.
   std::unique_ptr DL(
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1429,6 +1429,8 @@
 
 static enum CXChildVisitResult PrintMangledName(CXCursor cursor, CXCursor p,
 CXClientData d) {
+  if (clang_isInvalid(clang_getCursorKind(cursor)))
+return CXChildVisit_Recurse;
   CXString MangledName;
   PrintCursor(cursor, NULL);
   MangledName = clang_Cursor_getMangling(cursor);
Index: test/Index/print-mangled-name.cpp
===
--- test/Index/print-mangled-name.cpp
+++ test/Index/print-mangled-name.cpp
@@ -29,3 +29,8 @@
 // ITANIUM: mangled=_Z3foo1SRS_
 // MACHO: mangled=__Z3foo1SRS_
 // MICROSOFT: mangled=?foo@@YAHUS
+
+extern "C" int foo(int);
+// ITANIUM: mangled=foo
+// MACHO: mangled=_foo
+// MICROSOFT: mangled=_foo
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13407: [libcxx] Capture configuration information when installing the libc++ headers

2015-10-05 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

Design doc looks good! I think it captures all the design constraints well, and 
the proposed solution satisfies those constraints as far as I am concerned.

Thumbs up from me... but I'll still defer the final 'LGTM' to @mclow.lists.


http://reviews.llvm.org/D13407



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


Re: [PATCH] D13317: clang_Cursor_getMangling shouldn't mangle if the declaration isn't mangled

2015-10-05 Thread Michael Wu via cfe-commits
michaelwu marked 2 inline comments as done.
michaelwu added a comment.

http://reviews.llvm.org/D13317



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


r249319 - [VFS] Fix the windows build by including the right headers.

2015-10-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct  5 09:06:36 2015
New Revision: 249319

URL: http://llvm.org/viewvc/llvm-project?rev=249319&view=rev
Log:
[VFS] Fix the windows build by including the right headers.

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249319&r1=249318&r2=249319&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 09:06:36 2015
@@ -19,9 +19,17 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/YAMLParser.h"
+#include "llvm/Config/llvm-config.h"
 #include 
 #include 
 
+// For chdir.
+#ifdef LLVM_ON_WIN32
+#  include 
+#else
+#  include 
+#endif
+
 using namespace clang;
 using namespace clang::vfs;
 using namespace llvm;


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


Re: [PATCH] D13398: [clang-tidy] add check cppcoreguidelines-pro-type-const-cast

2015-10-05 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, despite being bizarrely restrictive guidance.

~Aaron


http://reviews.llvm.org/D13398



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


r249318 - [VFS] Fix compilation on systems where time_t is not int64_t.

2015-10-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct  5 09:02:15 2015
New Revision: 249318

URL: http://llvm.org/viewvc/llvm-project?rev=249318&view=rev
Log:
[VFS] Fix compilation on systems where time_t is not int64_t.

No functional change intended.

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249318&r1=249317&r2=249318&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 09:02:15 2015
@@ -495,7 +495,7 @@ void InMemoryFileSystem::addFile(const T
 // End of the path, create a new file.
 // FIXME: expose the status details in the interface.
 Status Stat(Path, getNextVirtualUniqueID(),
-llvm::sys::TimeValue(ModificationTime), 0, 0,
+llvm::sys::TimeValue(ModificationTime, 0), 0, 0,
 Buffer->getBufferSize(),
 llvm::sys::fs::file_type::regular_file,
 llvm::sys::fs::all_all);
@@ -508,9 +508,9 @@ void InMemoryFileSystem::addFile(const T
   // FIXME: expose the status details in the interface.
   Status Stat(
   StringRef(Path.str().begin(), Name.end() - Path.str().begin()),
-  getNextVirtualUniqueID(), llvm::sys::TimeValue(ModificationTime), 0,
-  0, Buffer->getBufferSize(), llvm::sys::fs::file_type::directory_file,
-  llvm::sys::fs::all_all);
+  getNextVirtualUniqueID(), llvm::sys::TimeValue(ModificationTime, 0),
+  0, 0, Buffer->getBufferSize(),
+  llvm::sys::fs::file_type::directory_file, llvm::sys::fs::all_all);
   Dir = cast(Dir->addChild(
   Name, 
llvm::make_unique(std::move(Stat;
   continue;


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


Re: [PATCH] D13430: [VFS] Add an in-memory file system implementation.

2015-10-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249316: [VFS] Add working directories to every virtual file 
system. (authored by d0k).

Changed prior to commit:
  http://reviews.llvm.org/D13430?vs=36509&id=36515#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13430

Files:
  cfe/trunk/include/clang/Basic/VirtualFileSystem.h
  cfe/trunk/lib/Basic/VirtualFileSystem.cpp
  cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Index: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
===
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
@@ -43,6 +43,12 @@
   openFileForRead(const Twine &Path) override {
 llvm_unreachable("unimplemented");
   }
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+return std::string();
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
Index: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
===
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h
@@ -199,6 +199,25 @@
   /// \note The 'end' iterator is directory_iterator().
   virtual directory_iterator dir_begin(const Twine &Dir,
std::error_code &EC) = 0;
+
+  /// Set the working directory. This will affect all following operations on
+  /// this file system and may propagate down for nested file systems.
+  virtual std::error_code setCurrentWorkingDirectory(const Twine &Path) = 0;
+  /// Get the working directory of this file system.
+  virtual llvm::ErrorOr getCurrentWorkingDirectory() const = 0;
+
+  /// Make \a Path an absolute path.
+  ///
+  /// Makes \a Path absolute using the current directory if it is not already.
+  /// An empty \a Path will result in the current directory.
+  ///
+  /// /absolute/path   => /absolute/path
+  /// relative/../path => /relative/../path
+  ///
+  /// \param Path A path that is modified to be an absolute path.
+  /// \returns success if \a path has been made absolute, otherwise a
+  ///  platform-specific error_code.
+  std::error_code makeAbsolute(SmallVectorImpl &Path) const;
 };
 
 /// \brief Gets an \p vfs::FileSystem for the 'real' file system, as seen by
@@ -230,6 +249,8 @@
   llvm::ErrorOr>
   openFileForRead(const Twine &Path) override;
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
+  llvm::ErrorOr getCurrentWorkingDirectory() const override;
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
 
   typedef FileSystemList::reverse_iterator iterator;
   
@@ -248,6 +269,7 @@
 /// An in-memory file system.
 class InMemoryFileSystem : public FileSystem {
   std::unique_ptr Root;
+  std::string WorkingDirectory;
 
 public:
   InMemoryFileSystem();
@@ -260,6 +282,13 @@
   llvm::ErrorOr>
   openFileForRead(const Twine &Path) override;
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+return WorkingDirectory;
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+WorkingDirectory = Path.str();
+return std::error_code();
+  }
 };
 
 /// \brief Get a globally unique ID for a virtual file or directory.
Index: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
===
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp
@@ -89,6 +89,14 @@
   return (*F)->getBuffer(Name, FileSize, RequiresNullTerminator, IsVolatile);
 }
 
+std::error_code FileSystem::makeAbsolute(SmallVectorImpl &Path) const {
+  auto WorkingDir = getCurrentWorkingDirectory();
+  if (!WorkingDir)
+return WorkingDir.getError();
+
+  return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
+}
+
 //===---===/
 // RealFileSystem implementation
 //===---===/
@@ -160,6 +168,9 @@
   ErrorOr status(const Twine &Path) override;
   ErrorOr> openFileForRead(const Twine &Path) override;
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
+
+  llvm::ErrorOr getCurrentWorkingDirectory() const override;
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
 };
 } // end anonymous namespace
 
@@ -178,6 +189,28 @@
   return std::unique_ptr(new RealFile(FD, Name.str()));
 }
 
+llvm::ErrorOr RealFileSystem::getCurrentWorkingDirectory() const {
+  SmallString<256> Dir;
+  if (std::error_code EC = llvm::sys::fs::current_path(Dir))
+return EC;
+  return Dir.str().st

r249315 - [VFS] Add an in-memory file system implementation.

2015-10-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct  5 08:55:14 2015
New Revision: 249315

URL: http://llvm.org/viewvc/llvm-project?rev=249315&view=rev
Log:
[VFS] Add an in-memory file system implementation.

This is a simple file system tree of memory buffers that can be filled by a
client. In conjunction with an OverlayFS it can be used to make virtual
files accessible right next to physical files. This can be used as a
replacement for the virtual file handling in FileManager and which I intend
to remove eventually.

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
cfe/trunk/unittests/Tooling/RewriterTestContext.h

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=249315&r1=249314&r2=249315&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Oct  5 08:55:14 2015
@@ -241,6 +241,27 @@ public:
   iterator overlays_end() { return FSList.rend(); }
 };
 
+namespace detail {
+class InMemoryDirectory;
+} // end namespace detail
+
+/// An in-memory file system.
+class InMemoryFileSystem : public FileSystem {
+  std::unique_ptr Root;
+
+public:
+  InMemoryFileSystem();
+  ~InMemoryFileSystem() override;
+  void addFile(const Twine &Path, time_t ModificationTime,
+   std::unique_ptr Buffer);
+  StringRef toString() const;
+
+  llvm::ErrorOr status(const Twine &Path) override;
+  llvm::ErrorOr>
+  openFileForRead(const Twine &Path) override;
+  directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
+};
+
 /// \brief Get a globally unique ID for a virtual file or directory.
 llvm::sys::fs::UniqueID getNextVirtualUniqueID();
 

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249315&r1=249314&r2=249315&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 08:55:14 2015
@@ -320,6 +320,252 @@ directory_iterator OverlayFileSystem::di
   std::make_shared(Dir, *this, EC));
 }
 
+namespace clang {
+namespace vfs {
+namespace detail {
+
+enum InMemoryNodeKind { IME_File, IME_Directory };
+
+/// The in memory file system is a tree of Nodes. Every node can either be a
+/// file or a directory.
+class InMemoryNode {
+  Status Stat;
+  InMemoryNodeKind Kind;
+
+public:
+  InMemoryNode(Status Stat, InMemoryNodeKind Kind)
+  : Stat(std::move(Stat)), Kind(Kind) {}
+  virtual ~InMemoryNode() {}
+  const Status &getStatus() const { return Stat; }
+  InMemoryNodeKind getKind() const { return Kind; }
+  virtual std::string toString(unsigned Indent) const = 0;
+};
+
+namespace {
+class InMemoryFile : public InMemoryNode {
+  std::unique_ptr Buffer;
+
+public:
+  InMemoryFile(Status Stat, std::unique_ptr Buffer)
+  : InMemoryNode(std::move(Stat), IME_File), Buffer(std::move(Buffer)) {}
+
+  llvm::MemoryBuffer *getBuffer() { return Buffer.get(); }
+  std::string toString(unsigned Indent) const override {
+return (std::string(Indent, ' ') + getStatus().getName() + "\n").str();
+  }
+  static bool classof(const InMemoryNode *N) {
+return N->getKind() == IME_File;
+  }
+};
+
+/// Adapt a InMemoryFile for VFS' File interface.
+class InMemoryFileAdaptor : public File {
+  InMemoryFile &Node;
+
+public:
+  explicit InMemoryFileAdaptor(InMemoryFile &Node) : Node(Node) {}
+
+  llvm::ErrorOr status() override { return Node.getStatus(); }
+  llvm::ErrorOr>
+  getBuffer(const Twine &Name, int64_t FileSize = -1,
+bool RequiresNullTerminator = true,
+bool IsVolatile = false) override {
+llvm::MemoryBuffer *Buf = Node.getBuffer();
+return llvm::MemoryBuffer::getMemBuffer(
+Buf->getBuffer(), Buf->getBufferIdentifier(), RequiresNullTerminator);
+  }
+  std::error_code close() override { return std::error_code(); }
+};
+} // end anonymous namespace
+
+class InMemoryDirectory : public InMemoryNode {
+  std::map> Entries;
+
+public:
+  InMemoryDirectory(Status Stat)
+  : InMemoryNode(std::move(Stat), IME_Directory) {}
+  InMemoryNode *getChild(StringRef Name) {
+auto I = Entries.find(Name);
+if (I != Entries.end())
+  return I->second.get();
+return nullptr;
+  }
+  InMemoryNode *addChild(StringRef Name, std::unique_ptr Child) {
+return Entries.insert(make_pair(Name, std::move(Child)))
+.first->second.get();
+  }
+
+  typedef decltype(Entries)::const_iterator const_iterator;
+  const_iterator begin() const { return Entries.begin(); }
+  const_iterator end() const { return Entries.end(); }
+
+  std::string toString(unsigned Indent) const overri

r249316 - [VFS] Add working directories to every virtual file system.

2015-10-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct  5 08:55:20 2015
New Revision: 249316

URL: http://llvm.org/viewvc/llvm-project?rev=249316&view=rev
Log:
[VFS] Add working directories to every virtual file system.

For RealFileSystem this is getcwd()/chdir(), the synthetic file systems can
make up one for themselves. OverlayFileSystem now synchronizes the working
directories when a new FS is added to the overlay or the overlay working
directory is set. This allows purely artificial file systems that have zero
ties to the underlying disks.

Differential Revision: http://reviews.llvm.org/D13430

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=249316&r1=249315&r2=249316&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Oct  5 08:55:20 2015
@@ -199,6 +199,25 @@ public:
   /// \note The 'end' iterator is directory_iterator().
   virtual directory_iterator dir_begin(const Twine &Dir,
std::error_code &EC) = 0;
+
+  /// Set the working directory. This will affect all following operations on
+  /// this file system and may propagate down for nested file systems.
+  virtual std::error_code setCurrentWorkingDirectory(const Twine &Path) = 0;
+  /// Get the working directory of this file system.
+  virtual llvm::ErrorOr getCurrentWorkingDirectory() const = 0;
+
+  /// Make \a Path an absolute path.
+  ///
+  /// Makes \a Path absolute using the current directory if it is not already.
+  /// An empty \a Path will result in the current directory.
+  ///
+  /// /absolute/path   => /absolute/path
+  /// relative/../path => /relative/../path
+  ///
+  /// \param Path A path that is modified to be an absolute path.
+  /// \returns success if \a path has been made absolute, otherwise a
+  ///  platform-specific error_code.
+  std::error_code makeAbsolute(SmallVectorImpl &Path) const;
 };
 
 /// \brief Gets an \p vfs::FileSystem for the 'real' file system, as seen by
@@ -230,6 +249,8 @@ public:
   llvm::ErrorOr>
   openFileForRead(const Twine &Path) override;
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
+  llvm::ErrorOr getCurrentWorkingDirectory() const override;
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
 
   typedef FileSystemList::reverse_iterator iterator;
   
@@ -248,6 +269,7 @@ class InMemoryDirectory;
 /// An in-memory file system.
 class InMemoryFileSystem : public FileSystem {
   std::unique_ptr Root;
+  std::string WorkingDirectory;
 
 public:
   InMemoryFileSystem();
@@ -260,6 +282,13 @@ public:
   llvm::ErrorOr>
   openFileForRead(const Twine &Path) override;
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+return WorkingDirectory;
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+WorkingDirectory = Path.str();
+return std::error_code();
+  }
 };
 
 /// \brief Get a globally unique ID for a virtual file or directory.

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249316&r1=249315&r2=249316&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 08:55:20 2015
@@ -89,6 +89,14 @@ FileSystem::getBufferForFile(const llvm:
   return (*F)->getBuffer(Name, FileSize, RequiresNullTerminator, IsVolatile);
 }
 
+std::error_code FileSystem::makeAbsolute(SmallVectorImpl &Path) const {
+  auto WorkingDir = getCurrentWorkingDirectory();
+  if (!WorkingDir)
+return WorkingDir.getError();
+
+  return llvm::sys::fs::make_absolute(WorkingDir.get(), Path);
+}
+
 
//===---===/
 // RealFileSystem implementation
 
//===---===/
@@ -160,6 +168,9 @@ public:
   ErrorOr status(const Twine &Path) override;
   ErrorOr> openFileForRead(const Twine &Path) override;
   directory_iterator dir_begin(const Twine &Dir, std::error_code &EC) override;
+
+  llvm::ErrorOr getCurrentWorkingDirectory() const override;
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override;
 };
 } // end anonymous namespace
 
@@ -178,6 +189,28 @@ RealFileSystem::openFileForRead(const Tw
   return std::unique_ptr(new RealFile(FD, Name.str()));
 }
 
+llvm::ErrorOr RealFileSystem::getCurrentWorkingDirectory() const {
+  SmallStr

r249314 - [VFS] Move class out of method so it looks less like Java.

2015-10-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct  5 08:55:09 2015
New Revision: 249314

URL: http://llvm.org/viewvc/llvm-project?rev=249314&view=rev
Log:
[VFS] Move class out of method so it looks less like Java.

No functionality change.

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249314&r1=249313&r2=249314&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 08:55:09 2015
@@ -942,6 +942,33 @@ ErrorOr VFSFromYAML::status(cons
   return status(Path, *Result);
 }
 
+namespace {
+/// Provide a file wrapper that returns the external name when asked.
+class NamedFileAdaptor : public File {
+  std::unique_ptr InnerFile;
+  std::string NewName;
+
+public:
+  NamedFileAdaptor(std::unique_ptr InnerFile, std::string NewName)
+  : InnerFile(std::move(InnerFile)), NewName(std::move(NewName)) {}
+
+  llvm::ErrorOr status() override {
+auto InnerStatus = InnerFile->status();
+if (InnerStatus)
+  return Status::copyWithNewName(*InnerStatus, NewName);
+return InnerStatus.getError();
+  }
+  llvm::ErrorOr>
+  getBuffer(const Twine &Name, int64_t FileSize = -1,
+bool RequiresNullTerminator = true,
+bool IsVolatile = false) override {
+return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator,
+IsVolatile);
+  }
+  std::error_code close() override { return InnerFile->close(); }
+};
+} // end anonymous namespace
+
 ErrorOr> VFSFromYAML::openFileForRead(const Twine &Path) 
{
   ErrorOr E = lookupPath(Path);
   if (!E)
@@ -955,34 +982,9 @@ ErrorOr> VFSFromYA
   if (!Result)
 return Result;
 
-  if (!F->useExternalName(UseExternalNames)) {
-// Provide a file wrapper that returns the external name when asked.
-class NamedFileAdaptor : public File {
-  std::unique_ptr InnerFile;
-  std::string NewName;
-
-public:
-  NamedFileAdaptor(std::unique_ptr InnerFile, std::string NewName)
-  : InnerFile(std::move(InnerFile)), NewName(std::move(NewName)) {}
-
-  llvm::ErrorOr status() override {
-auto InnerStatus = InnerFile->status();
-if (InnerStatus)
-  return Status::copyWithNewName(*InnerStatus, NewName);
-return InnerStatus.getError();
-  }
-  llvm::ErrorOr>
-  getBuffer(const Twine &Name, int64_t FileSize = -1,
-bool RequiresNullTerminator = true,
-bool IsVolatile = false) override {
-return InnerFile->getBuffer(Name, FileSize, RequiresNullTerminator,
-IsVolatile);
-  }
-  std::error_code close() override { return InnerFile->close(); }
-};
+  if (!F->useExternalName(UseExternalNames))
 return std::unique_ptr(
 new NamedFileAdaptor(std::move(*Result), Path.str()));
-  }
 
   return Result;
 }


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


Re: [PATCH] D13430: [VFS] Add an in-memory file system implementation.

2015-10-05 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg



Comment at: lib/Basic/VirtualFileSystem.cpp:1263-1265
@@ -957,5 +1262,5 @@
 
   if (!F->useExternalName(UseExternalNames)) {
 // Provide a file wrapper that returns the external name when asked.
 class NamedFileAdaptor : public File {
   std::unique_ptr InnerFile;

Optional: I'd put this into an anonymous namespace. But I'm also fine with 
waiting how others think about this :)


http://reviews.llvm.org/D13430



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


r249312 - clang-format: Small doc fix.

2015-10-05 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Mon Oct  5 08:30:42 2015
New Revision: 249312

URL: http://llvm.org/viewvc/llvm-project?rev=249312&view=rev
Log:
clang-format: Small doc fix.

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=249312&r1=249311&r2=249312&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Mon Oct  5 08:30:42 2015
@@ -602,9 +602,9 @@ used by a codebase somewhere in the wild
 major projects and thus have established the following bar for adding style
 options. Each new style option must ..
 
-  * .. be used in a project of significant size (have dozens of contributors)
-  * .. have a publicly accessible style guide
-  * .. have a person willing to contribute and maintain patches
+  * be used in a project of significant size (have dozens of contributors)
+  * have a publicly accessible style guide
+  * have a person willing to contribute and maintain patches
 
 Examples
 


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


Re: [PATCH] D13430: [VFS] Add an in-memory file system implementation.

2015-10-05 Thread Benjamin Kramer via cfe-commits
bkramer marked 10 inline comments as done.


Comment at: include/clang/Basic/VirtualFileSystem.h:286-288
@@ +285,5 @@
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+WorkingDirectory = Path.str();
+return std::error_code();
+  }

klimek wrote:
> Return errc::success?
There is no errc::success, the preferred way is to just use error_code(). Fixed 
the comment.


Comment at: lib/Basic/VirtualFileSystem.cpp:80
@@ -79,1 +79,3 @@
 
+// FIXME: This is copypasted from LLVM's file system implementation.
+std::error_code FileSystem::make_absolute(SmallVectorImpl &path) const {

klimek wrote:
> What's the proposed fix? :)
Moving it to LLVM. That's done now :)


Comment at: lib/Basic/VirtualFileSystem.cpp:312-316
@@ -229,4 +311,7 @@
 
 void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr FS) {
   FSList.push_back(FS);
+  // Synchronize added file systems by duplicating the working directory from
+  // the first one in the list.
+  FS->setCurrentWorkingDirectory(getCurrentWorkingDirectory().get());
 }

klimek wrote:
> If I read this correctly, it gets and sets the pwd from FS for the first one? 
> That seems superfluous.
> (perhaps change the constructor to not use pushOverlay)
Good catch!


Comment at: lib/Basic/VirtualFileSystem.cpp:476
@@ +475,3 @@
+  std::error_code close() override { return std::error_code(); }
+  void setName(StringRef Name) override { Parent.getStatus().setName(Name); }
+};

klimek wrote:
> Is this used in the File interface? It seems - strange... is this really a 
> "mv" implementation?
Gone it is.


Comment at: lib/Basic/VirtualFileSystem.cpp:546-550
@@ +545,7 @@
+// End of the path, create a new file.
+Status Stat(Path, "", getNextVirtualUniqueID(),
+llvm::sys::TimeValue(ModificationTime), 0, 0,
+Buffer->getBufferSize(),
+llvm::sys::fs::file_type::regular_file,
+llvm::sys::fs::all_all);
+Dir->addChild(Name, llvm::make_unique(

klimek wrote:
> I think we'll want to get some of these into the interface. But that's fine 
> in a follow-up patch. Add a FIXME though.
FIXME added.


Comment at: lib/Basic/VirtualFileSystem.cpp:800
@@ -455,1 +799,3 @@
 
+  std::string WorkingDirectory;
+

klimek wrote:
> Doesn't the YAML FS work on the same pwd as the current process?
Changed the methods to forward to the inner FS of the yaml overlay.


http://reviews.llvm.org/D13430



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


Re: [PATCH] D13430: [VFS] Add an in-memory file system implementation.

2015-10-05 Thread Benjamin Kramer via cfe-commits
bkramer updated this revision to Diff 36509.
bkramer added a comment.

Rebased and addressed review comments.


http://reviews.llvm.org/D13430

Files:
  include/clang/Basic/VirtualFileSystem.h
  lib/Basic/VirtualFileSystem.cpp
  unittests/Basic/VirtualFileSystemTest.cpp
  unittests/Tooling/RewriterTestContext.h

Index: unittests/Tooling/RewriterTestContext.h
===
--- unittests/Tooling/RewriterTestContext.h
+++ unittests/Tooling/RewriterTestContext.h
@@ -34,25 +34,30 @@
 /// methods, which help with writing tests that change files.
 class RewriterTestContext {
  public:
-  RewriterTestContext()
-  : DiagOpts(new DiagnosticOptions()),
-Diagnostics(IntrusiveRefCntPtr(new DiagnosticIDs),
-&*DiagOpts),
-DiagnosticPrinter(llvm::outs(), &*DiagOpts),
-Files((FileSystemOptions())),
-Sources(Diagnostics, Files),
-Rewrite(Sources, Options) {
+   RewriterTestContext()
+   : DiagOpts(new DiagnosticOptions()),
+ Diagnostics(IntrusiveRefCntPtr(new DiagnosticIDs),
+ &*DiagOpts),
+ DiagnosticPrinter(llvm::outs(), &*DiagOpts),
+ InMemoryFileSystem(new vfs::InMemoryFileSystem),
+ OverlayFileSystem(
+ new vfs::OverlayFileSystem(vfs::getRealFileSystem())),
+ Files(FileSystemOptions(), OverlayFileSystem),
+ Sources(Diagnostics, Files), Rewrite(Sources, Options) {
 Diagnostics.setClient(&DiagnosticPrinter, false);
+// FIXME: To make these tests truly in-memory, we need to overlay the
+// builtin headers.
+OverlayFileSystem->pushOverlay(InMemoryFileSystem);
   }
 
   ~RewriterTestContext() {}
 
   FileID createInMemoryFile(StringRef Name, StringRef Content) {
 std::unique_ptr Source =
 llvm::MemoryBuffer::getMemBuffer(Content);
-const FileEntry *Entry =
-  Files.getVirtualFile(Name, Source->getBufferSize(), 0);
-Sources.overrideFileContents(Entry, std::move(Source));
+InMemoryFileSystem->addFile(Name, 0, std::move(Source));
+
+const FileEntry *Entry = Files.getFile(Name);
 assert(Entry != nullptr);
 return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User);
   }
@@ -109,6 +114,8 @@
   IntrusiveRefCntPtr DiagOpts;
   DiagnosticsEngine Diagnostics;
   TextDiagnosticPrinter DiagnosticPrinter;
+  IntrusiveRefCntPtr InMemoryFileSystem;
+  IntrusiveRefCntPtr OverlayFileSystem;
   FileManager Files;
   SourceManager Sources;
   LangOptions Options;
Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -43,6 +43,12 @@
   openFileForRead(const Twine &Path) override {
 llvm_unreachable("unimplemented");
   }
+  llvm::ErrorOr getCurrentWorkingDirectory() const override {
+return std::string();
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+return std::error_code();
+  }
 
   struct DirIterImpl : public clang::vfs::detail::DirIterImpl {
 std::map &FilesAndDirs;
@@ -515,6 +521,73 @@
   }
 }
 
+class InMemoryFileSystemTest : public ::testing::Test {
+protected:
+  clang::vfs::InMemoryFileSystem FS;
+};
+
+TEST_F(InMemoryFileSystemTest, IsEmpty) {
+  auto Stat = FS.status("/a");
+  ASSERT_EQ(errc::no_such_file_or_directory, Stat.getError()) << FS.toString();
+  Stat = FS.status("/");
+  ASSERT_EQ(errc::no_such_file_or_directory, Stat.getError()) << FS.toString();
+}
+
+TEST_F(InMemoryFileSystemTest, WindowsPath) {
+  FS.addFile("c:/windows/system128/foo.cpp", 0, MemoryBuffer::getMemBuffer(""));
+  auto Stat = FS.status("c:");
+  ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
+  Stat = FS.status("c:/windows/system128/foo.cpp");
+  ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
+  FS.addFile("d:/windows/foo.cpp", 0, MemoryBuffer::getMemBuffer(""));
+  Stat = FS.status("d:/windows/foo.cpp");
+  ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
+}
+
+TEST_F(InMemoryFileSystemTest, OverlayFile) {
+  FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
+  auto Stat = FS.status("/");
+  ASSERT_FALSE(Stat.getError()) << Stat.getError() << FS.toString();
+  Stat = FS.status("/a");
+  ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString();
+  ASSERT_EQ("/a", Stat->getName());
+}
+
+TEST_F(InMemoryFileSystemTest, OpenFileForRead) {
+  FS.addFile("/a", 0, MemoryBuffer::getMemBuffer("a"));
+  auto File = FS.openFileForRead("/a");
+  ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
+  File = FS.openFileForRead("/a"); // Open again.
+  ASSERT_EQ("a", (*(*File)->getBuffer("ignored"))->getBuffer());
+  File = FS.openFileForRead("/");
+  ASSERT_EQ(errc::invalid_argument, File.getError()) << FS.toString();
+  File = FS.openFileForRead("/b");
+  ASSERT_EQ(errc::no_such_file_or_directory, File.getE

r249310 - [VFS] Remove setName from the file interface.

2015-10-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Oct  5 08:15:33 2015
New Revision: 249310

URL: http://llvm.org/viewvc/llvm-project?rev=249310&view=rev
Log:
[VFS] Remove setName from the file interface.

This streamlines the interface a bit and makes Status more immutable.
No functional change intended.

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=249310&r1=249309&r2=249310&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Mon Oct  5 08:15:33 2015
@@ -45,14 +45,18 @@ public:
 public:
   Status() : Type(llvm::sys::fs::file_type::status_error) {}
   Status(const llvm::sys::fs::file_status &Status);
-  Status(StringRef Name, StringRef RealName, llvm::sys::fs::UniqueID UID,
+  Status(StringRef Name, llvm::sys::fs::UniqueID UID,
  llvm::sys::TimeValue MTime, uint32_t User, uint32_t Group,
  uint64_t Size, llvm::sys::fs::file_type Type,
  llvm::sys::fs::perms Perms);
 
+  /// Get a copy of a Status with a different name.
+  static Status copyWithNewName(const Status &In, StringRef NewName);
+  static Status copyWithNewName(const llvm::sys::fs::file_status &In,
+StringRef NewName);
+
   /// \brief Returns the name that should be used for this file or directory.
   StringRef getName() const { return Name; }
-  void setName(StringRef N) { Name = N; }
 
   /// @name Status interface from llvm::sys::fs
   /// @{
@@ -92,8 +96,6 @@ public:
 bool RequiresNullTerminator = true, bool IsVolatile = false) = 0;
   /// \brief Closes the file.
   virtual std::error_code close() = 0;
-  /// \brief Sets the name to use for this file.
-  virtual void setName(StringRef Name) = 0;
 };
 
 namespace detail {

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=249310&r1=249309&r2=249310&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Mon Oct  5 08:15:33 2015
@@ -35,12 +35,24 @@ Status::Status(const file_status &Status
   User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()),
   Type(Status.type()), Perms(Status.permissions()), IsVFSMapped(false)  {}
 
-Status::Status(StringRef Name, StringRef ExternalName, UniqueID UID,
-   sys::TimeValue MTime, uint32_t User, uint32_t Group,
-   uint64_t Size, file_type Type, perms Perms)
+Status::Status(StringRef Name, UniqueID UID, sys::TimeValue MTime,
+   uint32_t User, uint32_t Group, uint64_t Size, file_type Type,
+   perms Perms)
 : Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size),
   Type(Type), Perms(Perms), IsVFSMapped(false) {}
 
+Status Status::copyWithNewName(const Status &In, StringRef NewName) {
+  return Status(NewName, In.getUniqueID(), In.getLastModificationTime(),
+In.getUser(), In.getGroup(), In.getSize(), In.getType(),
+In.getPermissions());
+}
+
+Status Status::copyWithNewName(const file_status &In, StringRef NewName) {
+  return Status(NewName, In.getUniqueID(), In.getLastModificationTime(),
+In.getUser(), In.getGroup(), In.getSize(), In.type(),
+In.permissions());
+}
+
 bool Status::equivalent(const Status &Other) const {
   return getUniqueID() == Other.getUniqueID();
 }
@@ -87,7 +99,9 @@ class RealFile : public File {
   int FD;
   Status S;
   friend class RealFileSystem;
-  RealFile(int FD) : FD(FD) {
+  RealFile(int FD, StringRef NewName)
+  : FD(FD), S(NewName, {}, {}, {}, {}, {},
+  llvm::sys::fs::file_type::status_error, {}) {
 assert(FD >= 0 && "Invalid or inactive file descriptor");
   }
 
@@ -99,7 +113,6 @@ public:
 bool RequiresNullTerminator = true,
 bool IsVolatile = false) override;
   std::error_code close() override;
-  void setName(StringRef Name) override;
 };
 } // end anonymous namespace
 RealFile::~RealFile() { close(); }
@@ -110,9 +123,7 @@ ErrorOr RealFile::status() {
 file_status RealStatus;
 if (std::error_code EC = sys::fs::status(FD, RealStatus))
   return EC;
-Status NewS(RealStatus);
-NewS.setName(S.getName());
-S = std::move(NewS);
+S = Status::copyWithNewName(RealStatus, S.getName());
   }
   return S;
 }
@@ -142,10 +153,6 @@ std::error_code RealFile::close() {
   return std::error_code();
 }
 
-void RealFile::setName(StringRef Name) {
-  S.setName(Name);
-}
-
 namespace {
 /// \brief The file system acco

r249308 - The Driver does not set the +strict-align flag when targeting

2015-10-05 Thread Alexandros Lamprineas via cfe-commits
Author: alelab01
Date: Mon Oct  5 07:45:10 2015
New Revision: 249308

URL: http://llvm.org/viewvc/llvm-project?rev=249308&view=rev
Log:
The Driver does not set the +strict-align flag when targeting
[ARM] armv6m + netbsd. Tests are misssing for armv6m + darwin as well.

Differential Revision: http://reviews.llvm.org/D13217

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/arm-alignment.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249308&r1=249307&r2=249308&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Oct  5 07:45:10 2015
@@ -4452,10 +4452,6 @@ public:
   if (Feature[0] == '+')
 Features[Feature+1] = true; 
 
-if (ArchVersion < 6  || 
-   (ArchVersion == 6 && ArchProfile == llvm::ARM::PK_M))
-  Features["strict-align"] = true;
-
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
 

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=249308&r1=249307&r2=249308&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Oct  5 07:45:10 2015
@@ -834,7 +834,8 @@ static void getARMTargetFeatures(const T
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
 if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
-  if (VersionNum < 6)
+  if (VersionNum < 6 ||
+  Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
 } else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
   if (VersionNum < 7)

Modified: cfe/trunk/test/Driver/arm-alignment.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-alignment.c?rev=249308&r1=249307&r2=249308&view=diff
==
--- cfe/trunk/test/Driver/arm-alignment.c (original)
+++ cfe/trunk/test/Driver/arm-alignment.c Mon Oct  5 07:45:10 2015
@@ -59,6 +59,12 @@
 // RUN: %clang -target armv6-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv6m-apple-darwin -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
+// RUN: %clang -target armv6m-netbsd-eabi -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -mno-unaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
 


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


Re: [PATCH] D13217: [ARM] The Driver does not set the +strict-align flag when targeting armv6m + netbsd

2015-10-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL249308: The Driver does not set the +strict-align flag when 
targeting (authored by alelab01).

Changed prior to commit:
  http://reviews.llvm.org/D13217?vs=35883&id=36507#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13217

Files:
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/arm-alignment.c

Index: cfe/trunk/test/Driver/arm-alignment.c
===
--- cfe/trunk/test/Driver/arm-alignment.c
+++ cfe/trunk/test/Driver/arm-alignment.c
@@ -59,6 +59,12 @@
 // RUN: %clang -target armv6-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv6m-apple-darwin -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
+// RUN: %clang -target armv6m-netbsd-eabi -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -mno-unaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4452,10 +4452,6 @@
   if (Feature[0] == '+')
 Features[Feature+1] = true; 
 
-if (ArchVersion < 6  || 
-   (ArchVersion == 6 && ArchProfile == llvm::ARM::PK_M))
-  Features["strict-align"] = true;
-
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
 
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -834,7 +834,8 @@
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
 if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
-  if (VersionNum < 6)
+  if (VersionNum < 6 ||
+  Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
 } else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
   if (VersionNum < 7)


Index: cfe/trunk/test/Driver/arm-alignment.c
===
--- cfe/trunk/test/Driver/arm-alignment.c
+++ cfe/trunk/test/Driver/arm-alignment.c
@@ -59,6 +59,12 @@
 // RUN: %clang -target armv6-unknown-nacl-gnueabihf -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
 
+// RUN: %clang -target armv6m-apple-darwin -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
+// RUN: %clang -target armv6m-netbsd-eabi -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-ALIGNED-ARM < %t %s
+
 // RUN: %clang -target aarch64-none-gnueabi -mno-unaligned-access -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
 
Index: cfe/trunk/lib/Basic/Targets.cpp
===
--- cfe/trunk/lib/Basic/Targets.cpp
+++ cfe/trunk/lib/Basic/Targets.cpp
@@ -4452,10 +4452,6 @@
   if (Feature[0] == '+')
 Features[Feature+1] = true; 
 
-if (ArchVersion < 6  || 
-   (ArchVersion == 6 && ArchProfile == llvm::ARM::PK_M))
-  Features["strict-align"] = true;
-
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }
 
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -834,7 +834,8 @@
 // The above behavior is consistent with GCC.
 int VersionNum = getARMSubArchVersionNumber(Triple);
 if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
-  if (VersionNum < 6)
+  if (VersionNum < 6 ||
+  Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_back("+strict-align");
 } else if (Triple.isOSLinux() || Triple.isOSNaCl()) {
   if (VersionNum < 7)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13192: Fix incorrect parsing of arguments for nested functions

2015-10-05 Thread Arseny Kapoulkine via cfe-commits
arseny.kapoulkine added a comment.

Ping.


http://reviews.llvm.org/D13192



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


Re: [PATCH] D13134: [analyzer] Add keyboard shortcuts to report.html

2015-10-05 Thread Karl Skomski via cfe-commits
skomski removed rL LLVM as the repository for this revision.
skomski updated this revision to Diff 36490.
skomski added a comment.

Included mousetrap to get keyboard shortcuts working on all international 
keyboards.
Fixed behaviour without hash path present: Jump to #Path1 on j or k


http://reviews.llvm.org/D13134

Files:
  tools/scan-build/keyboard-shortcuts.js

Index: tools/scan-build/keyboard-shortcuts.js
===
--- tools/scan-build/keyboard-shortcuts.js
+++ tools/scan-build/keyboard-shortcuts.js
@@ -1,8 +1,26 @@
+/* mousetrap v1.5.3 craig.is/killing/mice */
+(function(C,r,g){function 
t(a,b,h){a.addEventListener?a.addEventListener(b,h,!1):a.attachEvent("on"+b,h)}function
 x(a){if("keypress"==a.type){var 
b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return 
l[a.which]?l[a.which]:p[a.which]?p[a.which]:String.fromCharCode(a.which).toLowerCase()}function
 D(a){var 
b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return
 b}function u(a){return"shift"==a||"ctrl"==a||"alt"==a||
+"meta"==a}function y(a,b){var 
h,c,e,g=[];h=a;"+"===h?h=["+"]:(h=h.replace(/\+{2}/g,"+plus"),h=h.split("+"));for(e=0;em||l.hasOwnProperty(m)&&(k[l[m]]=m)}e=k[h]?"keydown":"keypress"}"keypress"==e&&g.length&&(e="keydown");return{key:c,modifiers:g,action:e}}function
 B(a,b){return null===a||a===r?!1:a===b?!0:B(a.parentNode,b)}function 
c(a){function b(a){a=
+a||{};var b=!1,n;for(n in q)a[n]?b=!0:q[n]=0;b||(v=!1)}function 
h(a,b,n,f,c,h){var 
g,e,l=[],m=n.type;if(!d._callbacks[a])return[];"keyup"==m&&u(a)&&(b=[a]);for(g=0;g":".","?":"/","|":"\\"},z={option:"alt",command:"meta","return":"enter",
+escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},k;for(g=1;20>g;++g)l[111+g]="f"+g;for(g=0;9>=g;++g)l[g+96]=g;c.prototype.bind=function(a,b,c){a=a
 instanceof Array?a:[a];this._bindMultiple.call(this,a,b,c);return 
this};c.prototype.unbind=function(a,b){return 
this.bind.call(this,a,function(){},b)};c.prototype.trigger=function(a,b){if(this._directMap[a+":"+b])this._directMap[a+":"+b]({},a);return
 this};c.prototype.reset=function(){this._callbacks={};this._directMap=
+{};return this};c.prototype.stopCallback=function(a,b){return-1<(" 
"+b.className+" ").indexOf(" mousetrap 
")||B(b,this.target)?!1:"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable};c.prototype.handleKey=function(){return
 this._handleKey.apply(this,arguments)};c.init=function(){var a=c(r),b;for(b in 
a)"_"!==b.charAt(0)&&(c[b]=function(b){return function(){return 
a[b].apply(a,arguments)}}(b))};c.init();C.Mousetrap=c;"undefined"!==typeof 
module&&module.exports&&(module.exports=
+c);"function"===typeof define&&define.amd&&define(function(){return 
c})})(window,document);
+
+
 (function () {
+'use strict';
 
 function Jump(matchTarget, lastBlock) {
-  var match = document.location.hash.match(/Path\d+|EndPath/)[0];
-  var matches = document.querySelectorAll('#' + match + ' .PathNav')
+  var match = document.location.hash.match(/Path\d+|EndPath/);
+  if (!match) {
+document.location.hash = '#Path1';
+return;
+  }
+  var matches = document.querySelectorAll('#' + match[0] + ' .PathNav');
   if (matches.length == 2) {
 document.location = matches[matchTarget].children[0].href;
   } else {
@@ -10,32 +28,24 @@
   document.location = matches[0].children[0].href;
 }
   }
-};
+}
 
 function ShowHelp() {
-  alert("Keyboard shortcuts:\n\n" +
-"Jump to next path: j\n"  +
-"Jump to previous path: k\n");
+  alert('Keyboard shortcuts:\n\n' +
+'Jump to next path: j\n'  +
+'Jump to previous path: k\n');
 }
 
-const KEYS = {
-  J: 74,
-  K: 75,
-  SLASH: 191
-}
+Mousetrap.bind('j', function() {
+  Jump(1, '#EndPath');
+});
 
-document.onkeydown = function (e) {
-  switch(e.keyCode) {
-case KEYS.J:
-  Jump(1, '#EndPath');
-  break;
-case KEYS.K:
-  Jump(0, '#Path1');
-  break;
-case KEYS.SLASH:
-  ShowHelp();
-  break;
-  }
-};
+Mousetrap.bind('k', function() {
+  Jump(0, '#Path1');
+});
+
+Mousetrap.bind('?', function() {
+  ShowHelp();
+});
 
 }());


Index: tools/scan-build/keyboard-shortcuts.js
===
--- tools/scan-build/keyboard-shortcuts.js
+++ tools/scan-build/keyboard-shortcuts.js
@@ -1,8 +1,26 @@
+/* mousetrap v1.5.3 craig.is/killing/mice */
+(function(C,r,g){function t(a,b,h){a.addEventListener?a.addEventListener(b,h,!1):a.attachEvent("on"+b,h)}function x(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return l[a.which]?l[a.which]:p[a.which]?p[a.which]:String.fromCharCode(a.which).toLowerCase()}function D(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function u(a){return"shift"==a||"ctrl"==a

r249306 - [mips][p5600] Add -mcpu=p5600 option.

2015-10-05 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Mon Oct  5 07:24:30 2015
New Revision: 249306

URL: http://llvm.org/viewvc/llvm-project?rev=249306&view=rev
Log:
[mips][p5600] Add -mcpu=p5600 option.

Summary:

Reviewers: vkalintiris, atanasyan

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D12234

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/mips-abi.c
cfe/trunk/test/Driver/mips-as.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=249306&r1=249305&r2=249306&view=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Oct  5 07:24:30 2015
@@ -6312,6 +6312,7 @@ public:
 .Case("mips64r5", true)
 .Case("mips64r6", true)
 .Case("octeon", true)
+.Case("p5600", true)
 .Default(false);
   }
   const std::string& getCPU() const { return CPU; }

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=249306&r1=249305&r2=249306&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Oct  5 07:24:30 2015
@@ -1809,7 +1809,7 @@ static bool findMIPSMultilibs(const llvm
   addMultilibFlag(isMips16(Args), "mips16", Flags);
   addMultilibFlag(CPUName == "mips32", "march=mips32", Flags);
   addMultilibFlag(CPUName == "mips32r2" || CPUName == "mips32r3" ||
-  CPUName == "mips32r5",
+  CPUName == "mips32r5" || CPUName == "p5600",
   "march=mips32r2", Flags);
   addMultilibFlag(CPUName == "mips32r6", "march=mips32r6", Flags);
   addMultilibFlag(CPUName == "mips64", "march=mips64", Flags);

Modified: cfe/trunk/test/Driver/mips-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abi.c?rev=249306&r1=249305&r2=249306&view=diff
==
--- cfe/trunk/test/Driver/mips-abi.c (original)
+++ cfe/trunk/test/Driver/mips-abi.c Mon Oct  5 07:24:30 2015
@@ -99,6 +99,12 @@
 // MIPS-ARCH-32R2: "-target-abi" "o32"
 //
 // RUN: %clang -target mips-linux-gnu -### -c %s \
+// RUN:-march=p5600 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600 %s
+// MIPS-ARCH-P5600: "-target-cpu" "p5600"
+// MIPS-ARCH-P5600: "-target-abi" "o32"
+//
+// RUN: %clang -target mips-linux-gnu -### -c %s \
 // RUN:-march=mips64 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-3264 %s
 // MIPS-ARCH-3264: "-target-cpu" "mips64"

Modified: cfe/trunk/test/Driver/mips-as.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-as.c?rev=249306&r1=249305&r2=249306&view=diff
==
--- cfe/trunk/test/Driver/mips-as.c (original)
+++ cfe/trunk/test/Driver/mips-as.c Mon Oct  5 07:24:30 2015
@@ -58,6 +58,11 @@
 // RUN:   | FileCheck -check-prefix=MIPS-32R2 %s
 // MIPS-32R2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB"
 //
+// RUN: %clang -target mips-linux-gnu -march=p5600 -### \
+// RUN:   -no-integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=MIPS-P5600 %s
+// MIPS-P5600: as{{(.exe)?}}" "-march" "p5600" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB"
+//
 // RUN: %clang -target mips64-linux-gnu -march=octeon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-OCTEON %s


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


[clang-tools-extra] r249305 - Use better mocks in modernize-make-unique, and fix matcher.

2015-10-05 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Mon Oct  5 07:20:17 2015
New Revision: 249305

URL: http://llvm.org/viewvc/llvm-project?rev=249305&view=rev
Log:
Use better mocks in modernize-make-unique, and fix matcher.

Summary: Add the second template argument to the unique_ptr mock, and update 
the matcher so that it only matches against cases where the second argument is 
the default.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

Differential Revision: http://reviews.llvm.org/D13433

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp?rev=249305&r1=249304&r2=249305&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp Mon Oct  5 
07:20:17 2015
@@ -29,10 +29,18 @@ void MakeUniqueCheck::registerMatchers(M
 cxxConstructExpr(
 
hasType(qualType(hasDeclaration(classTemplateSpecializationDecl(
 matchesName("::std::unique_ptr"),
-templateArgumentCountIs(1),
+templateArgumentCountIs(2),
+hasTemplateArgument(0, templateArgument(refersToType(
+   qualType().bind(PointerType,
 hasTemplateArgument(
-0, templateArgument(
-   
refersToType(qualType().bind(PointerType,
+1, templateArgument(refersToType(qualType(
+   hasDeclaration(classTemplateSpecializationDecl(
+   matchesName("::std::default_delete"),
+   templateArgumentCountIs(1),
+   hasTemplateArgument(
+   0, templateArgument(refersToType(
+  qualType(equalsBoundNode(
+  PointerType))),
 argumentCountIs(1),
 hasArgument(0, cxxNewExpr(hasType(pointsTo(qualType(
   equalsBoundNode(PointerType)

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=249305&r1=249304&r2=249305&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Mon Oct  
5 07:20:17 2015
@@ -2,7 +2,10 @@
 
 namespace std {
 
-template 
+template 
+class default_delete {};
+
+template >
 class unique_ptr {
 public:
   unique_ptr(type *ptr);


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


Re: [PATCH] D13433: Use better mocks in modernize-make-unique, and fix matcher.

2015-10-05 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

lg


http://reviews.llvm.org/D13433



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


[PATCH] D13433: Use better mocks in modernize-make-unique, and fix matcher.

2015-10-05 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: cfe-commits, alexfh.

Add the second template argument to the unique_ptr mock, and update the matcher 
so that it only matches against cases where the second argument is the default.

http://reviews.llvm.org/D13433

Files:
  clang-tidy/modernize/MakeUniqueCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -2,7 +2,10 @@
 
 namespace std {
 
-template 
+template 
+class default_delete {};
+
+template >
 class unique_ptr {
 public:
   unique_ptr(type *ptr);
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -29,10 +29,18 @@
 cxxConstructExpr(
 
hasType(qualType(hasDeclaration(classTemplateSpecializationDecl(
 matchesName("::std::unique_ptr"),
-templateArgumentCountIs(1),
+templateArgumentCountIs(2),
+hasTemplateArgument(0, templateArgument(refersToType(
+   qualType().bind(PointerType,
 hasTemplateArgument(
-0, templateArgument(
-   
refersToType(qualType().bind(PointerType,
+1, templateArgument(refersToType(qualType(
+   hasDeclaration(classTemplateSpecializationDecl(
+   matchesName("::std::default_delete"),
+   templateArgumentCountIs(1),
+   hasTemplateArgument(
+   0, templateArgument(refersToType(
+  qualType(equalsBoundNode(
+  PointerType))),
 argumentCountIs(1),
 hasArgument(0, cxxNewExpr(hasType(pointsTo(qualType(
   equalsBoundNode(PointerType)


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -2,7 +2,10 @@
 
 namespace std {
 
-template 
+template 
+class default_delete {};
+
+template >
 class unique_ptr {
 public:
   unique_ptr(type *ptr);
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -29,10 +29,18 @@
 cxxConstructExpr(
 hasType(qualType(hasDeclaration(classTemplateSpecializationDecl(
 matchesName("::std::unique_ptr"),
-templateArgumentCountIs(1),
+templateArgumentCountIs(2),
+hasTemplateArgument(0, templateArgument(refersToType(
+   qualType().bind(PointerType,
 hasTemplateArgument(
-0, templateArgument(
-   refersToType(qualType().bind(PointerType,
+1, templateArgument(refersToType(qualType(
+   hasDeclaration(classTemplateSpecializationDecl(
+   matchesName("::std::default_delete"),
+   templateArgumentCountIs(1),
+   hasTemplateArgument(
+   0, templateArgument(refersToType(
+  qualType(equalsBoundNode(
+  PointerType))),
 argumentCountIs(1),
 hasArgument(0, cxxNewExpr(hasType(pointsTo(qualType(
   equalsBoundNode(PointerType)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249302 - Use llvm::errc instead of std::errc.

2015-10-05 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Mon Oct  5 06:49:35 2015
New Revision: 249302

URL: http://llvm.org/viewvc/llvm-project?rev=249302&view=rev
Log:
Use llvm::errc instead of std::errc.

Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=249302&r1=249301&r2=249302&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Oct  5 06:49:35 2015
@@ -641,7 +641,7 @@ std::unique_ptr
   if (llvm::sys::fs::exists(Status)) {
 // Fail early if we can't write to the final destination.
 if (!llvm::sys::fs::can_write(OutputPath)) {
-  Error = std::make_error_code(std::errc::operation_not_permitted);
+  Error = make_error_code(llvm::errc::operation_not_permitted);
   return nullptr;
 }
 


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


RE: [Patch][OpenCL] Custom atomic Builtin check ignores address space of a non-atomic pointer

2015-10-05 Thread Anastasia Stulova via cfe-commits
Thanks!

Yes, I agree it might make sense to drop the default AS parameter value in  
getPointerTo(). It doesn't seem like there is an enormous amount of places that 
need to be changed!

Cheers,
Anastasia

-Original Message-
From: Pekka Jääskeläinen [mailto:pekka.jaaskelai...@tut.fi] 
Sent: 02 October 2015 10:20
To: Anastasia Stulova; cfe-commits@lists.llvm.org
Subject: Re: [Patch][OpenCL] Custom atomic Builtin check ignores address space 
of a non-atomic pointer

LGTM.

Related to it:
There has been so many getPointerTo() issues with multi-AS in the past that I 
wonder if it'd be time to drop the default value from it, and go through all 
the places where it's called with the default AS, thus breaking multi-AS.  
Might be a worthwhile job to do at some point.

On 09/30/2015 01:23 PM, Anastasia Stulova via cfe-commits wrote:
> Hi all,
>
> Address spaces are not handled in custom semantic checks of atomic Builtins.
>
> If there are two pointers passed to the Builtin, it doesn't allow the 
> second
>
> (non-atomic) one to be qualified with an address space.
>
> This patch removed this restriction by recording the address space of 
> the
>
> passed pointers while checking its type correctness.
>
> Currently, the following code:
>
> _Atomic int __attribute__((address_space(1))) *A;
>
> int __attribute__((address_space(2))) *B;
>
> ...
>
> ... = __c11_atomic_compare_exchange_strong(A, B, 1, 
> memory_order_seq_cst, memory_order_seq_cst);
>
> fails to compile with an error:
>
> "passing '__attribute__((address_space(2))) int *' to parameter of 
> type 'int *' changes address space of pointer".
>
> Please, review the attached fix for it!
>
> Cheers,
>
> Anastasia
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>

--
Pekka



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


Re: [PATCH] D13203: [Clang] - Massaging code to fix MSVS 2015 win32-release configuration

2015-10-05 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Note: with VS Professional 14.0.23107.0 D14REL I do not get this error.


http://reviews.llvm.org/D13203



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


r249301 - [OpenCL] Fix casting a true boolean to an integer vector.

2015-10-05 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Mon Oct  5 06:27:41 2015
New Revision: 249301

URL: http://llvm.org/viewvc/llvm-project?rev=249301&view=rev
Log:
[OpenCL] Fix casting a true boolean to an integer vector.

OpenCL v1.1 s6.2.2: for the boolean value true, every bit in the result vector 
should be set.

This change treats the i1 value as signed for the purposes of performing the 
cast to integer,
and therefore sign extend into the result.

Patch by Neil Hickey!

http://reviews.llvm.org/D13349


Added:
cfe/trunk/test/CodeGenOpenCL/bool_cast.cl
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=249301&r1=249300&r2=249301&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Oct  5 06:27:41 2015
@@ -151,6 +151,9 @@ public:
   Value *EmitScalarConversion(Value *Src, QualType SrcTy, QualType DstTy,
   SourceLocation Loc);
 
+  Value *EmitScalarConversion(Value *Src, QualType SrcTy, QualType DstTy,
+  SourceLocation Loc, bool TreatBooleanAsSigned);
+
   /// Emit a conversion from the specified complex type to the specified
   /// destination type, where the destination type is an LLVM scalar type.
   Value *EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
@@ -733,6 +736,13 @@ void ScalarExprEmitter::EmitFloatConvers
 Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
QualType DstType,
SourceLocation Loc) {
+  return EmitScalarConversion(Src, SrcType, DstType, Loc, false);
+}
+
+Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
+   QualType DstType,
+   SourceLocation Loc,
+   bool TreatBooleanAsSigned) {
   SrcType = CGF.getContext().getCanonicalType(SrcType);
   DstType = CGF.getContext().getCanonicalType(DstType);
   if (SrcType == DstType) return Src;
@@ -807,7 +817,8 @@ Value *ScalarExprEmitter::EmitScalarConv
   if (DstType->isExtVectorType() && !SrcType->isVectorType()) {
 // Cast the scalar to element type
 QualType EltTy = DstType->getAs()->getElementType();
-llvm::Value *Elt = EmitScalarConversion(Src, SrcType, EltTy, Loc);
+llvm::Value *Elt = EmitScalarConversion(
+Src, SrcType, EltTy, Loc, CGF.getContext().getLangOpts().OpenCL);
 
 // Splat the element across to all elements
 unsigned NumElements = cast(DstTy)->getNumElements();
@@ -847,6 +858,9 @@ Value *ScalarExprEmitter::EmitScalarConv
 
   if (isa(SrcTy)) {
 bool InputSigned = SrcType->isSignedIntegerOrEnumerationType();
+if (SrcType->isBooleanType() && TreatBooleanAsSigned) {
+  InputSigned = true;
+}
 if (isa(DstTy))
   Res = Builder.CreateIntCast(Src, DstTy, InputSigned, "conv");
 else if (InputSigned)
@@ -1531,10 +1545,14 @@ Value *ScalarExprEmitter::VisitCastExpr(
   }
   case CK_VectorSplat: {
 llvm::Type *DstTy = ConvertType(DestTy);
-Value *Elt = Visit(const_cast(E));
-Elt = EmitScalarConversion(Elt, E->getType(),
+// Need an IgnoreImpCasts here as by default a boolean will be promoted to
+// an int, which will not perform the sign extension, so if we know we are
+// going to cast to a vector we have to strip the implicit cast off.
+Value *Elt = Visit(const_cast(E->IgnoreImpCasts()));
+Elt = EmitScalarConversion(Elt, E->IgnoreImpCasts()->getType(),
DestTy->getAs()->getElementType(),
-   CE->getExprLoc());
+   CE->getExprLoc(), 
+   CGF.getContext().getLangOpts().OpenCL);
 
 // Splat the element across to all elements
 unsigned NumElements = cast(DstTy)->getNumElements();

Added: cfe/trunk/test/CodeGenOpenCL/bool_cast.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/bool_cast.cl?rev=249301&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/bool_cast.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/bool_cast.cl Mon Oct  5 06:27:41 2015
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -O0 | FileCheck %s
+
+typedef unsigned char uchar4 __attribute((ext_vector_type(4)));
+typedef unsigned int int4 __attribute((ext_vector_type(4)));
+
+void kernel ker() {
+  bool t = true;
+  int4 vec4 = (int4)t;
+// CHECK: {{%.*}} = load i8, i8* %t, align 1
+// CHECK: {{%.*}} = trunc i8 {{%.*}} to i1
+// CHECK: {{%.*}} = sext i1 {{%.*}} to i32
+// CHECK: {{%.*}} = insertelement <4 x i32> undef, i32 {{%.*}}, i32 0
+// CHECK: {{%.*}} = shufflevector <

Re: [PATCH] D13430: [VFS] Add an in-memory file system implementation.

2015-10-05 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Basic/VirtualFileSystem.h:286-288
@@ +285,5 @@
+  }
+  std::error_code setCurrentWorkingDirectory(const Twine &Path) override {
+WorkingDirectory = Path.str();
+return std::error_code();
+  }

Return errc::success?


Comment at: lib/Basic/VirtualFileSystem.cpp:80
@@ -79,1 +79,3 @@
 
+// FIXME: This is copypasted from LLVM's file system implementation.
+std::error_code FileSystem::make_absolute(SmallVectorImpl &path) const {

What's the proposed fix? :)


Comment at: lib/Basic/VirtualFileSystem.cpp:312-316
@@ -229,4 +311,7 @@
 
 void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr FS) {
   FSList.push_back(FS);
+  // Synchronize added file systems by duplicating the working directory from
+  // the first one in the list.
+  FS->setCurrentWorkingDirectory(getCurrentWorkingDirectory().get());
 }

If I read this correctly, it gets and sets the pwd from FS for the first one? 
That seems superfluous.
(perhaps change the constructor to not use pushOverlay)


Comment at: lib/Basic/VirtualFileSystem.cpp:437
@@ +436,3 @@
+  virtual ~InMemoryNode() {}
+  Status &getStatus() { return Stat; }
+  InMemoryNodeKind getKind() const { return Kind; }

Do we want to make this const?


Comment at: lib/Basic/VirtualFileSystem.cpp:439
@@ +438,3 @@
+  InMemoryNodeKind getKind() const { return Kind; }
+  virtual std::string toString(unsigned Indent) = 0;
+};

This probably wants to be const.


Comment at: lib/Basic/VirtualFileSystem.cpp:461
@@ +460,3 @@
+class InMemoryFileAdaptor : public File {
+  InMemoryFile &Parent;
+

I think parent is a misleading name here (parent implies a hierarchy, but this 
is a simple adapter). Perhaps "Node".


Comment at: lib/Basic/VirtualFileSystem.cpp:476
@@ +475,3 @@
+  std::error_code close() override { return std::error_code(); }
+  void setName(StringRef Name) override { Parent.getStatus().setName(Name); }
+};

Is this used in the File interface? It seems - strange... is this really a "mv" 
implementation?


Comment at: lib/Basic/VirtualFileSystem.cpp:546-550
@@ +545,7 @@
+// End of the path, create a new file.
+Status Stat(Path, "", getNextVirtualUniqueID(),
+llvm::sys::TimeValue(ModificationTime), 0, 0,
+Buffer->getBufferSize(),
+llvm::sys::fs::file_type::regular_file,
+llvm::sys::fs::all_all);
+Dir->addChild(Name, llvm::make_unique(

I think we'll want to get some of these into the interface. But that's fine in 
a follow-up patch. Add a FIXME though.


Comment at: lib/Basic/VirtualFileSystem.cpp:800
@@ -455,1 +799,3 @@
 
+  std::string WorkingDirectory;
+

Doesn't the YAML FS work on the same pwd as the current process?


Comment at: unittests/Tooling/RewriterTestContext.h:42-45
@@ +41,6 @@
+ DiagnosticPrinter(llvm::outs(), &*DiagOpts),
+ InMemoryFileSystem(new vfs::InMemoryFileSystem),
+ OverlayFileSystem(
+ new vfs::OverlayFileSystem(vfs::getRealFileSystem())),
+ Files(FileSystemOptions(), OverlayFileSystem),
+ Sources(Diagnostics, Files), Rewrite(Sources, Options) {

Perhaps add a FIXME: To make these tests truly in-memory, we need to overlay 
the builtin headers.


http://reviews.llvm.org/D13430



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


Re: [PATCH] D13168: [OpenCL] OpenCL2.0 - Apply default address space rules

2015-10-05 Thread Anastasia Stulova via cfe-commits
Anastasia added inline comments.


Comment at: lib/Sema/SemaType.cpp:6282
@@ +6281,3 @@
+} else if (state.getCurrentChunkIndex() == 0 &&
+   D.getContext() == Declarator::FileContext &&
+   !D.isFunctionDeclarator() && !D.isFunctionDefinition() &&

pekka.jaaskelainen wrote:
> Should this "white list" the cases where it's safe to add the default AS, not 
> assume that it's applicable to any not listed here? Maybe safer that way.
It seems like there are no corresponding helper methods available in 
Declarator. So the code is therefore using negation everywhere. But also if we 
would add a helper function, I think we would implement it as a form of 
negation anyways.


http://reviews.llvm.org/D13168



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


  1   2   >