[PATCH] D31839: make -Winteger-overflow find overflows in function arguments

2017-04-11 Thread Nick Lewycky via Phabricator via cfe-commits
nlewycky added a comment.

In https://reviews.llvm.org/D31839#724551, @ahatanak wrote:

> OK, thanks for looking into it. Warnings for ObjCMessageExpr can probably be 
> implemented in a separate patch.
>
> It looks like clang still doesn't issue overflow warnings when the called 
> functions have a void return. Should we try to fix it in this patch too?
>
>   void foo(int);
>  
>   void test0() {
> foo(4068 * 1024 * 1024); // no warnings
>   }
>


That testcase and the ObjCMessageExpr can go together in another patch where we 
fix visiting of non-literal-type expressions. This patch is really about 
inconsistent visiting of the arguments of a CallExpr.

There's a problem with this patch, we sometimes revisit nodes leading to 
exponential time. I've written a fix to that locally but it's not upstreamable 
quality yet.


https://reviews.llvm.org/D31839



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


r300027 - [Modules] Remove darwin specific code to check for SystemVersion.plist

2017-04-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Apr 11 23:49:00 2017
New Revision: 300027

URL: http://llvm.org/viewvc/llvm-project?rev=300027=rev
Log:
[Modules] Remove darwin specific code to check for SystemVersion.plist

This isn't need anymore and modules options -fbuild-session-file and
-fmodules-validate-once-per-build-session already provide a sane
mechanism to validate the system headers.

rdar://problem/19767523

Removed:
cfe/trunk/test/Modules/system_version.m
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=300027=300026=300027=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 11 23:49:00 2017
@@ -2660,29 +2660,6 @@ std::string CompilerInvocation::getModul
 code = ext->hashExtension(code);
   }
 
-  // Darwin-specific hack: if we have a sysroot, use the contents and
-  // modification time of
-  //   $sysroot/System/Library/CoreServices/SystemVersion.plist
-  // as part of the module hash.
-  if (!hsOpts.Sysroot.empty()) {
-SmallString<128> systemVersionFile;
-systemVersionFile += hsOpts.Sysroot;
-llvm::sys::path::append(systemVersionFile, "System");
-llvm::sys::path::append(systemVersionFile, "Library");
-llvm::sys::path::append(systemVersionFile, "CoreServices");
-llvm::sys::path::append(systemVersionFile, "SystemVersion.plist");
-
-llvm::ErrorOr buffer =
-llvm::MemoryBuffer::getFile(systemVersionFile);
-if (buffer) {
-  code = hash_combine(code, buffer.get()->getBuffer());
-
-  struct stat statBuf;
-  if (stat(systemVersionFile.c_str(), ) == 0)
-code = hash_combine(code, statBuf.st_mtime);
-}
-  }
-
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }
 

Removed: cfe/trunk/test/Modules/system_version.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/system_version.m?rev=300026=auto
==
--- cfe/trunk/test/Modules/system_version.m (original)
+++ cfe/trunk/test/Modules/system_version.m (removed)
@@ -1,31 +0,0 @@
-// Test checking that we're hashing a system version file in the
-// module hash.
-
-// First, build a system root.
-// RUN: rm -rf %t
-// RUN: mkdir -p %t/usr/include
-// RUN: cp %S/Inputs/Modified/A.h %t/usr/include
-// RUN: cp %S/Inputs/Modified/B.h %t/usr/include
-// RUN: cp %S/Inputs/Modified/module.map %t/usr/include
-
-// Run once with no system version file. We should end up with one module.
-// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules 
-fimplicit-module-maps -isysroot %t -I %t/usr/include %s -verify
-// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 1
-
-// Add a system version file and run again. We should now have two
-// module variants.
-// RUN: mkdir -p %t/System/Library/CoreServices
-// RUN: echo "hello" > %t/System/Library/CoreServices/SystemVersion.plist
-// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules 
-fimplicit-module-maps -isysroot %t -I %t/usr/include %s -verify
-// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 2
-
-// Change the system version file and run again. We should now have three
-// module variants.
-// RUN: mkdir -p %t/System/Library/CoreServices
-// RUN: echo "modules" > %t/System/Library/CoreServices/SystemVersion.plist
-// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules 
-fimplicit-module-maps -isysroot %t -I %t/usr/include %s -verify
-// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 3
-
-// expected-no-diagnostics
-@import ModA;
-


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


[PATCH] D31839: make -Winteger-overflow find overflows in function arguments

2017-04-11 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

OK, thanks for looking into it. Warnings for ObjCMessageExpr can probably be 
implemented in a separate patch.

It looks like clang still doesn't issue overflow warnings when the called 
functions have a void return. Should we try to fix it in this patch too?

  void foo(int);
  
  void test0() {
foo(4068 * 1024 * 1024); // no warnings
  }


https://reviews.llvm.org/D31839



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


[PATCH] D30954: Modules: Simulate diagnostic settings for implicit modules

2017-04-11 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith closed this revision.
dexonsmith marked an inline comment as done.
dexonsmith added a comment.

And committed in:
r297770 c0c27f3 Modules: Optimize bitcode encoding of diagnostic state
r300021 5e5be8e Serialization: Skip check in WritePragmaDiagnosticMappings, NFC
r300024 91f051f Serialization: Emit the final diagnostic state last, almost NFC
r300025 d3992c5 Serialization: Simulate -Werror settings in implicit modules

Thanks again for the review.


https://reviews.llvm.org/D30954



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


r300025 - Serialization: Simulate -Werror settings in implicit modules

2017-04-11 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Tue Apr 11 22:58:58 2017
New Revision: 300025

URL: http://llvm.org/viewvc/llvm-project?rev=300025=rev
Log:
Serialization: Simulate -Werror settings in implicit modules

r293123 started serializing diagnostic pragma state for modules.  This
makes the serialization work properly for implicit modules.

An implicit module build (using Clang's internal build system) uses the
same PCM file location for different `-Werror` levels.

E.g., if a TU has `-Werror=format` and tries to load a PCM built without
`-Werror=format`, a new PCM will be built in its place (and the new PCM
should have the same signature, since r297655).  In the other direction,
if a TU does not have `-Werror=format` and tries to load a PCM built
with `-Werror=format`, it should "just work".

The idea is to evolve the PCM toward the strictest -Werror flags that
anyone tries.

r293123 started serializing the diagnostic pragma state for each PCM.
Since this encodes the -Werror settings at module-build time, it breaks
the implicit build model.

This commit filters the diagnostic state in order to simulate the
current compilation's diagnostic settings.  Firstly, it ignores the
module's serialized first diagnostic state, replacing it with the state
from this compilation's command-line.  Secondly, if a pragma warning was
upgraded to error/fatal when generating the PCM (e.g., due to `-Werror`
on the command-line), it checks whether it should still be upgraded in
its current context.

Added:
cfe/trunk/test/Modules/Inputs/implicit-built-Werror-using-W/
cfe/trunk/test/Modules/Inputs/implicit-built-Werror-using-W/convert.h
cfe/trunk/test/Modules/Inputs/implicit-built-Werror-using-W/module.modulemap
cfe/trunk/test/Modules/implicit-built-Werror-using-W.cpp
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Basic/DiagnosticIDs.h
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=300025=300024=300025=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue Apr 11 22:58:58 2017
@@ -223,6 +223,9 @@ private:
 void setMapping(diag::kind Diag, DiagnosticMapping Info) {
   DiagMap[Diag] = Info;
 }
+DiagnosticMapping lookupMapping(diag::kind Diag) const {
+  return DiagMap.lookup(Diag);
+}
 
 DiagnosticMapping (diag::kind Diag);
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=300025=300024=300025=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Tue Apr 11 22:58:58 2017
@@ -84,6 +84,7 @@ class DiagnosticMapping {
   unsigned IsPragma : 1;
   unsigned HasNoWarningAsError : 1;
   unsigned HasNoErrorAsFatal : 1;
+  unsigned WasUpgradedFromWarning : 1;
 
 public:
   static DiagnosticMapping Make(diag::Severity Severity, bool IsUser,
@@ -94,6 +95,7 @@ public:
 Result.IsPragma = IsPragma;
 Result.HasNoWarningAsError = 0;
 Result.HasNoErrorAsFatal = 0;
+Result.WasUpgradedFromWarning = 0;
 return Result;
   }
 
@@ -103,11 +105,33 @@ public:
   bool isUser() const { return IsUser; }
   bool isPragma() const { return IsPragma; }
 
+  bool isErrorOrFatal() const {
+return getSeverity() == diag::Severity::Error ||
+   getSeverity() == diag::Severity::Fatal;
+  }
+
   bool hasNoWarningAsError() const { return HasNoWarningAsError; }
   void setNoWarningAsError(bool Value) { HasNoWarningAsError = Value; }
 
   bool hasNoErrorAsFatal() const { return HasNoErrorAsFatal; }
   void setNoErrorAsFatal(bool Value) { HasNoErrorAsFatal = Value; }
+
+  /// Whether this mapping attempted to map the diagnostic to a warning, but
+  /// was overruled because the diagnostic was already mapped to an error or
+  /// fatal error.
+  bool wasUpgradedFromWarning() const { return WasUpgradedFromWarning; }
+  void setUpgradedFromWarning(bool Value) { WasUpgradedFromWarning = Value; }
+
+  /// Serialize the bits that aren't based on context.
+  unsigned serializeBits() const {
+return (WasUpgradedFromWarning << 3) | Severity;
+  }
+  static diag::Severity deserializeSeverity(unsigned Bits) {
+return (diag::Severity)(Bits & 0x7);
+  }
+  static bool deserializeUpgradedFromWarning(unsigned Bits) {
+return Bits >> 3;
+  }
 };
 
 /// \brief Used for handling and querying diagnostic IDs.

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=300025=300024=300025=diff

r300024 - Serialization: Emit the final diagnostic state last, almost NFC

2017-04-11 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Tue Apr 11 22:45:32 2017
New Revision: 300024

URL: http://llvm.org/viewvc/llvm-project?rev=300024=rev
Log:
Serialization: Emit the final diagnostic state last, almost NFC

Emit the final diagnostic state last to match source order.  This also
prepares for a follow-up commit for implicit modules.

There's no real functionaliy change, just a slightly different AST file
format.

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=300024=300023=300024=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Apr 11 22:45:32 2017
@@ -5533,27 +5533,16 @@ void ASTReader::ReadPragmaDiagnosticMapp
   return NewState;
 };
 
+// Read the first state.
 auto *FirstState = ReadDiagState(
 F.isModule() ? DiagState() : *Diag.DiagStatesByLoc.CurDiagState,
 SourceLocation(), F.isModule());
-SourceLocation CurStateLoc =
-ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]);
-auto *CurState = ReadDiagState(*FirstState, CurStateLoc, false);
 
-if (!F.isModule()) {
-  Diag.DiagStatesByLoc.CurDiagState = CurState;
-  Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
-
-  // Preserve the property that the imaginary root file describes the
-  // current state.
-  auto  = Diag.DiagStatesByLoc.Files[FileID()].StateTransitions;
-  if (T.empty())
-T.push_back({CurState, 0});
-  else
-T[0].State = CurState;
-}
-
-while (Idx < Record.size()) {
+// Read the state transitions.
+unsigned NumLocations = Record[Idx++];
+while (NumLocations--) {
+  assert(Idx < Record.size() &&
+ "Invalid data, missing pragma diagnostic states");
   SourceLocation Loc = ReadSourceLocation(F, Record[Idx++]);
   auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc);
   assert(IDAndOffset.second == 0 && "not a start location for a FileID");
@@ -5573,6 +5562,26 @@ void ASTReader::ReadPragmaDiagnosticMapp
   }
 }
 
+// Read the final state.
+assert(Idx < Record.size() &&
+   "Invalid data, missing final pragma diagnostic state");
+SourceLocation CurStateLoc =
+ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]);
+auto *CurState = ReadDiagState(*FirstState, CurStateLoc, false);
+
+if (!F.isModule()) {
+  Diag.DiagStatesByLoc.CurDiagState = CurState;
+  Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
+
+  // Preserve the property that the imaginary root file describes the
+  // current state.
+  auto  = Diag.DiagStatesByLoc.Files[FileID()].StateTransitions;
+  if (T.empty())
+T.push_back({CurState, 0});
+  else
+T[0].State = CurState;
+}
+
 // Don't try to read these mappings again.
 Record.clear();
   }

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=300024=300023=300024=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Apr 11 22:45:32 2017
@@ -2888,13 +2888,18 @@ void ASTWriter::WritePragmaDiagnosticMap
   };
 
   AddDiagState(Diag.DiagStatesByLoc.FirstDiagState, isModule);
-  AddSourceLocation(Diag.DiagStatesByLoc.CurDiagStateLoc, Record);
-  AddDiagState(Diag.DiagStatesByLoc.CurDiagState, false);
 
+  // Reserve a spot for the number of locations with state transitions.
+  auto NumLocationsIdx = Record.size();
+  Record.emplace_back();
+
+  // Emit the state transitions.
+  unsigned NumLocations = 0;
   for (auto  : Diag.DiagStatesByLoc.Files) {
 if (!FileIDAndFile.first.isValid() ||
 !FileIDAndFile.second.HasLocalTransitions)
   continue;
+++NumLocations;
 
AddSourceLocation(Diag.SourceMgr->getLocForStartOfFile(FileIDAndFile.first),
   Record);
 Record.push_back(FileIDAndFile.second.StateTransitions.size());
@@ -2904,6 +2909,13 @@ void ASTWriter::WritePragmaDiagnosticMap
 }
   }
 
+  // Backpatch the number of locations.
+  Record[NumLocationsIdx] = NumLocations;
+
+  // Emit CurDiagStateLoc.  Do it last in order to match source order.
+  AddSourceLocation(Diag.DiagStatesByLoc.CurDiagStateLoc, Record);
+  AddDiagState(Diag.DiagStatesByLoc.CurDiagState, false);
+
   Stream.EmitRecord(DIAG_PRAGMA_MAPPINGS, Record);
 }
 


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


r300021 - Serialization: Skip check in WritePragmaDiagnosticMappings, NFC

2017-04-11 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Tue Apr 11 21:31:17 2017
New Revision: 300021

URL: http://llvm.org/viewvc/llvm-project?rev=300021=rev
Log:
Serialization: Skip check in WritePragmaDiagnosticMappings, NFC

The record is never empty, since we always serialize the initial state.
Skip the check.

Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=300021=300020=300021=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Apr 11 21:31:17 2017
@@ -2904,8 +2904,7 @@ void ASTWriter::WritePragmaDiagnosticMap
 }
   }
 
-  if (!Record.empty())
-Stream.EmitRecord(DIAG_PRAGMA_MAPPINGS, Record);
+  Stream.EmitRecord(DIAG_PRAGMA_MAPPINGS, Record);
 }
 
 
//===--===//


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


[libunwind] r300020 - Reland "[CMake][libunwind] Use -nodefaultlibs for CMake checks"

2017-04-11 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Apr 11 21:28:07 2017
New Revision: 300020

URL: http://llvm.org/viewvc/llvm-project?rev=300020=rev
Log:
Reland "[CMake][libunwind] Use -nodefaultlibs for CMake checks"

This is a reland of commit r299796.

Turned out that we need gcc_s or compiler-rt on ARM when checking
the support for -funwind-tables which creates a dependency on
__aeabi_unwind_cpp_pr0 symbol that's provided by the compiler
runtime.

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

Added:
libunwind/trunk/cmake/Modules/
libunwind/trunk/cmake/Modules/HandleCompilerRT.cmake
Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/cmake/config-ix.cmake

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=300020=300019=300020=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Tue Apr 11 21:28:07 2017
@@ -8,6 +8,13 @@ if (POLICY CMP0042)
   cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default
 endif()
 
+# Add path for custom modules
+set(CMAKE_MODULE_PATH
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
+  ${CMAKE_MODULE_PATH}
+  )
+
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   project(libunwind)
 
@@ -111,6 +118,7 @@ endif()
 
#===
 # Setup CMake Options
 
#===
+include(HandleCompilerRT)
 
 # Define options.
 option(LIBUNWIND_BUILD_32_BITS "Build 32 bit libunwind" ${LLVM_BUILD_32_BITS})
@@ -122,6 +130,7 @@ option(LIBUNWIND_ENABLE_STATIC "Build li
 option(LIBUNWIND_ENABLE_CROSS_UNWINDING "Enable cross-platform unwinding 
support." OFF)
 option(LIBUNWIND_ENABLE_ARM_WMMX "Enable unwinding support for ARM WMMX 
registers." OFF)
 option(LIBUNWIND_ENABLE_THREADS "Build libunwind with threading support." ON)
+option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." 
${LLVM_INCLUDE_DOCS})
 
 set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross 
compiling.")
@@ -187,6 +196,10 @@ add_target_flags_if(LIBUNWIND_SYSROOT
 # Configure compiler.
 include(config-ix)
 
+if (LIBUNWIND_USE_COMPILER_RT)
+  list(APPEND LIBUNWIND_LINK_FLAGS "-rtlib=compiler-rt")
+endif()
+
 
#===
 # Setup Compiler Flags
 
#===

Added: libunwind/trunk/cmake/Modules/HandleCompilerRT.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/Modules/HandleCompilerRT.cmake?rev=300020=auto
==
--- libunwind/trunk/cmake/Modules/HandleCompilerRT.cmake (added)
+++ libunwind/trunk/cmake/Modules/HandleCompilerRT.cmake Tue Apr 11 21:28:07 
2017
@@ -0,0 +1,58 @@
+function(find_compiler_rt_library name dest)
+  if (NOT DEFINED LIBUNWIND_COMPILE_FLAGS)
+message(FATAL_ERROR "LIBUNWIND_COMPILE_FLAGS must be defined when using 
this function")
+  endif()
+  set(dest "" PARENT_SCOPE)
+  set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${TARGET_TRIPLE} 
${LIBUNWIND_COMPILE_FLAGS}
+  "--rtlib=compiler-rt" "--print-libgcc-file-name")
+  if (CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_CXX_COMPILER_TARGET)
+list(APPEND CLANG_COMMAND "--target=${CMAKE_CXX_COMPILER_TARGET}")
+  endif()
+  execute_process(
+  COMMAND ${CLANG_COMMAND}
+  RESULT_VARIABLE HAD_ERROR
+  OUTPUT_VARIABLE LIBRARY_FILE
+  )
+  string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
+  string(REPLACE "builtins" "${name}" LIBRARY_FILE "${LIBRARY_FILE}")
+  if (NOT HAD_ERROR AND EXISTS "${LIBRARY_FILE}")
+message(STATUS "Found compiler-rt library: ${LIBRARY_FILE}")
+set(${dest} "${LIBRARY_FILE}" PARENT_SCOPE)
+  else()
+message(STATUS "Failed to find compiler-rt library")
+  endif()
+endfunction()
+
+function(find_compiler_rt_dir dest)
+  if (NOT DEFINED LIBUNWIND_COMPILE_FLAGS)
+message(FATAL_ERROR "LIBUNWIND_COMPILE_FLAGS must be defined when using 
this function")
+  endif()
+  set(dest "" PARENT_SCOPE)
+  if (APPLE)
+set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBUNWIND_COMPILE_FLAGS}
+"-print-file-name=lib")
+execute_process(
+COMMAND ${CLANG_COMMAND}
+RESULT_VARIABLE HAD_ERROR
+OUTPUT_VARIABLE LIBRARY_DIR
+)
+string(STRIP "${LIBRARY_DIR}" LIBRARY_DIR)
+set(LIBRARY_DIR "${LIBRARY_DIR}/darwin")
+  else()
+set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBUNWIND_COMPILE_FLAGS}
+"--rtlib=compiler-rt" "--print-libgcc-file-name")
+execute_process(
+COMMAND ${CLANG_COMMAND}
+RESULT_VARIABLE HAD_ERROR
+OUTPUT_VARIABLE LIBRARY_FILE
+)
+string(STRIP 

Re: r300001 - Revert r298824 & r298816, recommit r298742 & r298754

2017-04-11 Thread Richard Smith via cfe-commits
Either this or your other ODR hash change seems to have broken the modules
buildbot:

http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/6274/steps/compile.llvm.stage2/logs/stdio

On 11 April 2017 at 15:32, Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Tue Apr 11 17:32:03 2017
> New Revision: 31
>
> URL: http://llvm.org/viewvc/llvm-project?rev=31=rev
> Log:
> Revert r298824 & r298816, recommit r298742 & r298754
>
> r299989 fixes the underlying issue by waiting long enough to late parsed
> arguments to be processed before doing an calculating the hash.
>
> r298742
> [ODRHash] Add error messages for mismatched parameters in methods.
>
> r298754
> [ODRHash] Add support for array and decayed types.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> cfe/trunk/lib/AST/ODRHash.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/test/Modules/odr_hash.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSerializationKinds.td?rev=31=30=31=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Apr
> 11 17:32:03 2017
> @@ -146,7 +146,12 @@ def err_module_odr_violation_mismatch_de
>"method %4 is %select{not static|static}5|"
>"method %4 is %select{not volatile|volatile}5|"
>"method %4 is %select{not const|const}5|"
> -  "method %4 is %select{not inline|inline}5}3">;
> +  "method %4 is %select{not inline|inline}5|"
> +  "method %4 that has %5 parameter%s5|"
> +  "method %4 with %ordinal5 parameter of type %6%select{| decayed from
> %8}7|"
> +  "method %4 with %ordinal5 parameter named %6|"
> +  "method %4 with %ordinal5 parameter with %select{no |}6default
> argument|"
> +  "method %4 with %ordinal5 parameter with default argument}3">;
>
>  def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0'
> found "
>"%select{"
> @@ -166,7 +171,12 @@ def note_module_odr_violation_mismatch_d
>"method %2 is %select{not static|static}3|"
>"method %2 is %select{not volatile|volatile}3|"
>"method %2 is %select{not const|const}3|"
> -  "method %2 is %select{not inline|inline}3}1">;
> +  "method %2 is %select{not inline|inline}3|"
> +  "method %2 that has %3 parameter%s3|"
> +  "method %2 with %ordinal3 parameter of type %4%select{| decayed from
> %6}5|"
> +  "method %2 with %ordinal3 parameter named %4|"
> +  "method %2 with %ordinal3 parameter with %select{no |}4default
> argument|"
> +  "method %2 with %ordinal3 parameter with different default argument}1">;
>
>  def warn_module_uses_date_time : Warning<
>"%select{precompiled header|module}0 uses __DATE__ or __TIME__">,
>
> Modified: cfe/trunk/lib/AST/ODRHash.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ODRHash.cpp?rev=31=30=31=diff
> 
> ==
> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
> +++ cfe/trunk/lib/AST/ODRHash.cpp Tue Apr 11 17:32:03 2017
> @@ -169,6 +169,11 @@ public:
>  Inherited::VisitValueDecl(D);
>}
>
> +  void VisitParmVarDecl(const ParmVarDecl *D) {
> +AddStmt(D->getDefaultArg());
> +Inherited::VisitParmVarDecl(D);
> +  }
> +
>void VisitAccessSpecDecl(const AccessSpecDecl *D) {
>  ID.AddInteger(D->getAccess());
>  Inherited::VisitAccessSpecDecl(D);
> @@ -202,6 +207,12 @@ public:
>  Hash.AddBoolean(D->isPure());
>  Hash.AddBoolean(D->isDeletedAsWritten());
>
> +ID.AddInteger(D->param_size());
> +
> +for (auto *Param : D->parameters()) {
> +  Hash.AddSubDecl(Param);
> +}
> +
>  Inherited::VisitFunctionDecl(D);
>}
>
> @@ -315,6 +326,14 @@ public:
>  }
>}
>
> +  void AddQualType(QualType T) {
> +Hash.AddQualType(T);
> +  }
> +
> +  void VisitQualifiers(Qualifiers Quals) {
> +ID.AddInteger(Quals.getAsOpaqueValue());
> +  }
> +
>void Visit(const Type *T) {
>  ID.AddInteger(T->getTypeClass());
>  Inherited::Visit(T);
> @@ -322,11 +341,92 @@ public:
>
>void VisitType(const Type *T) {}
>
> +  void VisitAdjustedType(const AdjustedType *T) {
> +AddQualType(T->getOriginalType());
> +AddQualType(T->getAdjustedType());
> +VisitType(T);
> +  }
> +
> +  void VisitDecayedType(const DecayedType *T) {
> +AddQualType(T->getDecayedType());
> +AddQualType(T->getPointeeType());
> +VisitAdjustedType(T);
> +  }
> +
> +  void VisitArrayType(const ArrayType *T) {
> +AddQualType(T->getElementType());
> +ID.AddInteger(T->getSizeModifier());
> +VisitQualifiers(T->getIndexTypeQualifiers());
> +VisitType(T);
> +  }
> +  void VisitConstantArrayType(const ConstantArrayType *T) {
> 

r300014 - [IR] Add AttributeSet to hide AttributeSetNode* again, NFC

2017-04-11 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Apr 11 19:38:00 2017
New Revision: 300014

URL: http://llvm.org/viewvc/llvm-project?rev=300014=rev
Log:
[IR] Add AttributeSet to hide AttributeSetNode* again, NFC

Summary:
For now, it just wraps AttributeSetNode*. Eventually, it will hold
AvailableAttrs as an inline bitset, and adding and removing enum
attributes will be super cheap.

This sinks AttributeSetNode back down to lib/IR/AttributeImpl.h.

Reviewers: pete, chandlerc

Subscribers: llvm-commits, jfb

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=300014=300013=300014=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Apr 11 19:38:00 2017
@@ -2935,7 +2935,7 @@ static void replaceUsesOfNonProtoConstan
   continue;
 
 // Get the call site's attribute list.
-SmallVector newAttrs;
+SmallVector newAttrs;
 llvm::AttributeList oldAttrs = callSite.getAttributes();
 
 // Collect any return attributes from the call.


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


[PATCH] D31966: [libcxx] [test] Avoid Clang's -Wunused-const-variable in is_constructible.pass.cpp.

2017-04-11 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT created this revision.

[libcxx] [test] Avoid Clang's -Wunused-const-variable in 
is_constructible.pass.cpp.

This happens when using Clang with MSVC's STL, so there are no actual uses of 
this variable.


https://reviews.llvm.org/D31966

Files:
  test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp


Index: 
test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
===
--- test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
+++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
@@ -251,6 +251,7 @@
 LIBCPP_STATIC_ASSERT(
 clang_disallows_valid_static_cast_bug !=
 std::__libcpp_is_constructible>::value, "");
+((void)clang_disallows_valid_static_cast_bug); // Prevent unused warning
 #else
 static_assert(clang_disallows_valid_static_cast_bug == false, "");
 LIBCPP_STATIC_ASSERT(std::__libcpp_is_constructible>::value, "");


Index: test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
===
--- test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
+++ test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp
@@ -251,6 +251,7 @@
 LIBCPP_STATIC_ASSERT(
 clang_disallows_valid_static_cast_bug !=
 std::__libcpp_is_constructible>::value, "");
+((void)clang_disallows_valid_static_cast_bug); // Prevent unused warning
 #else
 static_assert(clang_disallows_valid_static_cast_bug == false, "");
 LIBCPP_STATIC_ASSERT(std::__libcpp_is_constructible>::value, "");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31839: make -Winteger-overflow find overflows in function arguments

2017-04-11 Thread Nick Lewycky via Phabricator via cfe-commits
nlewycky added a comment.

In https://reviews.llvm.org/D31839#722763, @ahatanak wrote:

> Is it possible to fix ObjCMessageExpr too while you are in here?


I looked into this, but it turns out to be different enough to belong in a 
separate patch. An ObjCMessageExpr has void type which means that we bail very 
early in the expression evaluator since void isn't a literal type. I think the 
original design of the code was to turn an Expr* into an APValue, and as we 
push it past that original purpose we're going to need to restructure it a bit.

> I think clang should issue a warning when compiling the following code:
> 
>   @protocol NSObject
>   @end
>   
>   @interface NSObject
>   @end
>   
>   @interface C1 : NSObject
>   - (void)foo:(int)i;
>   @end
>   @implementation C1
>   - (void)foo:(int)i {
>   }
>   @end
>   
>   void test1(C1 *c) {
> [c foo:(4068 * 1024 * 1024)];
>   }




https://reviews.llvm.org/D31839



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


[libcxx] r300009 - Add some FAIL constexpr tests for optional's copy/move ctors.

2017-04-11 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Apr 11 19:07:29 2017
New Revision: 39

URL: http://llvm.org/viewvc/llvm-project?rev=39=rev
Log:
Add some FAIL constexpr tests for optional's copy/move ctors.

Added:

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp

Added: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp?rev=39=auto
==
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/copy.fail.cpp
 Tue Apr 11 19:07:29 2017
@@ -0,0 +1,36 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// 
+
+// constexpr optional(const optional& rhs);
+//   If is_trivially_copy_constructible_v is true, 
+//this constructor shall be a constexpr constructor.
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+struct S {
+   constexpr S()   : v_(0) {}
+   S(int v): v_(v) {}
+   S(const S ) : v_(rhs.v_) {}  // make it not trivially copyable
+   int v_;
+   };
+   
+
+int main()
+{
+static_assert (!std::is_trivially_copy_constructible_v, "" );
+constexpr std::optional o1;
+constexpr std::optional o2 = o1;  // not constexpr
+}

Added: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp?rev=39=auto
==
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/move.fail.cpp
 Tue Apr 11 19:07:29 2017
@@ -0,0 +1,37 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// 
+
+// constexpr optional(const optional&& rhs);
+//   If is_trivially_move_constructible_v is true, 
+//this constructor shall be a constexpr constructor.
+
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+struct S {
+   constexpr S()   : v_(0) {}
+   S(int v): v_(v) {}
+   constexpr S(const S  ) : v_(rhs.v_) {} // not trivially moveable
+   constexpr S(const S &) : v_(rhs.v_) {} // not trivially moveable
+   int v_;
+   };
+   
+
+int main()
+{
+static_assert (!std::is_trivially_move_constructible_v, "" );
+constexpr std::optional o1;
+constexpr std::optional o2 = std::move(o1);  // not constexpr
+}


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


r300006 - Silence unused variable warning in release builds.

2017-04-11 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Apr 11 18:06:49 2017
New Revision: 36

URL: http://llvm.org/viewvc/llvm-project?rev=36=rev
Log:
Silence unused variable warning in release builds.

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

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=36=35=36=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Tue Apr 11 18:06:49 2017
@@ -177,6 +177,7 @@ void ExternalASTMerger::FindExternalLexi
 Decl *ImportedDecl =
 IP.Forward->Import(const_cast(SourceDecl));
 assert(ImportedDecl->getDeclContext() == DC);
+(void)ImportedDecl;
   }
 }
   });


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


Re: r298824 - Revert r298742 "[ODRHash] Add error messages for mismatched parameters in methods."

2017-04-11 Thread Richard Trieu via cfe-commits
r299989 should prevent the build breakages.  I have recommited my changes
in r31.

On Sun, Mar 26, 2017 at 2:39 PM, Vassil Vassilev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vvassilev
> Date: Sun Mar 26 16:39:16 2017
> New Revision: 298824
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298824=rev
> Log:
> Revert r298742 "[ODRHash] Add error messages for mismatched parameters in
> methods."
>
> I failed to revert this in r298816.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> cfe/trunk/lib/AST/ODRHash.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/test/Modules/odr_hash.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSerializationKinds.td?rev=298824=298823=298824=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Sun Mar
> 26 16:39:16 2017
> @@ -146,12 +146,7 @@ def err_module_odr_violation_mismatch_de
>"method %4 is %select{not static|static}5|"
>"method %4 is %select{not volatile|volatile}5|"
>"method %4 is %select{not const|const}5|"
> -  "method %4 is %select{not inline|inline}5|"
> -  "method %4 that has %5 parameter%s5|"
> -  "method %4 with %ordinal5 parameter of type %6|"
> -  "method %4 with %ordinal5 parameter named %6|"
> -  "method %4 with %ordinal5 parameter with %select{no |}6default
> argument|"
> -  "method %4 with %ordinal5 parameter with default argument}3">;
> +  "method %4 is %select{not inline|inline}5}3">;
>
>  def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0'
> found "
>"%select{"
> @@ -171,12 +166,7 @@ def note_module_odr_violation_mismatch_d
>"method %2 is %select{not static|static}3|"
>"method %2 is %select{not volatile|volatile}3|"
>"method %2 is %select{not const|const}3|"
> -  "method %2 is %select{not inline|inline}3|"
> -  "method %2 that has %3 parameter%s3|"
> -  "method %2 with %ordinal3 parameter of type %4|"
> -  "method %2 with %ordinal3 parameter named %4|"
> -  "method %2 with %ordinal3 parameter with %select{no |}4default
> argument|"
> -  "method %2 with %ordinal3 parameter with different default argument}1">;
> +  "method %2 is %select{not inline|inline}3}1">;
>
>  def warn_module_uses_date_time : Warning<
>"%select{precompiled header|module}0 uses __DATE__ or __TIME__">,
>
> Modified: cfe/trunk/lib/AST/ODRHash.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ODRHash.cpp?rev=298824=298823=298824=diff
> 
> ==
> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
> +++ cfe/trunk/lib/AST/ODRHash.cpp Sun Mar 26 16:39:16 2017
> @@ -169,11 +169,6 @@ public:
>  Inherited::VisitValueDecl(D);
>}
>
> -  void VisitParmVarDecl(const ParmVarDecl *D) {
> -AddStmt(D->getDefaultArg());
> -Inherited::VisitParmVarDecl(D);
> -  }
> -
>void VisitAccessSpecDecl(const AccessSpecDecl *D) {
>  ID.AddInteger(D->getAccess());
>  Inherited::VisitAccessSpecDecl(D);
> @@ -207,12 +202,6 @@ public:
>  Hash.AddBoolean(D->isPure());
>  Hash.AddBoolean(D->isDeletedAsWritten());
>
> -ID.AddInteger(D->param_size());
> -
> -for (auto *Param : D->parameters()) {
> -  Hash.AddSubDecl(Param);
> -}
> -
>  Inherited::VisitFunctionDecl(D);
>}
>
> @@ -326,10 +315,6 @@ public:
>  }
>}
>
> -  void AddQualType(QualType T) {
> -Hash.AddQualType(T);
> -  }
> -
>void Visit(const Type *T) {
>  ID.AddInteger(T->getTypeClass());
>  Inherited::Visit(T);
> @@ -342,50 +327,6 @@ public:
>  VisitType(T);
>}
>
> -  void VisitFunctionType(const FunctionType *T) {
> -AddQualType(T->getReturnType());
> -T->getExtInfo().Profile(ID);
> -Hash.AddBoolean(T->isConst());
> -Hash.AddBoolean(T->isVolatile());
> -Hash.AddBoolean(T->isRestrict());
> -VisitType(T);
> -  }
> -
> -  void VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
> -VisitFunctionType(T);
> -  }
> -
> -  void VisitFunctionProtoType(const FunctionProtoType *T) {
> -ID.AddInteger(T->getNumParams());
> -for (auto ParamType : T->getParamTypes())
> -  AddQualType(ParamType);
> -
> -const auto  = T->getExtProtoInfo();
> -ID.AddInteger(epi.Variadic);
> -ID.AddInteger(epi.TypeQuals);
> -ID.AddInteger(epi.RefQualifier);
> -ID.AddInteger(epi.ExceptionSpec.Type);
> -
> -if (epi.ExceptionSpec.Type == EST_Dynamic) {
> -  for (QualType Ex : epi.ExceptionSpec.Exceptions)
> -AddQualType(Ex);
> -} else if (epi.ExceptionSpec.Type == EST_ComputedNoexcept &&
> -   epi.ExceptionSpec.NoexceptExpr) {
> -  AddStmt(epi.ExceptionSpec.NoexceptExpr);
> -} else if 

Re: r298816 - Revert 298754 and 298742.

2017-04-11 Thread Richard Trieu via cfe-commits
r299989 should prevent the build breakages.  I have recommited my changes
in r31.

On Sun, Mar 26, 2017 at 11:32 AM, Vassil Vassilev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: vvassilev
> Date: Sun Mar 26 13:32:53 2017
> New Revision: 298816
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298816=rev
> Log:
> Revert 298754 and 298742.
>
> They broke llvm modules builds and our internal modules infrastructure.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> cfe/trunk/lib/AST/ODRHash.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/test/Modules/odr_hash.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSerializationKinds.td?rev=298816=298815=298816=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
> (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Sun Mar
> 26 13:32:53 2017
> @@ -148,7 +148,7 @@ def err_module_odr_violation_mismatch_de
>"method %4 is %select{not const|const}5|"
>"method %4 is %select{not inline|inline}5|"
>"method %4 that has %5 parameter%s5|"
> -  "method %4 with %ordinal5 parameter of type %6%select{| decayed from
> %8}7|"
> +  "method %4 with %ordinal5 parameter of type %6|"
>"method %4 with %ordinal5 parameter named %6|"
>"method %4 with %ordinal5 parameter with %select{no |}6default
> argument|"
>"method %4 with %ordinal5 parameter with default argument}3">;
> @@ -173,7 +173,7 @@ def note_module_odr_violation_mismatch_d
>"method %2 is %select{not const|const}3|"
>"method %2 is %select{not inline|inline}3|"
>"method %2 that has %3 parameter%s3|"
> -  "method %2 with %ordinal3 parameter of type %4%select{| decayed from
> %6}5|"
> +  "method %2 with %ordinal3 parameter of type %4|"
>"method %2 with %ordinal3 parameter named %4|"
>"method %2 with %ordinal3 parameter with %select{no |}4default
> argument|"
>"method %2 with %ordinal3 parameter with different default argument}1">;
>
> Modified: cfe/trunk/lib/AST/ODRHash.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ODRHash.cpp?rev=298816=298815=298816=diff
> 
> ==
> --- cfe/trunk/lib/AST/ODRHash.cpp (original)
> +++ cfe/trunk/lib/AST/ODRHash.cpp Sun Mar 26 13:32:53 2017
> @@ -330,10 +330,6 @@ public:
>  Hash.AddQualType(T);
>}
>
> -  void VisitQualifiers(Qualifiers Quals) {
> -ID.AddInteger(Quals.getAsOpaqueValue());
> -  }
> -
>void Visit(const Type *T) {
>  ID.AddInteger(T->getTypeClass());
>  Inherited::Visit(T);
> @@ -341,43 +337,6 @@ public:
>
>void VisitType(const Type *T) {}
>
> -  void VisitAdjustedType(const AdjustedType *T) {
> -AddQualType(T->getOriginalType());
> -AddQualType(T->getAdjustedType());
> -VisitType(T);
> -  }
> -
> -  void VisitDecayedType(const DecayedType *T) {
> -AddQualType(T->getDecayedType());
> -AddQualType(T->getPointeeType());
> -VisitAdjustedType(T);
> -  }
> -
> -  void VisitArrayType(const ArrayType *T) {
> -AddQualType(T->getElementType());
> -ID.AddInteger(T->getSizeModifier());
> -VisitQualifiers(T->getIndexTypeQualifiers());
> -VisitType(T);
> -  }
> -  void VisitConstantArrayType(const ConstantArrayType *T) {
> -T->getSize().Profile(ID);
> -VisitArrayType(T);
> -  }
> -
> -  void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
> -AddStmt(T->getSizeExpr());
> -VisitArrayType(T);
> -  }
> -
> -  void VisitIncompleteArrayType(const IncompleteArrayType *T) {
> -VisitArrayType(T);
> -  }
> -
> -  void VisitVariableArrayType(const VariableArrayType *T) {
> -AddStmt(T->getSizeExpr());
> -VisitArrayType(T);
> -  }
> -
>void VisitBuiltinType(const BuiltinType *T) {
>  ID.AddInteger(T->getKind());
>  VisitType(T);
>
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Serialization/ASTReader.cpp?rev=298816=298815=298816=diff
> 
> ==
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Sun Mar 26 13:32:53 2017
> @@ -9586,33 +9586,13 @@ void ASTReader::diagnoseOdrViolations()
>  for (unsigned I = 0; I < FirstNumParameters; ++I) {
>const ParmVarDecl *FirstParam = FirstMethod->getParamDecl(I);
>const ParmVarDecl *SecondParam = SecondMethod->getParamDecl(I);
> -
> -  QualType FirstParamType = FirstParam->getType();
> -  QualType SecondParamType = SecondParam->getType();
> -  if (FirstParamType != SecondParamType) {
> -if (const DecayedType *ParamDecayedType =
> -

r300001 - Revert r298824 & r298816, recommit r298742 & r298754

2017-04-11 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Apr 11 17:32:03 2017
New Revision: 31

URL: http://llvm.org/viewvc/llvm-project?rev=31=rev
Log:
Revert r298824 & r298816, recommit r298742 & r298754

r299989 fixes the underlying issue by waiting long enough to late parsed
arguments to be processed before doing an calculating the hash.

r298742
[ODRHash] Add error messages for mismatched parameters in methods.

r298754
[ODRHash] Add support for array and decayed types.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=31=30=31=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Apr 11 
17:32:03 2017
@@ -146,7 +146,12 @@ def err_module_odr_violation_mismatch_de
   "method %4 is %select{not static|static}5|"
   "method %4 is %select{not volatile|volatile}5|"
   "method %4 is %select{not const|const}5|"
-  "method %4 is %select{not inline|inline}5}3">;
+  "method %4 is %select{not inline|inline}5|"
+  "method %4 that has %5 parameter%s5|"
+  "method %4 with %ordinal5 parameter of type %6%select{| decayed from %8}7|"
+  "method %4 with %ordinal5 parameter named %6|"
+  "method %4 with %ordinal5 parameter with %select{no |}6default argument|"
+  "method %4 with %ordinal5 parameter with default argument}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
   "%select{"
@@ -166,7 +171,12 @@ def note_module_odr_violation_mismatch_d
   "method %2 is %select{not static|static}3|"
   "method %2 is %select{not volatile|volatile}3|"
   "method %2 is %select{not const|const}3|"
-  "method %2 is %select{not inline|inline}3}1">;
+  "method %2 is %select{not inline|inline}3|"
+  "method %2 that has %3 parameter%s3|"
+  "method %2 with %ordinal3 parameter of type %4%select{| decayed from %6}5|"
+  "method %2 with %ordinal3 parameter named %4|"
+  "method %2 with %ordinal3 parameter with %select{no |}4default argument|"
+  "method %2 with %ordinal3 parameter with different default argument}1">;
 
 def warn_module_uses_date_time : Warning<
   "%select{precompiled header|module}0 uses __DATE__ or __TIME__">,

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=31=30=31=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue Apr 11 17:32:03 2017
@@ -169,6 +169,11 @@ public:
 Inherited::VisitValueDecl(D);
   }
 
+  void VisitParmVarDecl(const ParmVarDecl *D) {
+AddStmt(D->getDefaultArg());
+Inherited::VisitParmVarDecl(D);
+  }
+
   void VisitAccessSpecDecl(const AccessSpecDecl *D) {
 ID.AddInteger(D->getAccess());
 Inherited::VisitAccessSpecDecl(D);
@@ -202,6 +207,12 @@ public:
 Hash.AddBoolean(D->isPure());
 Hash.AddBoolean(D->isDeletedAsWritten());
 
+ID.AddInteger(D->param_size());
+
+for (auto *Param : D->parameters()) {
+  Hash.AddSubDecl(Param);
+}
+
 Inherited::VisitFunctionDecl(D);
   }
 
@@ -315,6 +326,14 @@ public:
 }
   }
 
+  void AddQualType(QualType T) {
+Hash.AddQualType(T);
+  }
+
+  void VisitQualifiers(Qualifiers Quals) {
+ID.AddInteger(Quals.getAsOpaqueValue());
+  }
+
   void Visit(const Type *T) {
 ID.AddInteger(T->getTypeClass());
 Inherited::Visit(T);
@@ -322,11 +341,92 @@ public:
 
   void VisitType(const Type *T) {}
 
+  void VisitAdjustedType(const AdjustedType *T) {
+AddQualType(T->getOriginalType());
+AddQualType(T->getAdjustedType());
+VisitType(T);
+  }
+
+  void VisitDecayedType(const DecayedType *T) {
+AddQualType(T->getDecayedType());
+AddQualType(T->getPointeeType());
+VisitAdjustedType(T);
+  }
+
+  void VisitArrayType(const ArrayType *T) {
+AddQualType(T->getElementType());
+ID.AddInteger(T->getSizeModifier());
+VisitQualifiers(T->getIndexTypeQualifiers());
+VisitType(T);
+  }
+  void VisitConstantArrayType(const ConstantArrayType *T) {
+T->getSize().Profile(ID);
+VisitArrayType(T);
+  }
+
+  void VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
+AddStmt(T->getSizeExpr());
+VisitArrayType(T);
+  }
+
+  void VisitIncompleteArrayType(const IncompleteArrayType *T) {
+VisitArrayType(T);
+  }
+
+  void VisitVariableArrayType(const VariableArrayType *T) {
+AddStmt(T->getSizeExpr());
+VisitArrayType(T);
+  }
+
   void VisitBuiltinType(const BuiltinType *T) {
 ID.AddInteger(T->getKind());
 VisitType(T);
   }
 
+  void 

[PATCH] D7573: [libc++] Fix PR20084 - std::is_function<void() const> failed.

2017-04-11 Thread Eric Niebler via Phabricator via cfe-commits
eric_niebler added a comment.

I just ran into this problem while trying to get range-v3 working on clang-3.6. 
This `is_function` implementation //probably// instantiates fewer templates 
than the version currently shipping with libc++. Disclaimer: I haven't tested 
it exhaustively yet.

  template
  struct priority_tag
  : priority_tag
  {};
  
  template<>
  struct priority_tag<0>
  {};
  
  // Function types here:
  template
  char (_function_impl_(priority_tag<0>))[1];
  
  // Array types here:
  template
  char (_function_impl_(priority_tag<1>))[2];
  
  // Anything that can be returned from a function here (including
  // void and reference types):
  template
  char (_function_impl_(priority_tag<2>))[3];
  
  // Classes and unions (including abstract types) here:
  template
  char (_function_impl_(priority_tag<3>))[4];
  
  template 
  struct is_function
  : integral_constant{})) 
== 1>
  {};




https://reviews.llvm.org/D7573



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


[PATCH] D31673: Allow casting C pointers declared using extern "C" to ObjC pointer types

2017-04-11 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL22: [Sema][ObjC] Check whether a variable has a 
definition, rather than (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D31673?vs=94686=94899#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31673

Files:
  cfe/trunk/lib/Sema/SemaExprObjC.cpp
  cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm


Index: cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm
===
--- cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm
+++ cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm
@@ -52,3 +52,19 @@
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateSomething();
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateNSString();
 }
+
+struct __CFAnnotatedObject {
+} cf0;
+
+extern const CFAnnotatedObjectRef r0;
+extern const CFAnnotatedObjectRef r1 = 
+extern "C" const CFAnnotatedObjectRef r2;
+extern "C" const CFAnnotatedObjectRef r3 = 
+
+void testExternC() {
+  id obj;
+  obj = (id)r0;
+  obj = (id)r1; // expected-error{{cast of C pointer type 
'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C 
pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to 
convert directly}} expected-note{{use __bridge_transfer to transfer ownership 
of a +1 'CFAnnotatedObjectRef'}}
+  obj = (id)r2;
+  obj = (id)r3; // expected-error{{cast of C pointer type 
'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C 
pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to 
convert directly}} expected-note{{use __bridge_transfer to transfer ownership 
of a +1 'CFAnnotatedObjectRef'}}
+}
Index: cfe/trunk/lib/Sema/SemaExprObjC.cpp
===
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp
@@ -3355,7 +3355,7 @@
   if (isAnyRetainable(TargetClass) &&
   isAnyRetainable(SourceClass) &&
   var &&
-  var->getStorageClass() == SC_Extern &&
+  !var->hasDefinition(Context) &&
   var->getType().isConstQualified()) {
 
 // In system headers, they can also be assumed to be immune to retains.


Index: cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm
===
--- cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm
+++ cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm
@@ -52,3 +52,19 @@
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateSomething();
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateNSString();
 }
+
+struct __CFAnnotatedObject {
+} cf0;
+
+extern const CFAnnotatedObjectRef r0;
+extern const CFAnnotatedObjectRef r1 = 
+extern "C" const CFAnnotatedObjectRef r2;
+extern "C" const CFAnnotatedObjectRef r3 = 
+
+void testExternC() {
+  id obj;
+  obj = (id)r0;
+  obj = (id)r1; // expected-error{{cast of C pointer type 'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to convert directly}} expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFAnnotatedObjectRef'}}
+  obj = (id)r2;
+  obj = (id)r3; // expected-error{{cast of C pointer type 'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to convert directly}} expected-note{{use __bridge_transfer to transfer ownership of a +1 'CFAnnotatedObjectRef'}}
+}
Index: cfe/trunk/lib/Sema/SemaExprObjC.cpp
===
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp
@@ -3355,7 +3355,7 @@
   if (isAnyRetainable(TargetClass) &&
   isAnyRetainable(SourceClass) &&
   var &&
-  var->getStorageClass() == SC_Extern &&
+  !var->hasDefinition(Context) &&
   var->getType().isConstQualified()) {
 
 // In system headers, they can also be assumed to be immune to retains.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r299992 - [Sema][ObjC] Check whether a variable has a definition, rather than

2017-04-11 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Tue Apr 11 17:01:33 2017
New Revision: 22

URL: http://llvm.org/viewvc/llvm-project?rev=22=rev
Log:
[Sema][ObjC] Check whether a variable has a definition, rather than
checking its storage class, when determining whether casting a C pointer
to an ObjC pointer is allowed.

This change allows casting variables whose declarations are directly
contained in a linkage specification to an ObjC pointer type. Those
variables are treated as if they contain the extern specifier for the
purpose of determining whether they are definitions or not.

rdar://problem/29249853

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

Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=22=21=22=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Tue Apr 11 17:01:33 2017
@@ -3355,7 +3355,7 @@ namespace {
   if (isAnyRetainable(TargetClass) &&
   isAnyRetainable(SourceClass) &&
   var &&
-  var->getStorageClass() == SC_Extern &&
+  !var->hasDefinition(Context) &&
   var->getType().isConstQualified()) {
 
 // In system headers, they can also be assumed to be immune to retains.

Modified: cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm?rev=22=21=22=diff
==
--- cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm (original)
+++ cfe/trunk/test/SemaObjCXX/arc-bridged-cast.mm Tue Apr 11 17:01:33 2017
@@ -52,3 +52,19 @@ void testObjCBridgeId() {
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateSomething();
   ref = (__bridge_retained CFAnnotatedObjectRef) CreateNSString();
 }
+
+struct __CFAnnotatedObject {
+} cf0;
+
+extern const CFAnnotatedObjectRef r0;
+extern const CFAnnotatedObjectRef r1 = 
+extern "C" const CFAnnotatedObjectRef r2;
+extern "C" const CFAnnotatedObjectRef r3 = 
+
+void testExternC() {
+  id obj;
+  obj = (id)r0;
+  obj = (id)r1; // expected-error{{cast of C pointer type 
'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C 
pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to 
convert directly}} expected-note{{use __bridge_transfer to transfer ownership 
of a +1 'CFAnnotatedObjectRef'}}
+  obj = (id)r2;
+  obj = (id)r3; // expected-error{{cast of C pointer type 
'CFAnnotatedObjectRef' (aka 'const __CFAnnotatedObject *') to Objective-C 
pointer type 'id' requires a bridged cast}} expected-note{{use __bridge to 
convert directly}} expected-note{{use __bridge_transfer to transfer ownership 
of a +1 'CFAnnotatedObjectRef'}}
+}


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


r299989 - [ODRHash] Improve handling of hash values

2017-04-11 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue Apr 11 16:31:00 2017
New Revision: 299989

URL: http://llvm.org/viewvc/llvm-project?rev=299989=rev
Log:
[ODRHash] Improve handling of hash values

Calculating the hash in Sema::ActOnTagFinishDefinition could happen before
all sub-Decls were parsed or processed, which would produce the wrong hash
value.  Change to calculating the hash on the first use and storing the value
instead.  Also, avoid using the macros that were only for Boolean fields and
use an explicit checker during the DefintionData merge.  No functional change,
but was this blocking other ODRHash patches.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=299989=299988=299989=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Apr 11 16:31:00 2017
@@ -464,6 +464,8 @@ class CXXRecordDecl : public RecordDecl
 /// \brief Whether we are currently parsing base specifiers.
 unsigned IsParsingBaseSpecifiers : 1;
 
+unsigned HasODRHash : 1;
+
 /// \brief A hash of parts of the class to help in ODR checking.
 unsigned ODRHash;
 
@@ -712,8 +714,7 @@ public:
 return data().IsParsingBaseSpecifiers;
   }
 
-  void computeODRHash();
-  unsigned getODRHash() const { return data().ODRHash; }
+  unsigned getODRHash() const;
 
   /// \brief Sets the base classes of this struct or class.
   void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=299989=299988=299989=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Apr 11 16:31:00 2017
@@ -73,8 +73,9 @@ CXXRecordDecl::DefinitionData::Definitio
   ImplicitCopyAssignmentHasConstParam(true),
   HasDeclaredCopyConstructorWithConstParam(false),
   HasDeclaredCopyAssignmentWithConstParam(false), IsLambda(false),
-  IsParsingBaseSpecifiers(false), ODRHash(0), NumBases(0), NumVBases(0),
-  Bases(), VBases(), Definition(D), FirstFriend() {}
+  IsParsingBaseSpecifiers(false), HasODRHash(false), ODRHash(0),
+  NumBases(0), NumVBases(0), Bases(), VBases(), Definition(D),
+  FirstFriend() {}
 
 CXXBaseSpecifier *CXXRecordDecl::DefinitionData::getBasesSlowCase() const {
   return Bases.get(Definition->getASTContext().getExternalSource());
@@ -381,16 +382,23 @@ CXXRecordDecl::setBases(CXXBaseSpecifier
   data().IsParsingBaseSpecifiers = false;
 }
 
-void CXXRecordDecl::computeODRHash() {
-  if (!DefinitionData)
-return;
+unsigned CXXRecordDecl::getODRHash() const {
+  assert(hasDefinition() && "ODRHash only for records with definitions");
 
-  ODRHash Hash;
-  Hash.AddCXXRecordDecl(this);
+  // Previously calculated hash is stored in DefinitionData.
+  if (DefinitionData->HasODRHash)
+return DefinitionData->ODRHash;
 
+  // Only calculate hash on first call of getODRHash per record.
+  ODRHash Hash;
+  Hash.AddCXXRecordDecl(getDefinition());
+  DefinitionData->HasODRHash = true;
   DefinitionData->ODRHash = Hash.CalculateHash();
+
+  return DefinitionData->ODRHash;
 }
 
+
 void CXXRecordDecl::addedClassSubobject(CXXRecordDecl *Subobj) {
   // C++11 [class.copy]p11:
   //   A defaulted copy/move constructor for a class X is defined as

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=299989=299988=299989=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 11 16:31:00 2017
@@ -13797,10 +13797,8 @@ void Sema::ActOnTagFinishDefinition(Scop
   RD->completeDefinition();
   }
 
-  if (auto *RD = dyn_cast(Tag)) {
+  if (isa(Tag)) {
 FieldCollector->FinishClass();
-if (Context.getLangOpts().Modules)
-  RD->computeODRHash();
   }
 
   // Exit this scope of this tag's definition.

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=299989=299988=299989=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Apr 11 16:31:00 2017
@@ -1536,6 +1536,7 @@ void ASTDeclReader::ReadCXXDefinitionDat
   Data.HasDeclaredCopyConstructorWithConstParam = Record.readInt();
   Data.HasDeclaredCopyAssignmentWithConstParam = Record.readInt();
   

r299987 - Modular Codegen: Support homing debug info for types in modular objects

2017-04-11 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Apr 11 16:13:37 2017
New Revision: 299987

URL: http://llvm.org/viewvc/llvm-project?rev=299987=rev
Log:
Modular Codegen: Support homing debug info for types in modular objects

Matching the function-homing support for modular codegen. Any type
implicitly (implicit template specializations) or explicitly defined in
a module is attached to that module's object file and omitted elsewhere
(only a declaration used if necessary for references).

Modified:
cfe/trunk/include/clang/AST/ExternalASTSource.h
cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/AST/ExternalASTSource.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/Modules/Inputs/codegen-nodep/foo.h
cfe/trunk/test/Modules/codegen-nodep.test
cfe/trunk/test/Modules/codegen.test

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=299987=299986=299987=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Tue Apr 11 16:13:37 2017
@@ -172,7 +172,7 @@ public:
 
   enum ExtKind { EK_Always, EK_Never, EK_ReplyHazy };
 
-  virtual ExtKind hasExternalDefinitions(const FunctionDecl *FD);
+  virtual ExtKind hasExternalDefinitions(const Decl *D);
 
   /// \brief Finds all declarations lexically contained within the given
   /// DeclContext, after applying an optional filter predicate.

Modified: cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h?rev=299987=299986=299987=diff
==
--- cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h (original)
+++ cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h Tue Apr 11 
16:13:37 2017
@@ -90,7 +90,7 @@ public:
   /// initializers themselves.
   CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) 
override;
 
-  ExtKind hasExternalDefinitions(const FunctionDecl *FD) override;
+  ExtKind hasExternalDefinitions(const Decl *D) override;
 
   /// \brief Find all declarations with the given name in the
   /// given context.

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=299987=299986=299987=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Apr 11 16:13:37 2017
@@ -1115,7 +1115,7 @@ private:
   /// predefines buffer may contain additional definitions.
   std::string SuggestedPredefines;
 
-  llvm::DenseMap BodySource;
+  llvm::DenseMap BodySource;
 
   /// \brief Reads a statement from the specified cursor.
   Stmt *ReadStmtFromStream(ModuleFile );
@@ -1999,7 +1999,7 @@ public:
   /// \brief Return a descriptor for the corresponding module.
   llvm::Optional getSourceDescriptor(unsigned ID) 
override;
 
-  ExtKind hasExternalDefinitions(const FunctionDecl *FD) override;
+  ExtKind hasExternalDefinitions(const Decl *D) override;
 
   /// \brief Retrieve a selector from the given module with its local ID
   /// number.

Modified: cfe/trunk/lib/AST/ExternalASTSource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTSource.cpp?rev=299987=299986=299987=diff
==
--- cfe/trunk/lib/AST/ExternalASTSource.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTSource.cpp Tue Apr 11 16:13:37 2017
@@ -29,7 +29,7 @@ ExternalASTSource::getSourceDescriptor(u
 }
 
 ExternalASTSource::ExtKind
-ExternalASTSource::hasExternalDefinitions(const FunctionDecl *FD) {
+ExternalASTSource::hasExternalDefinitions(const Decl *D) {
   return EK_ReplyHazy;
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=299987=299986=299987=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Apr 11 16:13:37 2017
@@ -1820,6 +1820,10 @@ static bool shouldOmitDefinition(codegen
   if (DebugTypeExtRefs && isDefinedInClangModule(RD->getDefinition()))
 return true;
 
+  if (auto *ES = RD->getASTContext().getExternalSource())
+if 

r299983 - [ExternalASTMerger] Removed a move constructor to address MSVC build failure

2017-04-11 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Tue Apr 11 15:51:21 2017
New Revision: 299983

URL: http://llvm.org/viewvc/llvm-project?rev=299983=rev
Log:
[ExternalASTMerger] Removed a move constructor to address MSVC build failure

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

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=299983=299982=299983=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Tue Apr 11 15:51:21 2017
@@ -23,7 +23,7 @@ namespace {
 
 template  struct Source {
   T t;
-  Source(T &) : t(std::move(t)) {}
+  Source(T t) : t(t) {}
   operator T() { return t; }
   template  U () { return t; }
   template  const U () const { return t; }


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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

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



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+  hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+  .bind("for_loop"),

hokein wrote:
> aaron.ballman wrote:
> > hokein wrote:
> > > aaron.ballman wrote:
> > > > hokein wrote:
> > > > > aaron.ballman wrote:
> > > > > > I'm really not keen on this. It will catch trivial cases, so there 
> > > > > > is some utility, but this will quickly fall apart with anything 
> > > > > > past the trivial case.
> > > > > The motivation of this check is to find code patterns like `for (int 
> > > > > i = 0; i < n; ++i) { v.push_back(i); }` and clean them in our 
> > > > > codebase (we have lots of similar cases). 
> > > > > [These](https://docs.google.com/document/d/1Bbc-6DlNs6zQujWD5-XOHWbfPJVMG7Z_T27Kv0WcFb4/edit?usp=sharing)
> > > > >  are all cases we want to support. Using `hasParent` is a simple and 
> > > > > sufficient way to do it IMO.
> > > > I'm not convinced of the utility without implementing this in a more 
> > > > sensitive way. Have you run this across any large code bases and found 
> > > > that it catches issues?
> > > Yeah, the check catches ~2800 cases (regexp shows ~17,000 total usages) 
> > > in our internal codebase. And all caught cases are what we are interested 
> > > in. It would catch more if we support for-range loops and iterator-based 
> > > for-loops. 
> > I wasn't worried about it not triggering often enough, I was worried about 
> > it triggering too often because of the lack of sensitivity. If you randomly 
> > sample some of those 2800 cases, do they reserve the space in a way that 
> > your check isn't catching?
> Ok, I see your concern now, thanks for pointing it out.
> 
> I have read through these caught cases. The results look reasonable. Most 
> cases (> 95%) are what we expected, the code pattern is like `vector v; 
> for (...) { v.push_back(...); }` where the vector definition statement and 
> for-loop statement are consecutive. Another option is to make the check more 
> strict (only detects the consecutive code pattern).
Okay, that sounds like it has utility then. Thank you for clarifying!


https://reviews.llvm.org/D31757



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


[PATCH] D29901: Modular Codegen: Add/use a bit in serialized function definitions to track whether they are the subject of modular codegen

2017-04-11 Thread David Blaikie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299982: Modular Codegen: Add/use a bit in serialized 
function definitions to track… (authored by dblaikie).

Changed prior to commit:
  https://reviews.llvm.org/D29901?vs=91193=94886#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29901

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/ExternalASTSource.h
  cfe/trunk/include/clang/Basic/Module.h
  cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
  cfe/trunk/include/clang/Serialization/ASTReader.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ExternalASTSource.cpp
  cfe/trunk/lib/Basic/Module.cpp
  cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
  cfe/trunk/test/Modules/Inputs/codegen-nodep/foo.h
  cfe/trunk/test/Modules/Inputs/codegen-nodep/foo.modulemap
  cfe/trunk/test/Modules/Inputs/codegen/foo.h
  cfe/trunk/test/Modules/Inputs/codegen/use.cpp
  cfe/trunk/test/Modules/codegen-nodep.test
  cfe/trunk/test/Modules/codegen.test

Index: cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
===
--- cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
+++ cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -90,7 +90,7 @@
   /// initializers themselves.
   CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) override;
 
-  ExtKind hasExternalDefinitions(unsigned ID) override;
+  ExtKind hasExternalDefinitions(const FunctionDecl *FD) override;
 
   /// \brief Find all declarations with the given name in the
   /// given context.
Index: cfe/trunk/include/clang/Basic/Module.h
===
--- cfe/trunk/include/clang/Basic/Module.h
+++ cfe/trunk/include/clang/Basic/Module.h
@@ -215,8 +215,6 @@
   /// and headers from used modules.
   unsigned NoUndeclaredIncludes : 1;
 
-  unsigned WithCodegen : 1;
-
   /// \brief Describes the visibility of the various names within a
   /// particular module.
   enum NameVisibilityKind {
Index: cfe/trunk/include/clang/Serialization/ASTReader.h
===
--- cfe/trunk/include/clang/Serialization/ASTReader.h
+++ cfe/trunk/include/clang/Serialization/ASTReader.h
@@ -1115,6 +1115,8 @@
   /// predefines buffer may contain additional definitions.
   std::string SuggestedPredefines;
 
+  llvm::DenseMap BodySource;
+
   /// \brief Reads a statement from the specified cursor.
   Stmt *ReadStmtFromStream(ModuleFile );
 
@@ -1997,7 +1999,7 @@
   /// \brief Return a descriptor for the corresponding module.
   llvm::Optional getSourceDescriptor(unsigned ID) override;
 
-  ExtKind hasExternalDefinitions(unsigned ID) override;
+  ExtKind hasExternalDefinitions(const FunctionDecl *FD) override;
 
   /// \brief Retrieve a selector from the given module with its local ID
   /// number.
Index: cfe/trunk/include/clang/AST/ExternalASTSource.h
===
--- cfe/trunk/include/clang/AST/ExternalASTSource.h
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h
@@ -172,7 +172,7 @@
 
   enum ExtKind { EK_Always, EK_Never, EK_ReplyHazy };
 
-  virtual ExtKind hasExternalDefinitions(unsigned ID);
+  virtual ExtKind hasExternalDefinitions(const FunctionDecl *FD);
 
   /// \brief Finds all declarations lexically contained within the given
   /// DeclContext, after applying an optional filter predicate.
Index: cfe/trunk/include/clang/AST/ASTContext.h
===
--- cfe/trunk/include/clang/AST/ASTContext.h
+++ cfe/trunk/include/clang/AST/ASTContext.h
@@ -2510,7 +2510,7 @@
   ///
   /// \returns true if the function/var must be CodeGen'ed/deserialized even if
   /// it is not used.
-  bool DeclMustBeEmitted(const Decl *D, bool ForModularCodegen = false);
+  bool DeclMustBeEmitted(const Decl *D);
 
   const CXXConstructorDecl *
   getCopyConstructorForExceptionObject(CXXRecordDecl *RD);
Index: cfe/trunk/test/Modules/Inputs/codegen/use.cpp
===
--- cfe/trunk/test/Modules/Inputs/codegen/use.cpp
+++ cfe/trunk/test/Modules/Inputs/codegen/use.cpp
@@ -0,0 +1,8 @@
+#include "foo.h"
+void non_modular_use_of_implicit_dtor() {
+  implicit_dtor d1;
+  uninst_implicit_dtor d2;
+}
+void use_of_instantiated_declaration_without_definition() {
+  inst();
+}
Index: cfe/trunk/test/Modules/Inputs/codegen/foo.h
===
--- cfe/trunk/test/Modules/Inputs/codegen/foo.h
+++ cfe/trunk/test/Modules/Inputs/codegen/foo.h
@@ -2,3 +2,29 @@
   __builtin_va_list args;
   __builtin_va_start(args, fmt);
 }
+
+struct 

r299982 - Modular Codegen: Add/use a bit in serialized function definitions to track whether they are the subject of modular codegen

2017-04-11 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue Apr 11 15:46:34 2017
New Revision: 299982

URL: http://llvm.org/viewvc/llvm-project?rev=299982=rev
Log:
Modular Codegen: Add/use a bit in serialized function definitions to track 
whether they are the subject of modular codegen

Some decls are created not where they are written, but in other module
files/users (implicit special members and function template implicit
specializations). To correctly identify them, use a bit next to the definition
to track the modular codegen property.

Discussed whether the module file bit could be omitted in favor of
reconstituting from the modular codegen decls list - best guess today is that
the efficiency improvement of not having to deserialize the whole list whenever
any function is queried by a module user is worth it for the small size
increase of this redundant (list + bit-on-def) representation.

Reviewers: rsmith

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

Added:
cfe/trunk/test/Modules/Inputs/codegen-nodep/
cfe/trunk/test/Modules/Inputs/codegen-nodep/foo.h
cfe/trunk/test/Modules/Inputs/codegen-nodep/foo.modulemap
cfe/trunk/test/Modules/Inputs/codegen/use.cpp
cfe/trunk/test/Modules/codegen-nodep.test
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/ExternalASTSource.h
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExternalASTSource.cpp
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Sema/MultiplexExternalSemaSource.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/Modules/Inputs/codegen/foo.h
cfe/trunk/test/Modules/codegen.test

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=299982=299981=299982=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Apr 11 15:46:34 2017
@@ -2510,7 +2510,7 @@ public:
   ///
   /// \returns true if the function/var must be CodeGen'ed/deserialized even if
   /// it is not used.
-  bool DeclMustBeEmitted(const Decl *D, bool ForModularCodegen = false);
+  bool DeclMustBeEmitted(const Decl *D);
 
   const CXXConstructorDecl *
   getCopyConstructorForExceptionObject(CXXRecordDecl *RD);

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=299982=299981=299982=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Tue Apr 11 15:46:34 2017
@@ -172,7 +172,7 @@ public:
 
   enum ExtKind { EK_Always, EK_Never, EK_ReplyHazy };
 
-  virtual ExtKind hasExternalDefinitions(unsigned ID);
+  virtual ExtKind hasExternalDefinitions(const FunctionDecl *FD);
 
   /// \brief Finds all declarations lexically contained within the given
   /// DeclContext, after applying an optional filter predicate.

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=299982=299981=299982=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Tue Apr 11 15:46:34 2017
@@ -215,8 +215,6 @@ public:
   /// and headers from used modules.
   unsigned NoUndeclaredIncludes : 1;
 
-  unsigned WithCodegen : 1;
-
   /// \brief Describes the visibility of the various names within a
   /// particular module.
   enum NameVisibilityKind {

Modified: cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h?rev=299982=299981=299982=diff
==
--- cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h (original)
+++ cfe/trunk/include/clang/Sema/MultiplexExternalSemaSource.h Tue Apr 11 
15:46:34 2017
@@ -90,7 +90,7 @@ public:
   /// initializers themselves.
   CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) 
override;
 
-  ExtKind hasExternalDefinitions(unsigned ID) override;
+  ExtKind hasExternalDefinitions(const FunctionDecl *FD) override;
 
   /// \brief Find all declarations with the given name in the
   /// given context.

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 

[PATCH] D31440: PR32382: Adapt to LLVM changes in DIExpression.

2017-04-11 Thread Eric Christopher via Phabricator via cfe-commits
echristo requested changes to this revision.
echristo added a comment.
This revision now requires changes to proceed.

Sounds like Dave is asking for changes so I'll put it down as Request Changes 
to get it out of my queue. :)


https://reviews.llvm.org/D31440



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


[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Commit in r299981.


https://reviews.llvm.org/D31153



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


r299981 - Add const children() accessors to match the existing non-const children() accessors.

2017-04-11 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Apr 11 15:21:30 2017
New Revision: 299981

URL: http://llvm.org/viewvc/llvm-project?rev=299981=rev
Log:
Add const children() accessors to match the existing non-const children() 
accessors.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/StmtIterator.h
cfe/trunk/lib/AST/Expr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=299981=299980=299981=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Apr 11 15:21:30 2017
@@ -908,6 +908,10 @@ public:
 return child_range(child_iterator(), child_iterator());
   }
 
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   /// The source expression of an opaque value expression is the
   /// expression which originally generated the value.  This is
   /// provided as a convenience for analyses that don't wish to
@@ -1168,6 +1172,10 @@ public:
 return child_range(child_iterator(), child_iterator());
   }
 
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   friend TrailingObjects;
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
@@ -1223,6 +1231,9 @@ public:
 
   // Iterators
   child_range children() { return child_range(,  + 1); }
+  const_child_range children() const {
+return const_child_range(,  + 1);
+  }
 
   friend class ASTStmtReader;
 };
@@ -1316,6 +1327,9 @@ public:
   child_range children() {
 return child_range(child_iterator(), child_iterator());
   }
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
 };
 
 class CharacterLiteral : public Expr {
@@ -1366,6 +1380,9 @@ public:
   child_range children() {
 return child_range(child_iterator(), child_iterator());
   }
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
 };
 
 class FloatingLiteral : public Expr, private APFloatStorage {
@@ -1430,6 +1447,9 @@ public:
   child_range children() {
 return child_range(child_iterator(), child_iterator());
   }
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
 };
 
 /// ImaginaryLiteral - We support imaginary integer and floating point 
literals,
@@ -1462,6 +1482,9 @@ public:
 
   // Iterators
   child_range children() { return child_range(, +1); }
+  const_child_range children() const {
+return const_child_range(,  + 1);
+  }
 };
 
 /// StringLiteral - This represents a string literal expression, e.g. "foo"
@@ -1629,6 +1652,9 @@ public:
   child_range children() {
 return child_range(child_iterator(), child_iterator());
   }
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
 };
 
 /// ParenExpr - This represents a parethesized expression, e.g. "(1)".  This
@@ -1670,6 +1696,9 @@ public:
 
   // Iterators
   child_range children() { return child_range(, +1); }
+  const_child_range children() const {
+return const_child_range(,  + 1);
+  }
 };
 
 /// UnaryOperator - This represents the unary-expression's (except sizeof and
@@ -1779,6 +1808,9 @@ public:
 
   // Iterators
   child_range children() { return child_range(, +1); }
+  const_child_range children() const {
+return const_child_range(,  + 1);
+  }
 };
 
 /// Helper class for OffsetOfExpr.
@@ -1982,6 +2014,11 @@ public:
 Stmt **begin = reinterpret_cast(getTrailingObjects());
 return child_range(begin, begin + NumExprs);
   }
+  const_child_range children() const {
+Stmt *const *begin =
+reinterpret_cast(getTrailingObjects());
+return const_child_range(begin, begin + NumExprs);
+  }
   friend TrailingObjects;
 };
 
@@ -2070,6 +2107,7 @@ public:
 
   // Iterators
   child_range children();
+  const_child_range children() const;
 };
 
 
//===--===//
@@ -2154,6 +2192,9 @@ public:
   child_range children() {
 return child_range([0], [0]+END_EXPR);
   }
+  const_child_range children() const {
+return const_child_range([0], [0] + END_EXPR);
+  }
 };
 
 /// CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
@@ -2314,6 +2355,11 @@ public:
 return child_range([0],
[0]+NumArgs+getNumPreArgs()+PREARGS_START);
   }
+
+  const_child_range children() const {
+return const_child_range([0], [0] + NumArgs +
+   getNumPreArgs() + 
PREARGS_START);
+  }
 };
 
 /// Extra data stored in some MemberExpr objects.
@@ -2568,6 +2614,9 @@ public:
 
   // Iterators
   child_range children() { 

[PATCH] D30837: [libcxx] Support for shared_ptr<T()>

2017-04-11 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Ping!


https://reviews.llvm.org/D30837



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


Re: [PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Richard Smith via cfe-commits
On 11 April 2017 at 08:35, Marshall Clow via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> mclow.lists added a comment.
>
> Complete reproducer:
>
> // Tested with with:  clang++ -std=c++14 -Wunused-function
> UnusedFVassily.cpp
> //
> // UnusedFVassily.cpp:8:39: warning: unused function '__test'
> [-Wunused-function]
> // template  static __two __test(...);
> //   ^
> // UnusedFVassily.cpp:9:38: warning: unused function '__test'
> [-Wunused-function]
> // template  static char __test(typename _Up::pointer* = 0);
> //  ^
> // 2 warnings generated.
>
> #include 
>
> namespace foo {
>
> struct __two {char __lx; char __lxx;};
> namespace __has_pointer_type_imp
> {
>
>   template  static __two __test(...);
>   template  static char __test(typename _Up::pointer* = 0);
>
> }
>
> template 
> struct __has_pointer_type
>
>   : public std::integral_constant sizeof(__has_pointer_type_imp::__test<_Tp>(0))
> == 1>
>

This is a bug in libc++. If this header is included into two translation
units, they will be referencing different __test functions here (because
the template has internal linkage due to the 'static'), resulting in an ODR
violation.


> {
> };
>
> }
>
> struct S1 {};
> struct S2 { typedef void *pointer; };
>
> int main () {
> static_assert (!foo::__has_pointer_type::value, "" );
> static_assert ( foo::__has_pointer_type::value, "" );
> }
>
>
> https://reviews.llvm.org/D29877
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31692: [coroutines] Wrap the body of the coroutine in try-catch

2017-04-11 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added inline comments.



Comment at: lib/Sema/SemaCoroutine.cpp:977
+  // Since the body of the coroutine will be wrapped in try-catch, it will
+  // be incompativle with SEH __try if present in a function. 
+  if (!S.getLangOpts().Borland && Fn.FirstSEHTryLoc.isValid()) {

s/incompativle/incompatible


https://reviews.llvm.org/D31692



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


r299977 - [ExternalASTMerger] Fix the MSVC build

2017-04-11 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Tue Apr 11 14:50:37 2017
New Revision: 299977

URL: http://llvm.org/viewvc/llvm-project?rev=299977=rev
Log:
[ExternalASTMerger] Fix the MSVC build

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

Modified: cfe/trunk/lib/AST/ExternalASTMerger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTMerger.cpp?rev=299977=299976=299977=diff
==
--- cfe/trunk/lib/AST/ExternalASTMerger.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTMerger.cpp Tue Apr 11 14:50:37 2017
@@ -172,10 +172,10 @@ void ExternalASTMerger::FindExternalLexi
   ForEachMatchingDC(
   DC, Importers, [DC, IsKindWeWant](const ImporterPair ,
 Source SourceDC) {
-for (Source SourceDecl : SourceDC.get()->decls()) {
-  if (IsKindWeWant(SourceDecl.get()->getKind())) {
+for (const Decl *SourceDecl : SourceDC.get()->decls()) {
+  if (IsKindWeWant(SourceDecl->getKind())) {
 Decl *ImportedDecl =
-IP.Forward->Import(const_cast(SourceDecl.get()));
+IP.Forward->Import(const_cast(SourceDecl));
 assert(ImportedDecl->getDeclContext() == DC);
   }
 }


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


[PATCH] D31956: Implement (part of) LWG2857: `{variant, optional, any}::emplace` should return the constructed value

2017-04-11 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists created this revision.

Implement the `optional` and `any` part of this issue.

This changes the return type of these functions.


https://reviews.llvm.org/D31956

Files:
  include/any
  include/optional
  test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
  
test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp

Index: test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
@@ -10,7 +10,7 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// template  void optional::emplace(Args&&... args);
+// template  T& optional::emplace(Args&&... args);
 
 #include 
 #include 
@@ -51,27 +51,35 @@
 using Opt = std::optional;
 {
 Opt opt;
-opt.emplace();
+auto & v = opt.emplace();
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
 assert(*opt == T(0));
+assert( == &*opt);
 }
 {
 Opt opt;
-opt.emplace(1);
+auto & v = opt.emplace(1);
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
 assert(*opt == T(1));
+assert( == &*opt);
 }
 {
 Opt opt(2);
-opt.emplace();
+auto & v = opt.emplace();
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
 assert(*opt == T(0));
+assert( == &*opt);
 }
 {
 Opt opt(2);
-opt.emplace(1);
+auto & v = opt.emplace(1);
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
 assert(*opt == T(1));
+assert( == &*opt);
 }
 }
 
@@ -83,20 +91,26 @@
 using Opt = std::optional;
 {
 Opt opt;
-opt.emplace(101, 41);
+auto  = opt.emplace(101, 41);
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
+assert(   v == T(101, 41));
 assert(*opt == T(101, 41));
 }
 {
 Opt opt;
-opt.emplace({1, 2, 3, 4});
+auto  = opt.emplace({1, 2, 3, 4});
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
-assert(*opt == T(4)); // T sets its value to the size of the init list
+assert(  v == T(4)); // T sets its value to the size of the init list
+assert(*opt == T(4));
 }
 {
 Opt opt;
-opt.emplace({1, 2, 3, 4, 5}, 6);
+auto  = opt.emplace({1, 2, 3, 4, 5}, 6);
+static_assert( std::is_same_v, "" );
 assert(static_cast(opt) == true);
+assert(  v == T(5)); // T sets its value to the size of the init list
 assert(*opt == T(5)); // T sets its value to the size of the init list
 }
 }
@@ -109,7 +123,8 @@
 assert(T::alive == 0);
 {
 T::reset_constructors();
-opt.emplace();
+auto  = opt.emplace();
+static_assert( std::is_same_v, "" );
 assert(T::alive == 1);
 assert(T::constructed == 1);
 assert(T::default_constructed == 1);
@@ -116,10 +131,12 @@
 assert(T::destroyed == 0);
 assert(static_cast(opt) == true);
 assert(*opt == T());
+assert( == &*opt);
 }
 {
 T::reset_constructors();
-opt.emplace();
+auto  = opt.emplace();
+static_assert( std::is_same_v, "" );
 assert(T::alive == 1);
 assert(T::constructed == 1);
 assert(T::default_constructed == 1);
@@ -126,10 +143,12 @@
 assert(T::destroyed == 1);
 assert(static_cast(opt) == true);
 assert(*opt == T());
+assert( == &*opt);
 }
 {
 T::reset_constructors();
-opt.emplace(101);
+auto  = opt.emplace(101);
+static_assert( std::is_same_v, "" );
 assert(T::alive == 1);
 assert(T::constructed == 1);
 assert(T::value_constructed == 1);
@@ -136,10 +155,12 @@
 assert(T::destroyed == 1);
 assert(static_cast(opt) == true);
 assert(*opt == T(101));
+assert( == &*opt);
 }
 {
 T::reset_constructors();
-opt.emplace(-10, 99);
+auto  = opt.emplace(-10, 99);
+static_assert( std::is_same_v, "" );
 assert(T::alive == 1);
 assert(T::constructed == 1);
 assert(T::value_constructed == 1);
@@ -146,10 +167,12 @@
 assert(T::destroyed == 1);
 assert(static_cast(opt) == true);
 assert(*opt == T(-10, 99));
+assert( == &*opt);
 }
 {
 

[PATCH] D30435: [clang-import-test] Lookup inside entities

2017-04-11 Thread Sean Callanan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299976: [clang-import-test] Lookup inside contexts (authored 
by spyffe).

Changed prior to commit:
  https://reviews.llvm.org/D30435?vs=93929=94875#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30435

Files:
  cfe/trunk/include/clang/AST/ExternalASTMerger.h
  cfe/trunk/lib/AST/CMakeLists.txt
  cfe/trunk/lib/AST/ExternalASTMerger.cpp
  cfe/trunk/test/Import/forward-declared-struct/Inputs/S1.c
  cfe/trunk/test/Import/forward-declared-struct/Inputs/S2.c
  cfe/trunk/test/Import/forward-declared-struct/test.c
  cfe/trunk/test/Import/member-in-struct/Inputs/S.c
  cfe/trunk/test/Import/member-in-struct/test.c
  cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S1.c
  cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S2.c
  cfe/trunk/test/Import/multiple-forward-declarations/test.c
  cfe/trunk/test/Import/overloaded-function/Inputs/F1.c
  cfe/trunk/test/Import/overloaded-function/Inputs/F2.c
  cfe/trunk/test/Import/overloaded-function/test.c
  cfe/trunk/test/Import/struct-in-namespace/Inputs/N1.cpp
  cfe/trunk/test/Import/struct-in-namespace/Inputs/N2.cpp
  cfe/trunk/test/Import/struct-in-namespace/Inputs/N3.cpp
  cfe/trunk/test/Import/struct-in-namespace/test.cpp
  cfe/trunk/test/Import/template-specialization/Inputs/T.cpp
  cfe/trunk/test/Import/template-specialization/test.cpp
  cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Index: cfe/trunk/test/Import/multiple-forward-declarations/test.c
===
--- cfe/trunk/test/Import/multiple-forward-declarations/test.c
+++ cfe/trunk/test/Import/multiple-forward-declarations/test.c
@@ -0,0 +1,4 @@
+// RUN: clang-import-test -import %S/Inputs/S1.c --import %S/Inputs/S2.c -expression %s
+void expr() {
+  struct S *MySPtr;
+}
Index: cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S2.c
===
--- cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S2.c
+++ cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S2.c
@@ -0,0 +1 @@
+struct S;
Index: cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S1.c
===
--- cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S1.c
+++ cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S1.c
@@ -0,0 +1 @@
+struct S;
Index: cfe/trunk/test/Import/struct-in-namespace/Inputs/N3.cpp
===
--- cfe/trunk/test/Import/struct-in-namespace/Inputs/N3.cpp
+++ cfe/trunk/test/Import/struct-in-namespace/Inputs/N3.cpp
@@ -0,0 +1,5 @@
+namespace M {
+  struct V {
+int d;
+  };
+}
Index: cfe/trunk/test/Import/struct-in-namespace/Inputs/N2.cpp
===
--- cfe/trunk/test/Import/struct-in-namespace/Inputs/N2.cpp
+++ cfe/trunk/test/Import/struct-in-namespace/Inputs/N2.cpp
@@ -0,0 +1,5 @@
+namespace N {
+  struct U {
+int c;
+  };
+}
Index: cfe/trunk/test/Import/struct-in-namespace/Inputs/N1.cpp
===
--- cfe/trunk/test/Import/struct-in-namespace/Inputs/N1.cpp
+++ cfe/trunk/test/Import/struct-in-namespace/Inputs/N1.cpp
@@ -0,0 +1,11 @@
+namespace N {
+  struct S {
+int a;
+  };
+}
+
+namespace N {
+  struct T {
+int b;
+  };
+}
Index: cfe/trunk/test/Import/struct-in-namespace/test.cpp
===
--- cfe/trunk/test/Import/struct-in-namespace/test.cpp
+++ cfe/trunk/test/Import/struct-in-namespace/test.cpp
@@ -0,0 +1,7 @@
+// RUN: clang-import-test -import %S/Inputs/N1.cpp -import %S/Inputs/N2.cpp -import %S/Inputs/N3.cpp -expression %s
+void expr() {
+  N::S s;
+  N::T t;
+  N::U u;
+  int d = s.a + t.b + u.c;
+}
Index: cfe/trunk/test/Import/member-in-struct/Inputs/S.c
===
--- cfe/trunk/test/Import/member-in-struct/Inputs/S.c
+++ cfe/trunk/test/Import/member-in-struct/Inputs/S.c
@@ -0,0 +1,3 @@
+struct S {
+  int a;
+};
Index: cfe/trunk/test/Import/member-in-struct/test.c
===
--- cfe/trunk/test/Import/member-in-struct/test.c
+++ cfe/trunk/test/Import/member-in-struct/test.c
@@ -0,0 +1,5 @@
+// RUN: clang-import-test -import %S/Inputs/S.c -expression %s
+void expr() {
+  struct S MyS;
+  MyS.a = 3;
+}
Index: cfe/trunk/test/Import/template-specialization/Inputs/T.cpp
===
--- cfe/trunk/test/Import/template-specialization/Inputs/T.cpp
+++ cfe/trunk/test/Import/template-specialization/Inputs/T.cpp
@@ -0,0 +1,14 @@
+template  struct A {
+};
+
+template <> struct A {
+  struct B {
+int f;
+  };
+};
+
+template <> struct A {
+  struct B {
+int g;
+  };
+};
Index: 

r299976 - [clang-import-test] Lookup inside contexts

2017-04-11 Thread Sean Callanan via cfe-commits
Author: spyffe
Date: Tue Apr 11 14:33:35 2017
New Revision: 299976

URL: http://llvm.org/viewvc/llvm-project?rev=299976=rev
Log:
[clang-import-test] Lookup inside contexts

clang-import-test has until now been only able to report top-level Decls.
This is clearly insufficient; we should be able to look inside structs 
and namespaces also.  This patch adds new test cases for a variety of 
lookups inside existing ASTContexts, and adds the functionality necessar
to make most of these testcases work.  (One testcase is known to fail 
because of ASTImporter limitations when importing templates; I'll look 
into that separately.)

This patch also separates the core functionality out into 
ExternalASTMerger, an interface that allows clients like LLDB to make 
use of it.  clang-import-test now only has the machinery necessary to
set up the tests.

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

Added:
cfe/trunk/include/clang/AST/ExternalASTMerger.h
cfe/trunk/lib/AST/ExternalASTMerger.cpp
cfe/trunk/test/Import/forward-declared-struct/
cfe/trunk/test/Import/forward-declared-struct/Inputs/
cfe/trunk/test/Import/forward-declared-struct/Inputs/S1.c
cfe/trunk/test/Import/forward-declared-struct/Inputs/S2.c
cfe/trunk/test/Import/forward-declared-struct/test.c
cfe/trunk/test/Import/member-in-struct/
cfe/trunk/test/Import/member-in-struct/Inputs/
cfe/trunk/test/Import/member-in-struct/Inputs/S.c
cfe/trunk/test/Import/member-in-struct/test.c
cfe/trunk/test/Import/multiple-forward-declarations/
cfe/trunk/test/Import/multiple-forward-declarations/Inputs/
cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S1.c
cfe/trunk/test/Import/multiple-forward-declarations/Inputs/S2.c
cfe/trunk/test/Import/multiple-forward-declarations/test.c
cfe/trunk/test/Import/overloaded-function/
cfe/trunk/test/Import/overloaded-function/Inputs/
cfe/trunk/test/Import/overloaded-function/Inputs/F1.c
cfe/trunk/test/Import/overloaded-function/Inputs/F2.c
cfe/trunk/test/Import/overloaded-function/test.c
cfe/trunk/test/Import/struct-in-namespace/
cfe/trunk/test/Import/struct-in-namespace/Inputs/
cfe/trunk/test/Import/struct-in-namespace/Inputs/N1.cpp
cfe/trunk/test/Import/struct-in-namespace/Inputs/N2.cpp
cfe/trunk/test/Import/struct-in-namespace/Inputs/N3.cpp
cfe/trunk/test/Import/struct-in-namespace/test.cpp
cfe/trunk/test/Import/template-specialization/
cfe/trunk/test/Import/template-specialization/Inputs/
cfe/trunk/test/Import/template-specialization/Inputs/T.cpp
cfe/trunk/test/Import/template-specialization/test.cpp
Modified:
cfe/trunk/lib/AST/CMakeLists.txt
cfe/trunk/tools/clang-import-test/clang-import-test.cpp

Added: cfe/trunk/include/clang/AST/ExternalASTMerger.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTMerger.h?rev=299976=auto
==
--- cfe/trunk/include/clang/AST/ExternalASTMerger.h (added)
+++ cfe/trunk/include/clang/AST/ExternalASTMerger.h Tue Apr 11 14:33:35 2017
@@ -0,0 +1,51 @@
+//===--- ExternalASTMerger.h - Merging External AST Interface ---*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file declares the ExternalASTMerger, which vends a combination of ASTs
+//  from several different ASTContext/FileManager pairs
+//
+//===--===//
+#ifndef LLVM_CLANG_AST_EXTERNALASTMERGER_H
+#define LLVM_CLANG_AST_EXTERNALASTMERGER_H
+
+#include "clang/AST/ASTImporter.h"
+#include "clang/AST/ExternalASTSource.h"
+
+namespace clang {
+
+class ExternalASTMerger : public ExternalASTSource {
+public:
+  struct ImporterPair {
+std::unique_ptr Forward;
+std::unique_ptr Reverse;
+  };
+
+private:
+  std::vector Importers;
+
+public:
+  struct ImporterEndpoint {
+ASTContext 
+FileManager 
+  };
+  ExternalASTMerger(const ImporterEndpoint ,
+llvm::ArrayRef Sources);
+
+  bool FindExternalVisibleDeclsByName(const DeclContext *DC,
+  DeclarationName Name) override;
+
+  void
+  FindExternalLexicalDecls(const DeclContext *DC,
+   llvm::function_ref IsKindWeWant,
+   SmallVectorImpl ) override;
+};
+
+} // end namespace clang
+
+#endif

Modified: cfe/trunk/lib/AST/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CMakeLists.txt?rev=299976=299975=299976=diff
==
--- cfe/trunk/lib/AST/CMakeLists.txt (original)
+++ cfe/trunk/lib/AST/CMakeLists.txt Tue Apr 11 14:33:35 

[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 94867.
gtbercea added a comment.

Refactor code.


Repository:
  rL LLVM

https://reviews.llvm.org/D29905

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) 
%ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,36 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
-
-if (SI == SE)
+if (Stack.empty())
   return false;
 
-if (CurrentRegionOnly) {
-  SE = std::next(SI);
-} else {
-  ++SI;
-}
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 
1, Check);
 
-for (; SI != SE; ++SI) {
-  auto MI = SI->MappedExprComponents.find(VD);
-  if (MI != SI->MappedExprComponents.end())
-for (auto  : MI->second.Components)
-  if (Check(L, MI->second.Kind))
-return true;
-}
+for (unsigned I = Stack.size(); I > 0; --I)
+  if (checkMappableExprComponentListsForDeclAtLevel(VD, I - 1, Check))
+return true;
+return false;
+  }
+
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> ) {
+auto StartI = std::next(Stack.begin());
+auto EndI = Stack.end();
+if (std::distance(StartI, EndI) <= (int)Level)
+  return false;
+std::advance(StartI, Level);
+
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto  : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
 return false;
   }
 
@@ -912,9 +923,8 @@
 bool IsVariableUsedInMapClause = false;
 bool IsVariableAssociatedWithSection = false;
 
-DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
+DSAStack->checkMappableExprComponentListsForDeclAtLevel(
+D, Level, [&](OMPClauseMappableExprCommon::MappableExprComponentListRef
 MapExprComponents,
 OpenMPClauseKind WhereFoundClauseKind) {
   // Only the map clause information influences how a variable is


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,20 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CK30 %s
+
+#ifdef CK30
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+#pragma omp target map(tofrom: ParamToKernel)
+  {
+ParamToKernel += 1;
+  }
+}
+
+// CK30: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4) %ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -333,25 +333,36 @@
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
OpenMPClauseKind)> ) {
-auto SI = Stack.rbegin();
-auto SE = Stack.rend();
-
-if (SI == SE)
+if (Stack.empty())
   return false;
 
-if (CurrentRegionOnly) {
-  SE = std::next(SI);
-} else {
-  ++SI;
-}
+if (CurrentRegionOnly)
+  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 1, Check);
 
-for (; SI != SE; ++SI) {
-  auto MI = SI->MappedExprComponents.find(VD);
-  if (MI != SI->MappedExprComponents.end())
-for (auto  : 

[PATCH] D27604: [Driver] Add compiler option to generate a reproducer

2017-04-11 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

LGTM with one change.




Comment at: include/clang/Basic/DiagnosticDriverKinds.td:95
 def err_drv_force_crash : Error<
-  "failing because environment variable '%0' is set">;
+  "failing because %select{environment variable|option}0 '%1' is set">;
 def err_drv_invalid_mfloat_abi : Error<

mehdi_amini wrote:
> Is it worth it? What about `"failing because %1 is set">;`
> 
> And then later:
> 
> ```
> Diags.Report(diag::err_drv_force_crash) << "option '-gen-reproducer'";
> ```
Even though we don't have translations for our diagnostics, it's intended that 
they be translatable, so you should not hardcode strings like "option " and 
"environment variable " in the code. Use a %select here instead, maybe? (See 
http://clang.llvm.org/docs/InternalsManual.html#the-format-string)


https://reviews.llvm.org/D27604



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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

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



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+  hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+  .bind("for_loop"),

aaron.ballman wrote:
> hokein wrote:
> > aaron.ballman wrote:
> > > hokein wrote:
> > > > aaron.ballman wrote:
> > > > > I'm really not keen on this. It will catch trivial cases, so there is 
> > > > > some utility, but this will quickly fall apart with anything past the 
> > > > > trivial case.
> > > > The motivation of this check is to find code patterns like `for (int i 
> > > > = 0; i < n; ++i) { v.push_back(i); }` and clean them in our codebase 
> > > > (we have lots of similar cases). 
> > > > [These](https://docs.google.com/document/d/1Bbc-6DlNs6zQujWD5-XOHWbfPJVMG7Z_T27Kv0WcFb4/edit?usp=sharing)
> > > >  are all cases we want to support. Using `hasParent` is a simple and 
> > > > sufficient way to do it IMO.
> > > I'm not convinced of the utility without implementing this in a more 
> > > sensitive way. Have you run this across any large code bases and found 
> > > that it catches issues?
> > Yeah, the check catches ~2800 cases (regexp shows ~17,000 total usages) in 
> > our internal codebase. And all caught cases are what we are interested in. 
> > It would catch more if we support for-range loops and iterator-based 
> > for-loops. 
> I wasn't worried about it not triggering often enough, I was worried about it 
> triggering too often because of the lack of sensitivity. If you randomly 
> sample some of those 2800 cases, do they reserve the space in a way that your 
> check isn't catching?
Ok, I see your concern now, thanks for pointing it out.

I have read through these caught cases. The results look reasonable. Most cases 
(> 95%) are what we expected, the code pattern is like `vector v; for (...) 
{ v.push_back(...); }` where the vector definition statement and for-loop 
statement are consecutive. Another option is to make the check more strict 
(only detects the consecutive code pattern).


https://reviews.llvm.org/D31757



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


[PATCH] D31781: [Modules] Allow local submodule visibility without c++

2017-04-11 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Can you also add a basic test that this works in C? Thanks!


https://reviews.llvm.org/D31781



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


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

2017-04-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


Re: [PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread David Blaikie via cfe-commits
Ah - perhaps it'd be worth having a standalone forward declaration for
clarity? I don't think I've seen this construct anywhere else in LLVM? But
I could be wrong.

On Tue, Apr 11, 2017 at 10:51 AM Aaron Ballman via Phabricator <
revi...@reviews.llvm.org> wrote:

> aaron.ballman added inline comments.
>
>
> 
> Comment at: include/clang/AST/StmtIterator.h:137
> +  inline friend StmtIterator
> +  cast_away_const(const struct ConstStmtIterator );
>  };
> 
> dblaikie wrote:
> > the "struct" here is a bit atypical/should be removed
> The forward reference is needed because `ConstStmtIterator` is defined
> below `StmtIterator`. If I use `class` rather than `struct`, then MSVC
> diagnoses because of the mismatched class-key (which is a pretty low-value
> diagnostic, but I see no reason to disable it either).
>
>
> https://reviews.llvm.org/D31153
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

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



Comment at: include/clang/AST/StmtIterator.h:137
+  inline friend StmtIterator
+  cast_away_const(const struct ConstStmtIterator );
 };

dblaikie wrote:
> the "struct" here is a bit atypical/should be removed
The forward reference is needed because `ConstStmtIterator` is defined below 
`StmtIterator`. If I use `class` rather than `struct`, then MSVC diagnoses 
because of the mismatched class-key (which is a pretty low-value diagnostic, 
but I see no reason to disable it either).


https://reviews.llvm.org/D31153



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


Re: [PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread David Blaikie via cfe-commits
On Tue, Apr 11, 2017 at 10:27 AM Aaron Ballman via Phabricator <
revi...@reviews.llvm.org> wrote:

> aaron.ballman added inline comments.
>
>
> 
> Comment at: include/clang/AST/Expr.h:4025
>child_range children() {
> +const_child_range CCR = const_cast *>(this)->children();
> +return child_range(cast_away_const(CCR.begin()),
> 
> dblaikie wrote:
> > If this is adding const, can you use a weaker cast? (I guess what would
> be ideal here would be implicit_cast - if you're interested you could add
> that - otherwise... yeah, I guess static_cast could do other nasty things,
> etc, so there's nothing good)
> I'm not certain what you mean. This is adding the const qualifier so that
> we call the proper overload. I'm not certain of what a weaker cast would be.
>

Oh, I meant something like tihs:
http://www.boost.org/doc/libs/1_39_0/boost/implicit_cast.hp
p

The thing about using a const_cast to add const is it can be a bit hard to
read/be sure about. I don't know if it's removing some const while it adds
other const.


>
>
> 
> Comment at: include/clang/AST/StmtIterator.h:148-150
> +inline StmtIterator cast_away_const(const ConstStmtIterator ) {
> +  return RHS;
> +}
> 
> dblaikie wrote:
> > Maybe I'm missing something - what stops code from doing this conversion
> implicitly/accidentally all over the place? (I would've expecetd
> cast_away_const to be a friend or something, to only allow the conversion
> through this explicit call/operation)
> Good catch, I've corrected this.
>
>
> https://reviews.llvm.org/D31153
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good to me - thanks!




Comment at: include/clang/AST/StmtIterator.h:137
+  inline friend StmtIterator
+  cast_away_const(const struct ConstStmtIterator );
 };

the "struct" here is a bit atypical/should be removed


https://reviews.llvm.org/D31153



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


[PATCH] D31646: [coroutines] Build GRO declaration and return GRO statement

2017-04-11 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added a comment.

Gentle ping. When all outstanding CRs are committed we will get 90% of working 
corouitnes in Clang


https://reviews.llvm.org/D31646



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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-11 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299965: [OpenCL] Map default address space to alloca address 
space (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D31404?vs=94399=94855#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31404

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/AddressSpaces.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ExprClassification.cpp
  cfe/trunk/lib/AST/TypePrinter.cpp
  cfe/trunk/lib/Basic/Targets.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/CodeGen/address-space.c
  cfe/trunk/test/CodeGen/default-address-space.c
  cfe/trunk/test/CodeGenOpenCL/address-spaces.cl
  cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
  cfe/trunk/test/CodeGenOpenCL/vla.cl
  cfe/trunk/test/Sema/address_spaces.c
  cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
  cfe/trunk/test/SemaOpenCL/invalid-assignment-constant-address-space.cl

Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -333,6 +333,20 @@
 
   bool hasAddressSpace() const { return Mask & AddressSpaceMask; }
   unsigned getAddressSpace() const { return Mask >> AddressSpaceShift; }
+  /// Get the address space attribute value to be printed by diagnostics.
+  unsigned getAddressSpaceAttributePrintValue() const {
+auto Addr = getAddressSpace();
+// This function is not supposed to be used with language specific
+// address spaces. If that happens, the diagnostic message should consider
+// printing the QualType instead of the address space value.
+assert(Addr == 0 || Addr >= LangAS::Count);
+if (Addr)
+  return Addr - LangAS::Count;
+// TODO: The diagnostic messages where Addr may be 0 should be fixed
+// since it cannot differentiate the situation where 0 denotes the default
+// address space or user specified __attribute__((address_space(0))).
+return 0;
+  }
   void setAddressSpace(unsigned space) {
 assert(space <= MaxAddressSpace);
 Mask = (Mask & ~AddressSpaceMask)
Index: cfe/trunk/include/clang/AST/ASTContext.h
===
--- cfe/trunk/include/clang/AST/ASTContext.h
+++ cfe/trunk/include/clang/AST/ASTContext.h
@@ -2317,21 +2317,15 @@
 return getTargetAddressSpace(Q.getAddressSpace());
   }
 
-  unsigned getTargetAddressSpace(unsigned AS) const {
-if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count)
-  return AS;
-else
-  return (*AddrSpaceMap)[AS - LangAS::Offset];
-  }
+  unsigned getTargetAddressSpace(unsigned AS) const;
 
   /// Get target-dependent integer value for null pointer which is used for
   /// constant folding.
   uint64_t getTargetNullPointerValue(QualType QT) const;
 
   bool addressSpaceMapManglingFor(unsigned AS) const {
-return AddrSpaceMapMangling ||
-   AS < LangAS::Offset ||
-   AS >= LangAS::Offset + LangAS::Count;
+return AddrSpaceMapMangling || 
+   AS >= LangAS::Count;
   }
 
 private:
Index: cfe/trunk/include/clang/Basic/AddressSpaces.h
===
--- cfe/trunk/include/clang/Basic/AddressSpaces.h
+++ cfe/trunk/include/clang/Basic/AddressSpaces.h
@@ -20,24 +20,32 @@
 
 namespace LangAS {
 
-/// \brief Defines the set of possible language-specific address spaces.
+/// \brief Defines the address space values used by the address space qualifier
+/// of QualType.
 ///
-/// This uses a high starting offset so as not to conflict with any address
-/// space used by a target.
 enum ID {
-  Offset = 0x7FFF00,
+  // The default value 0 is the value used in QualType for the the situation
+  // where there is no address space qualifier. For most languages, this also
+  // corresponds to the situation where there is no address space qualifier in
+  // the source code, except for OpenCL, where the address space value 0 in
+  // QualType represents private address space in OpenCL source code.
+  Default = 0,
 
-  opencl_global = Offset,
+  // OpenCL specific address spaces.
+  opencl_global,
   opencl_local,
   opencl_constant,
   opencl_generic,
 
+  // CUDA specific address spaces.
   cuda_device,
   cuda_constant,
   cuda_shared,
 
-  Last,
-  Count = Last-Offset
+  // This denotes the count of language-specific address spaces and also
+  // the offset added to the target-specific address spaces, which are usually
+  // specified by address space attributes __attribute__(address_space(n))).
+  Count
 };
 
 /// The type of a lookup table which maps from language-specific address spaces
Index: cfe/trunk/test/SemaOpenCL/invalid-assignment-constant-address-space.cl

r299965 - [OpenCL] Map default address space to alloca address space

2017-04-11 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Apr 11 12:24:23 2017
New Revision: 299965

URL: http://llvm.org/viewvc/llvm-project?rev=299965=rev
Log:
[OpenCL] Map default address space to alloca address space

For OpenCL, the private address space qualifier is 0 in AST. Before this 
change, 0 address space qualifier
is always mapped to target address space 0. As now target private address space 
is specified by
alloca address space in data layout, address space qualifier 0 needs to be 
mapped to alloca addr space specified by the data layout.

This change has no impact on targets whose alloca addr space is 0.

With contributions from Matt Arsenault, Tony Tye and Wen-Heng (Jack) Chung

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

Added:
cfe/trunk/test/CodeGen/default-address-space.c
cfe/trunk/test/SemaOpenCL/invalid-assignment-constant-address-space.cl
Removed:
cfe/trunk/test/Sema/invalid-assignment-constant-address-space.c
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/AddressSpaces.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CodeGen/address-space.c
cfe/trunk/test/CodeGenOpenCL/address-spaces.cl
cfe/trunk/test/CodeGenOpenCL/amdgpu-env-amdgiz.cl
cfe/trunk/test/CodeGenOpenCL/vla.cl
cfe/trunk/test/Sema/address_spaces.c

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=299965=299964=299965=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Tue Apr 11 12:24:23 2017
@@ -2317,21 +2317,15 @@ public:
 return getTargetAddressSpace(Q.getAddressSpace());
   }
 
-  unsigned getTargetAddressSpace(unsigned AS) const {
-if (AS < LangAS::Offset || AS >= LangAS::Offset + LangAS::Count)
-  return AS;
-else
-  return (*AddrSpaceMap)[AS - LangAS::Offset];
-  }
+  unsigned getTargetAddressSpace(unsigned AS) const;
 
   /// Get target-dependent integer value for null pointer which is used for
   /// constant folding.
   uint64_t getTargetNullPointerValue(QualType QT) const;
 
   bool addressSpaceMapManglingFor(unsigned AS) const {
-return AddrSpaceMapMangling ||
-   AS < LangAS::Offset ||
-   AS >= LangAS::Offset + LangAS::Count;
+return AddrSpaceMapMangling || 
+   AS >= LangAS::Count;
   }
 
 private:

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=299965=299964=299965=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Apr 11 12:24:23 2017
@@ -333,6 +333,20 @@ public:
 
   bool hasAddressSpace() const { return Mask & AddressSpaceMask; }
   unsigned getAddressSpace() const { return Mask >> AddressSpaceShift; }
+  /// Get the address space attribute value to be printed by diagnostics.
+  unsigned getAddressSpaceAttributePrintValue() const {
+auto Addr = getAddressSpace();
+// This function is not supposed to be used with language specific
+// address spaces. If that happens, the diagnostic message should consider
+// printing the QualType instead of the address space value.
+assert(Addr == 0 || Addr >= LangAS::Count);
+if (Addr)
+  return Addr - LangAS::Count;
+// TODO: The diagnostic messages where Addr may be 0 should be fixed
+// since it cannot differentiate the situation where 0 denotes the default
+// address space or user specified __attribute__((address_space(0))).
+return 0;
+  }
   void setAddressSpace(unsigned space) {
 assert(space <= MaxAddressSpace);
 Mask = (Mask & ~AddressSpaceMask)

Modified: cfe/trunk/include/clang/Basic/AddressSpaces.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AddressSpaces.h?rev=299965=299964=299965=diff
==
--- cfe/trunk/include/clang/Basic/AddressSpaces.h (original)
+++ cfe/trunk/include/clang/Basic/AddressSpaces.h Tue Apr 11 12:24:23 2017
@@ -20,24 +20,32 @@ namespace clang {
 
 namespace LangAS {
 
-/// \brief Defines the set of possible language-specific address spaces.
+/// \brief Defines the address space values used by the address space qualifier
+/// of QualType.
 ///
-/// This uses a high starting offset so as not to conflict with any address
-/// space used by a target.
 enum ID {
-  Offset = 0x7FFF00,
+  // The default value 0 is the value used in QualType for the the situation
+  // where there is no address space 

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 94852.
aaron.ballman added a comment.

Addressing review comments.


https://reviews.llvm.org/D31153

Files:
  include/clang/AST/Expr.h
  include/clang/AST/StmtIterator.h
  lib/AST/Expr.cpp

Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2730,7 +2730,11 @@
   }
   case InitListExprClass: {
 const InitListExpr *ILE = cast(this);
-if (ILE->getType()->isArrayType()) {
+QualType UnderlyingType = ILE->getType();
+if (UnderlyingType->isAtomicType())
+  UnderlyingType = UnderlyingType->castAs()->getValueType();
+
+if (UnderlyingType->isArrayType()) {
   unsigned numInits = ILE->getNumInits();
   for (unsigned i = 0; i < numInits; i++) {
 if (!ILE->getInit(i)->isConstantInitializer(Ctx, false, Culprit))
@@ -2739,9 +2743,9 @@
   return true;
 }
 
-if (ILE->getType()->isRecordType()) {
+if (UnderlyingType->isRecordType()) {
   unsigned ElementNo = 0;
-  RecordDecl *RD = ILE->getType()->getAs()->getDecl();
+  RecordDecl *RD = UnderlyingType->getAs()->getDecl();
   for (const auto *Field : RD->fields()) {
 // If this is a union, skip all the fields that aren't being initialized.
 if (RD->isUnion() && ILE->getInitializedFieldInUnion() != Field)
@@ -3887,16 +3891,22 @@
 
 // UnaryExprOrTypeTraitExpr
 Stmt::child_range UnaryExprOrTypeTraitExpr::children() {
+  const_child_range CCR =
+  const_cast(this)->children();
+  return child_range(cast_away_const(CCR.begin()), cast_away_const(CCR.end()));
+}
+
+Stmt::const_child_range UnaryExprOrTypeTraitExpr::children() const {
   // If this is of a type and the type is a VLA type (and not a typedef), the
   // size expression of the VLA needs to be treated as an executable expression.
   // Why isn't this weirdness documented better in StmtIterator?
   if (isArgumentType()) {
-if (const VariableArrayType* T = dyn_cast(
-   getArgumentType().getTypePtr()))
-  return child_range(child_iterator(T), child_iterator());
-return child_range(child_iterator(), child_iterator());
+if (const VariableArrayType *T =
+dyn_cast(getArgumentType().getTypePtr()))
+  return const_child_range(const_child_iterator(T), const_child_iterator());
+return const_child_range(const_child_iterator(), const_child_iterator());
   }
-  return child_range(,  + 1);
+  return const_child_range(,  + 1);
 }
 
 AtomicExpr::AtomicExpr(SourceLocation BLoc, ArrayRef args,
Index: include/clang/AST/StmtIterator.h
===
--- include/clang/AST/StmtIterator.h
+++ include/clang/AST/StmtIterator.h
@@ -128,6 +128,13 @@
 
   StmtIterator(const VariableArrayType *t)
 : StmtIteratorImpl(t) {}
+
+private:
+  StmtIterator(const StmtIteratorBase )
+  : StmtIteratorImpl(RHS) {}
+
+  inline friend StmtIterator
+  cast_away_const(const struct ConstStmtIterator );
 };
 
 struct ConstStmtIterator : public StmtIteratorImpl(RHS) {}
+
+  ConstStmtIterator(Stmt * const *S)
+  : StmtIteratorImpl(
+const_cast(S)) {}
 };
 
+inline StmtIterator cast_away_const(const ConstStmtIterator ) {
+  return RHS;
+}
 } // end namespace clang
 
 #endif
Index: include/clang/AST/Expr.h
===
--- include/clang/AST/Expr.h
+++ include/clang/AST/Expr.h
@@ -908,6 +908,10 @@
 return child_range(child_iterator(), child_iterator());
   }
 
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   /// The source expression of an opaque value expression is the
   /// expression which originally generated the value.  This is
   /// provided as a convenience for analyses that don't wish to
@@ -1168,6 +1172,10 @@
 return child_range(child_iterator(), child_iterator());
   }
 
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
   friend TrailingObjects;
   friend class ASTStmtReader;
   friend class ASTStmtWriter;
@@ -1223,6 +1231,9 @@
 
   // Iterators
   child_range children() { return child_range(,  + 1); }
+  const_child_range children() const {
+return const_child_range(,  + 1);
+  }
 
   friend class ASTStmtReader;
 };
@@ -1316,6 +1327,9 @@
   child_range children() {
 return child_range(child_iterator(), child_iterator());
   }
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
 };
 
 class CharacterLiteral : public Expr {
@@ -1366,6 +1380,9 @@
   child_range children() {
 

[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

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



Comment at: include/clang/AST/Expr.h:4025
   child_range children() {
+const_child_range CCR = const_cast(this)->children();
+return child_range(cast_away_const(CCR.begin()),

dblaikie wrote:
> If this is adding const, can you use a weaker cast? (I guess what would be 
> ideal here would be implicit_cast - if you're interested you could add that - 
> otherwise... yeah, I guess static_cast could do other nasty things, etc, so 
> there's nothing good)
I'm not certain what you mean. This is adding the const qualifier so that we 
call the proper overload. I'm not certain of what a weaker cast would be.



Comment at: include/clang/AST/StmtIterator.h:148-150
+inline StmtIterator cast_away_const(const ConstStmtIterator ) {
+  return RHS;
+}

dblaikie wrote:
> Maybe I'm missing something - what stops code from doing this conversion 
> implicitly/accidentally all over the place? (I would've expecetd 
> cast_away_const to be a friend or something, to only allow the conversion 
> through this explicit call/operation)
Good catch, I've corrected this.


https://reviews.llvm.org/D31153



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


[libcxx] r299963 - Implement LWG#2873: 'Add noexcept to several shared_ptr related functions' This issue missed a couple, so I added those as well (see LWG#2942)

2017-04-11 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Apr 11 12:08:53 2017
New Revision: 299963

URL: http://llvm.org/viewvc/llvm-project?rev=299963=rev
Log:
Implement LWG#2873: 'Add noexcept to several shared_ptr related functions' This 
issue missed a couple, so I added those as well (see LWG#2942)

Modified:
libcxx/trunk/include/memory

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=299963=299962=299963=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Tue Apr 11 12:08:53 2017
@@ -433,8 +433,8 @@ public:
 long use_count() const noexcept;
 bool unique() const noexcept;
 explicit operator bool() const noexcept;
-template bool owner_before(shared_ptr const& b) const;
-template bool owner_before(weak_ptr const& b) const;
+template bool owner_before(shared_ptr const& b) const noexcept;
+template bool owner_before(weak_ptr const& b) const noexcept;
 };
 
 // shared_ptr comparisons:
@@ -531,8 +531,8 @@ public:
 long use_count() const noexcept;
 bool expired() const noexcept;
 shared_ptr lock() const noexcept;
-template bool owner_before(shared_ptr const& b) const;
-template bool owner_before(weak_ptr const& b) const;
+template bool owner_before(shared_ptr const& b) const noexcept;
+template bool owner_before(weak_ptr const& b) const noexcept;
 };
 
 // weak_ptr specialized algorithms:
@@ -546,9 +546,9 @@ struct owner_less
 : binary_function
 {
 typedef bool result_type;
-bool operator()(shared_ptr const&, shared_ptr const&) const;
-bool operator()(shared_ptr const&, weak_ptr const&) const;
-bool operator()(weak_ptr const&, shared_ptr const&) const;
+bool operator()(shared_ptr const&, shared_ptr const&) const noexcept;
+bool operator()(shared_ptr const&, weak_ptr const&) const noexcept;
+bool operator()(weak_ptr const&, shared_ptr const&) const noexcept;
 };
 
 template
@@ -556,9 +556,24 @@ struct owner_less
 : binary_function
 {
 typedef bool result_type;
-bool operator()(weak_ptr const&, weak_ptr const&) const;
-bool operator()(shared_ptr const&, weak_ptr const&) const;
-bool operator()(weak_ptr const&, shared_ptr const&) const;
+bool operator()(weak_ptr const&, weak_ptr const&) const noexcept;
+bool operator()(shared_ptr const&, weak_ptr const&) const noexcept;
+bool operator()(weak_ptr const&, shared_ptr const&) const noexcept;
+};
+
+template <>  // Added in C++14
+struct owner_less
+{
+template 
+bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) 
const noexcept;
+template 
+bool operator()( shared_ptr<_Tp> const& __x,   weak_ptr<_Up> const& __y) 
const noexcept;
+template 
+bool operator()(   weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) 
const noexcept;
+template 
+bool operator()(   weak_ptr<_Tp> const& __x,   weak_ptr<_Up> const& __y) 
const noexcept;
+
+typedef void is_transparent;
 };
 
 template
@@ -3807,11 +3822,11 @@ public:
 _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;}
 template 
 _LIBCPP_INLINE_VISIBILITY
-bool owner_before(shared_ptr<_Up> const& __p) const
+bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT
 {return __cntrl_ < __p.__cntrl_;}
 template 
 _LIBCPP_INLINE_VISIBILITY
-bool owner_before(weak_ptr<_Up> const& __p) const
+bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT
 {return __cntrl_ < __p.__cntrl_;}
 _LIBCPP_INLINE_VISIBILITY
 bool
@@ -4907,11 +4922,11 @@ public:
 shared_ptr<_Tp> lock() const _NOEXCEPT;
 template
 _LIBCPP_INLINE_VISIBILITY
-bool owner_before(const shared_ptr<_Up>& __r) const
+bool owner_before(const shared_ptr<_Up>& __r) const _NOEXCEPT
 {return __cntrl_ < __r.__cntrl_;}
 template
 _LIBCPP_INLINE_VISIBILITY
-bool owner_before(const weak_ptr<_Up>& __r) const
+bool owner_before(const weak_ptr<_Up>& __r) const _NOEXCEPT
 {return __cntrl_ < __r.__cntrl_;}
 
 template  

[PATCH] D31167: Use FPContractModeKind universally

2017-04-11 Thread Adam Nemet via Phabricator via cfe-commits
anemet added inline comments.



Comment at: cfe/trunk/include/clang/Basic/LangOptions.def:220
+/// \brief FP_CONTRACT mode (on/off/fast).
+ENUM_LANGOPT(DefaultFPContractMode, FPContractModeKind, 2, FPC_Off, "FP 
contraction type")
 LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")

hfinkel wrote:
> yaxunl wrote:
> > hfinkel wrote:
> > > yaxunl wrote:
> > > > anemet wrote:
> > > > > yaxunl wrote:
> > > > > > anemet wrote:
> > > > > > > yaxunl wrote:
> > > > > > > > This change seemed to cause some performance degradations in 
> > > > > > > > some OpenCL applications.
> > > > > > > > 
> > > > > > > > This option used to be on by default. Now it is off by default.
> > > > > > > > 
> > > > > > > > There are applications do separated compile/link/codegen 
> > > > > > > > stages. In the codegen stage, clang is invoked with .bc as 
> > > > > > > > input, therefore this option is off by default, whereas it was 
> > > > > > > > on by default before this change.
> > > > > > > > 
> > > > > > > > Is there any reason not to keep the original behavior?
> > > > > > > > 
> > > > > > > > Thanks.
> > > > > > > > This change seemed to cause some performance degradations in 
> > > > > > > > some OpenCL applications.
> > > > > > > > 
> > > > > > > > This option used to be on by default. Now it is off by default.
> > > > > > > 
> > > > > > > It's always been off.  It was set to fast for CUDA which should 
> > > > > > > still be the case.  See the changes further down on the patch.
> > > > > > > 
> > > > > > > > 
> > > > > > > > There are applications do separated compile/link/codegen 
> > > > > > > > stages. In the codegen stage, clang is invoked with .bc as 
> > > > > > > > input, therefore this option is off by default, whereas it was 
> > > > > > > > on by default before this change.
> > > > > > > > 
> > > > > > > > Is there any reason not to keep the original behavior?
> > > > > > > 
> > > > > > > Sorry but I am not sure what changed, can you elaborate on what 
> > > > > > > you're doing and how things used to work for you?
> > > > > > Before your change, -ffp-contract was a codegen option defined as
> > > > > > 
> > > > > > 
> > > > > > ```
> > > > > > ENUM_CODEGENOPT(FPContractMode, FPContractModeKind, 2, FPC_On)
> > > > > > ```
> > > > > > 
> > > > > > therefore the default value as on. After your change, it becomes 
> > > > > > off by default.
> > > > > No. -ffp-contract=on was a FE option and -ffp-contract=fast was a 
> > > > > backend option.  I still don't understand your use-case.  Can you 
> > > > > include a small testcase how this used to work before?
> > > > -ffp-contract=on used to be a codegen option before this change. In 
> > > > CodeGen/BackendUtil.cpp, before this change:
> > > > 
> > > > ```
> > > > switch (CodeGenOpts.getFPContractMode()) {
> > > >   switch (LangOpts.getDefaultFPContractMode()) {
> > > >   case LangOptions::FPC_Off:
> > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > > > break;
> > > >   case LangOptions::FPC_On:
> > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > > > break;
> > > >   case LangOptions::FPC_Fast:
> > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > > > break;
> > > >   }
> > > > ```
> > > > By default, -fp-contract=on, which results in 
> > > > llvm::FPOpFusion::Standard in the backend. This options allows backend 
> > > > to translate llvm.fmuladd to FMA machine instructions.
> > > > 
> > > > After this change, it becomes:
> > > > 
> > > > ```
> > > > switch (LangOpts.getDefaultFPContractMode()) {
> > > >   case LangOptions::FPC_Off:
> > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > > > break;
> > > >   case LangOptions::FPC_On:
> > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > > > break;
> > > >   case LangOptions::FPC_Fast:
> > > > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > > > break;
> > > >   }
> > > > ```
> > > > now by default -ffp-contract=off, which results in  
> > > > llvm::FPOpFusion::Strict in the backend. This option disables backend 
> > > > translating llvm.fmuladd to FMA machine instructions in certain 
> > > > situations.
> > > > 
> > > > A simple lit test is as follows:
> > > > 
> > > > 
> > > > ```
> > > > ; RUN: %clang_cc1 -triple amdgcn -S -o - %s| FileCheck %s
> > > > 
> > > > define amdgpu_kernel void @f(double addrspace(1)* nocapture %out, 
> > > > double %a, double %b, double %c) local_unnamed_addr #0 {
> > > > entry:
> > > >   ; CHECK: v_fma_f64
> > > >   %0 = tail call double @llvm.fmuladd.f64(double %b, double %c, double 
> > > > %a)
> > > >   store double %0, double addrspace(1)* %out, align 8, !tbaa !6
> > > >   ret void
> > > > }
> > > > 
> > > > declare double @llvm.fmuladd.f64(double, double, double) #1
> > > > 
> > > > attributes #0 = { nounwind 
> > > > "correctly-rounded-divide-sqrt-fp-math"="false" 
> > > > "disable-tail-calls"="false" "less-precise-fpmad"="false" 

[PATCH] D31167: Use FPContractModeKind universally

2017-04-11 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: cfe/trunk/include/clang/Basic/LangOptions.def:220
+/// \brief FP_CONTRACT mode (on/off/fast).
+ENUM_LANGOPT(DefaultFPContractMode, FPContractModeKind, 2, FPC_Off, "FP 
contraction type")
 LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")

yaxunl wrote:
> hfinkel wrote:
> > yaxunl wrote:
> > > anemet wrote:
> > > > yaxunl wrote:
> > > > > anemet wrote:
> > > > > > yaxunl wrote:
> > > > > > > This change seemed to cause some performance degradations in some 
> > > > > > > OpenCL applications.
> > > > > > > 
> > > > > > > This option used to be on by default. Now it is off by default.
> > > > > > > 
> > > > > > > There are applications do separated compile/link/codegen stages. 
> > > > > > > In the codegen stage, clang is invoked with .bc as input, 
> > > > > > > therefore this option is off by default, whereas it was on by 
> > > > > > > default before this change.
> > > > > > > 
> > > > > > > Is there any reason not to keep the original behavior?
> > > > > > > 
> > > > > > > Thanks.
> > > > > > > This change seemed to cause some performance degradations in some 
> > > > > > > OpenCL applications.
> > > > > > > 
> > > > > > > This option used to be on by default. Now it is off by default.
> > > > > > 
> > > > > > It's always been off.  It was set to fast for CUDA which should 
> > > > > > still be the case.  See the changes further down on the patch.
> > > > > > 
> > > > > > > 
> > > > > > > There are applications do separated compile/link/codegen stages. 
> > > > > > > In the codegen stage, clang is invoked with .bc as input, 
> > > > > > > therefore this option is off by default, whereas it was on by 
> > > > > > > default before this change.
> > > > > > > 
> > > > > > > Is there any reason not to keep the original behavior?
> > > > > > 
> > > > > > Sorry but I am not sure what changed, can you elaborate on what 
> > > > > > you're doing and how things used to work for you?
> > > > > Before your change, -ffp-contract was a codegen option defined as
> > > > > 
> > > > > 
> > > > > ```
> > > > > ENUM_CODEGENOPT(FPContractMode, FPContractModeKind, 2, FPC_On)
> > > > > ```
> > > > > 
> > > > > therefore the default value as on. After your change, it becomes off 
> > > > > by default.
> > > > No. -ffp-contract=on was a FE option and -ffp-contract=fast was a 
> > > > backend option.  I still don't understand your use-case.  Can you 
> > > > include a small testcase how this used to work before?
> > > -ffp-contract=on used to be a codegen option before this change. In 
> > > CodeGen/BackendUtil.cpp, before this change:
> > > 
> > > ```
> > > switch (CodeGenOpts.getFPContractMode()) {
> > >   switch (LangOpts.getDefaultFPContractMode()) {
> > >   case LangOptions::FPC_Off:
> > > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > > break;
> > >   case LangOptions::FPC_On:
> > > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > > break;
> > >   case LangOptions::FPC_Fast:
> > > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > > break;
> > >   }
> > > ```
> > > By default, -fp-contract=on, which results in llvm::FPOpFusion::Standard 
> > > in the backend. This options allows backend to translate llvm.fmuladd to 
> > > FMA machine instructions.
> > > 
> > > After this change, it becomes:
> > > 
> > > ```
> > > switch (LangOpts.getDefaultFPContractMode()) {
> > >   case LangOptions::FPC_Off:
> > > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > > break;
> > >   case LangOptions::FPC_On:
> > > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > > break;
> > >   case LangOptions::FPC_Fast:
> > > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > > break;
> > >   }
> > > ```
> > > now by default -ffp-contract=off, which results in  
> > > llvm::FPOpFusion::Strict in the backend. This option disables backend 
> > > translating llvm.fmuladd to FMA machine instructions in certain 
> > > situations.
> > > 
> > > A simple lit test is as follows:
> > > 
> > > 
> > > ```
> > > ; RUN: %clang_cc1 -triple amdgcn -S -o - %s| FileCheck %s
> > > 
> > > define amdgpu_kernel void @f(double addrspace(1)* nocapture %out, double 
> > > %a, double %b, double %c) local_unnamed_addr #0 {
> > > entry:
> > >   ; CHECK: v_fma_f64
> > >   %0 = tail call double @llvm.fmuladd.f64(double %b, double %c, double %a)
> > >   store double %0, double addrspace(1)* %out, align 8, !tbaa !6
> > >   ret void
> > > }
> > > 
> > > declare double @llvm.fmuladd.f64(double, double, double) #1
> > > 
> > > attributes #0 = { nounwind 
> > > "correctly-rounded-divide-sqrt-fp-math"="false" 
> > > "disable-tail-calls"="false" "less-precise-fpmad"="false" 
> > > "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" 
> > > "no-jump-tables"="false" "no-nans-fp-math"="false" 
> > > "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" 
> > > "stack-protector-buffer-size"="8" 
> > > 

r299962 - [ASTPrinter] Print nested name specifiers for out-of-line functions

2017-04-11 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Apr 11 11:46:03 2017
New Revision: 299962

URL: http://llvm.org/viewvc/llvm-project?rev=299962=rev
Log:
[ASTPrinter] Print nested name specifiers for out-of-line functions

rdar://31501863

Added:
cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp
Modified:
cfe/trunk/lib/AST/DeclPrinter.cpp
cfe/trunk/lib/AST/DeclarationName.cpp
cfe/trunk/test/Index/comment-cplus-decls.cpp
cfe/trunk/test/Index/overriding-method-comments.mm

Modified: cfe/trunk/lib/AST/DeclPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclPrinter.cpp?rev=299962=299961=299962=diff
==
--- cfe/trunk/lib/AST/DeclPrinter.cpp (original)
+++ cfe/trunk/lib/AST/DeclPrinter.cpp Tue Apr 11 11:46:03 2017
@@ -504,7 +504,14 @@ void DeclPrinter::VisitFunctionDecl(Func
 
   PrintingPolicy SubPolicy(Policy);
   SubPolicy.SuppressSpecifiers = false;
-  std::string Proto = D->getNameInfo().getAsString();
+  std::string Proto;
+  if (!Policy.SuppressScope) {
+if (const NestedNameSpecifier *NS = D->getQualifier()) {
+  llvm::raw_string_ostream OS(Proto);
+  NS->print(OS, Policy);
+}
+  }
+  Proto += D->getNameInfo().getAsString();
   if (GuideDecl)
 Proto = GuideDecl->getDeducedTemplate()->getDeclName().getAsString();
   if (const TemplateArgumentList *TArgs = D->getTemplateSpecializationArgs()) {

Modified: cfe/trunk/lib/AST/DeclarationName.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclarationName.cpp?rev=299962=299961=299962=diff
==
--- cfe/trunk/lib/AST/DeclarationName.cpp (original)
+++ cfe/trunk/lib/AST/DeclarationName.cpp Tue Apr 11 11:46:03 2017
@@ -660,7 +660,9 @@ void DeclarationNameInfo::printName(raw_
   LangOptions LO;
   LO.CPlusPlus = true;
   LO.Bool = true;
-  OS << TInfo->getType().getAsString(PrintingPolicy(LO));
+  PrintingPolicy PP(LO);
+  PP.SuppressScope = true;
+  OS << TInfo->getType().getAsString(PP);
 } else
   OS << Name;
 return;

Modified: cfe/trunk/test/Index/comment-cplus-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-cplus-decls.cpp?rev=299962=299961=299962=diff
==
--- cfe/trunk/test/Index/comment-cplus-decls.cpp (original)
+++ cfe/trunk/test/Index/comment-cplus-decls.cpp Tue Apr 11 11:46:03 2017
@@ -102,7 +102,7 @@ namespace test0 {
 friend void ns::f(int a);
   };
 }
-// CHECK: friend void f(int a)
+// CHECK: friend void ns::f(int a)
 
 namespace test1 {
   template  struct Outer {
@@ -115,7 +115,7 @@ namespace test1 {
 };
   };
 }
-// CHECK: friend void foo(T)
+// CHECK: friend void OuterT::foo(T)
 
 namespace test2 {
   namespace foo {
@@ -129,7 +129,7 @@ namespace test2 {
 friend void ::test2::foo::Func(int x);
   };
 }
-// CHECK: friend void Func(int x)
+// CHECK: friend void ::test2::foo::Func(int x)
 
 namespace test3 {
   template class vector {
@@ -149,7 +149,7 @@ namespace test3 {
   };
 }
 // CHECK: void f(const T t = T())
-// CHECK: friend void f(const test3::A )
+// CHECK: friend void vectorA::f(const test3::A 
)
 
 class MyClass
 {

Modified: cfe/trunk/test/Index/overriding-method-comments.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/overriding-method-comments.mm?rev=299962=299961=299962=diff
==
--- cfe/trunk/test/Index/overriding-method-comments.mm (original)
+++ cfe/trunk/test/Index/overriding-method-comments.mm Tue Apr 11 11:46:03 2017
@@ -78,7 +78,7 @@ struct Base {
 
 void Base::foo_outofline(int RRR) {}
 
-// CHECK: FullCommentAsXML=[foo_outoflinec:@S@Base@F@foo_outofline#I#void
 foo_outofline(int RRR) Does something. 
RRR0in argument to undefined 
virtual.]
+// CHECK: FullCommentAsXML=[foo_outoflinec:@S@Base@F@foo_outofline#I#void
 Base::foo_outofline(int RRR) Does something. 
RRR0in argument to undefined 
virtual.]
 
 struct Derived : public Base {
   virtual void foo_pure(int PPP);

Added: cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp?rev=299962=auto
==
--- cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp (added)
+++ cfe/trunk/test/Misc/ast-print-out-of-line-func.cpp Tue Apr 11 11:46:03 2017
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -ast-print -std=c++14 %s | FileCheck %s
+
+namespace ns {
+
+struct Wrapper {
+class Inner {
+  Inner();
+  Inner(int);
+  ~Inner();
+
+  void operator += (int);
+
+  template
+  void member();
+
+  static void staticMember();
+
+  operator int();
+
+  operator ns::Wrapper();
+  // CHECK: operator ns::Wrapper()
+};
+};
+
+Wrapper::Inner::Inner() { }
+// CHECK: Wrapper::Inner::Inner()
+
+void 

[PATCH] D31167: Use FPContractModeKind universally

2017-04-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: cfe/trunk/include/clang/Basic/LangOptions.def:220
+/// \brief FP_CONTRACT mode (on/off/fast).
+ENUM_LANGOPT(DefaultFPContractMode, FPContractModeKind, 2, FPC_Off, "FP 
contraction type")
 LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")

hfinkel wrote:
> yaxunl wrote:
> > anemet wrote:
> > > yaxunl wrote:
> > > > anemet wrote:
> > > > > yaxunl wrote:
> > > > > > This change seemed to cause some performance degradations in some 
> > > > > > OpenCL applications.
> > > > > > 
> > > > > > This option used to be on by default. Now it is off by default.
> > > > > > 
> > > > > > There are applications do separated compile/link/codegen stages. In 
> > > > > > the codegen stage, clang is invoked with .bc as input, therefore 
> > > > > > this option is off by default, whereas it was on by default before 
> > > > > > this change.
> > > > > > 
> > > > > > Is there any reason not to keep the original behavior?
> > > > > > 
> > > > > > Thanks.
> > > > > > This change seemed to cause some performance degradations in some 
> > > > > > OpenCL applications.
> > > > > > 
> > > > > > This option used to be on by default. Now it is off by default.
> > > > > 
> > > > > It's always been off.  It was set to fast for CUDA which should still 
> > > > > be the case.  See the changes further down on the patch.
> > > > > 
> > > > > > 
> > > > > > There are applications do separated compile/link/codegen stages. In 
> > > > > > the codegen stage, clang is invoked with .bc as input, therefore 
> > > > > > this option is off by default, whereas it was on by default before 
> > > > > > this change.
> > > > > > 
> > > > > > Is there any reason not to keep the original behavior?
> > > > > 
> > > > > Sorry but I am not sure what changed, can you elaborate on what 
> > > > > you're doing and how things used to work for you?
> > > > Before your change, -ffp-contract was a codegen option defined as
> > > > 
> > > > 
> > > > ```
> > > > ENUM_CODEGENOPT(FPContractMode, FPContractModeKind, 2, FPC_On)
> > > > ```
> > > > 
> > > > therefore the default value as on. After your change, it becomes off by 
> > > > default.
> > > No. -ffp-contract=on was a FE option and -ffp-contract=fast was a backend 
> > > option.  I still don't understand your use-case.  Can you include a small 
> > > testcase how this used to work before?
> > -ffp-contract=on used to be a codegen option before this change. In 
> > CodeGen/BackendUtil.cpp, before this change:
> > 
> > ```
> > switch (CodeGenOpts.getFPContractMode()) {
> >   switch (LangOpts.getDefaultFPContractMode()) {
> >   case LangOptions::FPC_Off:
> > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > break;
> >   case LangOptions::FPC_On:
> > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > break;
> >   case LangOptions::FPC_Fast:
> > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > break;
> >   }
> > ```
> > By default, -fp-contract=on, which results in llvm::FPOpFusion::Standard in 
> > the backend. This options allows backend to translate llvm.fmuladd to FMA 
> > machine instructions.
> > 
> > After this change, it becomes:
> > 
> > ```
> > switch (LangOpts.getDefaultFPContractMode()) {
> >   case LangOptions::FPC_Off:
> > Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> > break;
> >   case LangOptions::FPC_On:
> > Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> > break;
> >   case LangOptions::FPC_Fast:
> > Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> > break;
> >   }
> > ```
> > now by default -ffp-contract=off, which results in  
> > llvm::FPOpFusion::Strict in the backend. This option disables backend 
> > translating llvm.fmuladd to FMA machine instructions in certain situations.
> > 
> > A simple lit test is as follows:
> > 
> > 
> > ```
> > ; RUN: %clang_cc1 -triple amdgcn -S -o - %s| FileCheck %s
> > 
> > define amdgpu_kernel void @f(double addrspace(1)* nocapture %out, double 
> > %a, double %b, double %c) local_unnamed_addr #0 {
> > entry:
> >   ; CHECK: v_fma_f64
> >   %0 = tail call double @llvm.fmuladd.f64(double %b, double %c, double %a)
> >   store double %0, double addrspace(1)* %out, align 8, !tbaa !6
> >   ret void
> > }
> > 
> > declare double @llvm.fmuladd.f64(double, double, double) #1
> > 
> > attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" 
> > "disable-tail-calls"="false" "less-precise-fpmad"="false" 
> > "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" 
> > "no-jump-tables"="false" "no-nans-fp-math"="false" 
> > "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" 
> > "stack-protector-buffer-size"="8" 
> > "target-features"="+fp64-fp16-denormals,-fp32-denormals" 
> > "unsafe-fp-math"="false" "use-soft-float"="false" }
> > attributes #1 = { nounwind readnone }
> > 
> > ```
> > The test passes before this change and fails after this change.
> I'm missing something 

[PATCH] D31167: Use FPContractModeKind universally

2017-04-11 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added inline comments.



Comment at: cfe/trunk/include/clang/Basic/LangOptions.def:220
+/// \brief FP_CONTRACT mode (on/off/fast).
+ENUM_LANGOPT(DefaultFPContractMode, FPContractModeKind, 2, FPC_Off, "FP 
contraction type")
 LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")

yaxunl wrote:
> anemet wrote:
> > yaxunl wrote:
> > > anemet wrote:
> > > > yaxunl wrote:
> > > > > This change seemed to cause some performance degradations in some 
> > > > > OpenCL applications.
> > > > > 
> > > > > This option used to be on by default. Now it is off by default.
> > > > > 
> > > > > There are applications do separated compile/link/codegen stages. In 
> > > > > the codegen stage, clang is invoked with .bc as input, therefore this 
> > > > > option is off by default, whereas it was on by default before this 
> > > > > change.
> > > > > 
> > > > > Is there any reason not to keep the original behavior?
> > > > > 
> > > > > Thanks.
> > > > > This change seemed to cause some performance degradations in some 
> > > > > OpenCL applications.
> > > > > 
> > > > > This option used to be on by default. Now it is off by default.
> > > > 
> > > > It's always been off.  It was set to fast for CUDA which should still 
> > > > be the case.  See the changes further down on the patch.
> > > > 
> > > > > 
> > > > > There are applications do separated compile/link/codegen stages. In 
> > > > > the codegen stage, clang is invoked with .bc as input, therefore this 
> > > > > option is off by default, whereas it was on by default before this 
> > > > > change.
> > > > > 
> > > > > Is there any reason not to keep the original behavior?
> > > > 
> > > > Sorry but I am not sure what changed, can you elaborate on what you're 
> > > > doing and how things used to work for you?
> > > Before your change, -ffp-contract was a codegen option defined as
> > > 
> > > 
> > > ```
> > > ENUM_CODEGENOPT(FPContractMode, FPContractModeKind, 2, FPC_On)
> > > ```
> > > 
> > > therefore the default value as on. After your change, it becomes off by 
> > > default.
> > No. -ffp-contract=on was a FE option and -ffp-contract=fast was a backend 
> > option.  I still don't understand your use-case.  Can you include a small 
> > testcase how this used to work before?
> -ffp-contract=on used to be a codegen option before this change. In 
> CodeGen/BackendUtil.cpp, before this change:
> 
> ```
> switch (CodeGenOpts.getFPContractMode()) {
>   switch (LangOpts.getDefaultFPContractMode()) {
>   case LangOptions::FPC_Off:
> Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> break;
>   case LangOptions::FPC_On:
> Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> break;
>   case LangOptions::FPC_Fast:
> Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> break;
>   }
> ```
> By default, -fp-contract=on, which results in llvm::FPOpFusion::Standard in 
> the backend. This options allows backend to translate llvm.fmuladd to FMA 
> machine instructions.
> 
> After this change, it becomes:
> 
> ```
> switch (LangOpts.getDefaultFPContractMode()) {
>   case LangOptions::FPC_Off:
> Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
> break;
>   case LangOptions::FPC_On:
> Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
> break;
>   case LangOptions::FPC_Fast:
> Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
> break;
>   }
> ```
> now by default -ffp-contract=off, which results in  llvm::FPOpFusion::Strict 
> in the backend. This option disables backend translating llvm.fmuladd to FMA 
> machine instructions in certain situations.
> 
> A simple lit test is as follows:
> 
> 
> ```
> ; RUN: %clang_cc1 -triple amdgcn -S -o - %s| FileCheck %s
> 
> define amdgpu_kernel void @f(double addrspace(1)* nocapture %out, double %a, 
> double %b, double %c) local_unnamed_addr #0 {
> entry:
>   ; CHECK: v_fma_f64
>   %0 = tail call double @llvm.fmuladd.f64(double %b, double %c, double %a)
>   store double %0, double addrspace(1)* %out, align 8, !tbaa !6
>   ret void
> }
> 
> declare double @llvm.fmuladd.f64(double, double, double) #1
> 
> attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" 
> "disable-tail-calls"="false" "less-precise-fpmad"="false" 
> "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" 
> "no-jump-tables"="false" "no-nans-fp-math"="false" 
> "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" 
> "stack-protector-buffer-size"="8" 
> "target-features"="+fp64-fp16-denormals,-fp32-denormals" 
> "unsafe-fp-math"="false" "use-soft-float"="false" }
> attributes #1 = { nounwind readnone }
> 
> ```
> The test passes before this change and fails after this change.
I'm missing something here. We're calling for OpenCL:

  Opts.setDefaultFPContractMode(LangOptions::FPC_On);

which seems like it should change the result returned by 
getDefaultFPContractMode(). Why does it not?



Repository:
  rL LLVM

https://reviews.llvm.org/D31167




[PATCH] D31153: Add the ability to use the children() range API in a const-correct manner

2017-04-11 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: include/clang/AST/Expr.h:4025
   child_range children() {
+const_child_range CCR = const_cast(this)->children();
+return child_range(cast_away_const(CCR.begin()),

If this is adding const, can you use a weaker cast? (I guess what would be 
ideal here would be implicit_cast - if you're interested you could add that - 
otherwise... yeah, I guess static_cast could do other nasty things, etc, so 
there's nothing good)



Comment at: include/clang/AST/StmtIterator.h:148-150
+inline StmtIterator cast_away_const(const ConstStmtIterator ) {
+  return RHS;
+}

Maybe I'm missing something - what stops code from doing this conversion 
implicitly/accidentally all over the place? (I would've expecetd 
cast_away_const to be a friend or something, to only allow the conversion 
through this explicit call/operation)


https://reviews.llvm.org/D31153



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


[PATCH] D31860: Add more examples to clang tidy checkers

2017-04-11 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added inline comments.



Comment at: docs/clang-tidy/checks/misc-unused-parameters.rst:15
+
+  void a(int  /*i*/) {}
+

alexfh wrote:
> nit: two spaces before the comment.
I believe it is the case ? 
I stole this from the unit test //test/clang-tidy/misc-unused-parameters.c//



Comment at: docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst:11
+
+  delete P.release();
+

alexfh wrote:
> nit: I'd add a bit more context, namely the definition of P.
done in r299961


https://reviews.llvm.org/D31860



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


[clang-tools-extra] r299961 - Add the definition of P in the clang tidy example

2017-04-11 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Tue Apr 11 11:28:15 2017
New Revision: 299961

URL: http://llvm.org/viewvc/llvm-project?rev=299961=rev
Log:
Add the definition of P in the clang tidy example

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst?rev=299961=299960=299961=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uniqueptr-delete-release.rst
 Tue Apr 11 11:28:15 2017
@@ -8,8 +8,10 @@ The latter is shorter, simpler and does
 
 .. code-block:: c++
 
+  std::unique_ptr P;
   delete P.release();
 
   // becomes
 
+  std::unique_ptr P;
   P = nullptr;


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


[PATCH] D31167: Use FPContractModeKind universally

2017-04-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: cfe/trunk/include/clang/Basic/LangOptions.def:220
+/// \brief FP_CONTRACT mode (on/off/fast).
+ENUM_LANGOPT(DefaultFPContractMode, FPContractModeKind, 2, FPC_Off, "FP 
contraction type")
 LANGOPT(NoBitFieldTypeAlign , 1, 0, "bit-field type alignment")

anemet wrote:
> yaxunl wrote:
> > anemet wrote:
> > > yaxunl wrote:
> > > > This change seemed to cause some performance degradations in some 
> > > > OpenCL applications.
> > > > 
> > > > This option used to be on by default. Now it is off by default.
> > > > 
> > > > There are applications do separated compile/link/codegen stages. In the 
> > > > codegen stage, clang is invoked with .bc as input, therefore this 
> > > > option is off by default, whereas it was on by default before this 
> > > > change.
> > > > 
> > > > Is there any reason not to keep the original behavior?
> > > > 
> > > > Thanks.
> > > > This change seemed to cause some performance degradations in some 
> > > > OpenCL applications.
> > > > 
> > > > This option used to be on by default. Now it is off by default.
> > > 
> > > It's always been off.  It was set to fast for CUDA which should still be 
> > > the case.  See the changes further down on the patch.
> > > 
> > > > 
> > > > There are applications do separated compile/link/codegen stages. In the 
> > > > codegen stage, clang is invoked with .bc as input, therefore this 
> > > > option is off by default, whereas it was on by default before this 
> > > > change.
> > > > 
> > > > Is there any reason not to keep the original behavior?
> > > 
> > > Sorry but I am not sure what changed, can you elaborate on what you're 
> > > doing and how things used to work for you?
> > Before your change, -ffp-contract was a codegen option defined as
> > 
> > 
> > ```
> > ENUM_CODEGENOPT(FPContractMode, FPContractModeKind, 2, FPC_On)
> > ```
> > 
> > therefore the default value as on. After your change, it becomes off by 
> > default.
> No. -ffp-contract=on was a FE option and -ffp-contract=fast was a backend 
> option.  I still don't understand your use-case.  Can you include a small 
> testcase how this used to work before?
-ffp-contract=on used to be a codegen option before this change. In 
CodeGen/BackendUtil.cpp, before this change:

```
switch (CodeGenOpts.getFPContractMode()) {
  switch (LangOpts.getDefaultFPContractMode()) {
  case LangOptions::FPC_Off:
Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
break;
  case LangOptions::FPC_On:
Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
break;
  case LangOptions::FPC_Fast:
Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
break;
  }
```
By default, -fp-contract=on, which results in llvm::FPOpFusion::Standard in the 
backend. This options allows backend to translate llvm.fmuladd to FMA machine 
instructions.

After this change, it becomes:

```
switch (LangOpts.getDefaultFPContractMode()) {
  case LangOptions::FPC_Off:
Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
break;
  case LangOptions::FPC_On:
Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
break;
  case LangOptions::FPC_Fast:
Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
break;
  }
```
now by default -ffp-contract=off, which results in  llvm::FPOpFusion::Strict in 
the backend. This option disables backend translating llvm.fmuladd to FMA 
machine instructions in certain situations.

A simple lit test is as follows:


```
; RUN: %clang_cc1 -triple amdgcn -S -o - %s| FileCheck %s

define amdgpu_kernel void @f(double addrspace(1)* nocapture %out, double %a, 
double %b, double %c) local_unnamed_addr #0 {
entry:
  ; CHECK: v_fma_f64
  %0 = tail call double @llvm.fmuladd.f64(double %b, double %c, double %a)
  store double %0, double addrspace(1)* %out, align 8, !tbaa !6
  ret void
}

declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" 
"disable-tail-calls"="false" "less-precise-fpmad"="false" 
"no-frame-pointer-elim"="false" "no-infs-fp-math"="false" 
"no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false" 
"stack-protector-buffer-size"="8" 
"target-features"="+fp64-fp16-denormals,-fp32-denormals" 
"unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone }

```
The test passes before this change and fails after this change.



Comment at: cfe/trunk/lib/Frontend/CompilerInvocation.cpp:1638
 Opts.LaxVectorConversions = 0;
-Opts.DefaultFPContract = 1;
+Opts.setDefaultFPContractMode(LangOptions::FPC_On);
 Opts.NativeHalfType = 1;

yaxunl wrote:
> hfinkel wrote:
> > yaxunl wrote:
> > > hfinkel wrote:
> > > > Looks like the intent is certainly to have kept the OpenCL default the 
> > > > same here.
> > > Well we also use clang to compile LLVM IR to ISA. Before this change, 
> > > fp-contract 

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

2017-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 94842.
gtbercea added a comment.

Run clang format.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s 
intermediate files.
 // RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,7 +492,12 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP)
+CC1Args.push_back(
+DriverArgs.getLastArgValue(options::OPT_fopenmp_ptx_EQ, "+ptx42"));
+  else
+CC1Args.push_back("+ptx42");
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], "fopenmp-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
   HelpText<"Pass a single CUDA GPU architecture (default sm_20) to be used by 
OpenMP device offloading.">;
+def fopenmp_ptx_EQ : Joined<["--"], "fopenmp-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Pass a PTX version +ptxXX, default +ptx42 (for PTX version 4.2) 
used by OpenMP device offloading.">;
 def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
   HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s intermediate files.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,7 +492,12 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP)
+CC1Args.push_back(
+DriverArgs.getLastArgValue(options::OPT_fopenmp_ptx_EQ, "+ptx42"));
+  else
+CC1Args.push_back("+ptx42");
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : 

[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Reverted in r299956, due to failures like:

  template  static int __test(...);
  
  template
  auto v = __test<_Tp>(0);


https://reviews.llvm.org/D29877



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


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

2017-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 94841.
gtbercea added a comment.

Refactor.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s 
intermediate files.
 // RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,7 +492,11 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP)
+CC1Args.push_back(DriverArgs.getLastArgValue(options::OPT_fopenmp_ptx_EQ, 
"+ptx42"));
+  else
+CC1Args.push_back("+ptx42");
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], "fopenmp-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
   HelpText<"Pass a single CUDA GPU architecture (default sm_20) to be used by 
OpenMP device offloading.">;
+def fopenmp_ptx_EQ : Joined<["--"], "fopenmp-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Pass a PTX version +ptxXX, default +ptx42 (for PTX version 4.2) 
used by OpenMP device offloading.">;
 def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
   HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s intermediate files.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,7 +492,11 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP)
+CC1Args.push_back(DriverArgs.getLastArgValue(options::OPT_fopenmp_ptx_EQ, "+ptx42"));
+  else
+CC1Args.push_back("+ptx42");
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], 

[PATCH] D30863: [clang-format] make docs/tools/{dump_format_style.py, dump_ast_matchers.py} flake8 compliant

2017-04-11 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Manuel, is that ok with you?


https://reviews.llvm.org/D30863



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


r299956 - Revert temporarily D29877 "Warn about unused static file scope function template declarations."

2017-04-11 Thread Vassil Vassilev via cfe-commits
Author: vvassilev
Date: Tue Apr 11 11:05:23 2017
New Revision: 299956

URL: http://llvm.org/viewvc/llvm-project?rev=299956=rev
Log:
Revert temporarily D29877 "Warn about unused static file scope function 
template declarations."

We need to address cases (breaking libc++) such as

template  static int __test(...);

template
auto v = __test<_Tp>(0);




Modified:
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=299956=299955=299956=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Tue Apr 11 11:05:23 2017
@@ -470,13 +470,6 @@ static bool ShouldRemoveFromUnused(Sema
 return true;
 
   if (const FunctionDecl *FD = dyn_cast(D)) {
-// If this is a function template and none of its specializations is used,
-// we should warn.
-if (FunctionTemplateDecl *Template = FD->getDescribedFunctionTemplate())
-  for (const auto *Spec : Template->specializations())
-if (ShouldRemoveFromUnused(SemaRef, Spec))
-  return true;
-
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const FunctionDecl *DeclToCheck;
@@ -500,13 +493,6 @@ static bool ShouldRemoveFromUnused(Sema
 VD->isUsableInConstantExpressions(SemaRef->Context))
   return true;
 
-if (VarTemplateDecl *Template = VD->getDescribedVarTemplate())
-  // If this is a variable template and none of its specializations is 
used,
-  // we should warn.
-  for (const auto *Spec : Template->specializations())
-if (ShouldRemoveFromUnused(SemaRef, Spec))
-  return true;
-
 // UnusedFileScopedDecls stores the first declaration.
 // The declaration may have become definition so check again.
 const VarDecl *DeclToCheck = VD->getDefinition();

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=299956=299955=299956=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 11 11:05:23 2017
@@ -8887,7 +8887,6 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 if (FunctionTemplate) {
   if (NewFD->isInvalidDecl())
 FunctionTemplate->setInvalidDecl();
-  MarkUnusedFileScopedDecl(NewFD);
   return FunctionTemplate;
 }
   }
@@ -10988,7 +10987,8 @@ static bool hasDependentAlignment(VarDec
 
 /// FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform
 /// any semantic actions necessary after any initializer has been attached.
-void Sema::FinalizeDeclaration(Decl *ThisDecl) {
+void
+Sema::FinalizeDeclaration(Decl *ThisDecl) {
   // Note that we are no longer parsing the initializer for this declaration.
   ParsingInitForAutoVars.erase(ThisDecl);
 
@@ -11153,8 +11153,9 @@ void Sema::FinalizeDeclaration(Decl *Thi
   if (DC->getRedeclContext()->isFileContext() && VD->isExternallyVisible())
 AddPushedVisibilityAttribute(VD);
 
-  // FIXME: Warn on unused var template partial specializations.
-  if (VD->isFileVarDecl() && !isa(VD))
+  // FIXME: Warn on unused templates.
+  if (VD->isFileVarDecl() && !VD->getDescribedVarTemplate() &&
+  !isa(VD))
 MarkUnusedFileScopedDecl(VD);
 
   // Now we have parsed the initializer and can update the table of magic

Modified: cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp?rev=299956=299955=299956=diff
==
--- cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-filescoped.cpp Tue Apr 11 11:05:23 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function 
-Wno-unused-local-typedefs -Wno-c++11-extensions -std=c++98 %s
-// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function 
-Wno-unused-local-typedefs -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused -Wunused-member-function 
-Wno-unused-local-typedefs -std=c++11 %s
 
 #ifdef HEADER
 
@@ -65,7 +65,7 @@ namespace {
   template <> void TS::m() { }  // expected-warning{{unused}}
 
   template 
-  void tf() { }  // expected-warning{{unused}}
+  void tf() { }
   template <> void tf() { }  // expected-warning{{unused}}
   
   struct VS {
@@ -200,18 +200,6 @@ void bar() { void func() __attribute__((
 static void func() {}
 }
 
-namespace test9 {
-template
-static void completeRedeclChainForTemplateSpecialization() { } // 
expected-warning {{unused}}
-}
-
-namespace test10 {
-#if __cplusplus >= 201103L
-template
-constexpr T pi = T(3.14); // 

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM! Thanks!


https://reviews.llvm.org/D31404



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-11 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

Landed in r299952: 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170410/189882.html


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


r299952 - [clang-format] Recognize Java logical shift assignment operator

2017-04-11 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Apr 11 10:50:04 2017
New Revision: 299952

URL: http://llvm.org/viewvc/llvm-project?rev=299952=rev
Log:
[clang-format] Recognize Java logical shift assignment operator 

At present, clang-format mangles Java containing logical right shift operators
('>>>=' or '>>>'), splitting them in two, resulting in invalid code:

 public class Minimal {
   public void func(String args) {
 int i = 42;
-i >>>= 1;
+i >> >= 1;
 return i;
   }
 }

This adds both forms of logical right shift to the FormatTokenLexer, so
clang-format won't attempt to split them and insert bogus whitespace.

https://reviews.llvm.org/D31652
Patch from Richard Bradfield !

Modified:
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp

Modified: cfe/trunk/lib/Format/FormatTokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.cpp?rev=299952=299951=299952=diff
==
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp (original)
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp Tue Apr 11 10:50:04 2017
@@ -84,6 +84,19 @@ void FormatTokenLexer::tryMergePreviousT
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
   }
+
+  if (Style.Language == FormatStyle::LK_Java) {
+static const tok::TokenKind JavaRightLogicalShift[] = {tok::greater,
+   tok::greater,
+   tok::greater};
+static const tok::TokenKind JavaRightLogicalShiftAssign[] = {tok::greater,
+ tok::greater,
+ 
tok::greaterequal};
+if (tryMergeTokens(JavaRightLogicalShift, TT_BinaryOperator))
+  return;
+if (tryMergeTokens(JavaRightLogicalShiftAssign, TT_BinaryOperator))
+  return;
+  }
 }
 
 bool FormatTokenLexer::tryMergeNSStringLiteral() {

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=299952=299951=299952=diff
==
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Apr 11 10:50:04 2017
@@ -522,5 +522,17 @@ TEST_F(FormatTestJava, AlignsBlockCommen
"  void f() {}"));
 }
 
+TEST_F(FormatTestJava, RetainsLogicalShifts) {
+verifyFormat("void f() {\n"
+ "  int a = 1;\n"
+ "  a >>>= 1;\n"
+ "}");
+verifyFormat("void f() {\n"
+ "  int a = 1;\n"
+ "  a = a >>> 1;\n"
+ "}");
+}
+
+
 } // end namespace tooling
 } // end namespace clang


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


[PATCH] D25321: Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

2017-04-11 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299951: Fix PR13910: Don't warn that __builtin_unreachable() 
is unreachable (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D25321?vs=73898=94834#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25321

Files:
  cfe/trunk/lib/Analysis/ReachableCode.cpp
  cfe/trunk/test/Sema/warn-unreachable.c


Index: cfe/trunk/test/Sema/warn-unreachable.c
===
--- cfe/trunk/test/Sema/warn-unreachable.c
+++ cfe/trunk/test/Sema/warn-unreachable.c
@@ -461,3 +461,40 @@
   if (!true) // expected-note {{silence by adding parentheses to mark code as 
explicitly dead}}
 testTrueFalseMacros(); // expected-warning {{code will never be executed}}
 }
+
+int pr13910_foo(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  __builtin_unreachable(); // expected no warning
+}
+
+int pr13910_bar(int x) {
+  switch (x) {
+  default:
+return x + 1;
+  }
+  pr13910_foo(x); // expected-warning {{code will never be executed}}
+}
+
+int pr13910_bar2(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+  __builtin_unreachable(); // expected no warning
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+}
+
+void pr13910_noreturn() {
+  raze();
+  __builtin_unreachable(); // expected no warning
+}
+
+void pr13910_assert() {
+  myassert(0 && "unreachable");
+  return;
+  __builtin_unreachable(); // expected no warning
+}
Index: cfe/trunk/lib/Analysis/ReachableCode.cpp
===
--- cfe/trunk/lib/Analysis/ReachableCode.cpp
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp
@@ -58,6 +58,14 @@
   return false;
 }
 
+static bool isBuiltinUnreachable(const Stmt *S) {
+  if (const auto *DRE = dyn_cast(S))
+if (const auto *FDecl = dyn_cast(DRE->getDecl()))
+  return FDecl->getIdentifier() &&
+ FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
+  return false;
+}
+
 static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
   // Look to see if the current control flow ends with a 'return', and see if
   // 'S' is a substatement. The 'return' may not be the last element in the
@@ -592,8 +600,7 @@
 
   if (isa(S)) {
 UK = reachable_code::UK_Break;
-  }
-  else if (isTrivialDoWhile(B, S)) {
+  } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(S)) {
 return;
   }
   else if (isDeadReturn(B, S)) {


Index: cfe/trunk/test/Sema/warn-unreachable.c
===
--- cfe/trunk/test/Sema/warn-unreachable.c
+++ cfe/trunk/test/Sema/warn-unreachable.c
@@ -461,3 +461,40 @@
   if (!true) // expected-note {{silence by adding parentheses to mark code as explicitly dead}}
 testTrueFalseMacros(); // expected-warning {{code will never be executed}}
 }
+
+int pr13910_foo(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  __builtin_unreachable(); // expected no warning
+}
+
+int pr13910_bar(int x) {
+  switch (x) {
+  default:
+return x + 1;
+  }
+  pr13910_foo(x); // expected-warning {{code will never be executed}}
+}
+
+int pr13910_bar2(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+  __builtin_unreachable(); // expected no warning
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+}
+
+void pr13910_noreturn() {
+  raze();
+  __builtin_unreachable(); // expected no warning
+}
+
+void pr13910_assert() {
+  myassert(0 && "unreachable");
+  return;
+  __builtin_unreachable(); // expected no warning
+}
Index: cfe/trunk/lib/Analysis/ReachableCode.cpp
===
--- cfe/trunk/lib/Analysis/ReachableCode.cpp
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp
@@ -58,6 +58,14 @@
   return false;
 }
 
+static bool isBuiltinUnreachable(const Stmt *S) {
+  if (const auto *DRE = dyn_cast(S))
+if (const auto *FDecl = dyn_cast(DRE->getDecl()))
+  return FDecl->getIdentifier() &&
+ FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
+  return false;
+}
+
 static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
   // Look to see if the current control flow ends with a 'return', and see if
   // 'S' is a substatement. The 'return' may not be the last element in the
@@ -592,8 +600,7 @@
 
   if (isa(S)) {
 UK = reachable_code::UK_Break;
-  }
-  else if (isTrivialDoWhile(B, S)) {
+  } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(S)) {
 return;
   }
   else if (isDeadReturn(B, S)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r299951 - Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

2017-04-11 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Apr 11 10:36:06 2017
New Revision: 299951

URL: http://llvm.org/viewvc/llvm-project?rev=299951=rev
Log:
Fix PR13910: Don't warn that __builtin_unreachable() is unreachable

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

Modified:
cfe/trunk/lib/Analysis/ReachableCode.cpp
cfe/trunk/test/Sema/warn-unreachable.c

Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=299951=299950=299951=diff
==
--- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp Tue Apr 11 10:36:06 2017
@@ -58,6 +58,14 @@ static bool isTrivialDoWhile(const CFGBl
   return false;
 }
 
+static bool isBuiltinUnreachable(const Stmt *S) {
+  if (const auto *DRE = dyn_cast(S))
+if (const auto *FDecl = dyn_cast(DRE->getDecl()))
+  return FDecl->getIdentifier() &&
+ FDecl->getBuiltinID() == Builtin::BI__builtin_unreachable;
+  return false;
+}
+
 static bool isDeadReturn(const CFGBlock *B, const Stmt *S) {
   // Look to see if the current control flow ends with a 'return', and see if
   // 'S' is a substatement. The 'return' may not be the last element in the
@@ -592,8 +600,7 @@ void DeadCodeScan::reportDeadCode(const
 
   if (isa(S)) {
 UK = reachable_code::UK_Break;
-  }
-  else if (isTrivialDoWhile(B, S)) {
+  } else if (isTrivialDoWhile(B, S) || isBuiltinUnreachable(S)) {
 return;
   }
   else if (isDeadReturn(B, S)) {

Modified: cfe/trunk/test/Sema/warn-unreachable.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-unreachable.c?rev=299951=299950=299951=diff
==
--- cfe/trunk/test/Sema/warn-unreachable.c (original)
+++ cfe/trunk/test/Sema/warn-unreachable.c Tue Apr 11 10:36:06 2017
@@ -461,3 +461,40 @@ void testTrueFalseMacros() {
   if (!true) // expected-note {{silence by adding parentheses to mark code as 
explicitly dead}}
 testTrueFalseMacros(); // expected-warning {{code will never be executed}}
 }
+
+int pr13910_foo(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  __builtin_unreachable(); // expected no warning
+}
+
+int pr13910_bar(int x) {
+  switch (x) {
+  default:
+return x + 1;
+  }
+  pr13910_foo(x); // expected-warning {{code will never be executed}}
+}
+
+int pr13910_bar2(int x) {
+  if (x == 1)
+return 0;
+  else
+return x;
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+  __builtin_unreachable(); // expected no warning
+  pr13910_foo(x);  // expected-warning {{code will never be executed}}
+}
+
+void pr13910_noreturn() {
+  raze();
+  __builtin_unreachable(); // expected no warning
+}
+
+void pr13910_assert() {
+  myassert(0 && "unreachable");
+  return;
+  __builtin_unreachable(); // expected no warning
+}


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


[PATCH] D31417: [OpenMP] Add support for omp simd pragmas without runtime

2017-04-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Parse/ParseOpenMP.cpp:174
+  case OMPD_target_teams_distribute_simd:
+DKind = OMPD_simd;
+break;

huntergr wrote:
> ABataev wrote:
> > huntergr wrote:
> > > rengolin wrote:
> > > > I'd like @ABataev to confirm this is the right semantics.
> > > Yes, would be good. I don't think there's a formal spec for this feature, 
> > > but it's possible that directives intended for a different target than 
> > > the cpu shouldn't apply with this flag.
> > I don't think you need it here. Instead, you should keep an existing logic 
> > in Sema/Parsing code, but you need to create your own OpenMPRuntime support 
> > class, that supports only emission of simd part of the constructs.
> Thanks for taking a look.
> 
> I tried this method first, but came to the conclusion it was too invasive. 
> I've now tried it a second time and came to the same conclusion.
> 
> The problem isn't in generating 'simd' or 'declare simd' from a custom 
> runtime class, but in generating everything else. Take a 'parallel for' 
> directive -- I have to generate something close to unmodified code, but 
> 'emitCommonOMPParallelDirective' in CGStmtOpenMP.cpp will only pass the loop 
> codegen lambda through to the runtime class's 'emitParallelOutlinedFunction', 
> which doesn't take the current CodeGenFunction as an argument (as it's 
> expected to create a new one). There doesn't seem to be a good way to look up 
> the CGF that the call will be made from.
> 
> You also won't get unmodified code in that instance anyway, as the loop is 
> generated by CodeGenFunction::EmitWorkSharingLoop, and a cancellation region 
> may be created; very little of this is under the control of the runtime 
> class, so it would need extensive modification to work.
> 
> So I'll switch to using a simd-only 'runtime' class, but I still think we 
> need to filter out non-simd directives before we get to codegen. Will post 
> updated patch soon.
1. I don't think it is a good idea to skip the checks for non-simd constructs 
in this new mode. I'd prefer to emit all diagnostics as usual. Thus, we can't 
simply translate all simd-related constructs into 'omp simd' only, as we're 
going to loose checks/diagnostics.
Keep in minв that you will need to update all diagnostics-specific tests to 
check that the same errors/warnings are emitted even in `-fopenmp-simd` mode.
2. You should not rewrite everything. You can do something like this:
file lib/CodeGen/CGStmt.cpp, function `void CodeGenFunction::EmitStmt(const 
Stmt *S)`
Insert before `switch (S->getStmtClass())`:
```
if (LangOpts.OpenMPSimd && isa(S)) {
  if (isOpenMPSimdDirective(S))
EmitOMPSimdDirective(S);
  else
EmitOMPInlinedDirective(S);
  return;
}
```
`EmitOMPSimdDirective(S)` shall emit the simd-specific code for all 
simd-related directives, while `EmitOMPInlinedDirective(S)` shall emit the code 
for all other constructs, ingnoring OpenMP directives.


https://reviews.llvm.org/D31417



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Complete reproducer:

// Tested with with:  clang++ -std=c++14 -Wunused-function UnusedFVassily.cpp 
//
// UnusedFVassily.cpp:8:39: warning: unused function '__test' 
[-Wunused-function]
// template  static __two __test(...);
//   ^
// UnusedFVassily.cpp:9:38: warning: unused function '__test' 
[-Wunused-function]
// template  static char __test(typename _Up::pointer* = 0);
//  ^
// 2 warnings generated.

#include 

namespace foo {

struct __two {char __lx; char __lxx;};
namespace __has_pointer_type_imp
{

  template  static __two __test(...);
  template  static char __test(typename _Up::pointer* = 0);

}

template 
struct __has_pointer_type

  : public std::integral_constant(0)) == 1>

{
};

}

struct S1 {};
struct S2 { typedef void *pointer; };

int main () {
static_assert (!foo::__has_pointer_type::value, "" );
static_assert ( foo::__has_pointer_type::value, "" );
}


https://reviews.llvm.org/D29877



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


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

2017-04-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:499
+options::OPT_fopenmp_ptx_EQ);
+CC1Args.back() = (!PtxVersion.empty()) ? PtxVersion.data() : "+ptx42";
+  } else

No, use `CC1Args.push_back()` here, or `CC1Args.emplace_back()`, which is even 
better.
Why you don't want to use the code I proposed in my previous comment?


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:358-360
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(

gtbercea wrote:
> ABataev wrote:
> > Could you join these 2 functions into one?
> Since SI and StarI use different types of iterations the functions cannot be 
> merged.
I still believe you can reuse this new code:
```
  bool checkMappableExprComponentListsForDecl(
  ValueDecl *VD, bool CurrentRegionOnly,
  const llvm::function_ref<
  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
   OpenMPClauseKind)> ) {
if (Stack.empty())
  return false;

if (CurrentRegionOnly)
  return checkMappableExprComponentListsForDeclAtLevel(VD, Stack.size() - 
1, Check);

for (unsigned I = Stack.size(); I > 0; --I)
  if (checkMappableExprComponentListsForDeclAtLevel(VD, I - 1, Check))
return true; 
return false;
  }
```
or something like this.


Repository:
  rL LLVM

https://reviews.llvm.org/D29905



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-11 Thread Richard Bradfield via Phabricator via cfe-commits
bradfier added a comment.

In https://reviews.llvm.org/D31652#723664, @thakis wrote:

> Looks good. Do you have commit access?


Thanks! And no I don't have commit access.


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

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



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+  hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+  .bind("for_loop"),

hokein wrote:
> aaron.ballman wrote:
> > hokein wrote:
> > > aaron.ballman wrote:
> > > > I'm really not keen on this. It will catch trivial cases, so there is 
> > > > some utility, but this will quickly fall apart with anything past the 
> > > > trivial case.
> > > The motivation of this check is to find code patterns like `for (int i = 
> > > 0; i < n; ++i) { v.push_back(i); }` and clean them in our codebase (we 
> > > have lots of similar cases). 
> > > [These](https://docs.google.com/document/d/1Bbc-6DlNs6zQujWD5-XOHWbfPJVMG7Z_T27Kv0WcFb4/edit?usp=sharing)
> > >  are all cases we want to support. Using `hasParent` is a simple and 
> > > sufficient way to do it IMO.
> > I'm not convinced of the utility without implementing this in a more 
> > sensitive way. Have you run this across any large code bases and found that 
> > it catches issues?
> Yeah, the check catches ~2800 cases (regexp shows ~17,000 total usages) in 
> our internal codebase. And all caught cases are what we are interested in. It 
> would catch more if we support for-range loops and iterator-based for-loops. 
I wasn't worried about it not triggering often enough, I was worried about it 
triggering too often because of the lack of sensitivity. If you randomly sample 
some of those 2800 cases, do they reserve the space in a way that your check 
isn't catching?


https://reviews.llvm.org/D31757



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-11 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Looks good. Do you have commit access?


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


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

2017-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 94824.
gtbercea added a comment.

Integrate review.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s 
intermediate files.
 // RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,7 +492,13 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+StringRef PtxVersion = DriverArgs.getLastArgValue(
+options::OPT_fopenmp_ptx_EQ);
+CC1Args.back() = (!PtxVersion.empty()) ? PtxVersion.data() : "+ptx42";
+  } else
+CC1Args.push_back("+ptx42");
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -529,6 +529,8 @@
   HelpText<"CUDA installation path">;
 def fopenmp_cuda_gpu_arch_EQ : Joined<["--"], "fopenmp-cuda-gpu-arch=">, 
Flags<[DriverOption]>,
   HelpText<"Pass a single CUDA GPU architecture (default sm_20) to be used by 
OpenMP device offloading.">;
+def fopenmp_ptx_EQ : Joined<["--"], "fopenmp-ptx=">, Flags<[DriverOption]>,
+  HelpText<"Pass a PTX version +ptxXX, default +ptx42 (for PTX version 4.2) 
used by OpenMP device offloading.">;
 def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
   HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -634,6 +634,16 @@
 
 /// ###
 
+/// Check PTXAS is passed the compute capability passed to the driver.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
+
+// CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+// CHK-PTXAS-VERSION-NEXT: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s intermediate files.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -492,7 +492,13 @@
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+
+  if (DeviceOffloadingKind == Action::OFK_OpenMP) {
+StringRef PtxVersion = DriverArgs.getLastArgValue(
+options::OPT_fopenmp_ptx_EQ);
+CC1Args.back() = (!PtxVersion.empty()) ? PtxVersion.data() : "+ptx42";
+  } else
+CC1Args.push_back("+ptx42");
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
Index: include/clang/Driver/Options.td
===
--- 

[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@mclow.lists, hm... it seems that I cannot reproduce it. It'd really help if 
you could paste a standalone reproducer.


https://reviews.llvm.org/D29877



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


[PATCH] D26503: [Parser][ObjC] Improve diagnostics and recovery when C++ keywords are used as identifiers in Objective-C++

2017-04-11 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299950: [Parser][ObjC++] Improve diagnostics and recovery 
when C++ keywords are used (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D26503?vs=78218=94823#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26503

Files:
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/include/clang/Basic/IdentifierTable.h
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/lib/Basic/IdentifierTable.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/lib/Parse/Parser.cpp
  cfe/trunk/test/Parser/objc-cxx-keyword-identifiers.mm

Index: cfe/trunk/include/clang/Basic/IdentifierTable.h
===
--- cfe/trunk/include/clang/Basic/IdentifierTable.h
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h
@@ -280,7 +280,11 @@
   bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; }
 
   /// \brief Return true if this token is a keyword in the specified language.
-  bool isKeyword(const LangOptions );
+  bool isKeyword(const LangOptions ) const;
+
+  /// \brief Return true if this token is a C++ keyword in the specified
+  /// language.
+  bool isCPlusPlusKeyword(const LangOptions ) const;
 
   /// getFETokenInfo/setFETokenInfo - The language front-end is allowed to
   /// associate arbitrary metadata with this token.
Index: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
@@ -436,6 +436,13 @@
   "declaration does not declare a parameter">;
 def err_no_matching_param : Error<"parameter named %0 is missing">;
 
+/// Objective-C++ parser diagnostics
+def err_expected_token_instead_of_objcxx_keyword : Error<
+  "expected %0; %1 is a keyword in Objective-C++">;
+def err_expected_member_name_or_semi_objcxx_keyword : Error<
+  "expected member name or ';' after declaration specifiers; "
+  "%0 is a keyword in Objective-C++">;
+
 /// C++ parser diagnostics
 def err_invalid_operator_on_type : Error<
   "cannot use %select{dot|arrow}0 operator on a type">;
Index: cfe/trunk/include/clang/Parse/Parser.h
===
--- cfe/trunk/include/clang/Parse/Parser.h
+++ cfe/trunk/include/clang/Parse/Parser.h
@@ -800,6 +800,14 @@
   /// \brief Consume any extra semi-colons until the end of the line.
   void ConsumeExtraSemi(ExtraSemiKind Kind, unsigned TST = TST_unspecified);
 
+  /// Return false if the next token is an identifier. An 'expected identifier'
+  /// error is emitted otherwise.
+  ///
+  /// The parser tries to recover from the error by checking if the next token
+  /// is a C++ keyword when parsing Objective-C++. Return false if the recovery
+  /// was successful.
+  bool expectIdentifier();
+
 public:
   //======//
   // Scope manipulation
Index: cfe/trunk/test/Parser/objc-cxx-keyword-identifiers.mm
===
--- cfe/trunk/test/Parser/objc-cxx-keyword-identifiers.mm
+++ cfe/trunk/test/Parser/objc-cxx-keyword-identifiers.mm
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-objc-root-class -Wno-incomplete-implementation -triple x86_64-apple-macosx10.10.0 -verify %s
+
+// rdar://20626062
+
+struct S {
+  int throw; // expected-error {{expected member name or ';' after declaration specifiers; 'throw' is a keyword in Objective-C++}}
+};
+
+@interface class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
+@end
+
+@interface Bar: class // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
+@end
+
+@protocol P // ok
+@end
+
+@protocol new // expected-error {{expected identifier; 'new' is a keyword in Objective-C++}}
+@end
+
+@protocol P2, delete; // expected-error {{expected identifier; 'delete' is a keyword in Objective-C++}}
+
+@class Foo, try; // expected-error {{expected identifier; 'try' is a keyword in Objective-C++}}
+
+@interface Foo
+
+@property (readwrite, nonatomic) int a, b, throw; // expected-error {{expected member name or ';' after declaration specifiers; 'throw' is a keyword in Objective-C++}}
+
+-foo:(int)class; // expected-error {{expected identifier; 'class' is a keyword in Objective-C++}}
++foo:(int)constexpr; // expected-error {{expected identifier; 'constexpr' is a keyword in Objective-C++}}
+
+@end
+
+@interface Foo ()  // expected-error {{expected identifier; 'new' is a keyword in Objective-C++}}
+@end
+
+@implementation Foo
+
+@synthesize a = _a; // ok
+@synthesize b = virtual; // expected-error {{expected identifier; 'virtual' is a keyword in Objective-C++}}
+
+@dynamic throw; // expected-error {{expected identifier; 

r299950 - [Parser][ObjC++] Improve diagnostics and recovery when C++ keywords are used

2017-04-11 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue Apr 11 10:01:53 2017
New Revision: 299950

URL: http://llvm.org/viewvc/llvm-project?rev=299950=rev
Log:
[Parser][ObjC++] Improve diagnostics and recovery when C++ keywords are used
as identifiers in Objective-C++

This commit improves the 'expected identifier' errors that are presented when a
C++ keyword is used as an identifier in Objective-C++ by mentioning that this is
a C++ keyword in the diagnostic message. It also improves the error recovery:
the parser will now treat the C++ keywords as identifiers to prevent unrelated
parsing errors.

rdar://20626062

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

Added:
cfe/trunk/test/Parser/objc-cxx-keyword-identifiers.mm
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=299950=299949=299950=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Tue Apr 11 10:01:53 
2017
@@ -436,6 +436,13 @@ def err_declaration_does_not_declare_par
   "declaration does not declare a parameter">;
 def err_no_matching_param : Error<"parameter named %0 is missing">;
 
+/// Objective-C++ parser diagnostics
+def err_expected_token_instead_of_objcxx_keyword : Error<
+  "expected %0; %1 is a keyword in Objective-C++">;
+def err_expected_member_name_or_semi_objcxx_keyword : Error<
+  "expected member name or ';' after declaration specifiers; "
+  "%0 is a keyword in Objective-C++">;
+
 /// C++ parser diagnostics
 def err_invalid_operator_on_type : Error<
   "cannot use %select{dot|arrow}0 operator on a type">;

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=299950=299949=299950=diff
==
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Tue Apr 11 10:01:53 2017
@@ -280,7 +280,11 @@ public:
   bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; }
 
   /// \brief Return true if this token is a keyword in the specified language.
-  bool isKeyword(const LangOptions );
+  bool isKeyword(const LangOptions ) const;
+
+  /// \brief Return true if this token is a C++ keyword in the specified
+  /// language.
+  bool isCPlusPlusKeyword(const LangOptions ) const;
 
   /// getFETokenInfo/setFETokenInfo - The language front-end is allowed to
   /// associate arbitrary metadata with this token.

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=299950=299949=299950=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Tue Apr 11 10:01:53 2017
@@ -800,6 +800,14 @@ private:
   /// \brief Consume any extra semi-colons until the end of the line.
   void ConsumeExtraSemi(ExtraSemiKind Kind, unsigned TST = TST_unspecified);
 
+  /// Return false if the next token is an identifier. An 'expected identifier'
+  /// error is emitted otherwise.
+  ///
+  /// The parser tries to recover from the error by checking if the next token
+  /// is a C++ keyword when parsing Objective-C++. Return false if the recovery
+  /// was successful.
+  bool expectIdentifier();
+
 public:
   
//======//
   // Scope manipulation

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=299950=299949=299950=diff
==
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Tue Apr 11 10:01:53 2017
@@ -244,7 +244,7 @@ static KeywordStatus getTokenKwStatus(co
 
 /// \brief Returns true if the identifier represents a keyword in the
 /// specified language.
-bool IdentifierInfo::isKeyword(const LangOptions ) {
+bool IdentifierInfo::isKeyword(const LangOptions ) const {
   switch (getTokenKwStatus(LangOpts, getTokenID())) {
   case KS_Enabled:
   case KS_Extension:
@@ -254,6 +254,19 @@ bool IdentifierInfo::isKeyword(const Lan
   }
 }
 
+/// \brief Returns true if the identifier represents a C++ keyword in the
+/// specified language.
+bool IdentifierInfo::isCPlusPlusKeyword(const LangOptions ) 

[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@chapuni, the LLVM warnings should be fixed in r299947.

@mclow.lists, sorry for not giving heads up :( I am working on the false 
positive that you reported.


https://reviews.llvm.org/D29877



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

The following idiom for detecting member typedefs now throws an warning:

  struct __two {char __lx; char __lxx;};
  
  namespace __has_pointer_type_imp
  {
  template  __two __test(...);
  template  char __test(typename _Up::pointer* = 0);
  }
  
  template 
  struct __has_pointer_type
  : public integral_constant(0)) == 1>
  {
  };

Neither function named `__test` is unused; but clang now claims that they are.
Libc++ no longer builds when you have "warnings as errors" enabled.


https://reviews.llvm.org/D29877



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


[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

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



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+  hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+  .bind("for_loop"),

aaron.ballman wrote:
> hokein wrote:
> > aaron.ballman wrote:
> > > I'm really not keen on this. It will catch trivial cases, so there is 
> > > some utility, but this will quickly fall apart with anything past the 
> > > trivial case.
> > The motivation of this check is to find code patterns like `for (int i = 0; 
> > i < n; ++i) { v.push_back(i); }` and clean them in our codebase (we have 
> > lots of similar cases). 
> > [These](https://docs.google.com/document/d/1Bbc-6DlNs6zQujWD5-XOHWbfPJVMG7Z_T27Kv0WcFb4/edit?usp=sharing)
> >  are all cases we want to support. Using `hasParent` is a simple and 
> > sufficient way to do it IMO.
> I'm not convinced of the utility without implementing this in a more 
> sensitive way. Have you run this across any large code bases and found that 
> it catches issues?
Yeah, the check catches ~2800 cases (regexp shows ~17,000 total usages) in our 
internal codebase. And all caught cases are what we are interested in. It would 
catch more if we support for-range loops and iterator-based for-loops. 


https://reviews.llvm.org/D31757



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


[PATCH] D31652: [clang-format] Recognize Java logical shift assignment operator

2017-04-11 Thread Richard Bradfield via Phabricator via cfe-commits
bradfier added a comment.

Friendly ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D31652



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


Re: [PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Marshall Clow via cfe-commits
On Tue, Apr 11, 2017 at 6:59 AM, Alex Lorenz via Phabricator via
cfe-commits  wrote:

> arphaman added a comment.
>
> Ah, I see. I guess if `static` is removed the warning will go away. Thanks!
>
> https://reviews.llvm.org/D29877
>
>
I would have appreciated a heads-up here, since libc++ no longer builds
with warnings-as-errors.

include/memory:

namespace __has_pointer_type_imp
{
template  static __two __test(...);
template  static char __test(typename _Up::pointer* = 0);
}

template 
struct __has_pointer_type
: public integral_constant(0)) == 1>
{
};

That first function is not really "unused" (though clang now claims that it
is)

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


[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-04-11 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/Sema/SemaOpenMP.cpp:358-360
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(

ABataev wrote:
> Could you join these 2 functions into one?
Since SI and StarI use different types of iterations the functions cannot be 
merged.


Repository:
  rL LLVM

https://reviews.llvm.org/D29905



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


[PATCH] D31887: [clangd] Add documentation page

2017-04-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle-ericsson added a comment.

Sorry about all the typos. I have now installed a spell checked in VS Code :)


https://reviews.llvm.org/D31887



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


[PATCH] D31887: [clangd] Add documentation page

2017-04-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle-ericsson updated this revision to Diff 94815.
malaperle-ericsson marked 6 inline comments as done.
malaperle-ericsson added a comment.

Fixed typos and other comments.


https://reviews.llvm.org/D31887

Files:
  docs/clangd.rst
  docs/index.rst

Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -25,6 +25,7 @@
modularize
pp-trace
clang-rename
+   clangd
 
 
 Doxygen Documentation
Index: docs/clangd.rst
===
--- /dev/null
+++ docs/clangd.rst
@@ -0,0 +1,94 @@
+
+Clangd
+
+
+.. contents::
+
+.. toctree::
+   :maxdepth: 1
+
+:program:`clangd` is an implementation of the `Language Server Protocol `_ leveraging Clang.
+Clangd's goal is to provide language "smartness" features like code completion, find references, etc. for clients such as C/C++ Editors.
+
+Using Clangd
+==
+
+:program:`Clangd` is not meant to be used by C/C++ developers directly but rather from a client implementing the protocol.
+A client would be typically implemented in an IDE or an editor.
+
+At the moment, `Visual Studio Code `_ is mainly used
+in order to test :program:`Clangd`` but more clients are likely to make use of :program:`Clangd`` in the
+future as it matures and becomes a production quality tool. If you are interested
+in trying :program:`Clangd`` in combination with Visual Studio Code, you can start by `building Clangd`_,
+then open Visual Studio Code in the clangd-vscode folder and launch the extension.
+
+Building Clangd
+==
+
+You can follow the instructions for `building Clang `_ but "extra Clang Tool" is **not** optional.
+
+Current Status
+==
+
+Many features could be implemented in :program:`Clangd``.
+Here is a list of features that could be useful with the status of whether or
+not they are already implemented in :program:`Clangd`` and specified in the Language Server Protocol.
+Note that for some of the features, it is not clear whether or not they should be part of the
+Language Server Protocol, so those features might be eventually developed outside :program:`Clangd``.
+
++-++--+
+| C/C++ Editor feature|  LSP   |  Clangd  |
++=++==+
+| Formatting  | Yes|   Yes|
++-++--+
+| Completion  | Yes|   Yes|
++-++--+
+| Diagnostics | Yes|   Yes|
++-++--+ 
+| Fix-its | Yes|   Yes|
++-++--+
+| Go to Definition| Yes|   No |
++-++--+
+| Source hover| Yes|   No |
++-++--+
+| Signature Help  | Yes|   No |
++-++--+
+| Find References | Yes|   No |
++-++--+
+| Document Highlights | Yes|   No |
++-++--+
+| Rename  | Yes|   No |
++-++--+
+| Code Lens   | Yes|   No |
++-++--+
+| Syntax and Semantic Coloring| No |   No |
++-++--+
+| Code folding| No |   No |
++-++--+
+| Call hierarchy  | No |   No |
++-++--+
+| Type hierarchy  | No |   No |
++-++--+
+| Organize Includes   | No |   No |
++-++--+
+| Quick Assist| No |   No |
++-++--+
+| Extract Local Variable  | No |   No |
++-++--+
+| Extract Function/Method | No |   No |

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-04-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

Any further comments? Thanks.


https://reviews.llvm.org/D31404



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


[libcxx] r299942 - [libc++] Fix unknown pragma warning on MSVC

2017-04-11 Thread Ben Craig via cfe-commits
Author: bcraig
Date: Tue Apr 11 09:06:39 2017
New Revision: 299942

URL: http://llvm.org/viewvc/llvm-project?rev=299942=rev
Log:
[libc++] Fix unknown pragma warning on MSVC

Modified:
libcxx/trunk/include/limits

Modified: libcxx/trunk/include/limits
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/limits?rev=299942=299941=299942=diff
==
--- libcxx/trunk/include/limits (original)
+++ libcxx/trunk/include/limits Tue Apr 11 09:06:39 2017
@@ -101,12 +101,12 @@ template<> class numeric_limits
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
 
-#include <__config>
 #include 
 
 #include <__undef_min_max>


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


[libcxx] r299941 - Mark P0599 as complete. It was implemented in r298573

2017-04-11 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Apr 11 09:04:03 2017
New Revision: 299941

URL: http://llvm.org/viewvc/llvm-project?rev=299941=rev
Log:
Mark P0599 as complete. It was implemented in r298573

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=299941=299940=299941=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue Apr 11 09:04:03 2017
@@ -156,7 +156,7 @@
http://wg21.link/P0548R1;>P0548R1LWGcommon_type and 
durationKonaComplete5.0
http://wg21.link/P0558R1;>P0558R1LWGResolving 
atomicT named base class 
inconsistenciesKona
http://wg21.link/P0574R1;>P0574R1LWGAlgorithm 
Complexity Constraints and Parallel 
OverloadsKona
-   http://wg21.link/P0599R1;>P0599R1LWGnoexcept for 
hash functionsKona
+   http://wg21.link/P0599R1;>P0599R1LWGnoexcept for 
hash functionsKonaComplete5.0
http://wg21.link/P0604R0;>P0604R0LWGResolving GB 
55, US 84, US 85, US 86Kona
http://wg21.link/P0607R0;>P0607R0LWGInline 
Variables for the Standard LibraryKona
http://wg21.link/P0618R0;>P0618R0LWGDeprecating 
codecvtKona
@@ -489,7 +489,7 @@
 
   
 
-  Last Updated: 23-Mar-2017
+  Last Updated: 11-Apr-2017
 
 
 


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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-04-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 94814.
xazax.hun edited the summary of this revision.
xazax.hun added a comment.

- Removed a clang tool, replaced with python tool functionality.


https://reviews.llvm.org/D30691

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Decl.h
  include/clang/AST/Mangle.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/ItaniumMangle.cpp
  lib/Basic/SourceManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/Inputs/ctu-chain.cpp
  test/Analysis/Inputs/ctu-other.cpp
  test/Analysis/Inputs/externalFnMap.txt
  test/Analysis/ctu-main.cpp
  tools/CMakeLists.txt
  tools/clang-func-mapping/CMakeLists.txt
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/ctu-analysis/ctu-analyze.py
  tools/ctu-analysis/ctu-build.py
  tools/scan-build-py/libscanbuild/runner.py

Index: tools/scan-build-py/libscanbuild/runner.py
===
--- tools/scan-build-py/libscanbuild/runner.py
+++ tools/scan-build-py/libscanbuild/runner.py
@@ -162,7 +162,8 @@
 
 def target():
 """ Creates output file name for reports. """
-if opts['output_format'] in {'plist', 'plist-html'}:
+if opts['output_format'] in {'plist', 'plist-html',
+ 'plist-multi-file'}:
 (handle, name) = tempfile.mkstemp(prefix='report-',
   suffix='.plist',
   dir=opts['output_dir'])
Index: tools/ctu-analysis/ctu-build.py
===
--- /dev/null
+++ tools/ctu-analysis/ctu-build.py
@@ -0,0 +1,230 @@
+#!/usr/bin/env python
+
+import argparse
+import json
+import logging
+import multiprocessing
+import os
+import re
+import signal
+import subprocess
+import shlex
+
+SOURCE_PATTERN = re.compile('.*\.(C|c|cc|cpp|cxx|ii|m|mm)$', re.IGNORECASE)
+TIMEOUT = 86400
+DEFINED_FUNCTIONS_FILENAME = 'definedFns.txt'
+EXTERNAL_FUNCTIONS_FILENAME = 'externalFns.txt'
+EXTERNAL_FUNCTION_MAP_FILENAME = 'externalFnMap.txt'
+
+
+def get_args():
+parser = argparse.ArgumentParser(
+description='Executes 1st pass of CTU analysis where we preprocess '
+'all files in the compilation database and generate '
+'AST dumps and other necessary information from those '
+'to be used later by the 2nd pass of '
+'Cross Translation Unit analysis',
+formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+parser.add_argument('-b', required=True, dest='buildlog',
+metavar='build.json',
+help='JSON Compilation Database to be used')
+parser.add_argument('-p', metavar='preanalyze-dir', dest='ctuindir',
+help='Target directory for preanalyzation data',
+default='.ctu')
+parser.add_argument('-j', metavar='threads', dest='threads', type=int,
+help='Number of threads to be used',
+default=int(multiprocessing.cpu_count() * 1.0))
+parser.add_argument('-v', dest='verbose', action='store_true',
+help='Verbose output')
+parser.add_argument('--clang-path', metavar='clang-path',
+dest='clang_path',
+help='Set path to directory of clang binaries used '
+ '(default taken from CLANG_PATH envvar)',
+default=os.environ.get('CLANG_PATH'))
+mainargs = parser.parse_args()
+
+if mainargs.verbose:
+logging.getLogger().setLevel(logging.INFO)
+
+if mainargs.clang_path is None:
+clang_path = ''
+else:
+clang_path = os.path.abspath(mainargs.clang_path)
+logging.info('CTU uses clang dir: ' +
+ (clang_path if clang_path != '' else ''))
+
+return mainargs, clang_path
+
+
+def process_buildlog(buildlog_filename, src_2_dir, src_2_cmd, src_order,
+ cmd_2_src, cmd_order):
+with open(buildlog_filename, 'r') as buildlog_file:
+buildlog = json.load(buildlog_file)
+for step in buildlog:
+if SOURCE_PATTERN.match(step['file']):
+if step['file'] not in src_2_dir:
+src_2_dir[step['file']] = step['directory']
+src_2_cmd[step['file']] = step['command']
+src_order.append(step['file'])
+if step['command'] not in cmd_2_src:
+cmd_2_src[step['command']] = [step['file']]
+

[PATCH] D31757: [clang-tidy] Add a clang-tidy check for possible inefficient vector operations

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



Comment at: clang-tidy/performance/InefficientVectorOperationCheck.cpp:53-54
+PushBackCall)),
+  hasParent(compoundStmt(unless(has(ReserveCall)),
+ has(VectorVarDefStmt
+  .bind("for_loop"),

hokein wrote:
> aaron.ballman wrote:
> > I'm really not keen on this. It will catch trivial cases, so there is some 
> > utility, but this will quickly fall apart with anything past the trivial 
> > case.
> The motivation of this check is to find code patterns like `for (int i = 0; i 
> < n; ++i) { v.push_back(i); }` and clean them in our codebase (we have lots 
> of similar cases). 
> [These](https://docs.google.com/document/d/1Bbc-6DlNs6zQujWD5-XOHWbfPJVMG7Z_T27Kv0WcFb4/edit?usp=sharing)
>  are all cases we want to support. Using `hasParent` is a simple and 
> sufficient way to do it IMO.
I'm not convinced of the utility without implementing this in a more sensitive 
way. Have you run this across any large code bases and found that it catches 
issues?


https://reviews.llvm.org/D31757



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ah, I see. I guess if `static` is removed the warning will go away. Thanks!


https://reviews.llvm.org/D29877



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@arphaman, it seems they are marked as static and this seemed like a bug to 
@rsmith.


https://reviews.llvm.org/D29877



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

The operators in PointerUnion seem useful. I don't think they should be removed 
even if they're not used in tree, since they might be used by some out-of-tree 
code.


https://reviews.llvm.org/D29877



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added a comment.

I think yes, you may do. Warnings fix may be trivial as far as they are NFC.

It'd be fine that clang tree should be free from warnings with just-built clang.


https://reviews.llvm.org/D29877



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


[PATCH] D29877: Warn about unused static file scope function template declarations.

2017-04-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Thanks for pinging us. Yeah, I knew them but I was hesitant whether I should 
fix them or they should be fixed by the code owners. Shall I commit the fixes?


https://reviews.llvm.org/D29877



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


[PATCH] D31853: [clangd] Implement item kind for completion results

2017-04-11 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299935: [clangd] Implement item kind for completion results 
(authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D31853?vs=94720=94811#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31853

Files:
  clang-tools-extra/trunk/clangd/ASTManager.cpp
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/test/clangd/completion.test

Index: clang-tools-extra/trunk/clangd/ASTManager.cpp
===
--- clang-tools-extra/trunk/clangd/ASTManager.cpp
+++ clang-tools-extra/trunk/clangd/ASTManager.cpp
@@ -76,6 +76,49 @@
   llvm_unreachable("Unknown diagnostic level!");
 }
 
+static CompletionItemKind getKind(CXCursorKind K) {
+  switch (K) {
+  case CXCursor_MacroInstantiation:
+  case CXCursor_MacroDefinition:
+return CompletionItemKind::Text;
+  case CXCursor_CXXMethod:
+return CompletionItemKind::Method;
+  case CXCursor_FunctionDecl:
+  case CXCursor_FunctionTemplate:
+return CompletionItemKind::Function;
+  case CXCursor_Constructor:
+  case CXCursor_Destructor:
+return CompletionItemKind::Constructor;
+  case CXCursor_FieldDecl:
+return CompletionItemKind::Field;
+  case CXCursor_VarDecl:
+  case CXCursor_ParmDecl:
+return CompletionItemKind::Variable;
+  case CXCursor_ClassDecl:
+  case CXCursor_StructDecl:
+  case CXCursor_UnionDecl:
+  case CXCursor_ClassTemplate:
+  case CXCursor_ClassTemplatePartialSpecialization:
+return CompletionItemKind::Class;
+  case CXCursor_Namespace:
+  case CXCursor_NamespaceAlias:
+  case CXCursor_NamespaceRef:
+return CompletionItemKind::Module;
+  case CXCursor_EnumConstantDecl:
+return CompletionItemKind::Value;
+  case CXCursor_EnumDecl:
+return CompletionItemKind::Enum;
+  case CXCursor_TypeAliasDecl:
+  case CXCursor_TypeAliasTemplateDecl:
+  case CXCursor_TypedefDecl:
+  case CXCursor_MemberRef:
+  case CXCursor_TypeRef:
+return CompletionItemKind::Reference;
+  default:
+return CompletionItemKind::Missing;
+  }
+}
+
 ASTManager::ASTManager(JSONOutput , DocumentStore ,
bool RunSynchronously)
 : Output(Output), Store(Store), RunSynchronously(RunSynchronously),
@@ -334,13 +377,15 @@
   CodeCompletionResult *Results,
   unsigned NumResults) override {
 for (unsigned I = 0; I != NumResults; ++I) {
-  CodeCompletionString *CCS = Results[I].CreateCodeCompletionString(
+  CodeCompletionResult  = Results[I];
+  CodeCompletionString *CCS = Result.CreateCodeCompletionString(
   S, Context, *Allocator, CCTUInfo,
   CodeCompleteOpts.IncludeBriefComments);
   if (CCS) {
 CompletionItem Item;
 assert(CCS->getTypedText());
 Item.label = CCS->getTypedText();
+Item.kind = getKind(Result.CursorKind);
 if (CCS->getBriefComment())
   Item.documentation = CCS->getBriefComment();
 Items->push_back(std::move(Item));
Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -672,7 +672,7 @@
   assert(!CI.label.empty() && "completion item label is required");
   Os << R"("label":")" << llvm::yaml::escape(CI.label) << R"(",)";
   if (CI.kind != CompletionItemKind::Missing)
-Os << R"("kind":)" << static_cast(CI.kind) << R"(",)";
+Os << R"("kind":)" << static_cast(CI.kind) << R"(,)";
   if (!CI.detail.empty())
 Os << R"("detail":")" << llvm::yaml::escape(CI.detail) << R"(",)";
   if (!CI.documentation.empty())
Index: clang-tools-extra/trunk/test/clangd/completion.test
===
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/test/clangd/completion.test
@@ -16,9 +16,9 @@
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a"}
-# CHECK-DAG: {"label":"bb"}
-# CHECK-DAG: {"label":"ccc"}
+# CHECK-DAG: {"label":"a","kind":5}
+# CHECK-DAG: {"label":"bb","kind":5}
+# CHECK-DAG: {"label":"ccc","kind":5}
 # CHECK: ]}
 Content-Length: 44
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >