r248015 - [CMake] Refactoring and cleaning up clang symlink generation.

2015-09-18 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Sep 18 13:09:15 2015
New Revision: 248015

URL: http://llvm.org/viewvc/llvm-project?rev=248015=rev
Log:
[CMake] Refactoring and cleaning up clang symlink generation.

Generation of clang symlinks now uses add_clang_symlink macro which uses 
add_llvm_symlink. Also the list of symlinks to generate is configurable via 
CLANG_LINKS_TO_CREATE.

Removed:
cfe/trunk/tools/driver/clang_symlink.cmake
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=248015=248014=248015=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Sep 18 13:09:15 2015
@@ -414,6 +414,14 @@ macro(add_clang_executable name)
   set_clang_windows_version_resource_properties(${name})
 endmacro(add_clang_executable)
 
+macro(add_clang_symlink name dest)
+  add_llvm_tool_symlink(${name} ${dest})
+  # Always generate install targets
+  if(LLVM_INSTALL_TOOLCHAIN_ONLY)
+llvm_install_symlink(${name} ${dest})
+  endif()
+endmacro()
+
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 include_directories(BEFORE

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=248015=248014=248015=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Fri Sep 18 13:09:15 2015
@@ -51,33 +51,6 @@ endif()
 
 add_dependencies(clang clang-headers)
 
-if(UNIX)
-  set(CLANGXX_LINK_OR_COPY create_symlink)
-# Create a relative symlink
-  set(clang_binary "clang${CMAKE_EXECUTABLE_SUFFIX}")
-else()
-  set(CLANGXX_LINK_OR_COPY copy)
-  set(clang_binary 
"${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
-endif()
-
-# Create the clang++ symlink in the build directory.
-set(clang_pp "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++${CMAKE_EXECUTABLE_SUFFIX}")
-add_custom_command(TARGET clang POST_BUILD
-COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" 
"${clang_pp}"
-WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
-
-set_property(DIRECTORY APPEND
-  PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_pp})
-
-# Create the clang-cl symlink in the build directory.
-set(clang_cl 
"${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl${CMAKE_EXECUTABLE_SUFFIX}")
-add_custom_command(TARGET clang POST_BUILD
-COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" 
"${clang_cl}"
-WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
-
-set_property(DIRECTORY APPEND
-  PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_cl})
-
 install(TARGETS clang
   RUNTIME DESTINATION bin
   COMPONENT clang)
@@ -87,8 +60,13 @@ add_custom_target(install-clang
   -DCMAKE_INSTALL_COMPONENT=clang
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
 
-# Create the clang++ and clang-cl symlinks at installation time.
-install(SCRIPT clang_symlink.cmake 
-DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
+if(NOT CLANG_LINKS_TO_CREATE)
+  set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
+endif()
+
+foreach(link ${CLANG_LINKS_TO_CREATE})
+  add_clang_symlink(${link} clang)
+endforeach()
 
 # Configure plist creation for OS X.
 set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")

Removed: cfe/trunk/tools/driver/clang_symlink.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/clang_symlink.cmake?rev=248014=auto
==
--- cfe/trunk/tools/driver/clang_symlink.cmake (original)
+++ cfe/trunk/tools/driver/clang_symlink.cmake (removed)
@@ -1,43 +0,0 @@
-# We need to execute this script at installation time because the
-# DESTDIR environment variable may be unset at configuration time.
-# See PR8397.
-
-if(UNIX)
-  set(CLANGXX_LINK_OR_COPY create_symlink)
-  set(CLANGXX_DESTDIR $ENV{DESTDIR})
-else()
-  set(CLANGXX_LINK_OR_COPY copy)
-endif()
-
-# CMAKE_EXECUTABLE_SUFFIX is undefined on cmake scripts. See PR9286.
-if( WIN32 )
-  set(EXECUTABLE_SUFFIX ".exe")
-else()
-  set(EXECUTABLE_SUFFIX "")
-endif()
-
-set(bindir "${CLANGXX_DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/")
-set(clang "clang${EXECUTABLE_SUFFIX}")
-set(clangxx "clang++${EXECUTABLE_SUFFIX}")
-set(clang_cl "clang-cl${EXECUTABLE_SUFFIX}")
-set(cl "cl${EXECUTABLE_SUFFIX}")
-
-message("Creating clang++ executable based on ${clang}")
-
-execute_process(
-  COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "${clangxx}"
-  WORKING_DIRECTORY "${bindir}")
-
-message("Creating clang-cl executable based on ${clang}")
-
-execute_process(
-  COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" 
"${clang_cl}"
-  WORKING_DIRECTORY "${bindir}")
-
-if (WIN32)
-  message("Creating cl executable based on ${clang}")
-
-  execute_process(
-COMMAND 

r248025 - Revert "[CMake] Refactoring and cleaning up clang symlink generation."

2015-09-18 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Sep 18 14:59:51 2015
New Revision: 248025

URL: http://llvm.org/viewvc/llvm-project?rev=248025=rev
Log:
Revert "[CMake] Refactoring and cleaning up clang symlink generation."

This reverts commit r248015, because it broke bots. I'll revise and recommit.

Added:
cfe/trunk/tools/driver/clang_symlink.cmake
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=248025=248024=248025=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Sep 18 14:59:51 2015
@@ -414,14 +414,6 @@ macro(add_clang_executable name)
   set_clang_windows_version_resource_properties(${name})
 endmacro(add_clang_executable)
 
-macro(add_clang_symlink name dest)
-  add_llvm_tool_symlink(${name} ${dest})
-  # Always generate install targets
-  if(LLVM_INSTALL_TOOLCHAIN_ONLY)
-llvm_install_symlink(${name} ${dest})
-  endif()
-endmacro()
-
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 include_directories(BEFORE

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=248025=248024=248025=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Fri Sep 18 14:59:51 2015
@@ -51,6 +51,33 @@ endif()
 
 add_dependencies(clang clang-headers)
 
+if(UNIX)
+  set(CLANGXX_LINK_OR_COPY create_symlink)
+# Create a relative symlink
+  set(clang_binary "clang${CMAKE_EXECUTABLE_SUFFIX}")
+else()
+  set(CLANGXX_LINK_OR_COPY copy)
+  set(clang_binary 
"${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
+endif()
+
+# Create the clang++ symlink in the build directory.
+set(clang_pp "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++${CMAKE_EXECUTABLE_SUFFIX}")
+add_custom_command(TARGET clang POST_BUILD
+COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" 
"${clang_pp}"
+WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
+
+set_property(DIRECTORY APPEND
+  PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_pp})
+
+# Create the clang-cl symlink in the build directory.
+set(clang_cl 
"${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl${CMAKE_EXECUTABLE_SUFFIX}")
+add_custom_command(TARGET clang POST_BUILD
+COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" 
"${clang_cl}"
+WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
+
+set_property(DIRECTORY APPEND
+  PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_cl})
+
 install(TARGETS clang
   RUNTIME DESTINATION bin
   COMPONENT clang)
@@ -60,13 +87,8 @@ add_custom_target(install-clang
   -DCMAKE_INSTALL_COMPONENT=clang
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
 
-if(NOT CLANG_LINKS_TO_CREATE)
-  set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
-endif()
-
-foreach(link ${CLANG_LINKS_TO_CREATE})
-  add_clang_symlink(${link} clang)
-endforeach()
+# Create the clang++ and clang-cl symlinks at installation time.
+install(SCRIPT clang_symlink.cmake 
-DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
 
 # Configure plist creation for OS X.
 set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")

Added: cfe/trunk/tools/driver/clang_symlink.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/clang_symlink.cmake?rev=248025=auto
==
--- cfe/trunk/tools/driver/clang_symlink.cmake (added)
+++ cfe/trunk/tools/driver/clang_symlink.cmake Fri Sep 18 14:59:51 2015
@@ -0,0 +1,43 @@
+# We need to execute this script at installation time because the
+# DESTDIR environment variable may be unset at configuration time.
+# See PR8397.
+
+if(UNIX)
+  set(CLANGXX_LINK_OR_COPY create_symlink)
+  set(CLANGXX_DESTDIR $ENV{DESTDIR})
+else()
+  set(CLANGXX_LINK_OR_COPY copy)
+endif()
+
+# CMAKE_EXECUTABLE_SUFFIX is undefined on cmake scripts. See PR9286.
+if( WIN32 )
+  set(EXECUTABLE_SUFFIX ".exe")
+else()
+  set(EXECUTABLE_SUFFIX "")
+endif()
+
+set(bindir "${CLANGXX_DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/")
+set(clang "clang${EXECUTABLE_SUFFIX}")
+set(clangxx "clang++${EXECUTABLE_SUFFIX}")
+set(clang_cl "clang-cl${EXECUTABLE_SUFFIX}")
+set(cl "cl${EXECUTABLE_SUFFIX}")
+
+message("Creating clang++ executable based on ${clang}")
+
+execute_process(
+  COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "${clangxx}"
+  WORKING_DIRECTORY "${bindir}")
+
+message("Creating clang-cl executable based on ${clang}")
+
+execute_process(
+  COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" 
"${clang_cl}"
+  WORKING_DIRECTORY "${bindir}")
+
+if (WIN32)
+  message("Creating cl executable based on ${clang}")
+
+  execute_process(
+COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" 
"../msbuild-bin/${cl}"
+

Re: r248064 - Split off the binary literal warning into a subgroup of C++14 warnings

2015-09-18 Thread Richard Smith via cfe-commits
Can we arrange for this warning to also be controlled by the
-Wgnu-binary-literal option, as it is outside C++ mode?

On Fri, Sep 18, 2015 at 4:18 PM, Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Fri Sep 18 18:18:39 2015
> New Revision: 248064
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248064=rev
> Log:
> Split off the binary literal warning into a subgroup of C++14 warnings
>
> Binary literals predate C++14, but they are listed as a C++14 extension
> since
> this was the first time they were standardized in the language.  Move the
> warning into a subgroup so it can be selectively disabled when checking for
> other C++14 features.
>
> Added:
> cfe/trunk/test/Lexer/warn_binary_literals.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=248064=248063=248064=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Sep 18 18:18:39
> 2015
> @@ -29,6 +29,7 @@ def ArrayBoundsPointerArithmetic : DiagG
>  def Availability : DiagGroup<"availability">;
>  def Section : DiagGroup<"section">;
>  def AutoImport : DiagGroup<"auto-import">;
> +def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
>  def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;
>  def GNUCompoundLiteralInitializer :
> DiagGroup<"gnu-compound-literal-initializer">;
>  def BitFieldConstantConversion :
> DiagGroup<"bitfield-constant-conversion">;
> @@ -680,7 +681,7 @@ def CXX11 : DiagGroup<"c++11-extensions"
>
>  // A warning group for warnings about using C++14 features as extensions
> in
>  // earlier C++ versions.
> -def CXX14 : DiagGroup<"c++14-extensions">;
> +def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral]>;
>
>  // A warning group for warnings about using C++1z features as extensions
> in
>  // earlier C++ versions.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=248064=248063=248064=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Sep 18
> 18:18:39 2015
> @@ -184,7 +184,7 @@ def ext_hexconstant_invalid : Extension<
>  def ext_binary_literal : Extension<
>"binary integer literals are a GNU extension">,
> InGroup;
>  def ext_binary_literal_cxx14 : Extension<
> -  "binary integer literals are a C++14 extension">, InGroup;
> +  "binary integer literals are a C++14 extension">,
> InGroup;
>  def warn_cxx11_compat_binary_literal : Warning<
>"binary integer literals are incompatible with C++ standards before
> C++14">,
>InGroup, DefaultIgnore;
>
> Added: cfe/trunk/test/Lexer/warn_binary_literals.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/warn_binary_literals.cpp?rev=248064=auto
>
> ==
> --- cfe/trunk/test/Lexer/warn_binary_literals.cpp (added)
> +++ cfe/trunk/test/Lexer/warn_binary_literals.cpp Fri Sep 18 18:18:39 2015
> @@ -0,0 +1,5 @@
> +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
> -Wc++14-binary-literal
> +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wc++14-extensions
> +
> +int x = 0b11;
> +// expected-warning@-1{{binary integer literals are a C++14 extension}}
>
>
> ___
> 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


r248070 - Rename ASTSourceDescriptor::ModuleName to FullModuleName for clarity.

2015-09-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 18 19:10:37 2015
New Revision: 248070

URL: http://llvm.org/viewvc/llvm-project?rev=248070=rev
Log:
Rename ASTSourceDescriptor::ModuleName to FullModuleName for clarity.

Modified:
cfe/trunk/include/clang/AST/ExternalASTSource.h
cfe/trunk/lib/AST/ExternalASTSource.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=248070=248069=248070=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Fri Sep 18 19:10:37 2015
@@ -146,12 +146,13 @@ public:
   /// everything needed to generate debug info for an imported module
   /// or PCH.
   struct ASTSourceDescriptor {
+ASTSourceDescriptor(){};
 ASTSourceDescriptor(std::string Name, std::string Path, std::string 
ASTFile,
 uint64_t Signature)
-: ModuleName(Name), Path(Path), ASTFile(ASTFile),
+: FullModuleName(Name), Path(Path), ASTFile(ASTFile),
   Signature(Signature){};
 ASTSourceDescriptor(const Module );
-std::string ModuleName;
+std::string FullModuleName;
 std::string Path;
 std::string ASTFile;
 uint64_t Signature = 0;

Modified: cfe/trunk/lib/AST/ExternalASTSource.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTSource.cpp?rev=248070=248069=248070=diff
==
--- cfe/trunk/lib/AST/ExternalASTSource.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTSource.cpp Fri Sep 18 19:10:37 2015
@@ -29,7 +29,7 @@ ExternalASTSource::getSourceDescriptor(u
 }
 
 ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module )
-: ModuleName(M.getFullModuleName()), Signature(M.Signature) {
+: FullModuleName(M.getFullModuleName()), Signature(M.Signature) {
   if (M.Directory)
 Path = M.Directory->getName();
   if (auto *File = M.getASTFile())

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248070=248069=248070=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 19:10:37 2015
@@ -1675,7 +1675,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
 llvm::DIModule *
 CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
   bool CreateSkeletonCU) {
-  auto  = ModuleRefCache[Mod.ModuleName];
+  auto  = ModuleRefCache[Mod.FullModuleName];
   if (ModRef)
 return cast(ModRef);
 
@@ -1705,15 +1705,15 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   llvm::DIModule *M = nullptr;
   if (CreateSkeletonCU) {
 llvm::DIBuilder DIB(CGM.getModule());
-auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), 
Mod.ModuleName,
- Mod.Path, TheCU->getProducer(), true,
- StringRef(), 0, Mod.ASTFile,
- llvm::DIBuilder::FullDebug, 
Mod.Signature);
-M = DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
+auto *CU = DIB.createCompileUnit(
+TheCU->getSourceLanguage(), Mod.FullModuleName, Mod.Path,
+TheCU->getProducer(), true, StringRef(), 0, Mod.ASTFile,
+llvm::DIBuilder::FullDebug, Mod.Signature);
+M = DIB.createModule(CU, Mod.FullModuleName, ConfigMacros, Mod.Path,
  CGM.getHeaderSearchOpts().Sysroot);
 DIB.finalize();
   } else
-M = DBuilder.createModule(TheCU, Mod.ModuleName, ConfigMacros, Mod.Path,
+M = DBuilder.createModule(TheCU, Mod.FullModuleName, ConfigMacros, 
Mod.Path,
   CGM.getHeaderSearchOpts().Sysroot);
   ModRef.reset(M);
   return M;


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


r248069 - Refactor ASTReader::getSourceDescriptor(const Module &) into a constructor

2015-09-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 18 19:10:32 2015
New Revision: 248069

URL: http://llvm.org/viewvc/llvm-project?rev=248069=rev
Log:
Refactor ASTReader::getSourceDescriptor(const Module &) into a constructor
of ASTSourceDescriptor. It was effectively a static function.

NFC.

Modified:
cfe/trunk/include/clang/AST/ExternalASTSource.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/AST/ExternalASTSource.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=248069=248068=248069=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Fri Sep 18 19:10:32 2015
@@ -142,19 +142,23 @@ public:
   /// \brief Retrieve the module that corresponds to the given module ID.
   virtual Module *getModule(unsigned ID) { return nullptr; }
 
-  /// \brief Holds everything needed to generate debug info for an
-  /// imported module or precompiled header file.
+  /// Abstracts clang modules and precompiled header files and holds
+  /// everything needed to generate debug info for an imported module
+  /// or PCH.
   struct ASTSourceDescriptor {
+ASTSourceDescriptor(std::string Name, std::string Path, std::string 
ASTFile,
+uint64_t Signature)
+: ModuleName(Name), Path(Path), ASTFile(ASTFile),
+  Signature(Signature){};
+ASTSourceDescriptor(const Module );
 std::string ModuleName;
 std::string Path;
 std::string ASTFile;
-uint64_t Signature;
+uint64_t Signature = 0;
   };
 
-  /// \brief Return a descriptor for the corresponding module, if one exists.
+  /// Return a descriptor for the corresponding module, if one exists.
   virtual llvm::Optional getSourceDescriptor(unsigned ID);
-  /// \brief Return a descriptor for the module.
-  virtual ASTSourceDescriptor getSourceDescriptor(const Module );
 
   /// \brief Finds all declarations lexically contained within the given
   /// DeclContext, after applying an optional filter predicate.

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=248069=248068=248069=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Sep 18 19:10:32 2015
@@ -1889,8 +1889,6 @@ public:
 
   /// \brief Return a descriptor for the corresponding module.
   llvm::Optional getSourceDescriptor(unsigned ID) 
override;
-  /// \brief Return a descriptor for the module.
-  ASTSourceDescriptor getSourceDescriptor(const Module ) 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=248069=248068=248069=diff
==
--- cfe/trunk/lib/AST/ExternalASTSource.cpp (original)
+++ cfe/trunk/lib/AST/ExternalASTSource.cpp Fri Sep 18 19:10:32 2015
@@ -16,6 +16,7 @@
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/Basic/Module.h"
 #include "llvm/Support/ErrorHandling.h"
 
 using namespace clang;
@@ -27,9 +28,12 @@ ExternalASTSource::getSourceDescriptor(u
   return None;
 }
 
-ExternalASTSource::ASTSourceDescriptor
-ExternalASTSource::getSourceDescriptor(const Module ) {
-  return ASTSourceDescriptor();
+ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module )
+: ModuleName(M.getFullModuleName()), Signature(M.Signature) {
+  if (M.Directory)
+Path = M.Directory->getName();
+  if (auto *File = M.getASTFile())
+ASTFile = File->getName();
 }
 
 void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248069=248068=248069=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 19:10:32 2015
@@ -3391,8 +3391,7 @@ void CGDebugInfo::EmitUsingDecl(const Us
 }
 
 void CGDebugInfo::EmitImportDecl(const ImportDecl ) {
-  auto *Reader = CGM.getContext().getExternalSource();
-  auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
+  auto Info = ExternalASTSource::ASTSourceDescriptor(*ID.getImportedModule());
   DBuilder.createImportedDeclaration(
   getCurrentContextDescriptor(cast(ID.getDeclContext())),
   

r248068 - Eliminate a redundant check.

2015-09-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 18 19:10:25 2015
New Revision: 248068

URL: http://llvm.org/viewvc/llvm-project?rev=248068=rev
Log:
Eliminate a redundant check.

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

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=248068=248067=248068=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Sep 18 
19:10:25 2015
@@ -172,9 +172,8 @@ public:
 if (Diags.hasErrorOccurred())
   return;
 
-if (CodeGen::CGDebugInfo *DI = Builder->getModuleDebugInfo())
-  if (const RecordDecl *RD = dyn_cast(D))
-DI->completeRequiredType(RD);
+if (const RecordDecl *RD = dyn_cast(D))
+  Builder->getModuleDebugInfo()->completeRequiredType(RD);
   }
 
   /// Emit a container holding the serialized AST.


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


Re: r248062 - CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.

2015-09-18 Thread David Blaikie via cfe-commits
On Fri, Sep 18, 2015 at 4:01 PM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Fri Sep 18 18:01:45 2015
> New Revision: 248062
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248062=rev
> Log:
> CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.
> We don't want a skeleton CU when generating debug info for the module
> itself.
>
> NFC.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248062=248061=248062=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 18:01:45 2015
> @@ -1673,7 +1673,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
>  }
>
>  llvm::DIModule *
> -CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor
> Mod) {
> +CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor
> Mod,
> +  bool CreateSkeletonCU) {
>auto  = ModuleRefCache[Mod.ModuleName];
>if (ModRef)
>  return cast(ModRef);
> @@ -1700,15 +1701,20 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>OS << '\"';
>  }
>}
> -  llvm::DIBuilder DIB(CGM.getModule());
> -  auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(),
> Mod.ModuleName,
> -   Mod.Path, TheCU->getProducer(), true,
> -   StringRef(), 0, Mod.ASTFile,
> -   llvm::DIBuilder::FullDebug,
> Mod.Signature);
> -  llvm::DIModule *M =
> -  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
> -   CGM.getHeaderSearchOpts().Sysroot);
> -  DIB.finalize();
> +
> +  llvm::DIModule *M = nullptr;
> +  if (CreateSkeletonCU) {
> +llvm::DIBuilder DIB(CGM.getModule());
> +auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(),
> Mod.ModuleName,
> + Mod.Path, TheCU->getProducer(), true,
> + StringRef(), 0, Mod.ASTFile,
> + llvm::DIBuilder::FullDebug,
> Mod.Signature);
> +M = DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
> + CGM.getHeaderSearchOpts().Sysroot);
>

Could you remind me why we have a module in the skeleton CU?


> +DIB.finalize();
> +  } else
> +M = DBuilder.createModule(TheCU, Mod.ModuleName, ConfigMacros,
> Mod.Path,
> +  CGM.getHeaderSearchOpts().Sysroot);
>ModRef.reset(M);
>return M;
>  }
> @@ -2158,12 +2164,13 @@ llvm::DIModule *CGDebugInfo::getParentMo
>if (!DebugTypeExtRefs || !D->isFromASTFile())
>  return nullptr;
>
> +  // Record a reference to an imported clang module or precompiled header.
>llvm::DIModule *ModuleRef = nullptr;
>auto *Reader = CGM.getContext().getExternalSource();
>auto Idx = D->getOwningModuleID();
>auto Info = Reader->getSourceDescriptor(Idx);
>if (Info)
> -ModuleRef = getOrCreateModuleRef(*Info);
> +ModuleRef = getOrCreateModuleRef(*Info, true);
>return ModuleRef;
>  }
>
> @@ -3387,9 +3394,9 @@ void CGDebugInfo::EmitImportDecl(const I
>auto *Reader = CGM.getContext().getExternalSource();
>auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
>DBuilder.createImportedDeclaration(
> -getCurrentContextDescriptor(cast(ID.getDeclContext())),
> -getOrCreateModuleRef(Info),
> -getLineNumber(ID.getLocation()));
> +  getCurrentContextDescriptor(cast(ID.getDeclContext())),
> +  getOrCreateModuleRef(Info, DebugTypeExtRefs),
> +  getLineNumber(ID.getLocation()));
>  }
>
>  llvm::DIImportedEntity *
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=248062=248061=248062=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri Sep 18 18:01:45 2015
> @@ -403,9 +403,11 @@ private:
>/// Get the type from the cache or create a new type if necessary.
>llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg);
>
> -  /// Get a reference to a clang module.
> +  /// Get a reference to a clang module.  If \p CreateSkeletonCU is true,
> +  /// this also creates a split dwarf skeleton compile unit.
>llvm::DIModule *
> -  getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod);
> +  getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
> +   bool CreateSkeletonCU);
>
>/// DebugTypeExtRefs: If \p D originated in a clang module, return it.
>

Re: PATCH: Provide the compile commands of the JSON database in consistent order

2015-09-18 Thread Manuel Klimek via cfe-commits
LG in general; I think if we like the order to be deterministic we should
try to come up with a unit test so nobody regresses this in the future.

On Fri, Sep 18, 2015 at 4:44 PM Argyrios Kyrtzidis 
wrote:

> Hi,
>
> I have found it useful for the getAllCompileCommands() to return the
> commands in the order that they were provided in the JSON file.
> This is useful for debugging of issues and reduction of test cases.
> For example, an issue may show up due to the order that some commands were
> processed. It is convenient to be able to remove commands from the file and
> still preserve the order that they are returned, instead of getting a
> completely different order when removing a few commands.
>
> Let me know what you think!
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r248062 - CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.

2015-09-18 Thread Adrian Prantl via cfe-commits

> On Sep 18, 2015, at 5:47 PM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Sep 18, 2015 at 5:45 PM, Adrian Prantl  > wrote:
> 
>> On Sep 18, 2015, at 5:11 PM, David Blaikie > > wrote:
>> 
>> 
>> 
>> On Fri, Sep 18, 2015 at 4:01 PM, Adrian Prantl via cfe-commits 
>> > wrote:
>> Author: adrian
>> Date: Fri Sep 18 18:01:45 2015
>> New Revision: 248062
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=248062=rev 
>> 
>> Log:
>> CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.
>> We don't want a skeleton CU when generating debug info for the module
>> itself.
>> 
>> NFC.
>> 
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248062=248061=248062=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 18:01:45 2015
>> @@ -1673,7 +1673,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
>>  }
>> 
>>  llvm::DIModule *
>> -CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor 
>> Mod) {
>> +CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor 
>> Mod,
>> +  bool CreateSkeletonCU) {
>>auto  = ModuleRefCache[Mod.ModuleName];
>>if (ModRef)
>>  return cast(ModRef);
>> @@ -1700,15 +1701,20 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>>OS << '\"';
>>  }
>>}
>> -  llvm::DIBuilder DIB(CGM.getModule());
>> -  auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), 
>> Mod.ModuleName,
>> -   Mod.Path, TheCU->getProducer(), true,
>> -   StringRef(), 0, Mod.ASTFile,
>> -   llvm::DIBuilder::FullDebug, 
>> Mod.Signature);
>> -  llvm::DIModule *M =
>> -  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
>> -   CGM.getHeaderSearchOpts().Sysroot);
>> -  DIB.finalize();
>> +
>> +  llvm::DIModule *M = nullptr;
>> +  if (CreateSkeletonCU) {
>> +llvm::DIBuilder DIB(CGM.getModule());
>> +auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), 
>> Mod.ModuleName,
>> + Mod.Path, TheCU->getProducer(), true,
>> + StringRef(), 0, Mod.ASTFile,
>> + llvm::DIBuilder::FullDebug, 
>> Mod.Signature);
>> +M = DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
>> + CGM.getHeaderSearchOpts().Sysroot);
>> 
>> Could you remind me why we have a module in the skeleton CU?
> 
> Note that this does not emit the module *in* the skeleton CU it just creates 
> a skeleton CU alongside the module. The fact that it is mentioned as scope of 
> the module here is misleading (and I should changed that to TheCU for 
> clarity), DIBuilder ignores any DICompileUnits that are passed in as parent 
> scopes.
> 
> So why are you passing it & why are you using DIB to build it? (why not 
> remove this and make the else block unconditional?)

I’m running exactly this patch through check-clang as we speak :-)

-- adrian

>  
> 
> -- adrian
> 
>>  
>> +DIB.finalize();
>> +  } else
>> +M = DBuilder.createModule(TheCU, Mod.ModuleName, ConfigMacros, Mod.Path,
>> +  CGM.getHeaderSearchOpts().Sysroot);
>>ModRef.reset(M);
>>return M;
>>  }
>> @@ -2158,12 +2164,13 @@ llvm::DIModule *CGDebugInfo::getParentMo
>>if (!DebugTypeExtRefs || !D->isFromASTFile())
>>  return nullptr;
>> 
>> +  // Record a reference to an imported clang module or precompiled header.
>>llvm::DIModule *ModuleRef = nullptr;
>>auto *Reader = CGM.getContext().getExternalSource();
>>auto Idx = D->getOwningModuleID();
>>auto Info = Reader->getSourceDescriptor(Idx);
>>if (Info)
>> -ModuleRef = getOrCreateModuleRef(*Info);
>> +ModuleRef = getOrCreateModuleRef(*Info, true);
>>return ModuleRef;
>>  }
>> 
>> @@ -3387,9 +3394,9 @@ void CGDebugInfo::EmitImportDecl(const I
>>auto *Reader = CGM.getContext().getExternalSource();
>>auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
>>DBuilder.createImportedDeclaration(
>> -getCurrentContextDescriptor(cast(ID.getDeclContext())),
>> -getOrCreateModuleRef(Info),
>> -getLineNumber(ID.getLocation()));
>> +  

Re: [PATCH] D11844: [Modules] More descriptive diagnostics for misplaced import directive

2015-09-18 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a reviewer: rsmith.


Comment at: include/clang/Parse/Parser.h:2560-2562
@@ +2559,5 @@
+  bool tryParseMisplacedModuleImport() {
+tok::TokenKind Kind = Tok.getKind();
+if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
+Kind == tok::annot_module_include)
+  return parseMisplacedModuleImport();

Use `Tok.isOneOf` here.


http://reviews.llvm.org/D11844



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


Re: [PATCH] D11279: Initial patch for PS4 toolchain

2015-09-18 Thread Sean Silva via cfe-commits
silvas added a subscriber: silvas.
silvas added a comment.

Once this lands, I think we can revert r247977


http://reviews.llvm.org/D11279



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


r248065 - [Static Analyzer] Fixed a false positive case in DynamicTypeChecker when dealing with forward declarations.

2015-09-18 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Sep 18 18:38:57 2015
New Revision: 248065

URL: http://llvm.org/viewvc/llvm-project?rev=248065=rev
Log:
[Static Analyzer] Fixed a false positive case in DynamicTypeChecker when 
dealing with forward declarations.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
cfe/trunk/test/Analysis/dynamic_type_check.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp?rev=248065=248064=248065=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp Fri Sep 18 
18:38:57 2015
@@ -151,6 +151,14 @@ PathDiagnosticPiece *DynamicTypeChecker:
   return new PathDiagnosticEventPiece(Pos, OS.str(), true, nullptr);
 }
 
+static bool hasDefinition(const ObjCObjectPointerType *ObjPtr) {
+  const ObjCInterfaceDecl *Decl = ObjPtr->getInterfaceDecl();
+  if (!Decl)
+return false;
+
+  return Decl->getDefinition();
+}
+
 // TODO: consider checking explicit casts?
 void DynamicTypeChecker::checkPostStmt(const ImplicitCastExpr *CE,
CheckerContext ) const {
@@ -177,6 +185,9 @@ void DynamicTypeChecker::checkPostStmt(c
   if (!DynObjCType || !StaticObjCType)
 return;
 
+  if (!hasDefinition(DynObjCType) || !hasDefinition(StaticObjCType))
+return;
+
   ASTContext  = C.getASTContext();
 
   // Strip kindeofness to correctly detect subtyping relationships.

Modified: cfe/trunk/test/Analysis/dynamic_type_check.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dynamic_type_check.m?rev=248065=248064=248065=diff
==
--- cfe/trunk/test/Analysis/dynamic_type_check.m (original)
+++ cfe/trunk/test/Analysis/dynamic_type_check.m Fri Sep 18 18:38:57 2015
@@ -26,8 +26,18 @@ __attribute__((objc_root_class))
 @interface NSNumber : NSObject 
 @end
 
+@class MyType;
+
 void testTypeCheck(NSString* str) {
   id obj = str;
   NSNumber *num = obj; // expected-warning {{}}
   (void)num;
 }
+
+void testForwardDeclarations(NSString* str) {
+  id obj = str;
+  // Do not warn, since no information is available wether MyType is a sub or
+  // super class of any other type.
+  MyType *num = obj; // no warning
+  (void)num;
+}


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


Re: r247618 - C11 _Bool bitfield diagnostic

2015-09-18 Thread Richard Smith via cfe-commits
On Wed, Sep 16, 2015 at 5:33 PM, Richard Smith 
wrote:

> On Wed, Sep 16, 2015 at 5:27 PM, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Tue, Sep 15, 2015 at 5:50 PM, Richard Smith 
>> wrote:
>>
>>> On Tue, Sep 15, 2015 at 12:38 PM, Nico Weber 
>>> wrote:
>>>
 With this patch, we warn on `bool a : 4;`, yet we don't warn on `bool
 b` (which has 8 bits storage, 1 bit value). Warning on `bool b` is silly of
 course, but why is warning on `bool a : 4` useful? That's like 50% more
 storage efficient than `bool b` ;-)

 It's possible that this is a good warning for some reason, but I don't
 quite see why yet.

>>>
>>> Why would we warn on "unsigned n : 57;"? The bit-field is wider than
>>> necessary, and we have no idea what the programmer was trying to do
>>>
>>
>> Warning on this kind of makes sense to me, as the field is wider than the
>> default width of int. (Not warning on that doesn't seem terrible to me
>> either though.)
>>
>> I'm only confused about the bool case with bitfield sizes < 8 I think. We
>> warn that the bitfield is wider than the value size, even though it's
>> smaller than the default storage size, and we don't warn on regular bools.
>>
>> To get an idea how often this warning fires, I ran it on a large-ish open
>> source codebase I had flying around. The only place it fired on is one
>> header in protobuf (extension_set.h). I looked at the history of that file,
>> and it had a struct that used to look like
>>
>>   struct Extension {
>> SomeEnum e;
>> bool a;
>> bool b;
>> bool c;
>> int d;
>> // ...some more stuff...
>>   };
>>
>> Someone then added another field to this and for some reason decided to
>> do it like so:
>>
>>   struct Extension {
>> SomeEnum e;
>> bool a;
>> bool b1 : 4;
>> bool b2 : 4;
>> bool c;
>> int d;
>> // ...some more stuff...
>>   };
>>
>> Neither the commit message nor the review discussion mention the bitfield
>> at all as far as I can tell. Now, given that this isn't a small struct and
>> it has a bunch of normal bools, I don't know why they added the new field
>> as bitfield while this wasn't deemed necessary for the existing bools. My
>> best guess is that that they didn't want to add 3 bytes of padding (due to
>> the int field), which seems like a decent reason.
>>
>> Had the warning been in place when this code got written, I suppose they
>> had used ": 1" instead. Does this make this code much better? It doesn't
>> seem like it to me. So after doing a warning quality eval, I'd suggest to
>> not emit the warning for bool bitfields if the bitfield size is < 8. (But
>> since the warning fires only very rarely, I don't feel very strongly about
>> this.)
>>
>
> I agree it doesn't make the code /much/ better. But if I were reading
> that, I would certainly pause for a few moments wondering what the author
> was thinking. I also don't feel especially strongly about this, but I don't
> see a good rationale for warning on 'bool : 9' but not on 'bool : 5'.
>

I'm coming around to the opinion that we shouldn't give this warning on
bool at all -- the point of the warning is to point out that an 'unsigned :
40;' bitfield can't hold 2**40 - 1, and values of that size will be
truncated. There is no corresponding problematic case for bool, so we have
a much weaker justification for warning in this case -- we have no idea
what the user was trying to achieve, but we do not have a signal that their
code is wrong.

Thoughts?

, but it doesn't seem likely they got that effect. Would you be more
>>> convinced if we amended the diagnostic to provide a fixit suggesting using
>>> an anonymous bit-field to insert padding?
>>>
>>
>> Isn't the Right Fix (tm) to make bool bitfields 1 wide and rely on the
>> compiler to figure out padding?
>>
>
> It depends; maybe the intent is to be compatible with some on-disk format,
> and the explicit padding is important:
>
> struct X {
>   int n : 3;
>   bool b : 3;
>   int n : 2;
> };
>
> Changing the bool bit-field to 1 bit without inserting an anonymous
> bit-field would change the struct layout.
>
>
>> On Mon, Sep 14, 2015 at 11:06 PM, Richard Smith 
 wrote:

> On Mon, Sep 14, 2015 at 7:07 PM, Rachel Craik 
> wrote:
>
>> As of DR262, the C standard clarified that the width of a bit-field
>> can not exceed that of the specified type, and this change was primarily 
>> to
>> ensure that Clang correctly enforced this part of the standard. Looking 
>> at
>> the C++11 standard again, it states that although the specified width of 
>> a
>> bit-field may exceed the number of bits in the *object
>> representation* (which includes padding bits) of the specified type,
>> the extra bits will not take any part in the bit-field's *value
>> representation*.
>>
>> 

Re: r248062 - CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.

2015-09-18 Thread Adrian Prantl via cfe-commits

> On Sep 18, 2015, at 5:11 PM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Sep 18, 2015 at 4:01 PM, Adrian Prantl via cfe-commits 
> > wrote:
> Author: adrian
> Date: Fri Sep 18 18:01:45 2015
> New Revision: 248062
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=248062=rev 
> 
> Log:
> CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.
> We don't want a skeleton CU when generating debug info for the module
> itself.
> 
> NFC.
> 
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDebugInfo.h
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248062=248061=248062=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 18:01:45 2015
> @@ -1673,7 +1673,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
>  }
> 
>  llvm::DIModule *
> -CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor 
> Mod) {
> +CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
> +  bool CreateSkeletonCU) {
>auto  = ModuleRefCache[Mod.ModuleName];
>if (ModRef)
>  return cast(ModRef);
> @@ -1700,15 +1701,20 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>OS << '\"';
>  }
>}
> -  llvm::DIBuilder DIB(CGM.getModule());
> -  auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), 
> Mod.ModuleName,
> -   Mod.Path, TheCU->getProducer(), true,
> -   StringRef(), 0, Mod.ASTFile,
> -   llvm::DIBuilder::FullDebug, 
> Mod.Signature);
> -  llvm::DIModule *M =
> -  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
> -   CGM.getHeaderSearchOpts().Sysroot);
> -  DIB.finalize();
> +
> +  llvm::DIModule *M = nullptr;
> +  if (CreateSkeletonCU) {
> +llvm::DIBuilder DIB(CGM.getModule());
> +auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), 
> Mod.ModuleName,
> + Mod.Path, TheCU->getProducer(), true,
> + StringRef(), 0, Mod.ASTFile,
> + llvm::DIBuilder::FullDebug, 
> Mod.Signature);
> +M = DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
> + CGM.getHeaderSearchOpts().Sysroot);
> 
> Could you remind me why we have a module in the skeleton CU?

Note that this does not emit the module *in* the skeleton CU it just creates a 
skeleton CU alongside the module. The fact that it is mentioned as scope of the 
module here is misleading (and I should changed that to TheCU for clarity), 
DIBuilder ignores any DICompileUnits that are passed in as parent scopes.

-- adrian

>  
> +DIB.finalize();
> +  } else
> +M = DBuilder.createModule(TheCU, Mod.ModuleName, ConfigMacros, Mod.Path,
> +  CGM.getHeaderSearchOpts().Sysroot);
>ModRef.reset(M);
>return M;
>  }
> @@ -2158,12 +2164,13 @@ llvm::DIModule *CGDebugInfo::getParentMo
>if (!DebugTypeExtRefs || !D->isFromASTFile())
>  return nullptr;
> 
> +  // Record a reference to an imported clang module or precompiled header.
>llvm::DIModule *ModuleRef = nullptr;
>auto *Reader = CGM.getContext().getExternalSource();
>auto Idx = D->getOwningModuleID();
>auto Info = Reader->getSourceDescriptor(Idx);
>if (Info)
> -ModuleRef = getOrCreateModuleRef(*Info);
> +ModuleRef = getOrCreateModuleRef(*Info, true);
>return ModuleRef;
>  }
> 
> @@ -3387,9 +3394,9 @@ void CGDebugInfo::EmitImportDecl(const I
>auto *Reader = CGM.getContext().getExternalSource();
>auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
>DBuilder.createImportedDeclaration(
> -getCurrentContextDescriptor(cast(ID.getDeclContext())),
> -getOrCreateModuleRef(Info),
> -getLineNumber(ID.getLocation()));
> +  getCurrentContextDescriptor(cast(ID.getDeclContext())),
> +  getOrCreateModuleRef(Info, DebugTypeExtRefs),
> +  getLineNumber(ID.getLocation()));
>  }
> 
>  llvm::DIImportedEntity *
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=248062=248061=248062=diff
>  
> 
> ==
> --- 

Re: r248062 - CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.

2015-09-18 Thread David Blaikie via cfe-commits
On Fri, Sep 18, 2015 at 5:45 PM, Adrian Prantl  wrote:

>
> On Sep 18, 2015, at 5:11 PM, David Blaikie  wrote:
>
>
>
> On Fri, Sep 18, 2015 at 4:01 PM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Fri Sep 18 18:01:45 2015
>> New Revision: 248062
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=248062=rev
>> Log:
>> CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.
>> We don't want a skeleton CU when generating debug info for the module
>> itself.
>>
>> NFC.
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/lib/CodeGen/CGDebugInfo.h
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248062=248061=248062=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 18:01:45 2015
>> @@ -1673,7 +1673,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
>>  }
>>
>>  llvm::DIModule *
>> -CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor
>> Mod) {
>> +CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor
>> Mod,
>> +  bool CreateSkeletonCU) {
>>auto  = ModuleRefCache[Mod.ModuleName];
>>if (ModRef)
>>  return cast(ModRef);
>> @@ -1700,15 +1701,20 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>>OS << '\"';
>>  }
>>}
>> -  llvm::DIBuilder DIB(CGM.getModule());
>> -  auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(),
>> Mod.ModuleName,
>> -   Mod.Path, TheCU->getProducer(), true,
>> -   StringRef(), 0, Mod.ASTFile,
>> -   llvm::DIBuilder::FullDebug,
>> Mod.Signature);
>> -  llvm::DIModule *M =
>> -  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
>> -   CGM.getHeaderSearchOpts().Sysroot);
>> -  DIB.finalize();
>> +
>> +  llvm::DIModule *M = nullptr;
>> +  if (CreateSkeletonCU) {
>> +llvm::DIBuilder DIB(CGM.getModule());
>> +auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(),
>> Mod.ModuleName,
>> + Mod.Path, TheCU->getProducer(),
>> true,
>> + StringRef(), 0, Mod.ASTFile,
>> + llvm::DIBuilder::FullDebug,
>> Mod.Signature);
>> +M = DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
>> + CGM.getHeaderSearchOpts().Sysroot);
>>
>
> Could you remind me why we have a module in the skeleton CU?
>
>
> Note that this does not emit the module *in* the skeleton CU it just
> creates a skeleton CU alongside the module. The fact that it is mentioned
> as scope of the module here is misleading (and I should changed that to
> TheCU for clarity), DIBuilder ignores any DICompileUnits that are passed in
> as parent scopes.
>

So why are you passing it & why are you using DIB to build it? (why not
remove this and make the else block unconditional?)


>
> -- adrian
>
>
>
>> +DIB.finalize();
>> +  } else
>> +M = DBuilder.createModule(TheCU, Mod.ModuleName, ConfigMacros,
>> Mod.Path,
>> +  CGM.getHeaderSearchOpts().Sysroot);
>>ModRef.reset(M);
>>return M;
>>  }
>> @@ -2158,12 +2164,13 @@ llvm::DIModule *CGDebugInfo::getParentMo
>>if (!DebugTypeExtRefs || !D->isFromASTFile())
>>  return nullptr;
>>
>> +  // Record a reference to an imported clang module or precompiled
>> header.
>>llvm::DIModule *ModuleRef = nullptr;
>>auto *Reader = CGM.getContext().getExternalSource();
>>auto Idx = D->getOwningModuleID();
>>auto Info = Reader->getSourceDescriptor(Idx);
>>if (Info)
>> -ModuleRef = getOrCreateModuleRef(*Info);
>> +ModuleRef = getOrCreateModuleRef(*Info, true);
>>return ModuleRef;
>>  }
>>
>> @@ -3387,9 +3394,9 @@ void CGDebugInfo::EmitImportDecl(const I
>>auto *Reader = CGM.getContext().getExternalSource();
>>auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
>>DBuilder.createImportedDeclaration(
>> -getCurrentContextDescriptor(cast(ID.getDeclContext())),
>> -getOrCreateModuleRef(Info),
>> -getLineNumber(ID.getLocation()));
>> +  getCurrentContextDescriptor(cast(ID.getDeclContext())),
>> +  getOrCreateModuleRef(Info, DebugTypeExtRefs),
>> +  getLineNumber(ID.getLocation()));
>>  }
>>
>>  llvm::DIImportedEntity *
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=248062=248061=248062=diff
>>
>> ==
>> --- 

r248076 - Use std::move on these arguments.

2015-09-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 18 19:59:19 2015
New Revision: 248076

URL: http://llvm.org/viewvc/llvm-project?rev=248076=rev
Log:
Use std::move on these arguments.

Modified:
cfe/trunk/include/clang/AST/ExternalASTSource.h

Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=248076=248075=248076=diff
==
--- cfe/trunk/include/clang/AST/ExternalASTSource.h (original)
+++ cfe/trunk/include/clang/AST/ExternalASTSource.h Fri Sep 18 19:59:19 2015
@@ -149,8 +149,8 @@ public:
 ASTSourceDescriptor(){};
 ASTSourceDescriptor(std::string Name, std::string Path, std::string 
ASTFile,
 uint64_t Signature)
-: FullModuleName(Name), Path(Path), ASTFile(ASTFile),
-  Signature(Signature){};
+: FullModuleName(std::move(Name)), Path(std::move(Path)),
+  ASTFile(std::move(ASTFile)), Signature(Signature){};
 ASTSourceDescriptor(const Module );
 std::string FullModuleName;
 std::string Path;


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


r247975 - Fix for assertion fail for pragma weak on typedef.

2015-09-18 Thread Alexander Musman via cfe-commits
Author: amusman
Date: Fri Sep 18 02:40:22 2015
New Revision: 247975

URL: http://llvm.org/viewvc/llvm-project?rev=247975=rev
Log:
Fix for assertion fail for pragma weak on typedef.
Example:
typedef int __td3;
#pragma weak td3 = __td3

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


Modified:
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGen/pragma-weak.c

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=247975=247974=247975=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Fri Sep 18 02:40:22 2015
@@ -727,8 +727,15 @@ void Sema::ActOnEndOfTranslationUnit() {
 if (WeakID.second.getUsed())
   continue;
 
-Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
-<< WeakID.first;
+Decl *PrevDecl = LookupSingleName(TUScope, WeakID.first, SourceLocation(),
+  LookupOrdinaryName);
+if (PrevDecl != nullptr &&
+!(isa(PrevDecl) || isa(PrevDecl)))
+  Diag(WeakID.second.getLocation(), diag::warn_attribute_wrong_decl_type)
+  << "'weak'" << ExpectedVariableOrFunction;
+else
+  Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
+  << WeakID.first;
   }
 
   if (LangOpts.CPlusPlus11 &&

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=247975=247974=247975=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Sep 18 02:40:22 2015
@@ -14530,7 +14530,7 @@ void Sema::ActOnPragmaWeakAlias(Identifi
 LookupOrdinaryName);
   WeakInfo W = WeakInfo(Name, NameLoc);
 
-  if (PrevDecl) {
+  if (PrevDecl && (isa(PrevDecl) || isa(PrevDecl))) {
 if (!PrevDecl->hasAttr())
   if (NamedDecl *ND = dyn_cast(PrevDecl))
 DeclApplyPragmaWeak(TUScope, ND, W);

Modified: cfe/trunk/test/CodeGen/pragma-weak.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/pragma-weak.c?rev=247975=247974=247975=diff
==
--- cfe/trunk/test/CodeGen/pragma-weak.c (original)
+++ cfe/trunk/test/CodeGen/pragma-weak.c Fri Sep 18 02:40:22 2015
@@ -53,12 +53,14 @@ void __foo2(void) {}
 #pragma weak unused // expected-warning {{weak identifier 'unused' never 
declared}}
 #pragma weak unused_alias = __unused_alias  // expected-warning {{weak 
identifier '__unused_alias' never declared}}
 
-#pragma weak td // expected-warning {{weak identifier 'td' never declared}}
+#pragma weak td // expected-warning {{'weak' attribute only applies to 
variables and functions}}
 typedef int td;
 
-#pragma weak td2 = __td2 // expected-warning {{weak identifier '__td2' never 
declared}}
+#pragma weak td2 = __td2 // expected-warning {{'weak' attribute only applies 
to variables and functions}}
 typedef int __td2;
 
+typedef int __td3;
+#pragma weak td3 = __td3 // expected-warning {{'weak' attribute only applies 
to variables and functions}}
 
 / test weird cases
 


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


Re: [PATCH] D12904: fix for assertion fail for pragma weak on typedef

2015-09-18 Thread Alexander Musman via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247975: Fix for assertion fail for pragma weak on typedef. 
(authored by amusman).

Changed prior to commit:
  http://reviews.llvm.org/D12904?vs=34987=35066#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12904

Files:
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CodeGen/pragma-weak.c

Index: cfe/trunk/test/CodeGen/pragma-weak.c
===
--- cfe/trunk/test/CodeGen/pragma-weak.c
+++ cfe/trunk/test/CodeGen/pragma-weak.c
@@ -53,12 +53,14 @@
 #pragma weak unused // expected-warning {{weak identifier 'unused' never 
declared}}
 #pragma weak unused_alias = __unused_alias  // expected-warning {{weak 
identifier '__unused_alias' never declared}}
 
-#pragma weak td // expected-warning {{weak identifier 'td' never declared}}
+#pragma weak td // expected-warning {{'weak' attribute only applies to 
variables and functions}}
 typedef int td;
 
-#pragma weak td2 = __td2 // expected-warning {{weak identifier '__td2' never 
declared}}
+#pragma weak td2 = __td2 // expected-warning {{'weak' attribute only applies 
to variables and functions}}
 typedef int __td2;
 
+typedef int __td3;
+#pragma weak td3 = __td3 // expected-warning {{'weak' attribute only applies 
to variables and functions}}
 
 / test weird cases
 
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -14530,7 +14530,7 @@
 LookupOrdinaryName);
   WeakInfo W = WeakInfo(Name, NameLoc);
 
-  if (PrevDecl) {
+  if (PrevDecl && (isa(PrevDecl) || isa(PrevDecl))) {
 if (!PrevDecl->hasAttr())
   if (NamedDecl *ND = dyn_cast(PrevDecl))
 DeclApplyPragmaWeak(TUScope, ND, W);
Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -727,8 +727,15 @@
 if (WeakID.second.getUsed())
   continue;
 
-Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
-<< WeakID.first;
+Decl *PrevDecl = LookupSingleName(TUScope, WeakID.first, SourceLocation(),
+  LookupOrdinaryName);
+if (PrevDecl != nullptr &&
+!(isa(PrevDecl) || isa(PrevDecl)))
+  Diag(WeakID.second.getLocation(), diag::warn_attribute_wrong_decl_type)
+  << "'weak'" << ExpectedVariableOrFunction;
+else
+  Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
+  << WeakID.first;
   }
 
   if (LangOpts.CPlusPlus11 &&


Index: cfe/trunk/test/CodeGen/pragma-weak.c
===
--- cfe/trunk/test/CodeGen/pragma-weak.c
+++ cfe/trunk/test/CodeGen/pragma-weak.c
@@ -53,12 +53,14 @@
 #pragma weak unused // expected-warning {{weak identifier 'unused' never declared}}
 #pragma weak unused_alias = __unused_alias  // expected-warning {{weak identifier '__unused_alias' never declared}}
 
-#pragma weak td // expected-warning {{weak identifier 'td' never declared}}
+#pragma weak td // expected-warning {{'weak' attribute only applies to variables and functions}}
 typedef int td;
 
-#pragma weak td2 = __td2 // expected-warning {{weak identifier '__td2' never declared}}
+#pragma weak td2 = __td2 // expected-warning {{'weak' attribute only applies to variables and functions}}
 typedef int __td2;
 
+typedef int __td3;
+#pragma weak td3 = __td3 // expected-warning {{'weak' attribute only applies to variables and functions}}
 
 / test weird cases
 
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -14530,7 +14530,7 @@
 LookupOrdinaryName);
   WeakInfo W = WeakInfo(Name, NameLoc);
 
-  if (PrevDecl) {
+  if (PrevDecl && (isa(PrevDecl) || isa(PrevDecl))) {
 if (!PrevDecl->hasAttr())
   if (NamedDecl *ND = dyn_cast(PrevDecl))
 DeclApplyPragmaWeak(TUScope, ND, W);
Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -727,8 +727,15 @@
 if (WeakID.second.getUsed())
   continue;
 
-Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
-<< WeakID.first;
+Decl *PrevDecl = LookupSingleName(TUScope, WeakID.first, SourceLocation(),
+  LookupOrdinaryName);
+if (PrevDecl != nullptr &&
+!(isa(PrevDecl) || isa(PrevDecl)))
+  Diag(WeakID.second.getLocation(), diag::warn_attribute_wrong_decl_type)
+  << "'weak'" << ExpectedVariableOrFunction;
+else
+  Diag(WeakID.second.getLocation(), 

r247977 - clang/test/lit.cfg: *-ps4 doesn't have appropriate driver yet. Mark it as "non-clang-driver".

2015-09-18 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 18 03:11:36 2015
New Revision: 247977

URL: http://llvm.org/viewvc/llvm-project?rev=247977=rev
Log:
clang/test/lit.cfg: *-ps4 doesn't have appropriate driver yet. Mark it as 
"non-clang-driver".

Modified:
cfe/trunk/test/lit.cfg

Modified: cfe/trunk/test/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg?rev=247977=247976=247977=diff
==
--- cfe/trunk/test/lit.cfg (original)
+++ cfe/trunk/test/lit.cfg Fri Sep 18 03:11:36 2015
@@ -409,7 +409,7 @@ if not re.match(r'^x86_64.*-(win32|mingw
 config.available_features.add('LP64')
 
 # [PR12920] "clang-driver" -- set if gcc driver is not used.
-if not re.match(r'.*-(cygwin)$', config.target_triple):
+if not re.match(r'.*-(cygwin|ps4)$', config.target_triple):
 config.available_features.add('clang-driver')
 
 # [PR18856] Depends to remove opened file. On win32, a file could be removed


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


Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2015-09-18 Thread Alexander Droste via cfe-commits
Alexander_Droste marked 2 inline comments as done.
Alexander_Droste added a comment.

In http://reviews.llvm.org/D12761#248382, @zaks.anna wrote:

> > > It's more user friendly to report this issue at the last point where the 
> > > request is available rather than the last line of the function.
>
> > 
>
> > >  This looks similar to leak report checking. Is it?
>
> > 
>
> > 
>
> > Yes, that's not very common but possible.
>
> >  Does this change involve the use of a BugReporterVisitor?!
>
>
> You should register/report the diagnostic at check::DeadSymbols event instead 
> of check:: EndFunction; that way the error will be reported earlier.
>
> > You're right, it's very similar.
>


Sorry, I should have been more precise. The check tests if a request is in use 
by a nonblocking 
call at the end of a function. But the request can still be alive after return. 
You can think of it as
a pointer for which the memory must be freed in the function it was allocated. 
But the pointer 
can exist in global space outside a function. Multiple functions can use the 
same request.
So the symbol is not necessarily dead at the end of a function.



Comment at: 
tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPICheckerPathSensitive.cpp:33
@@ +32,3 @@
+  // There is no way to reason about a symbolic region.
+  if (MR->getBaseRegion()->getAs())
+return;

Is that assumption correct?


Comment at: tools/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPITypes.h:65
@@ +64,3 @@
+
+// Register data structure for path-sensitive analysis. The map stores MPI
+// requests which are identified by their memory region. Requests are used in

The LastUser defines the state of the request and is used in the diagnostic.
As the report will make use of the BugReportVisitor because the LastUser can 
be in another file, should I change the state marking to make use of an enum?
Currently the function classifier is used, to check what kind of function
the LastUser is, to obtain the requests state. Would this fail if the LastUser 
is from another file?


http://reviews.llvm.org/D12761



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


Re: [PATCH] D12906: [RFC] Bug identification("issue_hash") change for CmpRuns.py

2015-09-18 Thread Honggyu Kim via cfe-commits
honggyu.kim updated the summary for this revision.
honggyu.kim updated this revision to Diff 35070.

http://reviews.llvm.org/D12906

Files:
  include/clang/StaticAnalyzer/Core/BugId.h
  lib/StaticAnalyzer/Core/BugId.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  utils/analyzer/CmpRuns.py

Index: utils/analyzer/CmpRuns.py
===
--- utils/analyzer/CmpRuns.py
+++ utils/analyzer/CmpRuns.py
@@ -68,6 +68,8 @@
 
 def getIssueIdentifier(self) :
 id = self.getFileName() + "+"
+if 'check_name' in self._data :
+  id += self._data['check_name'] + "+"
 if 'issue_context' in self._data :
   id += self._data['issue_context'] + "+"
 if 'issue_hash' in self._data :
Index: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -391,14 +391,6 @@
 o << "   check_name";
 EmitString(o, D->getCheckName()) << '\n';
 
-o << "   bug_id_1";
-PathDiagnosticLocation UPDLoc = D->getUniqueingLoc();
-FullSourceLoc UL(SM->getExpansionLoc(UPDLoc.asLocation()), *SM);
-FullSourceLoc L(SM->getExpansionLoc(D->getLocation().asLocation()), *SM);
-const Decl *DeclWithIssue = D->getDeclWithIssue();
-EmitString(o, GetIssueHash(SM, UPDLoc.isValid() ? UL : L, D->getCheckName(),
-   D->getBugType(), DeclWithIssue).str()) << '\n';
-
 // Output information about the semantic context where
 // the issue occurred.
 if (const Decl *DeclWithIssue = D->getDeclWithIssue()) {
@@ -429,9 +421,9 @@
   EmitString(o, declName) << '\n';
 }
 
-// Output the bug hash for issue unique-ing. Currently, it's just an
-// offset from the beginning of the function.
-if (const Stmt *Body = DeclWithIssue->getBody()) {
+// Output the bug hash for issue unique-ing.
+// Currently, it generates bugid information from GetIssueHash
+if (DeclWithIssue->getBody()) {
 
   // If the bug uniqueing location exists, use it for the hash.
   // For example, this ensures that two leaks reported on the same line
@@ -442,19 +434,18 @@
   if (UPDLoc.isValid()) {
 FullSourceLoc UL(SM->getExpansionLoc(UPDLoc.asLocation()),
  *SM);
-FullSourceLoc UFunL(SM->getExpansionLoc(
-  D->getUniqueingDecl()->getBody()->getLocStart()), *SM);
 o << "  issue_hash"
-  << UL.getExpansionLineNumber() - UFunL.getExpansionLineNumber()
+  << GetIssueHash(SM, UL, D->getCheckName(), D->getBugType(),
+   DeclWithIssue)
   << "\n";
 
   // Otherwise, use the location on which the bug is reported.
   } else {
 FullSourceLoc L(SM->getExpansionLoc(D->getLocation().asLocation()),
 *SM);
-FullSourceLoc FunL(SM->getExpansionLoc(Body->getLocStart()), *SM);
 o << "  issue_hash"
-  << L.getExpansionLineNumber() - FunL.getExpansionLineNumber()
+  << GetIssueHash(SM, L, D->getCheckName(), D->getBugType(),
+   DeclWithIssue)
   << "\n";
   }
 
Index: lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -252,8 +252,8 @@
 
 os  << "\n\n";
 
-os  << "\n\n";
 
 os << 

r247976 - [OPENMP 4.0] Add 'if' clause for 'cancel' directive.

2015-09-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Sep 18 03:07:34 2015
New Revision: 247976

URL: http://llvm.org/viewvc/llvm-project?rev=247976=rev
Log:
[OPENMP 4.0] Add 'if' clause for 'cancel' directive.
Add parsing, sema analysis and codegen for 'if' clause in 'cancel' directive.

Added:
cfe/trunk/test/OpenMP/cancel_if_messages.cpp   (with props)
Modified:
cfe/trunk/include/clang/AST/StmtOpenMP.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/OpenMP/cancel_ast_print.cpp
cfe/trunk/test/OpenMP/cancel_codegen.cpp

Modified: cfe/trunk/include/clang/AST/StmtOpenMP.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtOpenMP.h?rev=247976=247975=247976=diff
==
--- cfe/trunk/include/clang/AST/StmtOpenMP.h (original)
+++ cfe/trunk/include/clang/AST/StmtOpenMP.h Fri Sep 18 03:07:34 2015
@@ -2127,17 +2127,21 @@ class OMPCancelDirective : public OMPExe
   ///
   /// \param StartLoc Starting location of the directive kind.
   /// \param EndLoc Ending location of the directive.
+  /// \param NumClauses Number of clauses.
   ///
-  OMPCancelDirective(SourceLocation StartLoc, SourceLocation EndLoc)
+  OMPCancelDirective(SourceLocation StartLoc, SourceLocation EndLoc,
+ unsigned NumClauses)
   : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
-   StartLoc, EndLoc, 0, 0),
+   StartLoc, EndLoc, NumClauses, 0),
 CancelRegion(OMPD_unknown) {}
 
   /// \brief Build an empty directive.
   ///
-  explicit OMPCancelDirective()
+  /// \param NumClauses Number of clauses.
+  explicit OMPCancelDirective(unsigned NumClauses)
   : OMPExecutableDirective(this, OMPCancelDirectiveClass, OMPD_cancel,
-   SourceLocation(), SourceLocation(), 0, 0),
+   SourceLocation(), SourceLocation(), NumClauses,
+   0),
 CancelRegion(OMPD_unknown) {}
 
   /// \brief Set cancel region for current cancellation point.
@@ -2150,17 +2154,19 @@ public:
   /// \param C AST context.
   /// \param StartLoc Starting location of the directive kind.
   /// \param EndLoc Ending Location of the directive.
+  /// \param Clauses List of clauses.
   ///
-  static OMPCancelDirective *Create(const ASTContext ,
-SourceLocation StartLoc,
-SourceLocation EndLoc,
-OpenMPDirectiveKind CancelRegion);
+  static OMPCancelDirective *
+  Create(const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc,
+ ArrayRef Clauses, OpenMPDirectiveKind CancelRegion);
 
   /// \brief Creates an empty directive.
   ///
   /// \param C AST context.
+  /// \param NumClauses Number of clauses.
   ///
-  static OMPCancelDirective *CreateEmpty(const ASTContext , EmptyShell);
+  static OMPCancelDirective *CreateEmpty(const ASTContext ,
+ unsigned NumClauses, EmptyShell);
 
   /// \brief Get cancellation region for the current cancellation point.
   OpenMPDirectiveKind getCancelRegion() const { return CancelRegion; }

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=247976=247975=247976=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Fri Sep 18 03:07:34 2015
@@ -63,6 +63,9 @@
 #ifndef OPENMP_TEAMS_CLAUSE
 #  define OPENMP_TEAMS_CLAUSE(Name)
 #endif
+#ifndef OPENMP_CANCEL_CLAUSE
+#  define OPENMP_CANCEL_CLAUSE(Name)
+#endif
 #ifndef OPENMP_DEFAULT_KIND
 #  define OPENMP_DEFAULT_KIND(Name)
 #endif
@@ -197,6 +200,9 @@ OPENMP_SINGLE_CLAUSE(firstprivate)
 OPENMP_SINGLE_CLAUSE(copyprivate)
 OPENMP_SINGLE_CLAUSE(nowait)
 
+// Clauses allowed for OpenMP directive 'cancel'.
+OPENMP_CANCEL_CLAUSE(if)
+
 // Static attributes for 'default' clause.
 OPENMP_DEFAULT_KIND(none)
 OPENMP_DEFAULT_KIND(shared)
@@ -313,6 +319,7 @@ OPENMP_TEAMS_CLAUSE(reduction)
 #undef OPENMP_DIRECTIVE
 #undef OPENMP_DIRECTIVE_EXT
 #undef OPENMP_CLAUSE
+#undef OPENMP_CANCEL_CLAUSE
 #undef OPENMP_SINGLE_CLAUSE
 #undef OPENMP_SECTIONS_CLAUSE
 #undef OPENMP_PARALLEL_CLAUSE

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 

Re: [PATCH] D12901: [Static Analyzer] Intersecting ranges and 64 bit to 32 bit truncations causing "System is over constrained." assertions.

2015-09-18 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Hi!

Thank you for the patch!

What happens if you factor the "index + 1" expression out into a separate 
variable?
E.g.: unsigned temp = index + 1; and use temp in the condition?

My impression is that, the ranges does not model the overflow behavior 
correctly (which is well defined for unsigned values). I wondering why do you 
think that, the right way to solve this is to modify assumeSymNE and 
assumeSymEQ? Wouldn't it be better to actually handle the ranges properly on 
assignments and other operations (such as +), so assumeSymNE and assumeSymEQ 
can remain unmodified?


http://reviews.llvm.org/D12901



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


Re: [PATCH] D12725: [analyzer] A fix for substraction of an integer from a pointer.

2015-09-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248021: [analyzer] A fix for substraction of an integer from 
a pointer. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12725?vs=34423=35122#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12725

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/ptr-arith.c

Index: cfe/trunk/test/Analysis/ptr-arith.c
===
--- cfe/trunk/test/Analysis/ptr-arith.c
+++ cfe/trunk/test/Analysis/ptr-arith.c
@@ -296,3 +296,20 @@
   clang_analyzer_eval([i].x < [i].y);// expected-warning{{TRUE}}
 }
 
+void negativeIndex(char *str) {
+  *(str + 1) = 'a';
+  clang_analyzer_eval(*(str + 1) == 'a'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(*(str - 1) == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr1 = str - 1;
+  clang_analyzer_eval(*ptr1 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr2 = str;
+  ptr2 -= 1;
+  clang_analyzer_eval(*ptr2 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr3 = str;
+  --ptr3;
+  clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}}
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -911,8 +911,9 @@
   elementType = elemReg->getElementType();
 }
 else if (isa(region)) {
+  assert(op == BO_Add || op == BO_Sub);
+  index = (op == BO_Add) ? rhs : evalMinus(rhs);
   superR = region;
-  index = rhs;
   if (resultTy->isAnyPointerType())
 elementType = resultTy->getPointeeType();
 }


Index: cfe/trunk/test/Analysis/ptr-arith.c
===
--- cfe/trunk/test/Analysis/ptr-arith.c
+++ cfe/trunk/test/Analysis/ptr-arith.c
@@ -296,3 +296,20 @@
   clang_analyzer_eval([i].x < [i].y);// expected-warning{{TRUE}}
 }
 
+void negativeIndex(char *str) {
+  *(str + 1) = 'a';
+  clang_analyzer_eval(*(str + 1) == 'a'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(*(str - 1) == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr1 = str - 1;
+  clang_analyzer_eval(*ptr1 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr2 = str;
+  ptr2 -= 1;
+  clang_analyzer_eval(*ptr2 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr3 = str;
+  --ptr3;
+  clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}}
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -911,8 +911,9 @@
   elementType = elemReg->getElementType();
 }
 else if (isa(region)) {
+  assert(op == BO_Add || op == BO_Sub);
+  index = (op == BO_Add) ? rhs : evalMinus(rhs);
   superR = region;
-  index = rhs;
   if (resultTy->isAnyPointerType())
 elementType = resultTy->getPointeeType();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11844: [Modules] More descriptive diagnostics for misplaced import directive

2015-09-18 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 35115.
sepavloff added a comment.

Updated patch.


http://reviews.llvm.org/D11844

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDecl.cpp
  test/Modules/Inputs/misplaced/misplaced-a.h
  test/Modules/Inputs/misplaced/misplaced-b.h
  test/Modules/Inputs/misplaced/misplaced.modulemap
  test/Modules/Inputs/misplaced2.cpp
  test/Modules/Inputs/misplaced3.cpp
  test/Modules/auto-module-import.m
  test/Modules/extern_c.cpp
  test/Modules/malformed.cpp
  test/Modules/misplaced-1.cpp
  test/Modules/misplaced-2.cpp
  test/Modules/misplaced-3.cpp
  test/Modules/misplaced-4.cpp
  test/Modules/misplaced-5.c

Index: test/Modules/misplaced-5.c
===
--- /dev/null
+++ test/Modules/misplaced-5.c
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify
+
+struct S1 {  // expected-note{{'struct S1' begins here}}
+#include "dummy.h"  // expected-error{{import of module 'dummy' appears within 'struct S1'}}
+}
Index: test/Modules/misplaced-4.cpp
===
--- /dev/null
+++ test/Modules/misplaced-4.cpp
@@ -0,0 +1,2 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=Misplaced -fmodules-cache-path=%t -x c++ -I %S/Inputs %S/Inputs/misplaced/misplaced.modulemap -verify
Index: test/Modules/misplaced-3.cpp
===
--- /dev/null
+++ test/Modules/misplaced-3.cpp
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify
+
+class C1 {  // expected-note{{'C1' begins here}}
+#include "dummy.h"  // expected-error{{import of module 'dummy' appears within 'C1'}}
+}
Index: test/Modules/misplaced-2.cpp
===
--- /dev/null
+++ test/Modules/misplaced-2.cpp
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify
+
+void func1() {  // expected-note{{function 'func1' begins here}}
+#include "dummy.h"  // expected-error{{import of module 'dummy' appears within function 'func1'}}
+}
Index: test/Modules/misplaced-1.cpp
===
--- /dev/null
+++ test/Modules/misplaced-1.cpp
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs %s -verify
+
+namespace N1 {  // expected-note{{namespace 'N1' begins here}}
+#include "dummy.h"  // expected-error{{import of module 'dummy' appears within namespace 'N1'}}
+}
Index: test/Modules/malformed.cpp
===
--- test/Modules/malformed.cpp
+++ test/Modules/malformed.cpp
@@ -12,20 +12,14 @@
 #include STR(HEADER)
 
 // CHECK-A: While building module 'malformed_a'
-// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} error: expected '}'
+// CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} error: expected '}' at end of module
 // CHECK-A: {{^}}Inputs/malformed/a1.h:1:{{.*}} note: to match this '{'
 //
 // CHECK-A: While building module 'malformed_a'
 // CHECK-A: {{^}}Inputs/malformed/a2.h:1:{{.*}} error: extraneous closing brace
 
 // CHECK-B: While building module 'malformed_b'
-// CHECK-B: {{^}}Inputs/malformed/b1.h:2:{{.*}} error: expected '}'
-// CHECK-B: {{^}}Inputs/malformed/b1.h:1:{{.*}} note: to match this '{'
-// CHECK-B: {{^}}Inputs/malformed/b1.h:3:{{.*}} error: extraneous closing brace ('}')
-//
-// CHECK-B: While building module 'malformed_b'
-// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} error: redefinition of 'g'
-// CHECK-B: {{^}}Inputs/malformed/b2.h:1:{{.*}} note: previous definition is here
+// CHECK-B: {{^}}Inputs/malformed/b1.h:2:{{.*}} error: import of module 'malformed_b.b2' appears within 'S'
 
 void test() { f(); }
 // Test that we use relative paths to name files within an imported module.
Index: test/Modules/extern_c.cpp
===
--- test/Modules/extern_c.cpp
+++ test/Modules/extern_c.cpp
@@ -68,7 +68,7 @@
   extern "C" {
 #endif
 int f;
-#if !defined(CXX_HEADER)
+#if !defined(CXX_HEADER) && !defined(NAMESPACE)
 // expected-error@-2 {{redefinition of 'f' as different kind of symbol}}
 // expected-note@c-header.h:1 {{previous}}
 #endif
@@ -78,4 +78,6 @@
 }
 #endif
 
+#if !defined(NAMESPACE)
 suppress_expected_no_diagnostics_error error_here; // expected-error {{}}
+#endif
Index: test/Modules/auto-module-import.m
===
--- 

Re: [PATCH] D12973: [Static Analyzer] General type checker based on dynamic type information.

2015-09-18 Thread Anna Zaks via cfe-commits
zaks.anna accepted this revision.
This revision is now accepted and ready to land.


Comment at: test/Analysis/generics.m:239
@@ -238,3 +238,3 @@
   NSArray *b = a;
-  NSString *str = [b getObjAtIndex: 0]; // expected-warning {{Conversion}}
+  NSString *str = [b getObjAtIndex: 0]; // expected-warning {{Object}}
   NSNumber *num = [b getObjAtIndex: 0];

Could you replace these with the full error message. It would much more 
readable this way.


http://reviews.llvm.org/D12973



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


Re: [PATCH] D11844: [Modules] More descriptive diagnostics for misplaced import directive

2015-09-18 Thread Serge Pavlov via cfe-commits
sepavloff added a comment.

Thanks for helpful notes!

There are similar cases in Objective C. Should they be implemented in this 
patch or separate patch is OK?



Comment at: include/clang/Basic/DiagnosticParseKinds.td:1016
@@ -1015,2 +1015,3 @@
   "expected ';' after module name">;
+def err_missing_before_module_end : Error<"expected %0 at the end of module">;
 }

rsmith wrote:
> I would drop the "the" in this error.
Done.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7774
@@ -7771,1 +7773,3 @@
   "@import of module '%0' in implementation of '%1'; use #import">;
+def note_module_need_top_level : Note<"consider moving the import to top 
level">;
+def note_module_need_textual : Note<"consider marking the header as textual">;

silvas wrote:
> rsmith wrote:
> > We'll already have said something like:
> > 
> >   error: import of module 'foo' appears within class X
> >   note: class X begins here
> > 
> > There are two likely situations here: either the header was intended to be 
> > included textually, or the user forgot a `}` or similar and didn't expect 
> > for the import to be inside the class. Either way, this note is not useful 
> > (either they thought it *was* at the top level, or the note is not 
> > applicable).
> > 
> > How about dropping this note? The "begins here" note seems to have already 
> > covered the interesting case.
> I think this makes sense. `error: ... import ... appears within ...` seems 
> like sufficient information about the nature of the error.
The message is removed.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7775
@@ -7772,1 +7774,3 @@
+def note_module_need_top_level : Note<"consider moving the import to top 
level">;
+def note_module_need_textual : Note<"consider marking the header as textual">;
 }

rsmith wrote:
> Textual headers are not the common case, so "consider" seems too strong; how 
> about weakening this to something like:
> 
>   "if this header is intended to be included textually, mark it 'textual' in 
> the module map"
This message is also removed, as Sean proposed.


Comment at: lib/Parse/ParseDeclCXX.cpp:213
@@ -212,2 +212,3 @@
   if (index == Ident.size()) {
-while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
+while (tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
+   Tok.isNot(tok::eof)) {

rsmith wrote:
> Move this `try...` call to the end of the `&&` here and elsewhere; it's much 
> more likely that we'll hit an `r_brace`.
Moved.


Comment at: lib/Parse/Parser.cpp:2023-2024
@@ +2022,4 @@
+/// be found.
+/// \returns true if the recover was successful and parsing may be continued, 
or
+/// false if parser must bail out to top level and handle the token there.
+bool Parser::tryParseMisplacedModuleImport() {

rsmith wrote:
> This is the opposite of how all the other `try` functions behave: they return 
> `true` if they consumed the thing they were asked to consume.
Meaning of the return value is inverted.


Comment at: lib/Parse/Parser.cpp:2025-2027
@@ +2024,5 @@
+/// false if parser must bail out to top level and handle the token there.
+bool Parser::tryParseMisplacedModuleImport() {
+  while (true) {
+switch (Tok.getKind()) {
+case tok::annot_module_end:

rsmith wrote:
> Refactor this as follows:
> 
> Rename this to `parseMisplacedModuleImport`. Add an inline 
> `tryParseMisplacedModuleImport` to Parser.h, which checks if the current 
> token is an EOM token. If it is, it calls this function. If it is not, it 
> returns immediately.
> 
> The purpose of having these `try` functions with thin wrappers in the .h file 
> is so that we can inline the cheap "are we looking at the right kind of 
> token" check (and allow it to be combined with other nearby checks on the 
> token kind).
Thank you for explanation. Fixed.


Comment at: lib/Sema/SemaDecl.cpp:14361-14366
@@ -14359,6 +14360,8 @@
   if (!isa(DC)) {
-S.Diag(ImportLoc, diag::err_module_import_not_at_top_level)
-  << M->getFullModuleName() << DC;
-S.Diag(cast(DC)->getLocStart(),
-   diag::note_module_import_not_at_top_level)
-  << DC;
+if (DC->isNamespace()) {
+  S.Diag(ImportLoc, diag::err_module_import_not_at_top_level)
+<< M->getFullModuleName() << DC;
+  S.Diag(cast(DC)->getLocStart(),
+ diag::note_module_import_not_at_top_level) << DC;
+  S.Diag(ImportLoc, diag::note_module_need_top_level);
+} else {

rsmith wrote:
> It looks like this will currently produce repeated diagnostics for an import 
> within multiple namespaces:
> 
> module.map:
>   module Foo { module X { header "foo1.h" } module Y { header "foo2.h" } }
> 
> foo1.h:
>   namespace A {
> namespace B {
>   #include "foo2.h"
> }
>   }
> 
> I believe this will diagnose:
> 1) import of 

Re: [PATCH] D12871: [OpenMP] Target directive host codegen - rebased

2015-09-18 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 35121.
sfantao added a comment.

Update if clause emission for target directive following Alexey's remark.


http://reviews.llvm.org/D12871

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  test/OpenMP/target_codegen.cpp

Index: test/OpenMP/target_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen.cpp
@@ -0,0 +1,644 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[TT:%.+]] = type { i64, i8 }
+// CHECK-DAG: [[S1:%.+]] = type { double }
+
+// We have 8 target regions, but only 7 that actually will generate offloading
+// code, only 6 will have mapped arguments, and only 4 have all-constant map
+// sizes.
+
+// CHECK-DAG: [[SIZET2:@.+]] = private unnamed_addr constant [1 x i{{32|64}}] [i[[SZ:32|64]] 2]
+// CHECK-DAG: [[MAPT2:@.+]] = private unnamed_addr constant [1 x i32] [i32 3]
+// CHECK-DAG: [[SIZET3:@.+]] = private unnamed_addr constant [2 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2]
+// CHECK-DAG: [[MAPT3:@.+]] = private unnamed_addr constant [2 x i32] [i32 3, i32 3]
+// CHECK-DAG: [[MAPT4:@.+]] = private unnamed_addr constant [9 x i32] [i32 3, i32 3, i32 1, i32 3, i32 3, i32 1, i32 1, i32 3, i32 3]
+// CHECK-DAG: [[SIZET5:@.+]] = private unnamed_addr constant [3 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT5:@.+]] = private unnamed_addr constant [3 x i32] [i32 3, i32 3, i32 3]
+// CHECK-DAG: [[SIZET6:@.+]] = private unnamed_addr constant [4 x i[[SZ]]] [i[[SZ]] 4, i[[SZ]] 2, i[[SZ]] 1, i[[SZ]] 40]
+// CHECK-DAG: [[MAPT6:@.+]] = private unnamed_addr constant [4 x i32] [i32 3, i32 3, i32 3, i32 3]
+// CHECK-DAG: [[MAPT7:@.+]] = private unnamed_addr constant [5 x i32] [i32 3, i32 3, i32 1, i32 1, i32 3]
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+// CHECK-DAG: @{{.*}} = private constant i8 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+// CHECK: define {{.*}}[[FOO:@.+]](
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 0, i8** null, i8** null, i[[SZ]]* null, i32* null)
+  // CHECK:   store i32 [[RET]], i32* [[RHV:%.+]], align 4
+  // CHECK:   [[RET2:%.+]] = load i32, i32* [[RHV]], align 4
+  // CHECK-NEXT:  [[ERROR:%.+]] = icmp ne i32 [[RET2]], 0
+  // CHECK-NEXT:  br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]]
+  // CHECK:   [[FAIL]]
+  // CHECK:   call void [[HVT0:@.+]]()
+  // CHECK-NEXT:  br label %[[END]]
+  // CHECK:   [[END]]
+  #pragma omp target
+  {
+  }
+
+  // CHECK:   store i32 0, i32* [[RHV:%.+]], align 4
+  // CHECK:   store i32 -1, i32* [[RHV]], align 4
+  // CHECK:   [[RET2:%.+]] = load i32, i32* [[RHV]], align 4
+  // CHECK-NEXT:  [[ERROR:%.+]] = icmp ne i32 [[RET2]], 0
+  // CHECK:   call void [[HVT1:@.+]](i32* {{[^,]+}})
+  #pragma omp target if(0)
+  {
+a += 1;
+  }
+
+  // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i[[SZ]]* getelementptr inbounds ([1 x i[[SZ]]], [1 x i[[SZ]]]* [[SIZET2]], i32 0, i32 0), i32* getelementptr inbounds ([1 x i32], [1 x i32]* [[MAPT2]], i32 0, i32 0))
+  // CHECK-DAG:   [[BP]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[P]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR:%[^,]+]], i32 0, i32 0
+  // CHECK-DAG:   [[BPADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[BPR]], i32 0, i32 [[IDX0:[0-9]+]]
+  // CHECK-DAG:   [[PADDR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[PR]], i32 0, i32 [[IDX0]]
+  // CHECK-DAG:   store i8* [[BP0:%[^,]+]], i8** [[BPADDR0]]
+  // CHECK-DAG:   store i8* [[P0:%[^,]+]], i8** [[PADDR0]]
+  // CHECK-DAG:   [[BP0]] = bitcast i16* %{{.+}} to i8*
+  // CHECK-DAG:   [[P0]] = bitcast i16* %{{.+}} to i8*
+
+  

r248021 - [analyzer] A fix for substraction of an integer from a pointer.

2015-09-18 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Sep 18 14:13:22 2015
New Revision: 248021

URL: http://llvm.org/viewvc/llvm-project?rev=248021=rev
Log:
[analyzer] A fix for substraction of an integer from a pointer.

Patch by Artem Dergachev!

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/test/Analysis/ptr-arith.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=248021=248020=248021=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Fri Sep 18 14:13:22 
2015
@@ -911,8 +911,9 @@ SVal SimpleSValBuilder::evalBinOpLN(Prog
   elementType = elemReg->getElementType();
 }
 else if (isa(region)) {
+  assert(op == BO_Add || op == BO_Sub);
+  index = (op == BO_Add) ? rhs : evalMinus(rhs);
   superR = region;
-  index = rhs;
   if (resultTy->isAnyPointerType())
 elementType = resultTy->getPointeeType();
 }

Modified: cfe/trunk/test/Analysis/ptr-arith.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ptr-arith.c?rev=248021=248020=248021=diff
==
--- cfe/trunk/test/Analysis/ptr-arith.c (original)
+++ cfe/trunk/test/Analysis/ptr-arith.c Fri Sep 18 14:13:22 2015
@@ -296,3 +296,20 @@ void symbolicFieldRegion(struct Point *p
   clang_analyzer_eval([i].x < [i].y);// expected-warning{{TRUE}}
 }
 
+void negativeIndex(char *str) {
+  *(str + 1) = 'a';
+  clang_analyzer_eval(*(str + 1) == 'a'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(*(str - 1) == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr1 = str - 1;
+  clang_analyzer_eval(*ptr1 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr2 = str;
+  ptr2 -= 1;
+  clang_analyzer_eval(*ptr2 == 'a'); // expected-warning{{UNKNOWN}}
+
+  char *ptr3 = str;
+  --ptr3;
+  clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}}
+}
+


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


[PATCH] D12981: [clang-cl]: Don't warn on /bigobj flag

2015-09-18 Thread Nico Weber via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
thakis added a subscriber: cfe-commits.

LLVM r217812 made it so that clang-cl implicitly creates bigobj files when 
needed, independent of this flag. It looks like cl has this flag to produce obj 
flags compatible with MSVS 2003's linker by default, something we don't care 
about. Since clang-cl always has /bigobj behavior, don't warn that the flag is 
unused, just ignore it silently.

http://reviews.llvm.org/D12981

Files:
  include/clang/Driver/CLCompatOptions.td

Index: include/clang/Driver/CLCompatOptions.td
===
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -243,6 +243,7 @@
 // Ignored:
 
 def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">;
+def _SLASH_bigobj : CLIgnoredFlag<"bigobj">;
 def _SLASH_cgthreads : CLIgnoredJoined<"cgthreads">;
 def _SLASH_d2Zi_PLUS : CLIgnoredFlag<"d2Zi+">;
 def _SLASH_errorReport : CLIgnoredJoined<"errorReport">;
@@ -274,7 +275,6 @@
 // Unsupported:
 
 def _SLASH_AI : CLJoined<"AI">;
-def _SLASH_bigobj : CLFlag<"bigobj">;
 def _SLASH_clr : CLJoined<"clr">;
 def _SLASH_doc : CLJoined<"doc">;
 def _SLASH_FA_joined : CLJoined<"FA">;


Index: include/clang/Driver/CLCompatOptions.td
===
--- include/clang/Driver/CLCompatOptions.td
+++ include/clang/Driver/CLCompatOptions.td
@@ -243,6 +243,7 @@
 // Ignored:
 
 def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">;
+def _SLASH_bigobj : CLIgnoredFlag<"bigobj">;
 def _SLASH_cgthreads : CLIgnoredJoined<"cgthreads">;
 def _SLASH_d2Zi_PLUS : CLIgnoredFlag<"d2Zi+">;
 def _SLASH_errorReport : CLIgnoredJoined<"errorReport">;
@@ -274,7 +275,6 @@
 // Unsupported:
 
 def _SLASH_AI : CLJoined<"AI">;
-def _SLASH_bigobj : CLFlag<"bigobj">;
 def _SLASH_clr : CLJoined<"clr">;
 def _SLASH_doc : CLJoined<"doc">;
 def _SLASH_FA_joined : CLJoined<"FA">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12871: [OpenMP] Target directive host codegen - rebased

2015-09-18 Thread Samuel Antao via cfe-commits
sfantao added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3044-3054
@@ +3043,13 @@
+
+  if (auto *VAT = dyn_cast(ElementType.getTypePtr())) {
+auto VATInfo = CGF.getVLASize(VAT);
+Size = llvm::ConstantInt::get(
+CGM.SizeTy,
+CGM.getContext().getTypeSizeInChars(VATInfo.second).getQuantity());
+Size = CGF.Builder.CreateNUWMul(Size, VATInfo.first);
+  } else {
+uint64_t ElementTypeSize =
+CGM.getContext().getTypeSizeInChars(ElementType).getQuantity();
+Size = llvm::ConstantInt::get(CGM.SizeTy, ElementTypeSize);
+  }
+

ABataev wrote:
> You were using uint64_t ASTContext::getTypeSize(ElementType), but I'm talking 
> about static llvm::Value *getTypeSize(CGF, ElementType), which is defined in 
> CGOpenMPRuntime.cpp. It does exactly the same thing you're doing in this part 
> of code.
Got it! Done!

Just a related question: isn't the loop in getTypeSize() doing the same thing 
as CGF.getVLASize()? Just wondering if that should be reused in there.

Thanks!


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3082-3128
@@ +3081,49 @@
+
+  // Generate the code to launch the target region. The pattern is the
+  // following:
+  //
+  //   ...
+  //   br IfCond (if any), omp_offload, omp_offload_fail
+  //
+  // omp_offload.try:
+  //   ; create arrays for offloading
+  //   error = __tgt_target(...)
+  //   br error, omp_offload_fail, omp_offload_end
+  //
+  // omp_offload.fail:
+  //   host_version(...)
+  //
+  // omp_offload.end:
+  //   ...
+  //
+
+  auto OffloadTryBlock = CGF.createBasicBlock("omp_offload.try");
+  auto OffloadFailBlock = CGF.createBasicBlock("omp_offload.fail");
+  auto ContBlock = CGF.createBasicBlock("omp_offload.end");
+
+  if (IfCond)
+CGF.EmitBranchOnBoolExpr(IfCond, OffloadTryBlock, OffloadFailBlock,
+ /*TrueCount=*/0);
+
+  CGF.EmitBlock(OffloadTryBlock);
+
+  unsigned PointerNumVal = BasePointers.size();
+  llvm::Value *PointerNum = CGF.Builder.getInt32(PointerNumVal);
+  llvm::Value *BasePointersArray;
+  llvm::Value *PointersArray;
+  llvm::Value *SizesArray;
+  llvm::Value *MapTypesArray;
+
+  if (PointerNumVal) {
+llvm::APInt PointerNumAP(32, PointerNumVal, /*isSigned=*/true);
+QualType PointerArrayType = CGF.getContext().getConstantArrayType(
+CGF.getContext().VoidPtrTy, PointerNumAP, ArrayType::Normal,
+/*IndexTypeQuals=*/0);
+
+BasePointersArray =
+CGF.CreateMemTemp(PointerArrayType, ".offload_baseptrs").getPointer();
+PointersArray =
+CGF.CreateMemTemp(PointerArrayType, ".offload_ptrs").getPointer();
+
+// If we don't have any VLA types, we can use a constant array for the map
+// sizes, otherwise we need to fill up the arrays as we do for the 
pointers.

ABataev wrote:
> You can emit an empty else block, it will be optimized by backend
In the new diff I now use a temp variable to keep the error code and try to 
reuse the if clause current logic. Let me know if this along the lines you want 
it to be.


http://reviews.llvm.org/D12871



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


Re: [PATCH] D12725: [analyzer] A fix for substraction of an integer from a pointer.

2015-09-18 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

In http://reviews.llvm.org/D12725#243150, @NoQ wrote:

> Thanks, fixed :)


Can you commit this or do you need someone to commit this for you?


http://reviews.llvm.org/D12725



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


r248029 - Fix test to pass when the directory name has lld in it.

2015-09-18 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Fri Sep 18 15:22:36 2015
New Revision: 248029

URL: http://llvm.org/viewvc/llvm-project?rev=248029=rev
Log:
Fix test to pass when the directory name has lld in it.

CHECK-LABEL assumes that there is only one occurrence of the match.

The output looks like:

clang version 3.8.0 (trunk 247999)

/path/to/build/dir/bin/clang-3.8 

If the path contains lld, the second CHECK-LABEL matches it and we fail since
there is no -cc1as between clang and lld.

Modified:
cfe/trunk/test/Driver/amdgpu-toolchain.c

Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=248029=248028=248029=diff
==
--- cfe/trunk/test/Driver/amdgpu-toolchain.c (original)
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c Fri Sep 18 15:22:36 2015
@@ -1,6 +1,5 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
-// AS_LINK-LABEL: clang
-// AS_LINK: "-cc1as"
-// AS_LINK-LABEL: lld
-// AS_LINK: "-flavor" "gnu" "-target" "amdgcn--amdhsa"
-// REQUIRES: clang-driver
+// AS_LINK: /clang
+// AS_LINK-SAME: "-cc1as"
+// AS_LINK: /lld
+// AS_LINK-SAME: "-flavor" "gnu" "-target" "amdgcn--amdhsa"


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


r248034 - clang-cl: Don't warn on /bigobj flag

2015-09-18 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Sep 18 15:49:33 2015
New Revision: 248034

URL: http://llvm.org/viewvc/llvm-project?rev=248034=rev
Log:
clang-cl: Don't warn on /bigobj flag

LLVM r217812 made it so that clang-cl implicitly creates bigobj files when
needed, independent of this flag. It looks like cl has this flag to produce obj
flags compatible with MSVS 2003's linker by default, something we don't care
about. Since clang-cl always has /bigobj behavior, don't warn that the flag is
unused, just ignore it silently.

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=248034=248033=248034=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Fri Sep 18 15:49:33 2015
@@ -243,6 +243,7 @@ def _SLASH_Zl : CLFlag<"Zl">,
 // Ignored:
 
 def _SLASH_analyze_ : CLIgnoredFlag<"analyze-">;
+def _SLASH_bigobj : CLIgnoredFlag<"bigobj">;
 def _SLASH_cgthreads : CLIgnoredJoined<"cgthreads">;
 def _SLASH_d2Zi_PLUS : CLIgnoredFlag<"d2Zi+">;
 def _SLASH_errorReport : CLIgnoredJoined<"errorReport">;
@@ -274,7 +275,6 @@ def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">;
 // Unsupported:
 
 def _SLASH_AI : CLJoined<"AI">;
-def _SLASH_bigobj : CLFlag<"bigobj">;
 def _SLASH_clr : CLJoined<"clr">;
 def _SLASH_doc : CLJoined<"doc">;
 def _SLASH_FA_joined : CLJoined<"FA">;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=248034=248033=248034=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Fri Sep 18 15:49:33 2015
@@ -221,6 +221,7 @@
 // Ignored options. Check that we don't get "unused during compilation" errors.
 // RUN: %clang_cl /c \
 // RUN:/analyze- \
+// RUN:/bigobj \
 // RUN:/cgthreads4 \
 // RUN:/cgthreads8 \
 // RUN:/d2Zi+ \


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


Re: r247618 - C11 _Bool bitfield diagnostic

2015-09-18 Thread Nico Weber via cfe-commits
On Fri, Sep 18, 2015 at 5:06 PM, Richard Smith 
wrote:

> On Wed, Sep 16, 2015 at 5:33 PM, Richard Smith 
> wrote:
>
>> On Wed, Sep 16, 2015 at 5:27 PM, Nico Weber via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Tue, Sep 15, 2015 at 5:50 PM, Richard Smith 
>>> wrote:
>>>
 On Tue, Sep 15, 2015 at 12:38 PM, Nico Weber 
 wrote:

> With this patch, we warn on `bool a : 4;`, yet we don't warn on `bool
> b` (which has 8 bits storage, 1 bit value). Warning on `bool b` is silly 
> of
> course, but why is warning on `bool a : 4` useful? That's like 50% more
> storage efficient than `bool b` ;-)
>
> It's possible that this is a good warning for some reason, but I don't
> quite see why yet.
>

 Why would we warn on "unsigned n : 57;"? The bit-field is wider than
 necessary, and we have no idea what the programmer was trying to do

>>>
>>> Warning on this kind of makes sense to me, as the field is wider than
>>> the default width of int. (Not warning on that doesn't seem terrible to me
>>> either though.)
>>>
>>> I'm only confused about the bool case with bitfield sizes < 8 I think.
>>> We warn that the bitfield is wider than the value size, even though it's
>>> smaller than the default storage size, and we don't warn on regular bools.
>>>
>>> To get an idea how often this warning fires, I ran it on a large-ish
>>> open source codebase I had flying around. The only place it fired on is one
>>> header in protobuf (extension_set.h). I looked at the history of that file,
>>> and it had a struct that used to look like
>>>
>>>   struct Extension {
>>> SomeEnum e;
>>> bool a;
>>> bool b;
>>> bool c;
>>> int d;
>>> // ...some more stuff...
>>>   };
>>>
>>> Someone then added another field to this and for some reason decided to
>>> do it like so:
>>>
>>>   struct Extension {
>>> SomeEnum e;
>>> bool a;
>>> bool b1 : 4;
>>> bool b2 : 4;
>>> bool c;
>>> int d;
>>> // ...some more stuff...
>>>   };
>>>
>>> Neither the commit message nor the review discussion mention the
>>> bitfield at all as far as I can tell. Now, given that this isn't a small
>>> struct and it has a bunch of normal bools, I don't know why they added the
>>> new field as bitfield while this wasn't deemed necessary for the existing
>>> bools. My best guess is that that they didn't want to add 3 bytes of
>>> padding (due to the int field), which seems like a decent reason.
>>>
>>> Had the warning been in place when this code got written, I suppose they
>>> had used ": 1" instead. Does this make this code much better? It doesn't
>>> seem like it to me. So after doing a warning quality eval, I'd suggest to
>>> not emit the warning for bool bitfields if the bitfield size is < 8. (But
>>> since the warning fires only very rarely, I don't feel very strongly about
>>> this.)
>>>
>>
>> I agree it doesn't make the code /much/ better. But if I were reading
>> that, I would certainly pause for a few moments wondering what the author
>> was thinking. I also don't feel especially strongly about this, but I don't
>> see a good rationale for warning on 'bool : 9' but not on 'bool : 5'.
>>
>
> I'm coming around to the opinion that we shouldn't give this warning on
> bool at all -- the point of the warning is to point out that an 'unsigned :
> 40;' bitfield can't hold 2**40 - 1, and values of that size will be
> truncated. There is no corresponding problematic case for bool, so we have
> a much weaker justification for warning in this case -- we have no idea
> what the user was trying to achieve, but we do not have a signal that their
> code is wrong.
>
> Thoughts?
>

Makes sense to me :-) What about `bool : 16`?


>
> , but it doesn't seem likely they got that effect. Would you be more
 convinced if we amended the diagnostic to provide a fixit suggesting using
 an anonymous bit-field to insert padding?

>>>
>>> Isn't the Right Fix (tm) to make bool bitfields 1 wide and rely on the
>>> compiler to figure out padding?
>>>
>>
>> It depends; maybe the intent is to be compatible with some on-disk
>> format, and the explicit padding is important:
>>
>> struct X {
>>   int n : 3;
>>   bool b : 3;
>>   int n : 2;
>> };
>>
>> Changing the bool bit-field to 1 bit without inserting an anonymous
>> bit-field would change the struct layout.
>>
>>
>>> On Mon, Sep 14, 2015 at 11:06 PM, Richard Smith 
> wrote:
>
>> On Mon, Sep 14, 2015 at 7:07 PM, Rachel Craik 
>> wrote:
>>
>>> As of DR262, the C standard clarified that the width of a bit-field
>>> can not exceed that of the specified type, and this change was 
>>> primarily to
>>> ensure that Clang correctly enforced this part of the standard. Looking 
>>> at
>>> the C++11 standard again, it states that although the 

Re: [clang-tools-extra] r248080 - clang-tools-extra: Appease PR24881. [-Wdocumentation]

2015-09-18 Thread Sean Silva via cfe-commits
Thanks!

-- Sean Silva

On Fri, Sep 18, 2015 at 7:21 PM, NAKAMURA Takumi via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: chapuni
> Date: Fri Sep 18 21:21:28 2015
> New Revision: 248080
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248080=rev
> Log:
> clang-tools-extra: Appease PR24881. [-Wdocumentation]
>
> \returns doesn't accept \li, but \parblock \li.
>
> Modified:
>
> clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
>
> clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
>
> clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
> clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.h
> clang-tools-extra/trunk/clang-modernize/Core/ReplacementHandling.h
> clang-tools-extra/trunk/clang-modernize/Core/Transform.h
>
> Modified:
> clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h?rev=248080=248079=248080=diff
>
> ==
> ---
> clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
> (original)
> +++
> clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
> Fri Sep 18 21:21:28 2015
> @@ -84,7 +84,8 @@ collectReplacementsFromDirectory(const l
>  /// file they target.
>  /// \param[in] SM SourceManager required for conflict reporting.
>  ///
> -/// \returns \li true If all changes were applied successfully.
> +/// \returns \parblock
> +///  \li true If all changes were applied successfully.
>  ///  \li false If there were conflicts.
>  bool mergeAndDeduplicate(const TUReplacements ,
>   FileToReplacementsMap ,
> @@ -97,7 +98,8 @@ bool mergeAndDeduplicate(const TUReplace
>  /// \param[out] Rewrites The results of applying replacements will be
> applied
>  /// to this Rewriter.
>  ///
> -/// \returns \li true If all changes were applied successfully.
> +/// \returns \parblock
> +///  \li true If all changes were applied successfully.
>  ///  \li false If a replacement failed to apply.
>  bool applyReplacements(const FileToReplacementsMap ,
> clang::Rewriter );
> @@ -125,7 +127,8 @@ bool writeFiles(const clang::Rewriter 
>  /// \param[in] Files Replacement files to delete.
>  /// \param[in] Diagnostics DiagnosticsEngine used for error output.
>  ///
> -/// \returns \li true If all files have been deleted successfully.
> +/// \returns \parblock
> +///  \li true If all files have been deleted successfully.
>  ///  \li false If at least one or more failures occur when
> deleting
>  /// files.
>  bool deleteReplacementFiles(const TUReplacementFiles ,
>
> Modified:
> clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=248080=248079=248080=diff
>
> ==
> ---
> clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
> (original)
> +++
> clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
> Fri Sep 18 21:21:28 2015
> @@ -131,7 +131,8 @@ static void reportConflict(
>  /// to be deduplicated and checked for conflicts.
>  /// \param[in] SM SourceManager required for conflict reporting.
>  ///
> -/// \returns \li true if conflicts were detected
> +/// \returns \parblock
> +///  \li true if conflicts were detected
>  ///  \li false if no conflicts were detected
>  static bool deduplicateAndDetectConflicts(FileToReplacementsMap
> ,
>SourceManager ) {
>
> Modified:
> clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=248080=248079=248080=diff
>
> ==
> ---
> clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
> (original)
> +++
> clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
> Fri Sep 18 21:21:28 2015
> @@ -100,7 +100,8 @@ static void printVersion() {
>  /// \param[out] Result Contents of the file after applying replacements if
>  /// replacements were provided.
>  ///
> -/// \returns \li true if all replacements were applied successfully.
> +/// \returns \parblock
> +///  \li true if all replacements were applied 

Re: [PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-09-18 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Thanks for the fix! We'll commit shortly.


Repository:
  rL LLVM

http://reviews.llvm.org/D12119



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


r248079 - Add test that we correctly allow some non-letter unicode characters in

2015-09-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Sep 18 21:14:12 2015
New Revision: 248079

URL: http://llvm.org/viewvc/llvm-project?rev=248079=rev
Log:
Add test that we correctly allow some non-letter unicode characters in
identifiers, and extend existing test to also cover C++.

Modified:
cfe/trunk/test/Lexer/unicode.c

Modified: cfe/trunk/test/Lexer/unicode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/unicode.c?rev=248079=248078=248079=diff
==
--- cfe/trunk/test/Lexer/unicode.c (original)
+++ cfe/trunk/test/Lexer/unicode.c Fri Sep 18 21:14:12 2015
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c -std=c11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++11 %s
 // RUN: %clang_cc1 -E -DPP_ONLY=1 %s -o %t
 // RUN: FileCheck --strict-whitespace --input-file=%t %s
 
@@ -24,3 +25,11 @@ COPYRIGHT
 // CHECK: Copyright © {{2012}}
 CHECK: The preprocessor should not complain about Unicode characters like ©.
 #endif
+
+// A 🌹 by any other name
+extern int 🌹;
+int 🌵(int 🌻) { return 🌻+ 1; }
+int main () {
+  int 🌷 = 🌵(🌹);
+  return 🌷;
+}


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


r248083 - Driver: avoid unnecessary string ops

2015-09-18 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Fri Sep 18 23:33:38 2015
New Revision: 248083

URL: http://llvm.org/viewvc/llvm-project?rev=248083=rev
Log:
Driver: avoid unnecessary string ops

Use an enumeration for the Floating Point ABIs supported on MIPS.  This is
replicating the ARM change to avoid string based tracking of the floating point
ABI.  NFC.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=248083=248082=248083=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Sep 18 23:33:38 2015
@@ -1090,33 +1090,37 @@ static StringRef getGnuCompatibleMipsABI
 
 // Select the MIPS float ABI as determined by -msoft-float, -mhard-float,
 // and -mfloat-abi=.
-static StringRef getMipsFloatABI(const Driver , const ArgList ) {
-  StringRef FloatABI;
+static mips::FloatABI getMipsFloatABI(const Driver , const ArgList ) {
+  mips::FloatABI ABI = mips::FloatABI::Invalid;
   if (Arg *A =
   Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float,
   options::OPT_mfloat_abi_EQ)) {
 if (A->getOption().matches(options::OPT_msoft_float))
-  FloatABI = "soft";
+  ABI = mips::FloatABI::Soft;
 else if (A->getOption().matches(options::OPT_mhard_float))
-  FloatABI = "hard";
+  ABI = mips::FloatABI::Hard;
 else {
-  FloatABI = A->getValue();
-  if (FloatABI != "soft" && FloatABI != "hard") {
+  ABI = llvm::StringSwitch(A->getValue())
+.Case("soft", mips::FloatABI::Soft)
+.Case("hard", mips::FloatABI::Hard)
+.Default(mips::FloatABI::Invalid);
+  if (ABI == mips::FloatABI::Invalid && !StringRef(A->getValue()).empty()) 
{
 D.Diag(diag::err_drv_invalid_mfloat_abi) << A->getAsString(Args);
-FloatABI = "hard";
+ABI = mips::FloatABI::Hard;
   }
 }
   }
 
   // If unspecified, choose the default based on the platform.
-  if (FloatABI.empty()) {
+  if (ABI == mips::FloatABI::Invalid) {
 // Assume "hard", because it's a default value used by gcc.
 // When we start to recognize specific target MIPS processors,
 // we will be able to select the default more correctly.
-FloatABI = "hard";
+ABI = mips::FloatABI::Hard;
   }
 
-  return FloatABI;
+  assert(ABI != mips::FloatABI::Invalid && "must select an ABI");
+  return ABI;
 }
 
 static void AddTargetFeature(const ArgList ,
@@ -1142,8 +1146,8 @@ static void getMIPSTargetFeatures(const
   AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
options::OPT_mabicalls, "noabicalls");
 
-  StringRef FloatABI = getMipsFloatABI(D, Args);
-  if (FloatABI == "soft") {
+  mips::FloatABI FloatABI = getMipsFloatABI(D, Args);
+  if (FloatABI == mips::FloatABI::Soft) {
 // FIXME: Note, this is a hack. We need to pass the selected float
 // mode to the MipsTargetInfoBase to define appropriate macros there.
 // Now it is the only method.
@@ -1215,16 +1219,15 @@ void Clang::AddMIPSTargetArgs(const ArgL
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName.data());
 
-  StringRef FloatABI = getMipsFloatABI(D, Args);
-
-  if (FloatABI == "soft") {
+  mips::FloatABI ABI = getMipsFloatABI(D, Args);
+  if (ABI == mips::FloatABI::Soft) {
 // Floating point operations and argument passing are soft.
 CmdArgs.push_back("-msoft-float");
 CmdArgs.push_back("-mfloat-abi");
 CmdArgs.push_back("soft");
   } else {
 // Floating point operations and argument passing are hard.
-assert(FloatABI == "hard" && "Invalid float abi!");
+assert(ABI == mips::FloatABI::Hard && "Invalid float abi!");
 CmdArgs.push_back("-mfloat-abi");
 CmdArgs.push_back("hard");
   }
@@ -6193,7 +6196,7 @@ bool mips::isNaN2008(const ArgList 
 }
 
 bool mips::isFPXXDefault(const llvm::Triple , StringRef CPUName,
- StringRef ABIName, StringRef FloatABI) {
+ StringRef ABIName, mips::FloatABI FloatABI) {
   if (Triple.getVendor() != llvm::Triple::ImaginationTechnologies &&
   Triple.getVendor() != llvm::Triple::MipsTechnologies)
 return false;
@@ -6203,7 +6206,7 @@ bool mips::isFPXXDefault(const llvm::Tri
 
   // FPXX shouldn't be used if either -msoft-float or -mfloat-abi=soft is
   // present.
-  if (FloatABI == "soft")
+  if (FloatABI == mips::FloatABI::Soft)
 return false;
 
   return llvm::StringSwitch(CPUName)
@@ -6215,7 +6218,7 @@ bool mips::isFPXXDefault(const llvm::Tri
 
 bool mips::shouldUseFPXX(const ArgList , const llvm::Triple ,
  StringRef CPUName, StringRef ABIName,
- StringRef FloatABI) {
+ mips::FloatABI FloatABI) {
   bool UseFPXX = isFPXXDefault(Triple, CPUName, ABIName, FloatABI);
 
   // FPXX 

[clang-tools-extra] r248080 - clang-tools-extra: Appease PR24881. [-Wdocumentation]

2015-09-18 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 18 21:21:28 2015
New Revision: 248080

URL: http://llvm.org/viewvc/llvm-project?rev=248080=rev
Log:
clang-tools-extra: Appease PR24881. [-Wdocumentation]

\returns doesn't accept \li, but \parblock \li.

Modified:

clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h

clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
clang-tools-extra/trunk/clang-modernize/Core/IncludeDirectives.h
clang-tools-extra/trunk/clang-modernize/Core/ReplacementHandling.h
clang-tools-extra/trunk/clang-modernize/Core/Transform.h

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h?rev=248080=248079=248080=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
 Fri Sep 18 21:21:28 2015
@@ -84,7 +84,8 @@ collectReplacementsFromDirectory(const l
 /// file they target.
 /// \param[in] SM SourceManager required for conflict reporting.
 ///
-/// \returns \li true If all changes were applied successfully.
+/// \returns \parblock
+///  \li true If all changes were applied successfully.
 ///  \li false If there were conflicts.
 bool mergeAndDeduplicate(const TUReplacements ,
  FileToReplacementsMap ,
@@ -97,7 +98,8 @@ bool mergeAndDeduplicate(const TUReplace
 /// \param[out] Rewrites The results of applying replacements will be applied
 /// to this Rewriter.
 ///
-/// \returns \li true If all changes were applied successfully.
+/// \returns \parblock
+///  \li true If all changes were applied successfully.
 ///  \li false If a replacement failed to apply.
 bool applyReplacements(const FileToReplacementsMap ,
clang::Rewriter );
@@ -125,7 +127,8 @@ bool writeFiles(const clang::Rewriter 
 /// \param[in] Files Replacement files to delete.
 /// \param[in] Diagnostics DiagnosticsEngine used for error output.
 ///
-/// \returns \li true If all files have been deleted successfully.
+/// \returns \parblock
+///  \li true If all files have been deleted successfully.
 ///  \li false If at least one or more failures occur when deleting
 /// files.
 bool deleteReplacementFiles(const TUReplacementFiles ,

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?rev=248080=248079=248080=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
 Fri Sep 18 21:21:28 2015
@@ -131,7 +131,8 @@ static void reportConflict(
 /// to be deduplicated and checked for conflicts.
 /// \param[in] SM SourceManager required for conflict reporting.
 ///
-/// \returns \li true if conflicts were detected
+/// \returns \parblock
+///  \li true if conflicts were detected
 ///  \li false if no conflicts were detected
 static bool deduplicateAndDetectConflicts(FileToReplacementsMap ,
   SourceManager ) {

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=248080=248079=248080=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
 Fri Sep 18 21:21:28 2015
@@ -100,7 +100,8 @@ static void printVersion() {
 /// \param[out] Result Contents of the file after applying replacements if
 /// replacements were provided.
 ///
-/// \returns \li true if all replacements were applied successfully.
+/// \returns \parblock
+///  \li true if all replacements were applied successfully.
 ///  \li false if at least one replacement failed to apply.
 static bool
 getRewrittenData(const std::vector ,
@@ -134,7 +135,8 @@ getRewrittenData(const std::vector ,
@@ -160,7 +162,8 @@ applyReplacements(const 

Re: [PATCH] D12903: Add -fplugin=name.so option to the driver

2015-09-18 Thread Saleem Abdulrasool via cfe-commits
compnerd accepted this revision.
compnerd added a reviewer: compnerd.
compnerd added a comment.
This revision is now accepted and ready to land.

Looks fine minus the one thing that needs a quick look at.



Comment at: include/clang/Driver/Options.td:952
@@ -951,1 +951,3 @@
 def fno_pie : Flag<["-"], "fno-pie">, Group;
+def fplugin : Joined<["-"], "fplugin=">, Group, 
Flags<[DriverOption]>, MetaVarName<"">,
+  HelpText<"Load the named plugin (dynamic shared object)">;

Don't most options of this type use the _EQ suffix?  Might be nice to follow 
the convention.


Repository:
  rL LLVM

http://reviews.llvm.org/D12903



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


Re: r247618 - C11 _Bool bitfield diagnostic

2015-09-18 Thread Richard Smith via cfe-commits
On Fri, Sep 18, 2015 at 8:49 PM, Nico Weber  wrote:

> On Fri, Sep 18, 2015 at 5:06 PM, Richard Smith 
> wrote:
>
>> On Wed, Sep 16, 2015 at 5:33 PM, Richard Smith 
>> wrote:
>>
>>> On Wed, Sep 16, 2015 at 5:27 PM, Nico Weber via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 On Tue, Sep 15, 2015 at 5:50 PM, Richard Smith 
 wrote:

> On Tue, Sep 15, 2015 at 12:38 PM, Nico Weber 
> wrote:
>
>> With this patch, we warn on `bool a : 4;`, yet we don't warn on `bool
>> b` (which has 8 bits storage, 1 bit value). Warning on `bool b` is silly 
>> of
>> course, but why is warning on `bool a : 4` useful? That's like 50% more
>> storage efficient than `bool b` ;-)
>>
>> It's possible that this is a good warning for some reason, but I
>> don't quite see why yet.
>>
>
> Why would we warn on "unsigned n : 57;"? The bit-field is wider than
> necessary, and we have no idea what the programmer was trying to do
>

 Warning on this kind of makes sense to me, as the field is wider than
 the default width of int. (Not warning on that doesn't seem terrible to me
 either though.)

 I'm only confused about the bool case with bitfield sizes < 8 I think.
 We warn that the bitfield is wider than the value size, even though it's
 smaller than the default storage size, and we don't warn on regular bools.

 To get an idea how often this warning fires, I ran it on a large-ish
 open source codebase I had flying around. The only place it fired on is one
 header in protobuf (extension_set.h). I looked at the history of that file,
 and it had a struct that used to look like

   struct Extension {
 SomeEnum e;
 bool a;
 bool b;
 bool c;
 int d;
 // ...some more stuff...
   };

 Someone then added another field to this and for some reason decided to
 do it like so:

   struct Extension {
 SomeEnum e;
 bool a;
 bool b1 : 4;
 bool b2 : 4;
 bool c;
 int d;
 // ...some more stuff...
   };

 Neither the commit message nor the review discussion mention the
 bitfield at all as far as I can tell. Now, given that this isn't a small
 struct and it has a bunch of normal bools, I don't know why they added the
 new field as bitfield while this wasn't deemed necessary for the existing
 bools. My best guess is that that they didn't want to add 3 bytes of
 padding (due to the int field), which seems like a decent reason.

 Had the warning been in place when this code got written, I suppose
 they had used ": 1" instead. Does this make this code much better? It
 doesn't seem like it to me. So after doing a warning quality eval, I'd
 suggest to not emit the warning for bool bitfields if the bitfield size is
 < 8. (But since the warning fires only very rarely, I don't feel very
 strongly about this.)

>>>
>>> I agree it doesn't make the code /much/ better. But if I were reading
>>> that, I would certainly pause for a few moments wondering what the author
>>> was thinking. I also don't feel especially strongly about this, but I don't
>>> see a good rationale for warning on 'bool : 9' but not on 'bool : 5'.
>>>
>>
>> I'm coming around to the opinion that we shouldn't give this warning on
>> bool at all -- the point of the warning is to point out that an 'unsigned :
>> 40;' bitfield can't hold 2**40 - 1, and values of that size will be
>> truncated. There is no corresponding problematic case for bool, so we have
>> a much weaker justification for warning in this case -- we have no idea
>> what the user was trying to achieve, but we do not have a signal that their
>> code is wrong.
>>
>> Thoughts?
>>
>
> Makes sense to me :-) What about `bool : 16`?
>

I don't think it makes sense to treat bool : 3 and bool : 16 differently.
The fact that an unadorned bool would occupy 8 bits doesn't seem relevant
to whether we should warn. Either we warn that there are padding bits, or
we don't.


> , but it doesn't seem likely they got that effect. Would you be more
> convinced if we amended the diagnostic to provide a fixit suggesting using
> an anonymous bit-field to insert padding?
>

 Isn't the Right Fix (tm) to make bool bitfields 1 wide and rely on the
 compiler to figure out padding?

>>>
>>> It depends; maybe the intent is to be compatible with some on-disk
>>> format, and the explicit padding is important:
>>>
>>> struct X {
>>>   int n : 3;
>>>   bool b : 3;
>>>   int n : 2;
>>> };
>>>
>>> Changing the bool bit-field to 1 bit without inserting an anonymous
>>> bit-field would change the struct layout.
>>>
>>>
 On Mon, Sep 14, 2015 at 11:06 PM, Richard Smith 
>> wrote:

Re: [PATCH] D10586: Add HSAIL support

2015-09-18 Thread Matt Arsenault via cfe-commits
arsenm updated this revision to Diff 35157.
arsenm added a comment.
Herald added a subscriber: rampitec.

Update for trunk. Fix __builtin_hsail_gridsize/__builtin_hsail_gridsizel


http://reviews.llvm.org/D10586

Files:
  include/clang/Basic/BuiltinsHSAIL.def
  include/clang/Basic/TargetBuiltins.h
  include/clang/module.modulemap
  lib/Basic/Targets.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  test/CodeGen/target-data.c
  test/CodeGenOpenCL/builtins-hsail.cl
  test/Driver/hsail-mcpu.cl
  test/Preprocessor/init.c
  test/SemaOpenCL/builtins-hsail-restrictions.cl

Index: test/SemaOpenCL/builtins-hsail-restrictions.cl
===
--- /dev/null
+++ test/SemaOpenCL/builtins-hsail-restrictions.cl
@@ -0,0 +1,82 @@
+// REQUIRES: hsail-registered-target
+// RUN: %clang_cc1 -triple hsail-unknown-unknown -verify -pedantic -fsyntax-only %s
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+typedef __attribute__((ext_vector_type(4))) long long4;
+
+
+void test_sqrt_builtin(volatile global double* out,
+   volatile float* outf,
+   double x,
+   float xf,
+   int var)
+{
+  *out = __builtin_hsail_fsqrt(var, 0, x); // expected-error {{argument to '__builtin_hsail_fsqrt' must be a constant integer}}
+  *outf = __builtin_hsail_fsqrtf(var, 0, xf); // expected-error {{argument to '__builtin_hsail_fsqrtf' must be a constant integer}}
+
+  *out = __builtin_hsail_fsqrt(0, var, x); // expected-error {{argument to '__builtin_hsail_fsqrt' must be a constant integer}}
+  *outf = __builtin_hsail_fsqrtf(0, var, xf); // expected-error {{argument to '__builtin_hsail_fsqrtf' must be a constant integer}}
+}
+
+void test_unpackcvt(volatile global float* out, int x, int y)
+{
+  *out = __builtin_hsail_unpackcvt(x, y); // expected-error {{argument to '__builtin_hsail_unpackcvt' must be a constant integer}}
+}
+
+void test_segmentp(volatile global int* out, int x)
+{
+  *out = __builtin_hsail_segmentp(x, false, (__attribute__((address_space(4))) char*)0); // expected-error {{argument to '__builtin_hsail_segmentp' must be a constant integer}}
+  *out = __builtin_hsail_segmentp(0, x, (__attribute__((address_space(4))) char*)0); // expected-error {{argument to '__builtin_hsail_segmentp' must be a constant integer}}
+}
+
+void test_memfence(int x)
+{
+  __builtin_hsail_memfence(x, 0); // expected-error {{argument to '__builtin_hsail_memfence' must be a constant integer}}
+  __builtin_hsail_memfence(0, x); // expected-error {{argument to '__builtin_hsail_memfence' must be a constant integer}}
+}
+
+void test_barrier_builtin(int x)
+{
+  __builtin_hsail_barrier(x); // expected-error {{argument to '__builtin_hsail_barrier' must be a constant integer}}
+}
+
+void test_activelanecount(volatile global int* out, int x)
+{
+  *out = __builtin_hsail_activelanecount(x, 0); // expected-error {{argument to '__builtin_hsail_activelanecount' must be a constant integer}}
+}
+
+void test_activelaneid(volatile global int* out, int x)
+{
+  *out = __builtin_hsail_activelaneid(x); // expected-error {{argument to '__builtin_hsail_activelaneid' must be a constant integer}}
+}
+
+void test_activelanemask(volatile global long4* out, int x)
+{
+  *out = __builtin_hsail_activelanemask(x, false); // expected-error {{argument to '__builtin_hsail_activelanemask' must be a constant integer}}
+}
+
+void test_activelanepermute(volatile global int* out, int x)
+{
+  *out = __builtin_hsail_activelanepermute(x, 0, 0, 0, 0); // expected-error {{argument to '__builtin_hsail_activelanepermute' must be a constant integer}}
+}
+
+void test_activelanepermutel(volatile global long* out, int x)
+{
+  *out = __builtin_hsail_activelanepermutel(x, 0, 0, 0, 0); // expected-error {{argument to '__builtin_hsail_activelanepermutel' must be a constant integer}}
+}
+
+void test_currentworkgroupsize(volatile global int* out, int x)
+{
+  *out = __builtin_hsail_currentworkgroupsize(x); // expected-error {{argument to '__builtin_hsail_currentworkgroupsize' must be a constant integer}}
+}
+
+void test_workitemabsid(volatile global int* out, int x)
+{
+  *out = __builtin_hsail_workitemabsid(x); // expected-error {{argument to '__builtin_hsail_workitemabsid' must be a constant integer}}
+}
+
+void test_workitemabsidl(volatile global long* out, int x)
+{
+  *out = __builtin_hsail_workitemabsidl(x); // expected-error {{argument to '__builtin_hsail_workitemabsidl' must be a constant integer}}
+}
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -6615,6 +6615,10 @@
 // AMDGPU:#define cl_khr_local_int32_base_atomics 1
 // AMDGPU:#define cl_khr_local_int32_extended_atomics 1
 
+// RUN: %clang_cc1 -x cl -E -dM -ffreestanding -triple=hsail < /dev/null | FileCheck -check-prefix=HSAIL %s
+// RUN: %clang_cc1 -x cl -E -dM 

Re: [PATCH] D12903: Add -fplugin=name.so option to the driver

2015-09-18 Thread Richard Smith via cfe-commits
On Fri, Sep 18, 2015 at 8:22 PM, Saleem Abdulrasool via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> compnerd accepted this revision.
> compnerd added a reviewer: compnerd.
> compnerd added a comment.
> This revision is now accepted and ready to land.
>
> Looks fine minus the one thing that needs a quick look at.
>
>
> 
> Comment at: include/clang/Driver/Options.td:952
> @@ -951,1 +951,3 @@
>  def fno_pie : Flag<["-"], "fno-pie">, Group;
> +def fplugin : Joined<["-"], "fplugin=">, Group,
> Flags<[DriverOption]>, MetaVarName<"">,
> +  HelpText<"Load the named plugin (dynamic shared object)">;
> 
> Don't most options of this type use the _EQ suffix?  Might be nice to
> follow the convention.


Please follow the rules listed on lines 106-123 of this file.


> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D12903
>
>
>
> ___
> 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


r248085 - [Modules] More descriptive diagnostics for misplaced import directive

2015-09-18 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Sat Sep 19 00:32:57 2015
New Revision: 248085

URL: http://llvm.org/viewvc/llvm-project?rev=248085=rev
Log:
[Modules] More descriptive diagnostics for misplaced import directive

If an import directive was put into wrong context, the error message was 
obscure,
complaining on misbalanced braces. To get more descriptive messages, annotation
tokens related to modules are processed where they must not be seen.

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

Added:
cfe/trunk/test/Modules/Inputs/misplaced/
cfe/trunk/test/Modules/Inputs/misplaced/misplaced-a.h
cfe/trunk/test/Modules/Inputs/misplaced/misplaced-b.h
cfe/trunk/test/Modules/Inputs/misplaced/misplaced.modulemap
cfe/trunk/test/Modules/misplaced-1.cpp
cfe/trunk/test/Modules/misplaced-2.cpp
cfe/trunk/test/Modules/misplaced-3.cpp
cfe/trunk/test/Modules/misplaced-4.cpp
cfe/trunk/test/Modules/misplaced-5.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Modules/auto-module-import.m
cfe/trunk/test/Modules/extern_c.cpp
cfe/trunk/test/Modules/malformed.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=248085=248084=248085=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Sat Sep 19 00:32:57 
2015
@@ -1013,6 +1013,7 @@ def err_module_expected_ident : Error<
   "expected a module name after module import">;
 def err_module_expected_semi : Error<
   "expected ';' after module name">;
+def err_missing_before_module_end : Error<"expected %0 at end of module">;
 }
 
 let CategoryName = "Generics Issue" in {

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=248085=248084=248085=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Sep 19 00:32:57 
2015
@@ -7776,6 +7776,8 @@ def note_module_import_in_extern_c : Not
   "extern \"C\" language linkage specification begins here">;
 def err_module_import_not_at_top_level : Error<
   "import of module '%0' appears within %1">;
+def err_module_import_not_at_top_level_fatal : Error<
+  "import of module '%0' appears within %1">, DefaultFatal;
 def note_module_import_not_at_top_level : Note<"%0 begins here">;
 def err_module_self_import : Error<
   "import of module '%0' appears within same top-level module '%1'">;

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=248085=248084=248085=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Sat Sep 19 00:32:57 2015
@@ -2555,6 +2555,14 @@ private:
   
//======//
   // Modules
   DeclGroupPtrTy ParseModuleImport(SourceLocation AtLoc);
+  bool parseMisplacedModuleImport();
+  bool tryParseMisplacedModuleImport() {
+tok::TokenKind Kind = Tok.getKind();
+if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
+Kind == tok::annot_module_include)
+  return parseMisplacedModuleImport();
+return false;
+  }
 
   
//======//
   // C++11/G++: Type Traits [Type-Traits.html in the GCC manual]

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=248085=248084=248085=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Sep 19 00:32:57 2015
@@ -1799,6 +1799,10 @@ public:
   /// \brief The parser has left a submodule.
   void ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
 
+  /// \brief Check if module import may be found in the current context,
+  /// emit error if not.
+  void diagnoseMisplacedModuleImport(Module *M, SourceLocation ImportLoc);
+
   /// \brief Create an implicit import of the given module at the given
   /// source location, for error recovery, if possible.
   ///

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp

Re: [PATCH] D11844: [Modules] More descriptive diagnostics for misplaced import directive

2015-09-18 Thread Serge Pavlov via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248085: [Modules] More descriptive diagnostics for misplaced 
import directive (authored by sepavloff).

Changed prior to commit:
  http://reviews.llvm.org/D11844?vs=35115=35161#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11844

Files:
  cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Parse/ParseStmt.cpp
  cfe/trunk/lib/Parse/Parser.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Modules/Inputs/misplaced/misplaced-a.h
  cfe/trunk/test/Modules/Inputs/misplaced/misplaced-b.h
  cfe/trunk/test/Modules/Inputs/misplaced/misplaced.modulemap
  cfe/trunk/test/Modules/auto-module-import.m
  cfe/trunk/test/Modules/extern_c.cpp
  cfe/trunk/test/Modules/malformed.cpp
  cfe/trunk/test/Modules/misplaced-1.cpp
  cfe/trunk/test/Modules/misplaced-2.cpp
  cfe/trunk/test/Modules/misplaced-3.cpp
  cfe/trunk/test/Modules/misplaced-4.cpp
  cfe/trunk/test/Modules/misplaced-5.c

Index: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
@@ -1013,6 +1013,7 @@
   "expected a module name after module import">;
 def err_module_expected_semi : Error<
   "expected ';' after module name">;
+def err_missing_before_module_end : Error<"expected %0 at end of module">;
 }
 
 let CategoryName = "Generics Issue" in {
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7776,6 +7776,8 @@
   "extern \"C\" language linkage specification begins here">;
 def err_module_import_not_at_top_level : Error<
   "import of module '%0' appears within %1">;
+def err_module_import_not_at_top_level_fatal : Error<
+  "import of module '%0' appears within %1">, DefaultFatal;
 def note_module_import_not_at_top_level : Note<"%0 begins here">;
 def err_module_self_import : Error<
   "import of module '%0' appears within same top-level module '%1'">;
Index: cfe/trunk/include/clang/Parse/Parser.h
===
--- cfe/trunk/include/clang/Parse/Parser.h
+++ cfe/trunk/include/clang/Parse/Parser.h
@@ -2555,6 +2555,14 @@
   //======//
   // Modules
   DeclGroupPtrTy ParseModuleImport(SourceLocation AtLoc);
+  bool parseMisplacedModuleImport();
+  bool tryParseMisplacedModuleImport() {
+tok::TokenKind Kind = Tok.getKind();
+if (Kind == tok::annot_module_begin || Kind == tok::annot_module_end ||
+Kind == tok::annot_module_include)
+  return parseMisplacedModuleImport();
+return false;
+  }
 
   //======//
   // C++11/G++: Type Traits [Type-Traits.html in the GCC manual]
Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -1799,6 +1799,10 @@
   /// \brief The parser has left a submodule.
   void ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod);
 
+  /// \brief Check if module import may be found in the current context,
+  /// emit error if not.
+  void diagnoseMisplacedModuleImport(Module *M, SourceLocation ImportLoc);
+
   /// \brief Create an implicit import of the given module at the given
   /// source location, for error recovery, if possible.
   ///
Index: cfe/trunk/test/Modules/Inputs/misplaced/misplaced-b.h
===
--- cfe/trunk/test/Modules/Inputs/misplaced/misplaced-b.h
+++ cfe/trunk/test/Modules/Inputs/misplaced/misplaced-b.h
@@ -0,0 +1 @@
+int a;
\ No newline at end of file
Index: cfe/trunk/test/Modules/Inputs/misplaced/misplaced-a.h
===
--- cfe/trunk/test/Modules/Inputs/misplaced/misplaced-a.h
+++ cfe/trunk/test/Modules/Inputs/misplaced/misplaced-a.h
@@ -0,0 +1,5 @@
+namespace A {
+  namespace B {  // expected-note{{namespace 'A::B' begins here}}
+#include "misplaced-b.h"  // expected-error{{import of module 'Misplaced.Sub_B' appears within namespace 'A::B'}}
+  }
+}
Index: cfe/trunk/test/Modules/Inputs/misplaced/misplaced.modulemap
===
--- cfe/trunk/test/Modules/Inputs/misplaced/misplaced.modulemap
+++ cfe/trunk/test/Modules/Inputs/misplaced/misplaced.modulemap
@@ -0,0 +1,8 @@
+module Misplaced {
+  module 

r248043 - [CMake] Refactoring and cleaning up clang symlink generation.

2015-09-18 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Sep 18 16:15:54 2015
New Revision: 248043

URL: http://llvm.org/viewvc/llvm-project?rev=248043=rev
Log:
[CMake] Refactoring and cleaning up clang symlink generation.

Generation of clang symlinks now uses add_clang_symlink macro which uses 
add_llvm_symlink. Also the list of symlinks to generate is configurable via 
CLANG_LINKS_TO_CREATE.

This re-lands r248015, with fixes for clang symlinks to always be generated as 
part of the clang and install-clang targets.

Removed:
cfe/trunk/tools/driver/clang_symlink.cmake
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=248043=248042=248043=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Sep 18 16:15:54 2015
@@ -414,6 +414,12 @@ macro(add_clang_executable name)
   set_clang_windows_version_resource_properties(${name})
 endmacro(add_clang_executable)
 
+macro(add_clang_symlink name dest)
+  add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
+  # Always generate install targets
+  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+endmacro()
+
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 include_directories(BEFORE

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=248043=248042=248043=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Fri Sep 18 16:15:54 2015
@@ -51,33 +51,6 @@ endif()
 
 add_dependencies(clang clang-headers)
 
-if(UNIX)
-  set(CLANGXX_LINK_OR_COPY create_symlink)
-# Create a relative symlink
-  set(clang_binary "clang${CMAKE_EXECUTABLE_SUFFIX}")
-else()
-  set(CLANGXX_LINK_OR_COPY copy)
-  set(clang_binary 
"${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${CMAKE_EXECUTABLE_SUFFIX}")
-endif()
-
-# Create the clang++ symlink in the build directory.
-set(clang_pp "${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++${CMAKE_EXECUTABLE_SUFFIX}")
-add_custom_command(TARGET clang POST_BUILD
-COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" 
"${clang_pp}"
-WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
-
-set_property(DIRECTORY APPEND
-  PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_pp})
-
-# Create the clang-cl symlink in the build directory.
-set(clang_cl 
"${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl${CMAKE_EXECUTABLE_SUFFIX}")
-add_custom_command(TARGET clang POST_BUILD
-COMMAND ${CMAKE_COMMAND} -E ${CLANGXX_LINK_OR_COPY} "${clang_binary}" 
"${clang_cl}"
-WORKING_DIRECTORY "${LLVM_RUNTIME_OUTPUT_INTDIR}")
-
-set_property(DIRECTORY APPEND
-  PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clang_cl})
-
 install(TARGETS clang
   RUNTIME DESTINATION bin
   COMPONENT clang)
@@ -87,8 +60,13 @@ add_custom_target(install-clang
   -DCMAKE_INSTALL_COMPONENT=clang
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
 
-# Create the clang++ and clang-cl symlinks at installation time.
-install(SCRIPT clang_symlink.cmake 
-DCMAKE_INSTALL_PREFIX=\"${CMAKE_INSTALL_PREFIX}\")
+if(NOT CLANG_LINKS_TO_CREATE)
+  set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
+endif()
+
+foreach(link ${CLANG_LINKS_TO_CREATE})
+  add_clang_symlink(${link} clang)
+endforeach()
 
 # Configure plist creation for OS X.
 set (TOOL_INFO_PLIST "Info.plist" CACHE STRING "Plist name")

Removed: cfe/trunk/tools/driver/clang_symlink.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/clang_symlink.cmake?rev=248042=auto
==
--- cfe/trunk/tools/driver/clang_symlink.cmake (original)
+++ cfe/trunk/tools/driver/clang_symlink.cmake (removed)
@@ -1,43 +0,0 @@
-# We need to execute this script at installation time because the
-# DESTDIR environment variable may be unset at configuration time.
-# See PR8397.
-
-if(UNIX)
-  set(CLANGXX_LINK_OR_COPY create_symlink)
-  set(CLANGXX_DESTDIR $ENV{DESTDIR})
-else()
-  set(CLANGXX_LINK_OR_COPY copy)
-endif()
-
-# CMAKE_EXECUTABLE_SUFFIX is undefined on cmake scripts. See PR9286.
-if( WIN32 )
-  set(EXECUTABLE_SUFFIX ".exe")
-else()
-  set(EXECUTABLE_SUFFIX "")
-endif()
-
-set(bindir "${CLANGXX_DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/")
-set(clang "clang${EXECUTABLE_SUFFIX}")
-set(clangxx "clang++${EXECUTABLE_SUFFIX}")
-set(clang_cl "clang-cl${EXECUTABLE_SUFFIX}")
-set(cl "cl${EXECUTABLE_SUFFIX}")
-
-message("Creating clang++ executable based on ${clang}")
-
-execute_process(
-  COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" "${clangxx}"
-  WORKING_DIRECTORY "${bindir}")
-
-message("Creating clang-cl executable based on ${clang}")
-
-execute_process(
-  COMMAND "${CMAKE_COMMAND}" -E ${CLANGXX_LINK_OR_COPY} "${clang}" 
"${clang_cl}"
-  WORKING_DIRECTORY "${bindir}")
-
-if 

r248053 - Simplify the interface of PCHContainerGenerator and friends

2015-09-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 18 17:10:59 2015
New Revision: 248053

URL: http://llvm.org/viewvc/llvm-project?rev=248053=rev
Log:
Simplify the interface of PCHContainerGenerator and friends
by passing in a CompilerInstance instead of all its individual members.

NFC.

Modified:
cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h
cfe/trunk/include/clang/Frontend/PCHContainerOperations.h
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/PCHContainerOperations.cpp

Modified: cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h?rev=248053=248052=248053=diff
==
--- cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h 
(original)
+++ cfe/trunk/include/clang/CodeGen/ObjectFilePCHContainerOperations.h Fri Sep 
18 17:10:59 2015
@@ -23,10 +23,9 @@ class ObjectFilePCHContainerWriter : pub
   /// PCHGenerator that produces a wrapper file format
   /// that also contains full debug info for the module.
   std::unique_ptr CreatePCHContainerGenerator(
-  DiagnosticsEngine , const HeaderSearchOptions ,
-  const PreprocessorOptions , const TargetOptions ,
-  const LangOptions , const std::string ,
-  const std::string , llvm::raw_pwrite_stream *OS,
+  DiagnosticsEngine , const CompilerInstance ,
+  const std::string , const std::string ,
+  llvm::raw_pwrite_stream *OS,
   std::shared_ptr Buffer) const override;
 };
 

Modified: cfe/trunk/include/clang/Frontend/PCHContainerOperations.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHContainerOperations.h?rev=248053=248052=248053=diff
==
--- cfe/trunk/include/clang/Frontend/PCHContainerOperations.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHContainerOperations.h Fri Sep 18 
17:10:59 2015
@@ -27,10 +27,7 @@ namespace clang {
 class ASTConsumer;
 class CodeGenOptions;
 class DiagnosticsEngine;
-class HeaderSearchOptions;
-class LangOptions;
-class PreprocessorOptions;
-class TargetOptions;
+class CompilerInstance;
 
 struct PCHBuffer {
   bool IsComplete;
@@ -49,11 +46,9 @@ public:
   /// PCHGenerator that produces a wrapper file format containing a
   /// serialized AST bitstream.
   virtual std::unique_ptr CreatePCHContainerGenerator(
-  DiagnosticsEngine , const HeaderSearchOptions ,
-  const PreprocessorOptions , const TargetOptions ,
-  const LangOptions , const std::string ,
-  const std::string , llvm::raw_pwrite_stream *OS,
-  std::shared_ptr Buffer) const = 0;
+  DiagnosticsEngine , const CompilerInstance ,
+  const std::string , const std::string ,
+  llvm::raw_pwrite_stream *OS, std::shared_ptr Buffer) const = 
0;
 };
 
 /// This abstract interface provides operations for unwrapping
@@ -78,10 +73,9 @@ class RawPCHContainerWriter : public PCH
   /// Return an ASTConsumer that can be chained with a
   /// PCHGenerator that writes the module to a flat file.
   std::unique_ptr CreatePCHContainerGenerator(
-  DiagnosticsEngine , const HeaderSearchOptions ,
-  const PreprocessorOptions , const TargetOptions ,
-  const LangOptions , const std::string ,
-  const std::string , llvm::raw_pwrite_stream *OS,
+  DiagnosticsEngine , const CompilerInstance ,
+  const std::string , const std::string ,
+  llvm::raw_pwrite_stream *OS,
   std::shared_ptr Buffer) const override;
 };
 

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=248053=248052=248053=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Fri Sep 18 
17:10:59 2015
@@ -18,6 +18,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/BackendUtil.h"
 #include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Serialization/ASTWriter.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Bitcode/BitstreamReader.h"
@@ -115,15 +116,15 @@ class PCHContainerGenerator : public AST
   };
 
 public:
-  PCHContainerGenerator(DiagnosticsEngine ,
-const HeaderSearchOptions ,
-const PreprocessorOptions , const TargetOptions 
,
-const LangOptions , const std::string ,
+  PCHContainerGenerator(DiagnosticsEngine , const CompilerInstance ,
+const std::string ,
 const std::string ,
 raw_pwrite_stream *OS,
 

r248046 - Reduce indentation in the TargetInfo implementations and fix up

2015-09-18 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Fri Sep 18 16:26:24 2015
New Revision: 248046

URL: http://llvm.org/viewvc/llvm-project?rev=248046=rev
Log:
Reduce indentation in the TargetInfo implementations and fix up
a couple of macro builtin redefines.

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

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=248046=248045=248046=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Sep 18 16:26:24 2015
@@ -1583,19 +1583,20 @@ public:
   }
 };
 
-  static const unsigned NVPTXAddrSpaceMap[] = {
-1,// opencl_global
-3,// opencl_local
-4,// opencl_constant
+static const unsigned NVPTXAddrSpaceMap[] = {
+1, // opencl_global
+3, // opencl_local
+4, // opencl_constant
 // FIXME: generic has to be added to the target
-0,// opencl_generic
-1,// cuda_device
-4,// cuda_constant
-3,// cuda_shared
-  };
-  class NVPTXTargetInfo : public TargetInfo {
-static const char * const GCCRegNames[];
-static const Builtin::Info BuiltinInfo[];
+0, // opencl_generic
+1, // cuda_device
+4, // cuda_constant
+3, // cuda_shared
+};
+
+class NVPTXTargetInfo : public TargetInfo {
+  static const char *const GCCRegNames[];
+  static const Builtin::Info BuiltinInfo[];
 
   // The GPU profiles supported by the NVPTX backend
   enum GPUKind {
@@ -1607,140 +1608,138 @@ public:
 GK_SM37,
   } GPU;
 
-  public:
-NVPTXTargetInfo(const llvm::Triple ) : TargetInfo(Triple) {
-  BigEndian = false;
-  TLSSupported = false;
-  LongWidth = LongAlign = 64;
-  AddrSpaceMap = 
-  UseAddrSpaceMapMangling = true;
-  // Define available target features
-  // These must be defined in sorted order!
-  NoAsmVariants = true;
-  // Set the default GPU to sm20
-  GPU = GK_SM20;
-}
-void getTargetDefines(const LangOptions ,
-  MacroBuilder ) const override {
-  Builder.defineMacro("__PTX__");
-  Builder.defineMacro("__NVPTX__");
-  if (Opts.CUDAIsDevice) {
-// Set __CUDA_ARCH__ for the GPU specified.
-std::string CUDAArchCode;
-switch (GPU) {
-case GK_SM20:
-  CUDAArchCode = "200";
-  break;
-case GK_SM21:
-  CUDAArchCode = "210";
-  break;
-case GK_SM30:
-  CUDAArchCode = "300";
-  break;
-case GK_SM35:
-  CUDAArchCode = "350";
-  break;
-case GK_SM37:
-  CUDAArchCode = "370";
-  break;
-default:
-  llvm_unreachable("Unhandled target CPU");
-}
-Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
-  }
-}
-void getTargetBuiltins(const Builtin::Info *,
-   unsigned ) const override {
-  Records = BuiltinInfo;
-  NumRecords = clang::NVPTX::LastTSBuiltin-Builtin::FirstTSBuiltin;
-}
-bool hasFeature(StringRef Feature) const override {
-  return Feature == "ptx" || Feature == "nvptx";
-}
-
-void getGCCRegNames(const char * const *,
-unsigned ) const override;
-void getGCCRegAliases(const GCCRegAlias *,
-  unsigned ) const override {
-  // No aliases.
-  Aliases = nullptr;
-  NumAliases = 0;
-}
-bool
-validateAsmConstraint(const char *,
-  TargetInfo::ConstraintInfo ) const override {
-  switch (*Name) {
-  default: return false;
-  case 'c':
-  case 'h':
-  case 'r':
-  case 'l':
-  case 'f':
-  case 'd':
-Info.setAllowsRegister();
-return true;
+public:
+  NVPTXTargetInfo(const llvm::Triple ) : TargetInfo(Triple) {
+BigEndian = false;
+TLSSupported = false;
+LongWidth = LongAlign = 64;
+AddrSpaceMap = 
+UseAddrSpaceMapMangling = true;
+// Define available target features
+// These must be defined in sorted order!
+NoAsmVariants = true;
+// Set the default GPU to sm20
+GPU = GK_SM20;
+  }
+  void getTargetDefines(const LangOptions ,
+MacroBuilder ) const override {
+Builder.defineMacro("__PTX__");
+Builder.defineMacro("__NVPTX__");
+if (Opts.CUDAIsDevice) {
+  // Set __CUDA_ARCH__ for the GPU specified.
+  std::string CUDAArchCode;
+  switch (GPU) {
+  case GK_SM20:
+CUDAArchCode = "200";
+break;
+  case GK_SM21:
+CUDAArchCode = "210";
+break;
+  case GK_SM30:
+CUDAArchCode = "300";
+break;
+  case GK_SM35:
+CUDAArchCode = "350";
+break;
+  case GK_SM37:
+CUDAArchCode = "370";
+break;
+  default:
+llvm_unreachable("Unhandled target CPU");
   }
+  Builder.defineMacro("__CUDA_ARCH__", 

Re: [PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-09-18 Thread Ismail Pazarbasi via cfe-commits
ismailp added a comment.

Thank you for reviewing!


Repository:
  rL LLVM

http://reviews.llvm.org/D12119



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


r248062 - CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.

2015-09-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 18 18:01:45 2015
New Revision: 248062

URL: http://llvm.org/viewvc/llvm-project?rev=248062=rev
Log:
CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.
We don't want a skeleton CU when generating debug info for the module
itself.

NFC.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248062=248061=248062=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 18:01:45 2015
@@ -1673,7 +1673,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
 }
 
 llvm::DIModule *
-CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) {
+CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
+  bool CreateSkeletonCU) {
   auto  = ModuleRefCache[Mod.ModuleName];
   if (ModRef)
 return cast(ModRef);
@@ -1700,15 +1701,20 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   OS << '\"';
 }
   }
-  llvm::DIBuilder DIB(CGM.getModule());
-  auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.ModuleName,
-   Mod.Path, TheCU->getProducer(), true,
-   StringRef(), 0, Mod.ASTFile,
-   llvm::DIBuilder::FullDebug, Mod.Signature);
-  llvm::DIModule *M =
-  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
-   CGM.getHeaderSearchOpts().Sysroot);
-  DIB.finalize();
+
+  llvm::DIModule *M = nullptr;
+  if (CreateSkeletonCU) {
+llvm::DIBuilder DIB(CGM.getModule());
+auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), 
Mod.ModuleName,
+ Mod.Path, TheCU->getProducer(), true,
+ StringRef(), 0, Mod.ASTFile,
+ llvm::DIBuilder::FullDebug, 
Mod.Signature);
+M = DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
+ CGM.getHeaderSearchOpts().Sysroot);
+DIB.finalize();
+  } else
+M = DBuilder.createModule(TheCU, Mod.ModuleName, ConfigMacros, Mod.Path,
+  CGM.getHeaderSearchOpts().Sysroot);
   ModRef.reset(M);
   return M;
 }
@@ -2158,12 +2164,13 @@ llvm::DIModule *CGDebugInfo::getParentMo
   if (!DebugTypeExtRefs || !D->isFromASTFile())
 return nullptr;
 
+  // Record a reference to an imported clang module or precompiled header.
   llvm::DIModule *ModuleRef = nullptr;
   auto *Reader = CGM.getContext().getExternalSource();
   auto Idx = D->getOwningModuleID();
   auto Info = Reader->getSourceDescriptor(Idx);
   if (Info)
-ModuleRef = getOrCreateModuleRef(*Info);
+ModuleRef = getOrCreateModuleRef(*Info, true);
   return ModuleRef;
 }
 
@@ -3387,9 +3394,9 @@ void CGDebugInfo::EmitImportDecl(const I
   auto *Reader = CGM.getContext().getExternalSource();
   auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
   DBuilder.createImportedDeclaration(
-getCurrentContextDescriptor(cast(ID.getDeclContext())),
-getOrCreateModuleRef(Info),
-getLineNumber(ID.getLocation()));
+  getCurrentContextDescriptor(cast(ID.getDeclContext())),
+  getOrCreateModuleRef(Info, DebugTypeExtRefs),
+  getLineNumber(ID.getLocation()));
 }
 
 llvm::DIImportedEntity *

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=248062=248061=248062=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri Sep 18 18:01:45 2015
@@ -403,9 +403,11 @@ private:
   /// Get the type from the cache or create a new type if necessary.
   llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg);
 
-  /// Get a reference to a clang module.
+  /// Get a reference to a clang module.  If \p CreateSkeletonCU is true,
+  /// this also creates a split dwarf skeleton compile unit.
   llvm::DIModule *
-  getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod);
+  getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
+   bool CreateSkeletonCU);
 
   /// DebugTypeExtRefs: If \p D originated in a clang module, return it.
   llvm::DIModule *getParentModuleOrNull(const Decl *D);


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


r248037 - Debug Info: Use the full module name as a key when caching DIModules.

2015-09-18 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Sep 18 16:06:14 2015
New Revision: 248037

URL: http://llvm.org/viewvc/llvm-project?rev=248037=rev
Log:
Debug Info: Use the full module name as a key when caching DIModules.
The signature may not have been computed at the time the module reference
is generated (e.g.: in the future while emitting debug info for a clang
module). Using the full module name is safe because each clang module may
only have a single definition.

NFC.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248037=248036=248037=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 16:06:14 2015
@@ -1674,7 +1674,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
 
 llvm::DIModule *
 CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) {
-  auto  = ModuleRefCache[Mod.Signature];
+  auto  = ModuleRefCache[Mod.ModuleName];
   if (ModRef)
 return cast(ModRef);
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=248037=248036=248037=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri Sep 18 16:06:14 2015
@@ -93,8 +93,8 @@ class CGDebugInfo {
   /// Cache of previously constructed interfaces which may change.
   llvm::SmallVector ObjCInterfaceCache;
 
-  /// Cache of references to AST files such as PCHs or modules.
-  llvm::DenseMap ModuleRefCache;
+  /// Cache of references to clang modules and precompiled headers.
+  llvm::StringMap ModuleRefCache;
 
   /// List of interfaces we want to keep even if orphaned.
   std::vector RetainedTypes;


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


r248050 - Analyzer: Fix a crasher in UbigraphViz

2015-09-18 Thread Ismail Pazarbasi via cfe-commits
Author: ismailp
Date: Fri Sep 18 16:54:47 2015
New Revision: 248050

URL: http://llvm.org/viewvc/llvm-project?rev=248050=rev
Log:
Analyzer: Fix a crasher in UbigraphViz

Summary:
Name `Out` refers to the parameter. It is moved into the member `Out`
in ctor-init. Dereferencing null pointer will crash clang, if user
passes '-analyzer-viz-egraph-ubigraph' argument.

Reviewers: zaks.anna, krememek

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Analysis/ubigraph-viz.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=248050=248049=248050=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Fri Sep 18 
16:54:47 2015
@@ -778,8 +778,9 @@ void UbigraphViz::AddEdge(ExplodedNode *
<< ", ('arrow','true'), ('oriented', 'true'))\n";
 }
 
-UbigraphViz::UbigraphViz(std::unique_ptr Out, StringRef Filename)
-: Out(std::move(Out)), Filename(Filename), Cntr(0) {
+UbigraphViz::UbigraphViz(std::unique_ptr OutStream,
+ StringRef Filename)
+: Out(std::move(OutStream)), Filename(Filename), Cntr(0) {
 
   *Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
   *Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"

Added: cfe/trunk/test/Analysis/ubigraph-viz.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ubigraph-viz.cpp?rev=248050=auto
==
--- cfe/trunk/test/Analysis/ubigraph-viz.cpp (added)
+++ cfe/trunk/test/Analysis/ubigraph-viz.cpp Fri Sep 18 16:54:47 2015
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API 
-analyzer-viz-egraph-ubigraph -verify %s
+// expected-no-diagnostics
+
+int f(int x) {
+  return x < 0 ? 0 : 42;
+}
+


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


Re: [PATCH] D12119: Analyzer: Fix a crasher in UbigraphViz

2015-09-18 Thread Ismail Pazarbasi via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248050: Analyzer: Fix a crasher in UbigraphViz (authored by 
ismailp).

Changed prior to commit:
  http://reviews.llvm.org/D12119?vs=35141=35142#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12119

Files:
  cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  cfe/trunk/test/Analysis/ubigraph-viz.cpp

Index: cfe/trunk/test/Analysis/ubigraph-viz.cpp
===
--- cfe/trunk/test/Analysis/ubigraph-viz.cpp
+++ cfe/trunk/test/Analysis/ubigraph-viz.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API 
-analyzer-viz-egraph-ubigraph -verify %s
+// expected-no-diagnostics
+
+int f(int x) {
+  return x < 0 ? 0 : 42;
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -778,8 +778,9 @@
<< ", ('arrow','true'), ('oriented', 'true'))\n";
 }
 
-UbigraphViz::UbigraphViz(std::unique_ptr Out, StringRef Filename)
-: Out(std::move(Out)), Filename(Filename), Cntr(0) {
+UbigraphViz::UbigraphViz(std::unique_ptr OutStream,
+ StringRef Filename)
+: Out(std::move(OutStream)), Filename(Filename), Cntr(0) {
 
   *Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
   *Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"


Index: cfe/trunk/test/Analysis/ubigraph-viz.cpp
===
--- cfe/trunk/test/Analysis/ubigraph-viz.cpp
+++ cfe/trunk/test/Analysis/ubigraph-viz.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API -analyzer-viz-egraph-ubigraph -verify %s
+// expected-no-diagnostics
+
+int f(int x) {
+  return x < 0 ? 0 : 42;
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -778,8 +778,9 @@
<< ", ('arrow','true'), ('oriented', 'true'))\n";
 }
 
-UbigraphViz::UbigraphViz(std::unique_ptr Out, StringRef Filename)
-: Out(std::move(Out)), Filename(Filename), Cntr(0) {
+UbigraphViz::UbigraphViz(std::unique_ptr OutStream,
+ StringRef Filename)
+: Out(std::move(OutStream)), Filename(Filename), Cntr(0) {
 
   *Out << "('vertex_style_attribute', 0, ('shape', 'icosahedron'))\n";
   *Out << "('vertex_style', 1, 0, ('shape', 'sphere'), ('color', '#ffcc66'),"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r248051 - Relax the test to get it passing with windows paths.

2015-09-18 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Fri Sep 18 17:01:10 2015
New Revision: 248051

URL: http://llvm.org/viewvc/llvm-project?rev=248051=rev
Log:
Relax the test to get it passing with windows paths.

Modified:
cfe/trunk/test/Driver/amdgpu-toolchain.c

Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=248051=248050=248051=diff
==
--- cfe/trunk/test/Driver/amdgpu-toolchain.c (original)
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c Fri Sep 18 17:01:10 2015
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
-// AS_LINK: bin/clang{{.*}} "-cc1as"
+// AS_LINK: clang{{.*}} "-cc1as"
 // AS_LINK: lld{{.*}} "-flavor" "gnu" "-target" "amdgcn--amdhsa"


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


r248064 - Split off the binary literal warning into a subgroup of C++14 warnings

2015-09-18 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Sep 18 18:18:39 2015
New Revision: 248064

URL: http://llvm.org/viewvc/llvm-project?rev=248064=rev
Log:
Split off the binary literal warning into a subgroup of C++14 warnings

Binary literals predate C++14, but they are listed as a C++14 extension since
this was the first time they were standardized in the language.  Move the
warning into a subgroup so it can be selectively disabled when checking for
other C++14 features.

Added:
cfe/trunk/test/Lexer/warn_binary_literals.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=248064=248063=248064=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Sep 18 18:18:39 2015
@@ -29,6 +29,7 @@ def ArrayBoundsPointerArithmetic : DiagG
 def Availability : DiagGroup<"availability">;
 def Section : DiagGroup<"section">;
 def AutoImport : DiagGroup<"auto-import">;
+def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;
 def GNUCompoundLiteralInitializer : 
DiagGroup<"gnu-compound-literal-initializer">;
 def BitFieldConstantConversion : DiagGroup<"bitfield-constant-conversion">;
@@ -680,7 +681,7 @@ def CXX11 : DiagGroup<"c++11-extensions"
 
 // A warning group for warnings about using C++14 features as extensions in
 // earlier C++ versions.
-def CXX14 : DiagGroup<"c++14-extensions">;
+def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral]>;
 
 // A warning group for warnings about using C++1z features as extensions in
 // earlier C++ versions.

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=248064=248063=248064=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Fri Sep 18 18:18:39 2015
@@ -184,7 +184,7 @@ def ext_hexconstant_invalid : Extension<
 def ext_binary_literal : Extension<
   "binary integer literals are a GNU extension">, InGroup;
 def ext_binary_literal_cxx14 : Extension<
-  "binary integer literals are a C++14 extension">, InGroup;
+  "binary integer literals are a C++14 extension">, 
InGroup;
 def warn_cxx11_compat_binary_literal : Warning<
   "binary integer literals are incompatible with C++ standards before C++14">,
   InGroup, DefaultIgnore;

Added: cfe/trunk/test/Lexer/warn_binary_literals.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/warn_binary_literals.cpp?rev=248064=auto
==
--- cfe/trunk/test/Lexer/warn_binary_literals.cpp (added)
+++ cfe/trunk/test/Lexer/warn_binary_literals.cpp Fri Sep 18 18:18:39 2015
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wc++14-binary-literal
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wc++14-extensions
+
+int x = 0b11;
+// expected-warning@-1{{binary integer literals are a C++14 extension}}


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


r248035 - Handle lld not being found in PATH.

2015-09-18 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Fri Sep 18 15:55:58 2015
New Revision: 248035

URL: http://llvm.org/viewvc/llvm-project?rev=248035=rev
Log:
Handle lld not being found in PATH.

Modified:
cfe/trunk/test/Driver/amdgpu-toolchain.c

Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=248035=248034=248035=diff
==
--- cfe/trunk/test/Driver/amdgpu-toolchain.c (original)
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c Fri Sep 18 15:55:58 2015
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: bin/clang{{.*}} "-cc1as"
-// AS_LINK: bin/lld{{.*}} "-flavor" "gnu" "-target" "amdgcn--amdhsa"
+// AS_LINK: lld{{.*}} "-flavor" "gnu" "-target" "amdgcn--amdhsa"


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


Re: [PATCH] D12955: Fix assertion in inline assembler IR gen

2015-09-18 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Generally LGTM, with one question about guarding against overflow.



Comment at: lib/Sema/SemaStmtAsm.cpp:447
@@ +446,3 @@
+// Make sure no more than one input constraint matches each output.
+if (InputMatchedToOutput[TiedTo] != ~0U) {
+  Diag(NS->getInputExpr(i)->getLocStart(),

Is it possible for InputConstraintsInfos.size() to be greater than 
OutputConstrainInfos.size()? Basically, I'm worried about buffer overflow here 
with TiedTo.


http://reviews.llvm.org/D12955



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


Re: [PATCH] D12981: [clang-cl]: Don't warn on /bigobj flag

2015-09-18 Thread Nico Weber via cfe-commits
thakis closed this revision.
thakis added a comment.

r248034, thanks! (with test)


http://reviews.llvm.org/D12981



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


r248041 - [Static Analyzer] General type checker based on dynamic type information.

2015-09-18 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Sep 18 16:15:37 2015
New Revision: 248041

URL: http://llvm.org/viewvc/llvm-project?rev=248041=rev
Log:
[Static Analyzer] General type checker based on dynamic type information.

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


Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
cfe/trunk/test/Analysis/dynamic_type_check.m
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/test/Analysis/generics.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=248041=248040=248041=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Fri Sep 18 16:15:37 
2015
@@ -33,6 +33,7 @@ add_clang_library(clangStaticAnalyzerChe
   DirectIvarAssignment.cpp
   DivZeroChecker.cpp
   DynamicTypePropagation.cpp
+  DynamicTypeChecker.cpp
   ExprInspectionChecker.cpp
   FixedAddressChecker.cpp
   GenericTaintChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=248041=248040=248041=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Fri Sep 18 16:15:37 2015
@@ -129,6 +129,10 @@ def TestAfterDivZeroChecker : Checker<"T
   HelpText<"Check for division by variable that is later compared against 0. 
Either the comparison is useless or there is division by zero.">,
   DescFile<"TestAfterDivZeroChecker.cpp">;
 
+def DynamicTypeChecker : Checker<"DynamicTypeChecker">,
+  HelpText<"Check for cases where the dynamic and the static type of an object 
are unrelated.">,
+  DescFile<"DynamicTypeChecker.cpp">;
+
 } // end "alpha.core"
 
 let ParentPackage = Nullability in {

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp?rev=248041=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp (added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp Fri Sep 18 
16:15:37 2015
@@ -0,0 +1,202 @@
+//== DynamicTypeChecker.cpp  -*- C++ 
-*--=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker looks for cases where the dynamic type of an object is 
unrelated
+// to its static type. The type information utilized by this check is collected
+// by the DynamicTypePropagation checker. This check does not report any type
+// error for ObjC Generic types, in order to avoid duplicate erros from the
+// ObjC Generics checker. This checker is not supposed to modify the program
+// state, it is just the observer of the type information provided by other
+// checkers.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class DynamicTypeChecker : public Checker {
+  mutable std::unique_ptr BT;
+  void initBugType() const {
+if (!BT)
+  BT.reset(
+  new BugType(this, "Dynamic and static type mismatch", "Type Error"));
+  }
+
+  class DynamicTypeBugVisitor
+  : public BugReporterVisitorImpl {
+  public:
+DynamicTypeBugVisitor(const MemRegion *Reg) : Reg(Reg) {}
+
+void Profile(llvm::FoldingSetNodeID ) const override {
+  static int X = 0;
+  ID.AddPointer();
+  ID.AddPointer(Reg);
+}
+
+PathDiagnosticPiece *VisitNode(const ExplodedNode *N,
+   const ExplodedNode *PrevN,
+   BugReporterContext ,
+   BugReport ) override;
+
+  private:
+// The tracked region.
+const MemRegion *Reg;
+  };
+
+  void reportTypeError(QualType 

Re: [PATCH] D12989: [CUDA] Added CUDA installation detector class.

2015-09-18 Thread Artem Belevich via cfe-commits
tra added a comment.

Any suggestions how to test this?


http://reviews.llvm.org/D12989



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


[PATCH] D12989: [CUDA] Added CUDA installation detector class.

2015-09-18 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added a reviewer: echristo.
tra added a subscriber: cfe-commits.

The class searches for a CUDA installation directory and provides accessors for 
relevant bits of info about it.

Added new option --cuda-path= which allows overriding default search 
paths. If it's not specified we look for CUDA installation in
/usr/include/cuda and /usr/include/cuda-7.0

Once CUDA installation is found we look for libdevice bitcode files and 
associate them with appropriate GPU type.



http://reviews.llvm.org/D12989

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h

Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -157,6 +157,42 @@
 protected:
   GCCInstallationDetector GCCInstallation;
 
+  // \brief A class to find a viable CUDA installation
+
+  class CudaInstallationDetector {
+bool IsValid;
+std::string CudaInstallPath;
+std::string CudaLibPath;
+std::string CudaLibDevicePath;
+std::string CudaIncludePath;
+llvm::StringMap CudaLibDeviceMap;
+
+  public:
+CudaInstallationDetector() : IsValid(false) {}
+void init(const Driver , const llvm::Triple ,
+  const llvm::opt::ArgList );
+
+/// \brief Check whether we detected a valid Cuda install.
+bool isValid() const { return IsValid; }
+/// \brief Print information about the detected CUDA installation.
+void print(raw_ostream ) const;
+
+/// \brief Get the detected Cuda installation path.
+StringRef getInstallPath() const { return CudaInstallPath; }
+/// \brief Get the detected Cuda Include path.
+StringRef getIncludePath() const { return CudaIncludePath; }
+/// \brief Get the detected Cuda library path.
+StringRef getLibPath() const { return CudaLibPath; }
+/// \brief Get the detected Cuda device library path.
+StringRef getLibDevicePath() const { return CudaLibDevicePath; }
+/// \brief Get libdevice file for given architecture
+StringRef getLibDeviceFile(StringRef Gpu) const {
+  return CudaLibDeviceMap.lookup(Gpu);
+}
+  };
+
+  CudaInstallationDetector CudaInstallation;
+
 public:
   Generic_GCC(const Driver , const llvm::Triple ,
   const llvm::opt::ArgList );
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1482,6 +1482,74 @@
 BiarchTripleAliases.push_back(BiarchTriple.str());
 }
 
+// \brief -- try common CUDA installation paths looking for files we need for
+// CUDA compilation.
+
+void
+Generic_GCC::CudaInstallationDetector::init(const Driver ,
+const llvm::Triple ,
+const llvm::opt::ArgList ) {
+  SmallVector CudaPathCandidates;
+
+  if (Args.hasArg(options::OPT_cuda_path_EQ))
+CudaPathCandidates.push_back(
+Args.getLastArgValue(options::OPT_cuda_path_EQ));
+  else {
+std::string Prefix = D.SysRoot.empty() ? "" : D.SysRoot;
+CudaPathCandidates.push_back(Prefix + "/usr/local/cuda");
+CudaPathCandidates.push_back(Prefix + "/usr/local/cuda-7.0");
+  }
+
+  for (const auto CudaPath : CudaPathCandidates) {
+if (CudaPath.empty() || !llvm::sys::fs::exists(CudaPath))
+  continue;
+
+CudaInstallPath = CudaPath;
+CudaIncludePath = CudaInstallPath + "/include";
+CudaLibDevicePath = CudaInstallPath + "/nvvm/libdevice";
+CudaLibPath =
+CudaInstallPath + (TargetTriple.isArch64Bit() ? "/lib64" : "/lib");
+
+if (!(llvm::sys::fs::exists(CudaIncludePath) &&
+  llvm::sys::fs::exists(CudaLibPath) &&
+  llvm::sys::fs::exists(CudaLibDevicePath)))
+  continue;
+
+const StringRef LibDeviceName = "libdevice.";
+std::error_code EC;
+for (llvm::sys::fs::directory_iterator LI(CudaLibDevicePath, EC), LE;
+ !EC && LI != LE; LI = LI.increment(EC)) {
+  StringRef FilePath = LI->path();
+  StringRef FileName = llvm::sys::path::filename(FilePath);
+  // Process all bitcode filenames that look like libdevice.compute_XX.YY.bc
+  if (!(FileName.startswith(LibDeviceName) && FileName.endswith(".bc")))
+continue;
+  StringRef GpuArch = FileName.slice(
+  LibDeviceName.size(), FileName.find('.', LibDeviceName.size()));
+  CudaLibDeviceMap[GpuArch] = FilePath.str();
+  // Insert map entries for specifc devices with this compute capability.
+  if (GpuArch == "compute_20") {
+CudaLibDeviceMap["sm_20"] = FilePath;
+CudaLibDeviceMap["sm_21"] = FilePath;
+  } else if (GpuArch == "compute_30") {
+CudaLibDeviceMap["sm_30"] = FilePath;
+CudaLibDeviceMap["sm_32"] = FilePath;
+  } else if (GpuArch == "compute_35") {
+CudaLibDeviceMap["sm_35"] = FilePath;
+CudaLibDeviceMap["sm_37"] = FilePath;
+   

Re: r248062 - CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.

2015-09-18 Thread Adrian Prantl via cfe-commits

> On Sep 18, 2015, at 4:01 PM, Adrian Prantl via cfe-commits 
>  wrote:
> 
> Author: adrian
> Date: Fri Sep 18 18:01:45 2015
> New Revision: 248062
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=248062=rev
> Log:
> CGDebugInfo: Make creating a skeleton CU in getOrCreateModuleRef optional.
> We don't want a skeleton CU when generating debug info for the module
> itself.
> 
> NFC.
> 
> Modified:
>cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>cfe/trunk/lib/CodeGen/CGDebugInfo.h
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248062=248061=248062=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Sep 18 18:01:45 2015
> @@ -1673,7 +1673,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
> }
> 
> llvm::DIModule *
> -CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor 
> Mod) {
> +CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
> +  bool CreateSkeletonCU) {
>   auto  = ModuleRefCache[Mod.ModuleName];
>   if (ModRef)
> return cast(ModRef);
> @@ -1700,15 +1701,20 @@ CGDebugInfo::getOrCreateModuleRef(Extern
>   OS << '\"';
> }
>   }
> -  llvm::DIBuilder DIB(CGM.getModule());
> -  auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), 
> Mod.ModuleName,
> -   Mod.Path, TheCU->getProducer(), true,
> -   StringRef(), 0, Mod.ASTFile,
> -   llvm::DIBuilder::FullDebug, 
> Mod.Signature);
> -  llvm::DIModule *M =
> -  DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
> -   CGM.getHeaderSearchOpts().Sysroot);
> -  DIB.finalize();
> +
> +  llvm::DIModule *M = nullptr;
> +  if (CreateSkeletonCU) {
> +llvm::DIBuilder DIB(CGM.getModule());
> +auto *CU = DIB.createCompileUnit(TheCU->getSourceLanguage(), 
> Mod.ModuleName,
> + Mod.Path, TheCU->getProducer(), true,
> + StringRef(), 0, Mod.ASTFile,
> + llvm::DIBuilder::FullDebug, 
> Mod.Signature);
> +M = DIB.createModule(CU, Mod.ModuleName, ConfigMacros, Mod.Path,
> + CGM.getHeaderSearchOpts().Sysroot);
> +DIB.finalize();
> +  } else
> +M = DBuilder.createModule(TheCU, Mod.ModuleName, ConfigMacros, Mod.Path,
> +  CGM.getHeaderSearchOpts().Sysroot);
>   ModRef.reset(M);
>   return M;
> }
> @@ -2158,12 +2164,13 @@ llvm::DIModule *CGDebugInfo::getParentMo
>   if (!DebugTypeExtRefs || !D->isFromASTFile())
> return nullptr;
> 
> +  // Record a reference to an imported clang module or precompiled header.
>   llvm::DIModule *ModuleRef = nullptr;
>   auto *Reader = CGM.getContext().getExternalSource();
>   auto Idx = D->getOwningModuleID();
>   auto Info = Reader->getSourceDescriptor(Idx);
>   if (Info)
> -ModuleRef = getOrCreateModuleRef(*Info);
> +ModuleRef = getOrCreateModuleRef(*Info, true);
>   return ModuleRef;
> }
> 
> @@ -3387,9 +3394,9 @@ void CGDebugInfo::EmitImportDecl(const I
>   auto *Reader = CGM.getContext().getExternalSource();
>   auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
>   DBuilder.createImportedDeclaration(
> -getCurrentContextDescriptor(cast(ID.getDeclContext())),
> -getOrCreateModuleRef(Info),
> -getLineNumber(ID.getLocation()));
> +  getCurrentContextDescriptor(cast(ID.getDeclContext())),
> +  getOrCreateModuleRef(Info, DebugTypeExtRefs),

I just realized that this line is not actually as NFC as advertised. Clang will 
no longer emit skeleton CUs (only DW_TAG_modules) for imported modules unless 
compiling with -gmodules.

-- adrian

> +  getLineNumber(ID.getLocation()));
> }
> 
> llvm::DIImportedEntity *
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=248062=248061=248062=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Fri Sep 18 18:01:45 2015
> @@ -403,9 +403,11 @@ private:
>   /// Get the type from the cache or create a new type if necessary.
>   llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg);
> 
> -  /// Get a reference to a clang module.
> +  /// Get a reference to a clang module.  If \p CreateSkeletonCU is true,
> +  /// this also creates a split dwarf skeleton compile unit.
>   llvm::DIModule *
> -  getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod);
> +  getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
> +   

Re: [PATCH] D12666: [LibClang] Fix clang_getCursorAvailability

2015-09-18 Thread Milian Wolff via cfe-commits
milianw added a subscriber: milianw.
milianw added a comment.

Ping? Can someone please submit this upstream?


http://reviews.llvm.org/D12666



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


Re: [PATCH] D10841: [Shave]: allow Clang to run the target linker.

2015-09-18 Thread Douglas Katzman via cfe-commits
dougk abandoned this revision.


Comment at: lib/Driver/Tools.cpp:9110
@@ +9109,3 @@
+
+  const char *ToolsRoot = ::getenv("MV_TOOLS_DIR");
+  // The version is numbered 'n.n.n.n' for arbitrary values that are opaque

jyknight wrote:
> Perhaps this should be a default plus a command-line argument, instead of an 
> environment variable?
How about if '--sysdir' provides the value, falling back to the environment 
var, and then a fixed default?
There is ample precedent for use of getenv() in some of the other toolchains.


Comment at: lib/Driver/Tools.cpp:9144
@@ +9143,3 @@
+ToolsRoot = "/usr/local/myriad/tools";
+ToolsVersion = "00.50.62.5";
+ToolsCommonDir = "/usr/local/mdk/tools/" + ToolsVersion + "/common";

jyknight wrote:
> Doesn't seem right to hardcode this particular version. Using a default for 
> ToolsRoot if MV_TOOLS_DIR isn't set sounds okay, but presumably should be 
> done up above before the loop.
> 
I could see a couple ways around hardcoding a version - if neither --sysroot 
nor MV_TOOLS_DIR is used, then the path is arbitrary anyway, so doesn't need a 
versioned subdir. And arguably is sysroot is given, then it could be an 
already-versioned pathname. Otoh, detecting the version works fine in that case.

For reference, the example sub-Makefile has hardcoded:
MV_TOOLS_VERSION ?= 00.50.62.5
MV_TOOLS_DIR ?= $(HOME)/WORK/Tools/Releases/General


Comment at: lib/Driver/Tools.cpp:9160
@@ +9159,3 @@
+  CmdArgs.push_back("-EL"); // Endianness = little
+  CmdArgs.push_back("-O9"); // Optimization
+  CmdArgs.push_back("--gc-sections");

jyknight wrote:
> "-O9"? That seems weird, and is not actually a thing.
This was cargo-cultism.   I've no objection to taking it out, but who's to say 
that their linker doesn't use it for something, as why else would they bother 
to put it in the examples?


http://reviews.llvm.org/D10841



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


Re: [PATCH] D12903: Add -fplugin=name.so option to the driver

2015-09-18 Thread John Brawn via cfe-commits
john.brawn added a comment.

In http://reviews.llvm.org/D12903#248453, @compnerd wrote:

> Do you know if GCC requires the = or can you do -fplugin name.so ?


GCC requires the =, or at least GCC 5.1.0 does when I tested it (you get "gcc: 
error: name.so: No such file or directory" and "gcc: error: unrecognized 
command line option '-fplugin'" if you do -fplugin name.so).


Repository:
  rL LLVM

http://reviews.llvm.org/D12903



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


r247981 - Pass the relocation model to LLVM for assembler files.

2015-09-18 Thread Joerg Sonnenberger via cfe-commits
Author: joerg
Date: Fri Sep 18 06:13:43 2015
New Revision: 247981

URL: http://llvm.org/viewvc/llvm-project?rev=247981=rev
Log:
Pass the relocation model to LLVM for assembler files.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=247981=247980=247981=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Sep 18 06:13:43 2015
@@ -463,6 +463,7 @@ TargetMachine *EmitAssemblyHelper::Creat
 FeaturesStr = Features.getString();
   }
 
+  // Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp.
   llvm::Reloc::Model RM = llvm::Reloc::Default;
   if (CodeGenOpts.RelocationModel == "static") {
 RM = llvm::Reloc::Static;

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=247981=247980=247981=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Fri Sep 18 06:13:43 2015
@@ -126,6 +126,9 @@ struct AssemblerInvocation {
   unsigned NoExecStack : 1;
   unsigned FatalWarnings : 1;
 
+  /// The name of the relocation model to use.
+  std::string RelocationModel;
+
   /// @}
 
 public:
@@ -248,6 +251,7 @@ bool AssemblerInvocation::CreateFromArgs
   Opts.RelaxAll = Args.hasArg(OPT_mrelax_all);
   Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
   Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
+  Opts.RelocationModel = Args.getLastArgValue(OPT_mrelocation_model, "pic");
 
   return Success;
 }
@@ -321,8 +325,19 @@ static bool ExecuteAssembler(AssemblerIn
   std::unique_ptr MOFI(new MCObjectFileInfo());
 
   MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), );
-  // FIXME: Assembler behavior can change with -static.
-  MOFI->InitMCObjectFileInfo(Triple(Opts.Triple), Reloc::Default,
+
+  llvm::Reloc::Model RM = llvm::Reloc::Default;
+  if (Opts.RelocationModel == "static") {
+RM = llvm::Reloc::Static;
+  } else if (Opts.RelocationModel == "pic") {
+RM = llvm::Reloc::PIC_;
+  } else {
+assert(Opts.RelocationModel == "dynamic-no-pic" &&
+   "Invalid PIC model!");
+RM = llvm::Reloc::DynamicNoPIC;
+  }
+
+  MOFI->InitMCObjectFileInfo(Triple(Opts.Triple), RM,
  CodeModel::Default, Ctx);
   if (Opts.SaveTemporaryLabels)
 Ctx.setAllowTemporaryLabels(false);


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


Re: [PATCH] D12726: [analyzer] A fix for symbolic element region index lifetime.

2015-09-18 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 35067.
NoQ added a comment.

Thanks for the quick reply, sorry for the delay! Was afk for a couple of days.

Yeah, right, in fact i didn't even fix the issue for store keys at all; only 
for store values and environment values.

It also seems much harder to test store keys, because it's quite a problem to 
guess the symbolic key once the symbol is not present anywhere else, though i 
can imagine an artificial checker that would rely on that. A test like...

  int a[1];
  {
int x = conjure_index();
a[x] = 0;
if (x != 0)
  return;
clang_analyzer_eval(a[0] == 0); // expected-warning{{TRUE}}
  }
  clang_analyzer_eval(a[0] == 0); // expected-warning{{TRUE}}

...should have exposed such problem, but this kind of lookup doesn't seem to be 
supported by the store yet (that is, the first `expected-warning{{TRUE}}` fails 
as well).

Hmm, what if i expand the `debug.ExprInspection` checker to allow testing 
`SymbolReaper` directly? Updated the diff with a proof of concept, which fixes 
the issue for the store keys and adds a test. I can split the `ExprInspection` 
change into a separate commit/review if necessary. It might be useful for 
testing other `SymbolReaper`-related patches as well.


http://reviews.llvm.org/D12726

Files:
  lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  lib/StaticAnalyzer/Core/Environment.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/return-ptr-range.cpp
  test/Analysis/symbol-reaper.c

Index: test/Analysis/symbol-reaper.c
===
--- test/Analysis/symbol-reaper.c
+++ test/Analysis/symbol-reaper.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.ExprInspection -verify %s
+
+void clang_analyzer_warnOnDeadSymbol(int);
+
+int arr[3];
+
+int conjure_index();
+
+void test_that_expr_inspection_works() {
+  do {
+int x = conjure_index();
+clang_analyzer_warnOnDeadSymbol(x);
+  } while(0); // expected-warning{{SYMBOL DEAD}}
+}
+
+void test_element_index_lifetime() {
+  do {
+int x = conjure_index();
+clang_analyzer_warnOnDeadSymbol(x);
+arr[x] = 1;
+if (x) {}
+  } while(0); // no-warning
+}
Index: test/Analysis/return-ptr-range.cpp
===
--- test/Analysis/return-ptr-range.cpp
+++ test/Analysis/return-ptr-range.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.security.ReturnPtrRange -verify %s
+
+int arr[10];
+int *ptr;
+
+int conjure_index();
+
+int *test_element_index_lifetime() {
+  do {
+int x = conjure_index();
+ptr = arr + x;
+if (x != 20)
+  return arr; // no-warning
+  } while (0);
+  return ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
+}
+
+int *test_element_index_lifetime_with_local_ptr() {
+  int *local_ptr;
+  do {
+int x = conjure_index();
+local_ptr = arr + x;
+if (x != 20)
+  return arr; // no-warning
+  } while (0);
+  return local_ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2237,8 +2237,20 @@
   if (const SymbolicRegion *SymR = dyn_cast(baseR))
 SymReaper.markLive(SymR->getSymbol());
 
-  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I)
+  for (ClusterBindings::iterator I = C->begin(), E = C->end(); I != E; ++I) {
+
+// Mark the index symbol of any ElementRegion key as live.
+const BindingKey  = I.getKey();
+auto subR = dyn_cast(K.getRegion());
+while (subR) {
+  if (auto elemR = dyn_cast(subR))
+if (SymbolRef Sym = elemR->getIndex().getAsSymbol())
+  SymReaper.markLive(Sym);
+  subR = dyn_cast(subR->getSuperRegion());
+}
+
 VisitBinding(I.getData());
+  }
 }
 
 void removeDeadBindingsWorker::VisitBinding(SVal V) {
@@ -2260,6 +2272,16 @@
   if (const MemRegion *R = V.getAsRegion()) {
 AddToWorkList(R);
 
+// Element index of an element region is live.
+if (const ElementRegion *ER = dyn_cast(R)) {
+  SVal Idx = ER->getIndex();
+  for (SymExpr::symbol_iterator SI = Idx.symbol_begin(),
+SE = Idx.symbol_end();
+   SI != SE; ++SI) {
+SymReaper.markLive(*SI);
+  }
+}
+
 // All regions captured by a block are also live.
 if (const BlockDataRegion *BR = dyn_cast(R)) {
   BlockDataRegion::referenced_vars_iterator I = BR->referenced_vars_begin(),
Index: lib/StaticAnalyzer/Core/Environment.cpp
===
--- lib/StaticAnalyzer/Core/Environment.cpp
+++ lib/StaticAnalyzer/Core/Environment.cpp
@@ -171,8 +171,15 @@
   EBMapRef = 

Re: [PATCH] D10305: [Clang Static Analyzer] Bug identification

2015-09-18 Thread Honggyu Kim via cfe-commits
honggyu.kim added a comment.

Hi Babati,

Can you please rebase this patch based on http://reviews.llvm.org/D12673?
It is just a whitespace cleanup patch and I wrote 
http://reviews.llvm.org/D12906 based on this patch after applying whitespace 
cleanup at the end of each line.
http://reviews.llvm.org/D12906 can be applied after applying this patch first.
Thank you.


http://reviews.llvm.org/D10305



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


[PATCH] D12961: Update clang-tidy documentation.

2015-09-18 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added subscribers: alexfh, klimek, cfe-commits.

Update documentation of the modernize module with clang-modernize's 
documentation.

http://reviews.llvm.org/D12961

Files:
  docs/clang-tidy/checks/modernize-loop-convert.rst
  docs/clang-tidy/checks/modernize-pass-by-value.rst
  docs/clang-tidy/checks/modernize-replace-auto-ptr.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  docs/clang-tidy/checks/modernize-use-nullptr.rst

Index: docs/clang-tidy/checks/modernize-use-nullptr.rst
===
--- docs/clang-tidy/checks/modernize-use-nullptr.rst
+++ docs/clang-tidy/checks/modernize-use-nullptr.rst
@@ -1,4 +1,65 @@
 modernize-use-nullptr
 =
 
+The check converts the usage of null pointer constants (eg. ``NULL``, ``0``)
+to use the new C++11 ``nullptr`` keyword.
 
+Example
+===
+
+.. code-block:: c++
+
+  void assignment() {
+char *a = NULL;
+char *b = 0;
+char c = 0;
+  }
+
+  int *ret_ptr() {
+return 0;
+  }
+
+
+transforms to:
+
+.. code-block:: c++
+
+  void assignment() {
+char *a = nullptr;
+char *b = nullptr;
+char c = 0;
+  }
+
+  int *ret_ptr() {
+return nullptr;
+  }
+
+
+User defined macros
+===
+
+By default this transform will only replace the ``NULL`` macro and will skip any
+user-defined macros that behaves like ``NULL``. The user can use the
+:option:``UserNullMacros`` option to specify a comma-separated list of macro
+names that will be transformed along with ``NULL``.
+
+Example
+---
+
+.. code-block:: c++
+
+  #define MY_NULL (void*)0
+  void assignment() {
+void *p = MY_NULL;
+  }
+
+transforms to:
+
+.. code-block:: c++
+
+  #define MY_NULL NULL
+  void assignment() {
+int *p = nullptr;
+  }
+
+  if the ``UserNullMacros`` option is set to ``MY_NULL``.
Index: docs/clang-tidy/checks/modernize-use-auto.rst
===
--- docs/clang-tidy/checks/modernize-use-auto.rst
+++ docs/clang-tidy/checks/modernize-use-auto.rst
@@ -1,4 +1,134 @@
 modernize-use-auto
 ==
 
+This check is responsible for using the ``auto`` type specifier for
+variable declarations to *improve code readability and maintainability*.
+For example:
+
+.. code-block:: c++
+
+  std::vector::iterator I = my_container.begin();
+
+  // transforms to:
+
+  auto I = my_container.begin();
+
+The ``auto`` type specifier will only be introduced in situations where the
+variable type matches the type of the initializer expression. In other words
+``auto`` should deduce the same type that was originally spelled in the source.
+However, not every situation should be transformed:
+
+.. code-block:: c++
+
+  int val = 42;
+  InfoStruct  = SomeObject.getInfo();
+
+  // Should not become:
+
+  auto val = 42;
+  auto  = SomeObject.getInfo();
+
+In this example using ``auto`` for builtins doesn't improve readability. In
+other situations it makes the code less self-documenting impairing readability
+and maintainability. As a result, ``auto`` is used only introduced in specific
+situations described below.
+
+Iterators
+=
+
+Iterator type specifiers tend to be long and used frequently, especially in
+loop constructs. Since the functions generating iterators have a common format,
+the type specifier can be replaced without obscuring the meaning of code while 
+improving readability and maintainability.
+
+.. code-block:: c++
+
+  for (std::vector::iterator I = my_container.begin(),
+  E = my_container.end();
+   I != E; ++I) {
+  }
+
+  // becomes
+
+  for (auto I = my_container.begin(), E = my_container.end(); I != E; ++I) {
+  }
+
+The transform will only replace iterator type-specifiers when all of the
+following conditions are satisfied:
+* The iterator is for one of the standard container in ``std`` namespace:
+
+  * ``array``
+
+  * ``deque``
+
+  * ``forward_list``
+
+  * ``list``
+
+  * ``vector``
+
+  * ``map``
+
+  * ``multimap``
+
+  * ``set``
+
+  * ``multiset``
+
+  * ``unordered_map``
+
+  * ``unordered_multimap``
+
+  * ``unordered_set``
+
+  * ``unordered_multiset``
+
+  * ``queue``
+
+  * ``priority_queue``
+
+  * ``stack``
+
+* The iterator is one of the possible iterator types for standard containers:
+
+  * ``iterator``
+
+  * ``reverse_iterator``
+
+  * ``const_iterator``
+
+  * ``const_reverse_iterator``
+
+* In addition to using iterator types directly, typedefs or other ways of
+  referring to those types are also allowed. However, implementation-specific
+  types for which a type like ``std::vector::iterator`` is itself a
+  typedef will not be transformed. Consider the following examples:
+
+.. code-block:: c++
+
+  // The following direct uses of iterator types will be transformed.
+  std::vector::iterator I = MyVec.begin();
+  {
+using namespace std;
+list::iterator I = MyList.begin();
+  }
+
+  // The type 

Re: [PATCH] D12961: Update clang-tidy documentation.

2015-09-18 Thread Angel Garcia via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247987: Update clang-tidy documentation. (authored by 
angelgarcia).

Changed prior to commit:
  http://reviews.llvm.org/D12961?vs=35080=35081#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12961

Files:
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-replace-auto-ptr.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst

Index: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
@@ -1,4 +1,134 @@
 modernize-use-auto
 ==
 
+This check is responsible for using the ``auto`` type specifier for
+variable declarations to *improve code readability and maintainability*.
+For example:
+
+.. code-block:: c++
+
+  std::vector::iterator I = my_container.begin();
+
+  // transforms to:
+
+  auto I = my_container.begin();
+
+The ``auto`` type specifier will only be introduced in situations where the
+variable type matches the type of the initializer expression. In other words
+``auto`` should deduce the same type that was originally spelled in the source.
+However, not every situation should be transformed:
+
+.. code-block:: c++
+
+  int val = 42;
+  InfoStruct  = SomeObject.getInfo();
+
+  // Should not become:
+
+  auto val = 42;
+  auto  = SomeObject.getInfo();
+
+In this example using ``auto`` for builtins doesn't improve readability. In
+other situations it makes the code less self-documenting impairing readability
+and maintainability. As a result, ``auto`` is used only introduced in specific
+situations described below.
+
+Iterators
+=
+
+Iterator type specifiers tend to be long and used frequently, especially in
+loop constructs. Since the functions generating iterators have a common format,
+the type specifier can be replaced without obscuring the meaning of code while 
+improving readability and maintainability.
+
+.. code-block:: c++
+
+  for (std::vector::iterator I = my_container.begin(),
+  E = my_container.end();
+   I != E; ++I) {
+  }
+
+  // becomes
+
+  for (auto I = my_container.begin(), E = my_container.end(); I != E; ++I) {
+  }
+
+The transform will only replace iterator type-specifiers when all of the
+following conditions are satisfied:
+* The iterator is for one of the standard container in ``std`` namespace:
+
+  * ``array``
+
+  * ``deque``
+
+  * ``forward_list``
+
+  * ``list``
+
+  * ``vector``
+
+  * ``map``
+
+  * ``multimap``
+
+  * ``set``
+
+  * ``multiset``
+
+  * ``unordered_map``
+
+  * ``unordered_multimap``
+
+  * ``unordered_set``
+
+  * ``unordered_multiset``
+
+  * ``queue``
+
+  * ``priority_queue``
+
+  * ``stack``
+
+* The iterator is one of the possible iterator types for standard containers:
+
+  * ``iterator``
+
+  * ``reverse_iterator``
+
+  * ``const_iterator``
+
+  * ``const_reverse_iterator``
+
+* In addition to using iterator types directly, typedefs or other ways of
+  referring to those types are also allowed. However, implementation-specific
+  types for which a type like ``std::vector::iterator`` is itself a
+  typedef will not be transformed. Consider the following examples:
+
+.. code-block:: c++
+
+  // The following direct uses of iterator types will be transformed.
+  std::vector::iterator I = MyVec.begin();
+  {
+using namespace std;
+list::iterator I = MyList.begin();
+  }
+
+  // The type specifier for J would transform to auto since it's a typedef
+  // to a standard iterator type.
+  typedef std::map::const_iterator map_iterator;
+  map_iterator J = MyMap.begin();
+
+  // The following implementation-specific iterator type for which
+  // std::vector::iterator could be a typedef would not be transformed.
+  __gnu_cxx::__normal_iterator K = MyVec.begin();
+
+* The initializer for the variable being declared is not a braced initializer
+  list. Otherwise, use of ``auto`` would cause the type of the variable to be
+  deduced as``std::initializer_list``.
+
+Known Limitations
+=
+* If the initializer is an explicit conversion constructor, the transform will
+  not replace the type specifier even though it would be safe to do so.
+* User-defined iterators are not handled at this time.
 
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst
+++ 

[clang-tools-extra] r247987 - Update clang-tidy documentation.

2015-09-18 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Fri Sep 18 09:08:57 2015
New Revision: 247987

URL: http://llvm.org/viewvc/llvm-project?rev=247987=rev
Log:
Update clang-tidy documentation.

Summary: Update documentation of the modernize module with clang-modernize's 
documentation.

Subscribers: cfe-commits, klimek, alexfh

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

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-pass-by-value.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-replace-auto-ptr.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst?rev=247987=247986=247987=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-loop-convert.rst 
Fri Sep 18 09:08:57 2015
@@ -1,4 +1,253 @@
 modernize-loop-convert
 ==
 
+This check converts ``for(...; ...; ...)`` loops to use the new range-based
+loops in C++11.
 
+Three kinds of loops can be converted:
+
+-  Loops over statically allocated arrays.
+-  Loops over containers, using iterators.
+-  Loops over array-like containers, using ``operator[]`` and ``at()``.
+
+MinConfidence option
+
+
+risky
+-
+
+In loops where the container expression is more complex than just a
+reference to a declared expression (a variable, function, enum, etc.),
+and some part of it appears elsewhere in the loop, we lower our confidence
+in the transformation due to the increased risk of changing semantics.
+Transformations for these loops are marked as `risky`, and thus will only
+be converted if the minimum required confidence level is set to ``risky``.
+
+.. code-block:: c++
+
+  int arr[10][20];
+  int l = 5;
+
+  for (int j = 0; j < 20; ++j)
+int k = arr[l][j] + l; // using l outside arr[l] is considered risky
+
+  for (int i = 0; i < obj.getVector().size(); ++i)
+obj.foo(10); // using 'obj' is considered risky
+
+See
+:ref:`Range-based loops evaluate end() only once`
+for an example of an incorrect transformation when the minimum required 
confidence
+level is set to `risky`.
+
+reasonable (Default)
+
+
+If a loop calls ``.end()`` or ``.size()`` after each iteration, the
+transformation for that loop is marked as `reasonable`, and thus will
+be converted if the required confidence level is set to ``reasonable``
+(default) or lower.
+
+.. code-block:: c++
+
+  // using size() is considered reasonable
+  for (int i = 0; i < container.size(); ++i)
+cout << container[i];
+
+safe
+
+
+Any other loops that do not match the above criteria to be marked as
+`risky` or `reasonable` are marked `safe`, and thus will be converted
+if the required confidence level is set to ``safe`` or lower.
+
+.. code-block:: c++
+
+  int arr[] = {1,2,3};
+
+  for (int i = 0; i < 3; ++i)
+cout << arr[i];
+
+Example
+===
+
+Original:
+
+.. code-block:: c++
+
+  const int N = 5;
+  int arr[] = {1,2,3,4,5};
+  vector v;
+  v.push_back(1);
+  v.push_back(2);
+  v.push_back(3);
+
+  // safe transform
+  for (int i = 0; i < N; ++i)
+cout << arr[i];
+
+  // reasonable transform
+  for (vector::iterator it = v.begin(); it != v.end(); ++it)
+cout << *it;*
+
+  // reasonable transform
+  for (int i = 0; i < v.size(); ++i)
+cout << v[i];
+
+After transformation with confidence level set to ``reasonable`` (default):
+
+.. code-block:: c++
+
+  const int N = 5;
+  int arr[] = {1,2,3,4,5};
+  vector v;
+  v.push_back(1);
+  v.push_back(2);
+  v.push_back(3);
+
+  // safe transform
+  for (auto & elem : arr)
+cout << elem;
+
+  // reasonable transform
+  for (auto & elem : v)
+cout << elem;
+
+  // reasonable transform
+  for (auto & elem : v)
+cout << elem;
+
+Limitations
+===
+
+There are certain situations where the tool may erroneously perform
+transformations that remove information and change semantics. Users of the tool
+should be aware of the behaviour and limitations of the transform outlined by
+the cases below.
+
+Comments inside loop headers
+
+
+Comments inside the original loop header are ignored and deleted when
+transformed.
+
+.. code-block:: c++
+
+  for (int i = 0; i < N; /* This will be deleted */ ++i) { }
+
+Range-based loops evaluate end() only once
+--
+
+The C++11 range-based for loop calls ``.end()`` only once during the
+initialization of the loop. If in the original loop ``.end()`` is called after
+each iteration the semantics of 

[PATCH] D12955: Fix assertion in inline assembler IR gen

2015-09-18 Thread Alexander Musman via cfe-commits
amusman created this revision.
amusman added reviewers: rsmith, aaron.ballman, ABataev.
amusman added a subscriber: cfe-commits.

Several inputs may not refer to one output constraint in inline assembler 
insertions, clang fails on assertion on such test case here:

llvm/lib/IR/InlineAsm.cpp:46: llvm::InlineAsm::InlineAsm(llvm::FunctionType*, 
const string&, const string&, bool, bool, llvm::InlineAsm::AsmDialect): 
Assertion `Verify(getFunctionType(), constraints) && "Function type not legal 
for constraints!"' failed.

I suggest to check this case in Sema.

Thanks,
Alexander


http://reviews.llvm.org/D12955

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaStmtAsm.cpp
  test/Sema/asm.c

Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -420,6 +420,8 @@
 diag::err_asm_unexpected_constraint_alternatives)
<< NumAlternatives << AltCount);
   }
+  SmallVector InputMatchedToOutput(OutputConstraintInfos.size(),
+  ~0U);
   for (unsigned i = 0, e = InputConstraintInfos.size(); i != e; ++i) {
 TargetInfo::ConstraintInfo  = InputConstraintInfos[i];
 StringRef ConstraintStr = Info.getConstraintStr();
@@ -441,6 +443,18 @@
 Expr *OutputExpr = Exprs[TiedTo];
 Expr *InputExpr = Exprs[InputOpNo];
 
+// Make sure no more than one input constraint matches each output.
+if (InputMatchedToOutput[TiedTo] != ~0U) {
+  Diag(NS->getInputExpr(i)->getLocStart(),
+   diag::err_asm_input_duplicate_match)
+  << TiedTo;
+  Diag(NS->getInputExpr(InputMatchedToOutput[TiedTo])->getLocStart(),
+   diag::note_asm_input_duplicate_first)
+  << TiedTo;
+  return StmtError();
+}
+InputMatchedToOutput[TiedTo] = i;
+
 if (OutputExpr->isTypeDependent() || InputExpr->isTypeDependent())
   continue;
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6418,6 +6418,8 @@
   def err_asm_non_addr_value_in_memory_constraint : Error <
 "reference to a %select{bit-field|vector element|global register 
variable}0"
 " in asm %select{input|output}1 with a memory constraint '%2'">;
+  def err_asm_input_duplicate_match : Error<
+"more than one input constraint matches the same output '%0'">;
 
   def warn_asm_label_on_auto_decl : Warning<
 "ignored asm label '%0' on automatic variable">;
@@ -6432,6 +6434,8 @@
 
   def note_asm_missing_constraint_modifier : Note<
 "use constraint modifier \"%0\"">;
+  def note_asm_input_duplicate_first : Note<
+"constraint '%0' is already present here">;
 }
 
 let CategoryName = "Semantic Issue" in {
Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -236,3 +236,15 @@
   : "m" (test16_baz)); // expected-error {{reference to a global 
register variable in asm output with a memory constraint 'm'}}
 }
 
+int test17(int t0)
+{
+  int r0, r1;
+  __asm ("addl %2, %2\n\t"
+ "movl $123, %0"
+ : "=a" (r0),
+   "=" (r1)
+ : "1" (t0),   // expected-note {{constraint '1' is already present 
here}}
+   "1" (t0));  // expected-error {{more than one input constraint 
matches the same output '1'}}
+  return r0 + r1;
+}
+


Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -420,6 +420,8 @@
 diag::err_asm_unexpected_constraint_alternatives)
<< NumAlternatives << AltCount);
   }
+  SmallVector InputMatchedToOutput(OutputConstraintInfos.size(),
+  ~0U);
   for (unsigned i = 0, e = InputConstraintInfos.size(); i != e; ++i) {
 TargetInfo::ConstraintInfo  = InputConstraintInfos[i];
 StringRef ConstraintStr = Info.getConstraintStr();
@@ -441,6 +443,18 @@
 Expr *OutputExpr = Exprs[TiedTo];
 Expr *InputExpr = Exprs[InputOpNo];
 
+// Make sure no more than one input constraint matches each output.
+if (InputMatchedToOutput[TiedTo] != ~0U) {
+  Diag(NS->getInputExpr(i)->getLocStart(),
+   diag::err_asm_input_duplicate_match)
+  << TiedTo;
+  Diag(NS->getInputExpr(InputMatchedToOutput[TiedTo])->getLocStart(),
+   diag::note_asm_input_duplicate_first)
+  << TiedTo;
+  return StmtError();
+}
+InputMatchedToOutput[TiedTo] = i;
+
 if (OutputExpr->isTypeDependent() || InputExpr->isTypeDependent())
   continue;
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- 

r248002 - [Static Analyzer] Use generics related information to infer dynamic types.

2015-09-18 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Fri Sep 18 11:43:27 2015
New Revision: 248002

URL: http://llvm.org/viewvc/llvm-project?rev=248002=rev
Log:
[Static Analyzer] Use generics related information to infer dynamic types.

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


Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/test/Analysis/DynamicTypePropagation.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp?rev=248002=248001=248002=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp Fri Sep 18 
11:43:27 2015
@@ -665,38 +665,36 @@ findMethodDecl(const ObjCMessageExpr *Me
 /// Get the returned ObjCObjectPointerType by a method based on the tracked 
type
 /// information, or null pointer when the returned type is not an
 /// ObjCObjectPointerType.
-static const ObjCObjectPointerType *getReturnTypeForMethod(
+static QualType getReturnTypeForMethod(
 const ObjCMethodDecl *Method, ArrayRef TypeArgs,
 const ObjCObjectPointerType *SelfType, ASTContext ) {
   QualType StaticResultType = Method->getReturnType();
 
   // Is the return type declared as instance type?
   if (StaticResultType == C.getObjCInstanceType())
-return SelfType;
+return QualType(SelfType, 0);
 
   // Check whether the result type depends on a type parameter.
   if (!isObjCTypeParamDependent(StaticResultType))
-return nullptr;
+return QualType();
 
   QualType ResultType = StaticResultType.substObjCTypeArgs(
   C, TypeArgs, ObjCSubstitutionContext::Result);
 
-  return ResultType->getAs();
+  return ResultType;
 }
 
 /// Validate that the return type of a message expression is used correctly.
 /// Returns true in case an error is detected.
 bool DynamicTypePropagation::isReturnValueMisused(
 const ObjCMessageExpr *MessageExpr,
-const ObjCObjectPointerType *SeflType, SymbolRef Sym,
+const ObjCObjectPointerType *ResultPtrType, SymbolRef Sym,
 const ObjCMethodDecl *Method, ArrayRef TypeArgs,
 bool SubscriptOrProperty, CheckerContext ) const {
-  ASTContext  = C.getASTContext();
-  const auto *ResultPtrType =
-  getReturnTypeForMethod(Method, TypeArgs, SeflType, ASTCtxt);
   if (!ResultPtrType)
 return false;
 
+  ASTContext  = C.getASTContext();
   const Stmt *Parent =
   C.getCurrentAnalysisDeclContext()->getParentMap().getParent(MessageExpr);
   if (SubscriptOrProperty) {
@@ -861,12 +859,32 @@ void DynamicTypePropagation::checkPostOb
   if (!TypeArgs)
 return;
 
-  if (isReturnValueMisused(MessageExpr, *TrackedType, RecSym, Method, 
*TypeArgs,
-   M.getMessageKind() != OCM_Message, C))
+  QualType ResultType =
+  getReturnTypeForMethod(Method, *TypeArgs, *TrackedType, ASTCtxt);
+  // The static type is the same as the deduced type.
+  if (ResultType.isNull())
+return;
+
+  const MemRegion *RetRegion = M.getReturnValue().getAsRegion();
+  ExplodedNode *Pred = C.getPredecessor();
+  // When there is an entry available for the return symbol in DynamicTypeMap,
+  // the call was inlined, and the information in the DynamicTypeMap is should
+  // be precise.
+  if (RetRegion && !State->get(RetRegion)) {
+// TODO: we have duplicated information in DynamicTypeMap and
+// MostSpecializedTypeArgsMap. We should only store anything in the later 
if
+// the stored data differs from the one stored in the former.
+State = setDynamicTypeInfo(State, RetRegion, ResultType,
+   /*CanBeSubclass=*/true);
+Pred = C.addTransition(State);
+  }
+
+  const auto *ResultPtrType = ResultType->getAs();
+
+  if (isReturnValueMisused(MessageExpr, ResultPtrType, RecSym, Method,
+   *TypeArgs, M.getMessageKind() != OCM_Message, C))
 return;
 
-  const auto *ResultPtrType =
-  getReturnTypeForMethod(Method, *TypeArgs, *TrackedType, ASTCtxt);
   if (!ResultPtrType || ResultPtrType->isUnspecialized())
 return;
 
@@ -874,7 +892,7 @@ void DynamicTypePropagation::checkPostOb
   // for the result symbol.
   if (!State->get(RetSym)) {
 State = State->set(RetSym, ResultPtrType);
-C.addTransition(State);
+C.addTransition(State, Pred);
   }
 }
 

Modified: cfe/trunk/test/Analysis/DynamicTypePropagation.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DynamicTypePropagation.m?rev=248002=248001=248002=diff
==
--- cfe/trunk/test/Analysis/DynamicTypePropagation.m (original)
+++ cfe/trunk/test/Analysis/DynamicTypePropagation.m Fri Sep 18 11:43:27 2015
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify %s
-// XFAIL: *
 
 

Re: [PATCH] D12916: [Static Analyzer] Use generics related information to infer dynamic types.

2015-09-18 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248002: [Static Analyzer] Use generics related information 
to infer dynamic types. (authored by xazax).

Changed prior to commit:
  http://reviews.llvm.org/D12916?vs=35027=35095#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12916

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  cfe/trunk/test/Analysis/DynamicTypePropagation.m

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -665,38 +665,36 @@
 /// Get the returned ObjCObjectPointerType by a method based on the tracked type
 /// information, or null pointer when the returned type is not an
 /// ObjCObjectPointerType.
-static const ObjCObjectPointerType *getReturnTypeForMethod(
+static QualType getReturnTypeForMethod(
 const ObjCMethodDecl *Method, ArrayRef TypeArgs,
 const ObjCObjectPointerType *SelfType, ASTContext ) {
   QualType StaticResultType = Method->getReturnType();
 
   // Is the return type declared as instance type?
   if (StaticResultType == C.getObjCInstanceType())
-return SelfType;
+return QualType(SelfType, 0);
 
   // Check whether the result type depends on a type parameter.
   if (!isObjCTypeParamDependent(StaticResultType))
-return nullptr;
+return QualType();
 
   QualType ResultType = StaticResultType.substObjCTypeArgs(
   C, TypeArgs, ObjCSubstitutionContext::Result);
 
-  return ResultType->getAs();
+  return ResultType;
 }
 
 /// Validate that the return type of a message expression is used correctly.
 /// Returns true in case an error is detected.
 bool DynamicTypePropagation::isReturnValueMisused(
 const ObjCMessageExpr *MessageExpr,
-const ObjCObjectPointerType *SeflType, SymbolRef Sym,
+const ObjCObjectPointerType *ResultPtrType, SymbolRef Sym,
 const ObjCMethodDecl *Method, ArrayRef TypeArgs,
 bool SubscriptOrProperty, CheckerContext ) const {
-  ASTContext  = C.getASTContext();
-  const auto *ResultPtrType =
-  getReturnTypeForMethod(Method, TypeArgs, SeflType, ASTCtxt);
   if (!ResultPtrType)
 return false;
 
+  ASTContext  = C.getASTContext();
   const Stmt *Parent =
   C.getCurrentAnalysisDeclContext()->getParentMap().getParent(MessageExpr);
   if (SubscriptOrProperty) {
@@ -861,20 +859,40 @@
   if (!TypeArgs)
 return;
 
-  if (isReturnValueMisused(MessageExpr, *TrackedType, RecSym, Method, *TypeArgs,
-   M.getMessageKind() != OCM_Message, C))
+  QualType ResultType =
+  getReturnTypeForMethod(Method, *TypeArgs, *TrackedType, ASTCtxt);
+  // The static type is the same as the deduced type.
+  if (ResultType.isNull())
+return;
+
+  const MemRegion *RetRegion = M.getReturnValue().getAsRegion();
+  ExplodedNode *Pred = C.getPredecessor();
+  // When there is an entry available for the return symbol in DynamicTypeMap,
+  // the call was inlined, and the information in the DynamicTypeMap is should
+  // be precise.
+  if (RetRegion && !State->get(RetRegion)) {
+// TODO: we have duplicated information in DynamicTypeMap and
+// MostSpecializedTypeArgsMap. We should only store anything in the later if
+// the stored data differs from the one stored in the former.
+State = setDynamicTypeInfo(State, RetRegion, ResultType,
+   /*CanBeSubclass=*/true);
+Pred = C.addTransition(State);
+  }
+
+  const auto *ResultPtrType = ResultType->getAs();
+
+  if (isReturnValueMisused(MessageExpr, ResultPtrType, RecSym, Method,
+   *TypeArgs, M.getMessageKind() != OCM_Message, C))
 return;
 
-  const auto *ResultPtrType =
-  getReturnTypeForMethod(Method, *TypeArgs, *TrackedType, ASTCtxt);
   if (!ResultPtrType || ResultPtrType->isUnspecialized())
 return;
 
   // When the result is a specialized type and it is not tracked yet, track it
   // for the result symbol.
   if (!State->get(RetSym)) {
 State = State->set(RetSym, ResultPtrType);
-C.addTransition(State);
+C.addTransition(State, Pred);
   }
 }
 
Index: cfe/trunk/test/Analysis/DynamicTypePropagation.m
===
--- cfe/trunk/test/Analysis/DynamicTypePropagation.m
+++ cfe/trunk/test/Analysis/DynamicTypePropagation.m
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify %s
-// XFAIL: *
 
 #if !__has_feature(objc_generics)
 #  error Compiler does not support Objective-C generics?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r248016 - [CMake] Set CLANG_LINKS_TO_CREATE in Apple-stage2.cmake so that we create cc and c++ links.

2015-09-18 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Fri Sep 18 13:11:18 2015
New Revision: 248016

URL: http://llvm.org/viewvc/llvm-project?rev=248016=rev
Log:
[CMake] Set CLANG_LINKS_TO_CREATE in Apple-stage2.cmake so that we create cc 
and c++ links.

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=248016=248015=248016=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Fri Sep 18 13:11:18 2015
@@ -10,6 +10,7 @@ set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(CLANG_INCLUDE_TESTS OFF CACHE BOOL "")
 set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
 set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "")
+set(CLANG_LINKS_TO_CREATE clang++ cc c++ CACHE STRING "")
 
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os -flto -gline-tables-only -DNDEBUG" 
CACHE STRING "")


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


Re: [PATCH] D12725: [analyzer] A fix for substraction of an integer from a pointer.

2015-09-18 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

I've got no commit access yet, sorry, that's my first patch here actually :)


http://reviews.llvm.org/D12725



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


Re: [PATCH] D11844: [Modules] More descriptive diagnostics for misplaced import directive

2015-09-18 Thread Richard Smith via cfe-commits
rsmith added a comment.

A separate patch for the ObjC cases is fine.


http://reviews.llvm.org/D11844



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


Re: [PATCH] D10305: [Clang Static Analyzer] Bug identification

2015-09-18 Thread Phillip Power via cfe-commits
phillip.power added a comment.

Hi Babati,

We at Sony are interested in this feature so that our tools can suppress 
undesirable bug warnings. You described at the end of the summary that you have 
thought about introducing new hash calculation algorithms if needed.  How do 
you expect this to work?  i.e. would bug_id_1 always be generated along with 
new improved bug_ids in the same plist file or would you expect the new bug_ids 
to replace old ones. I am hoping that the analyzer will always keep generating 
old bug_ids so that we can maintain backwards compatibility.

Regards,
Phillip

SN Systems - Sony Computer Entertainment


http://reviews.llvm.org/D10305



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


r248000 - Suppress amdgpu-toolchain.c for targeting ps4, for now. Investigating.

2015-09-18 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 18 11:21:27 2015
New Revision: 248000

URL: http://llvm.org/viewvc/llvm-project?rev=248000=rev
Log:
Suppress amdgpu-toolchain.c for targeting ps4, for now. Investigating.

Modified:
cfe/trunk/test/Driver/amdgpu-toolchain.c

Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=248000=247999=248000=diff
==
--- cfe/trunk/test/Driver/amdgpu-toolchain.c (original)
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c Fri Sep 18 11:21:27 2015
@@ -1,6 +1,6 @@
-// RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK-LABEL: clang
 // AS_LINK: "-cc1as"
 // AS_LINK-LABEL: lld
 // AS_LINK: "-flavor" "gnu" "-target" "amdgcn--amdhsa"
+// REQUIRES: clang-driver


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


r247997 - amdgpu-toolchain.c: Add a probe line temporally. Will revert later.

2015-09-18 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Fri Sep 18 10:56:16 2015
New Revision: 247997

URL: http://llvm.org/viewvc/llvm-project?rev=247997=rev
Log:
amdgpu-toolchain.c: Add a probe line temporally. Will revert later.

Modified:
cfe/trunk/test/Driver/amdgpu-toolchain.c

Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=247997=247996=247997=diff
==
--- cfe/trunk/test/Driver/amdgpu-toolchain.c (original)
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c Fri Sep 18 10:56:16 2015
@@ -1,3 +1,4 @@
+// RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK-LABEL: clang
 // AS_LINK: "-cc1as"


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


r247995 - Use None instead of an explicit constructor.

2015-09-18 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Fri Sep 18 10:23:16 2015
New Revision: 247995

URL: http://llvm.org/viewvc/llvm-project?rev=247995=rev
Log:
Use None instead of an explicit constructor.

And remove a needless 'const' since ArrayRef is immutable.
Both as suggested by dblaikie on cfe-commits.

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

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=247995=247994=247995=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Sep 18 10:23:16 2015
@@ -1171,7 +1171,7 @@ static llvm::StringRef getGCCToolchainDi
 /// triple.
 void Generic_GCC::GCCInstallationDetector::init(
 const Driver , const llvm::Triple , const ArgList ,
-const ArrayRef ExtraTripleAliases) {
+ArrayRef ExtraTripleAliases) {
   llvm::Triple BiarchVariantTriple = TargetTriple.isArch32Bit()
  ? TargetTriple.get64BitArchVariant()
  : TargetTriple.get32BitArchVariant();

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=247995=247994=247995=diff
==
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Fri Sep 18 10:23:16 2015
@@ -102,8 +102,7 @@ public:
 GCCInstallationDetector() : IsValid(false) {}
 void init(const Driver , const llvm::Triple ,
   const llvm::opt::ArgList ,
-  const ArrayRef ExtraTripleAliases =
-  ArrayRef());
+  ArrayRef ExtraTripleAliases = None);
 
 /// \brief Check whether we detected a valid GCC install.
 bool isValid() const { return IsValid; }


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


Re: [PATCH] D12571: [Analyzer] Fix assertions in commit r246345 (pr22954).

2015-09-18 Thread pierre gousseau via cfe-commits
pgousseau added a comment.

In http://reviews.llvm.org/D12571#248464, @dcoughlin wrote:

> Here is a reduced test case:


Very useful thanks !



Comment at: lib/StaticAnalyzer/Checkers/CStringChecker.cpp:198
@@ +197,3 @@
+
+  // Return true if the destination buffer of the copy function must/may be in
+  // bound.

dcoughlin wrote:
> Since this returns true on unknown, it should be "may".
Makes sense thanks !


Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1109
@@ +1108,3 @@
+  }
+  if (RO.getOffset() < 0) {
+// FIXME: should be an assert but this does occur on private build 
bots.

dcoughlin wrote:
> I think it is important to figure out enough of why the assert was triggering 
> so that we can add a test case for this 'if'. The preprocessed file that is 
> failing our bots is from the bugzilla for PR13765, in the 
> [[https://llvm.org/bugs/attachment.cgi?id=9155 |  clang2 attachment ]].
> 
> You can reproduce with:
> 
> ```
> clang -cc1 -analyze -analyzer-checker=core,cplusplus -fcxx-exceptions 
> -std=c++11 clang2/clang_crash_4pFspw.ii
> ```
Will have a look !


http://reviews.llvm.org/D12571



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


[PATCH] D12967: fix comments

2015-09-18 Thread don hinton via cfe-commits
hintonda created this revision.
hintonda added a reviewer: alexfh.
hintonda added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

Fix example comments.

http://reviews.llvm.org/D12967

Files:
  include/clang/Tooling/CommonOptionsParser.h

Index: include/clang/Tooling/CommonOptionsParser.h
===
--- include/clang/Tooling/CommonOptionsParser.h
+++ include/clang/Tooling/CommonOptionsParser.h
@@ -42,6 +42,7 @@
 /// \code
 /// #include "clang/Frontend/FrontendActions.h"
 /// #include "clang/Tooling/CommonOptionsParser.h"
+/// #include "clang/Tooling/Tooling.h"
 /// #include "llvm/Support/CommandLine.h"
 ///
 /// using namespace clang::tooling;
@@ -56,8 +57,8 @@
 /// int main(int argc, const char **argv) {
 ///   CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
 ///   ClangTool Tool(OptionsParser.getCompilations(),
-///  OptionsParser.getSourcePathListi());
-///   return Tool.run(newFrontendActionFactory());
+///  OptionsParser.getSourcePathList());
+///   return Tool.run(newFrontendActionFactory().get());
 /// }
 /// \endcode
 class CommonOptionsParser {


Index: include/clang/Tooling/CommonOptionsParser.h
===
--- include/clang/Tooling/CommonOptionsParser.h
+++ include/clang/Tooling/CommonOptionsParser.h
@@ -42,6 +42,7 @@
 /// \code
 /// #include "clang/Frontend/FrontendActions.h"
 /// #include "clang/Tooling/CommonOptionsParser.h"
+/// #include "clang/Tooling/Tooling.h"
 /// #include "llvm/Support/CommandLine.h"
 ///
 /// using namespace clang::tooling;
@@ -56,8 +57,8 @@
 /// int main(int argc, const char **argv) {
 ///   CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
 ///   ClangTool Tool(OptionsParser.getCompilations(),
-///  OptionsParser.getSourcePathListi());
-///   return Tool.run(newFrontendActionFactory());
+///  OptionsParser.getSourcePathList());
+///   return Tool.run(newFrontendActionFactory().get());
 /// }
 /// \endcode
 class CommonOptionsParser {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [cfe-commits] r171885 - in /cfe/trunk/www/analyzer: annotations.html available_checks.html dev_cxx.html index.html xcode.html

2015-09-18 Thread Jordan Rose via cfe-commits
Thanks, updated these links in r247999. In the future Anna's probably the right 
person to ping.

Jordan


> On Sep 17, 2015, at 6:57 , Aaron Ballman  wrote:
> 
> Sorry to resurrect an ancient commit, but...
> 
> On Tue, Jan 8, 2013 at 2:29 PM, Jordan Rose  wrote:
>> Author: jrose
>> Date: Tue Jan  8 13:29:37 2013
>> New Revision: 171885
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=171885=rev
>> Log:
>> Various tweaks and updates to the analyzer website.
>> 
>> Modified:
>>cfe/trunk/www/analyzer/annotations.html
>>cfe/trunk/www/analyzer/available_checks.html
>>cfe/trunk/www/analyzer/dev_cxx.html
>>cfe/trunk/www/analyzer/index.html
>>cfe/trunk/www/analyzer/xcode.html
>> 
>> Modified: cfe/trunk/www/analyzer/annotations.html
> 
> 
> 
>> 
>> Modified: cfe/trunk/www/analyzer/xcode.html
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/xcode.html?rev=171885=171884=171885=diff
>> ==
>> --- cfe/trunk/www/analyzer/xcode.html (original)
>> +++ cfe/trunk/www/analyzer/xcode.html Tue Jan  8 13:29:37 2013
>> @@ -2,7 +2,7 @@
>>   "http://www.w3.org/TR/html4/strict.dtd;>
>> 
>> 
>> -  Build and Analyze: running the analyzer within Xcode
>> +  Running the analyzer within Xcode
>>   
>>   
>>   
>> @@ -14,15 +14,16 @@
>> 
>> 
>> 
>> -Build and Analyze: running the analyzer within Xcode
>> +Running the analyzer within Xcode
>> 
>> > cellspacing="0">
>> 
>> 
>> What is it?
>> -Build and Analyze is an Xcode feature (introduced in Xcode 3.2) 
>> that
>> -allows users to run the Clang Static Analyzer > -href="http://developer.apple.com/mac/library/featuredarticles/StaticAnalysis/index.html;>directly
>> +
>> +Since Xcode 3.2, users have been able to run the Clang Static Analyzer
>> +> +href="https://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/060-Debug_Your_App/debug_app.html#//apple_ref/doc/uid/TP40010215-CH3-SW17;>directly
>> within Xcode.
> 
> This link is currently broken, and I do not know what the replacement
> link should be.
> 
>> It integrates directly with the Xcode build system and
>> @@ -45,23 +46,24 @@
>>  single keystroke or mouse click.
>>  Transparency: Works effortlessly with Xcode projects (including 
>> iPhone projects).
>>  Cons: Doesn't work well with non-Xcode projects. For those,
>> -  consider using scan-build.
>> +  consider using scan-build.
>> 
>> 
>> 
>> Getting Started
>> 
>> -Xcode 3.2 is available as a free download from Apple, with > -href="http://developer.apple.com/mac/library/featuredarticles/StaticAnalysis/index.html;>instructions
>>  available
>> -for using Build and Analyze.
>> +Xcode is available as a free download from Apple on the > +href="https://itunes.apple.com/us/app/xcode/id497799835?mt=12;>Mac
>> +App Store, with > +href="https://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/060->
>>  
>> Debug_Your_App/debug_app.html#//apple_ref/doc/uid/TP40010215-CH3-SW17">instructions
>> +available for using the analyzer.
> 
> Same with this link.
> 
> ~Aaron
> 
> On Tue, Jan 8, 2013 at 2:29 PM, Jordan Rose  wrote:
>> Author: jrose
>> Date: Tue Jan  8 13:29:37 2013
>> New Revision: 171885
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=171885=rev
>> Log:
>> Various tweaks and updates to the analyzer website.
>> 
>> Modified:
>>cfe/trunk/www/analyzer/annotations.html
>>cfe/trunk/www/analyzer/available_checks.html
>>cfe/trunk/www/analyzer/dev_cxx.html
>>cfe/trunk/www/analyzer/index.html
>>cfe/trunk/www/analyzer/xcode.html
>> 
>> Modified: cfe/trunk/www/analyzer/annotations.html
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/annotations.html?rev=171885=171884=171885=diff
>> ==
>> --- cfe/trunk/www/analyzer/annotations.html (original)
>> +++ cfe/trunk/www/analyzer/annotations.html Tue Jan  8 13:29:37 2013
>> @@ -127,7 +127,10 @@
>> 
>> One can educate the analyzer (and others who read your code) about 
>> methods or
>> functions that deviate from the Cocoa and Core Foundation conventions using 
>> the
>> -attributes described here.
>> +attributes described here. However, you should consider using proper naming
>> +conventions or the > +href="http://clang.llvm.org/docs/LanguageExtensions.html#the-objc-method-family-attribute;>objc_method_family
>> +attribute, if applicable.
>> 
>> Attribute 'ns_returns_retained'
>> (Clang-specific)
>> @@ -135,7 +138,9 @@
>> The GCC-style (Clang-specific) attribute 'ns_returns_retained' allows one 
>> to
>> annotate an Objective-C method or C function as returning a retained Cocoa
>> object that the caller is responsible for releasing (via sending a
>> -release message to the object).
>> +release message to the object). The Foundation framework defines a
>> +macro 

r247999 - [analyzer] Update links to developer.apple.com.

2015-09-18 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Fri Sep 18 11:12:16 2015
New Revision: 247999

URL: http://llvm.org/viewvc/llvm-project?rev=247999=rev
Log:
[analyzer] Update links to developer.apple.com.

The content at the new links is /also/ a little dated, but that's our
(Apple's) problem.

Modified:
cfe/trunk/www/analyzer/scan-build.html
cfe/trunk/www/analyzer/xcode.html

Modified: cfe/trunk/www/analyzer/scan-build.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/scan-build.html?rev=247999=247998=247999=diff
==
--- cfe/trunk/www/analyzer/scan-build.html (original)
+++ cfe/trunk/www/analyzer/scan-build.html Fri Sep 18 11:12:16 2015
@@ -309,11 +309,11 @@ steps they need to take (e.g., setup cod
 
 Recommendation: use Build and Analyze
 
-The absolute easiest way to analyze iPhone projects is to use the http://developer.apple.com/mac/library/featuredarticles/StaticAnalysis/index.html;>Build
-and Analyze feature in Xcode 3.2 (which is based on the Clang Static
-Analyzer). There a user can analyze their project with the click of a button
-without most of the setup described later.
+The absolute easiest way to analyze iPhone projects is to use the
+https://developer.apple.com/library/ios/recipes/xcode_help-source_editor/chapters/Analyze.html#//apple_ref/doc/uid/TP40009975-CH4-SW1;>Analyze
+feature in Xcode (which is based on the Clang Static Analyzer). There a
+user can analyze their project right from a menu without most of the setup
+described later.
 
 Instructions are available on this
 website on how to use open source builds of the analyzer as a replacement for

Modified: cfe/trunk/www/analyzer/xcode.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/analyzer/xcode.html?rev=247999=247998=247999=diff
==
--- cfe/trunk/www/analyzer/xcode.html (original)
+++ cfe/trunk/www/analyzer/xcode.html Fri Sep 18 11:12:16 2015
@@ -22,7 +22,7 @@
 
 Since Xcode 3.2, users have been able to run the Clang Static Analyzer
 https://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/060-Debug_Your_App/debug_app.html#//apple_ref/doc/uid/TP40010215-CH3-SW17;>directly
+href="https://developer.apple.com/library/ios/recipes/xcode_help-source_editor/chapters/Analyze.html#//apple_ref/doc/uid/TP40009975-CH4-SW1;>directly
 within Xcode.
 
 It integrates directly with the Xcode build system and
@@ -54,7 +54,7 @@ presents analysis results directly withi
 Xcode is available as a free download from Apple on the https://itunes.apple.com/us/app/xcode/id497799835?mt=12;>Mac
 App Store, with https://developer.apple.com/library/mac/documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/060-Debug_Your_App/debug_app.html#//apple_ref/doc/uid/TP40010215-CH3-SW17;>instructions
+href="https://developer.apple.com/library/ios/recipes/xcode_help-source_editor/chapters/Analyze.html#//apple_ref/doc/uid/TP40009975-CH4-SW1;>instructions
 available for using the analyzer.
 
 Using open source analyzer builds with Xcode


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


r248005 - clang-cl: Use 'pc' for the vendor field in the default triple

2015-09-18 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Sep 18 12:11:50 2015
New Revision: 248005

URL: http://llvm.org/viewvc/llvm-project?rev=248005=rev
Log:
clang-cl: Use 'pc' for the vendor field in the default triple

Leaving it unset can make the triple look confusing, especially
when using -m32 or -m64.

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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=248005=248004=248005=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Sep 18 12:11:50 2015
@@ -413,6 +413,7 @@ Compilation *Driver::BuildCompilation(Ar
 // clang-cl targets MSVC-style Win32.
 llvm::Triple T(DefaultTargetTriple);
 T.setOS(llvm::Triple::Win32);
+T.setVendor(llvm::Triple::PC);
 T.setEnvironment(llvm::Triple::MSVC);
 DefaultTargetTriple = T.str();
   }


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


[PATCH] D12973: [Static Analyzer] General type checker based on dynamic type information.

2015-09-18 Thread Gábor Horváth via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, dcoughlin, jordan_rose.
xazax.hun added a subscriber: cfe-commits.

This patch adds a checker that utilizes the information that was collected by 
DynamicTypePropagation and warns when the static type contradicts the dynamic 
type.

This checker also replaces the AST matching logic in ObjCGenericsChecker's 
return type checking which was error prone and fragile. As a positive side 
effect this change also reduced the false negative cases.

http://reviews.llvm.org/D12973

Files:
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/DynamicTypeChecker.cpp
  lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  test/Analysis/dynamic_type_check.m
  test/Analysis/generics.m

Index: test/Analysis/generics.m
===
--- test/Analysis/generics.m
+++ test/Analysis/generics.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify -Wno-objc-method-access %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify -Wno-objc-method-access %s -analyzer-output=plist -o %t.plist
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker -verify -Wno-objc-method-access %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker -verify -Wno-objc-method-access %s -analyzer-output=plist -o %t.plist
 // RUN: FileCheck --input-file %t.plist %s
 
 #if !__has_feature(objc_generics)
@@ -236,13 +236,13 @@
 
 void workWithProperties(NSArray *a) {
   NSArray *b = a;
-  NSString *str = [b getObjAtIndex: 0]; // expected-warning {{Conversion}}
+  NSString *str = [b getObjAtIndex: 0]; // expected-warning {{Object}}
   NSNumber *num = [b getObjAtIndex: 0];
-  str = [b firstObject]; // expected-warning {{Conversion}}
+  str = [b firstObject]; // expected-warning {{Object}}
   num = [b firstObject];
-  str = b.firstObject; // expected-warning {{Conversion}}
+  str = b.firstObject; // expected-warning {{Object}}
   num = b.firstObject;
-  str = b[0]; // expected-warning {{Conversion}}
+  str = b[0]; // expected-warning {{Object}}
   num = b[0];
 }
 
@@ -318,15 +318,14 @@
 
 void returnToUnrelatedType(NSArray *arr) {
   NSArray *erased = arr;
-  NSSet* a = [erased firstObject]; // expected-warning {{Conversion}}
+  NSSet* a = [erased firstObject]; // expected-warning {{Object}}
   (void)a;
 }
 
 void returnToIdVariable(NSArray *arr) {
   NSArray *erased = arr;
   id a = [erased firstObject];
-  // TODO: Warn in this case. Possibly in a separate checker.
-  NSNumber *res = a;
+  NSNumber *res = a; // expected-warning {{Object}}
 }
 
 // CHECK:  
@@ -4428,35 +4427,6 @@
 // CHECK:path
 // CHECK:
 // CHECK: 
-// CHECK:  kindevent
-// CHECK:  location
-// CHECK:  
-// CHECK:   line238
-// CHECK:   col16
-// CHECK:   file0
-// CHECK:  
-// CHECK:  ranges
-// CHECK:  
-// CHECK:
-// CHECK: 
-// CHECK:  line238
-// CHECK:  col16
-// CHECK:  file0
-// CHECK: 
-// CHECK: 
-// CHECK:  line238
-// CHECK:  col16
-// CHECK:  file0
-// CHECK: 
-// CHECK:
-// CHECK:  
-// CHECK:  depth0
-// CHECK:  extended_message
-// CHECK:  Type NSArrayNSNumber * * is inferred from implicit cast (from NSArrayNSNumber * * to NSArray *)
-// CHECK:  message
-// CHECK:  Type NSArrayNSNumber * * is inferred from implicit cast (from NSArrayNSNumber * * to NSArray *)
-// CHECK: 
-// CHECK: 
 // CHECK:  kindcontrol
 // CHECK:  edges
 // CHECK:   
@@ -4549,57 +4519,57 @@
 // CHECK:  
 // CHECK:  depth0
 // CHECK:  extended_message
-// CHECK:  Conversion from value of type NSNumber * to incompatible type NSString *
+// CHECK:  Type NSNumber * is inferred from this context
 // CHECK:  message
-// CHECK:  Conversion from value of type NSNumber * to incompatible type NSString *
+// CHECK:  Type NSNumber * is inferred from this context
 // CHECK: 
-// CHECK:
-// CHECK:descriptionConversion from value of type NSNumber * to incompatible type NSString *
-// CHECK:categoryCore Foundation/Objective-C
-// CHECK:typeGenerics
-// CHECK:check_namecore.DynamicTypePropagation
-// CHECK:   issue_context_kindfunction
-// CHECK:   issue_contextworkWithProperties
-// CHECK:   issue_hash2
-// CHECK:   location
-// CHECK:   
-// CHECK:line239
-// CHECK:col19
-// CHECK:file0
-// CHECK:   
-// CHECK:   
-// CHECK:   
-// CHECK:path
-// CHECK:
 // CHECK: 
 // CHECK:  kindevent
 // CHECK:  location
 // CHECK:  
-// CHECK:   line238
-// CHECK:   col16
+// CHECK:   line239
+// CHECK:   col19
 // CHECK:   file0
 // CHECK: