Re: [PATCH] D11832: [Patch] [Analyzer] false positive: Potential leak connected with memcpy (PR 22954)

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

In http://reviews.llvm.org/D11832#236672, @xazax.hun wrote:

> I reverted the commit until this assertion is fixed.
>
> Steps to reproduce:
>  Download the following preprocessed file: F804743: clang_crash_7QnDaH.i 
> 
>  Execute the analyzer on that one: clang -cc1 -analyze -analyzer-checker=core 
> -analyzer-checker=unix -fblocks clang_crash_7QnDaH.i


Thanks for the reproducible and revert, I will have a look !


Repository:
  rL LLVM

http://reviews.llvm.org/D11832



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


r246534 - [modules] When emitting line tables, only emit filenames that are actually referenced by the entries that we emit.

2015-09-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep  1 02:41:55 2015
New Revision: 246534

URL: http://llvm.org/viewvc/llvm-project?rev=246534&view=rev
Log:
[modules] When emitting line tables, only emit filenames that are actually 
referenced by the entries that we emit.

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

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=246534&r1=246533&r2=246534&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Sep  1 02:41:55 2015
@@ -1058,11 +1058,12 @@ bool ASTReader::ParseLineTable(ModuleFil
 
   // Parse the file names
   std::map FileIDs;
-  for (int I = 0, N = Record[Idx++]; I != N; ++I) {
+  for (unsigned I = 0; Record[Idx]; ++I) {
 // Extract the file name
 auto Filename = ReadPath(F, Record, Idx);
 FileIDs[I] = LineTable.getLineTableFilenameID(Filename);
   }
+  ++Idx;
 
   // Parse the line entries
   std::vector Entries;
@@ -1074,7 +1075,7 @@ bool ASTReader::ParseLineTable(ModuleFil
 
 // Extract the line entries
 unsigned NumEntries = Record[Idx++];
-assert(NumEntries && "Numentries is 0");
+assert(NumEntries && "no line entries for file ID");
 Entries.clear();
 Entries.reserve(NumEntries);
 for (unsigned I = 0; I != NumEntries; ++I) {

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=246534&r1=246533&r2=246534&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Sep  1 02:41:55 2015
@@ -1981,10 +1981,19 @@ void ASTWriter::WriteSourceManagerBlock(
 LineTableInfo &LineTable = SourceMgr.getLineTable();
 
 Record.clear();
-// Emit the file names.
-Record.push_back(LineTable.getNumFilenames());
-for (unsigned I = 0, N = LineTable.getNumFilenames(); I != N; ++I)
-  AddPath(LineTable.getFilename(I), Record);
+
+// Emit the needed file names.
+llvm::DenseMap FilenameMap;
+for (const auto &L : LineTable) {
+  if (L.first.ID < 0)
+continue;
+  for (auto &LE : L.second) {
+if (FilenameMap.insert(std::make_pair(LE.FilenameID,
+  FilenameMap.size())).second)
+  AddPath(LineTable.getFilename(LE.FilenameID), Record);
+  }
+}
+Record.push_back(0);
 
 // Emit the line entries
 for (LineTableInfo::iterator L = LineTable.begin(), LEnd = LineTable.end();
@@ -2003,11 +2012,12 @@ void ASTWriter::WriteSourceManagerBlock(
LE != LEEnd; ++LE) {
 Record.push_back(LE->FileOffset);
 Record.push_back(LE->LineNo);
-Record.push_back(LE->FilenameID);
+Record.push_back(FilenameMap[LE->FilenameID]);
 Record.push_back((unsigned)LE->FileKind);
 Record.push_back(LE->IncludeOffset);
   }
 }
+
 Stream.EmitRecord(SOURCE_MANAGER_LINE_TABLE, Record);
   }
 }


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


Re: r246534 - [modules] When emitting line tables, only emit filenames that are actually referenced by the entries that we emit.

2015-09-01 Thread Yaron Keren via cfe-commits
Hi Richard,

Since yesterday I see several clang test failures which *may* be related to
the series of patches of modules you comitted. These are:
 Clang :: Modules/cxx-templates.cpp
 Clang :: Modules/submodules-merge-defs.cpp
 Clang :: PCH/cxx-key-functions.cpp
 Clang :: PCH/cxx-templates.cpp

(failing as of r246534)

You can see these failing on clang-x64-ninja-win7 bot but you did not get
e-mail since it was masked by other test failing before them:

http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/4522

or on Takumi bot:

http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/2923

The bots do not seem to printout details, so here is debug stack dump with
symbols for the three tests failing. The fourth one prints huge AST.

Could you have a look?


  FAIL: Clang :: Modules/cxx-templates.cpp (4128 of 23311)
    TEST 'Clang :: Modules/cxx-templates.cpp' FAILED

   Script:
   --
   rm -rf
C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
   not C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1
-internal-isystem C:\llvm-clean\msvc\RELWITHDEB
   INFO\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
-fmodules -fimplicit-module-maps -fno-modules-error-recov
   ery
-fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
-I C:\
   llvm-clean\tools\clang\test\Modules/Inputs
C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -std=c++11 -ast
   -dump-lookups | C:/llvm-clean/msvc/RELWITHDEBINFO/bin\FileCheck.EXE
C:\llvm-clean\tools\clang\test\Modul
   es\cxx-templates.cpp --check-prefix=CHECK-GLOBAL
   not C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1
-internal-isystem C:\llvm-clean\msvc\RELWITHDEB
   INFO\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
-fmodules -fimplicit-module-maps -fno-modules-error-recov
   ery
-fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
-I C:\
   llvm-clean\tools\clang\test\Modules/Inputs
C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -std=c++11 -ast
   -dump-lookups -ast-dump-filter N |
C:/llvm-clean/msvc/RELWITHDEBINFO/bin\FileCheck.EXE C:\llvm-clean\too
   ls\clang\test\Modules\cxx-templates.cpp --check-prefix=CHECK-NAMESPACE-N
   not C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1
-internal-isystem C:\llvm-clean\msvc\RELWITHDEB
   INFO\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
-fmodules -fimplicit-module-maps -fno-modules-error-recov
   ery
-fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
-I C:\
   llvm-clean\tools\clang\test\Modules/Inputs
C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -std=c++11 -ast
   -dump -ast-dump-filter SomeTemplate |
C:/llvm-clean/msvc/RELWITHDEBINFO/bin\FileCheck.EXE C:\llvm-clean\
   tools\clang\test\Modules\cxx-templates.cpp --check-prefix=CHECK-DUMP
   C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1 -internal-isystem
C:\llvm-clean\msvc\RELWITHDEBINFO
   \bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
-fmodules -fimplicit-module-maps -fno-modules-error-recovery

 
-fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
-I C:\llvm
   -clean\tools\clang\test\Modules/Inputs
C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -verify -std=c++11
   C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1 -internal-isystem
C:\llvm-clean\msvc\RELWITHDEBINFO
   \bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
-fmodules -fimplicit-module-maps -fno-modules-error-recovery

 
-fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
-I C:\llvm
   -clean\tools\clang\test\Modules/Inputs
C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -verify -std=c++11
   -DEARLY_IMPORT
   --
   Exit Code: 2

   Command Output (stdout):
   --
   Command 0: "rm" "-rf"
"C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp"
   Command 0 Result: 0
   Command 0 Output:


   Command 0 Stderr:


   Command 1: "not" "C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE"
"-cc1" "-internal-isystem" "C:\llvm-c
   lean\msvc\RELWITHDEBINFO\bin\..\lib\clang\3.8.0\include"
"-nostdsysteminc" "-x" "objective-c++" "-fmodules" "-fimplicit-module
   -maps" "-fno-modules-error-recovery"
"-fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-t
   emplates.cpp.tmp" "-I" "C:\llvm-clean\tools\clang\test\Modules/Inputs"
"C:\llvm-clean\tools\clang\test\M
   odules\cxx-templates.cpp" "-std=c++11" "-ast-dump-lookups"
   Command 1 Result: 1
   Command 1 Output:


   Command 1 Stderr:
   0x000140F97571 (0x0358BCC0 0x0358B969
0x0358B920 0x05F6E52F), llvm::OnDiskChainedHashTable

 ::find_hashed()
+ 0x41 bytes(s), c:\llvm-clean\include
   \llvm\support\ondiskhashtable.h, line 330 + 0x

Re: r246534 - [modules] When emitting line tables, only emit filenames that are actually referenced by the entries that we emit.

2015-09-01 Thread NAKAMURA Takumi via cfe-commits
FYI,

MultiOnDiskHashTable.h:108   delete T;
It is crashing.

Modules/cxx-templates.cpp can fail if target is i686-pc-win32.

On Tue, Sep 1, 2015 at 5:09 PM Yaron Keren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Richard,
>
> Since yesterday I see several clang test failures which *may* be related
> to the series of patches of modules you comitted. These are:
>  Clang :: Modules/cxx-templates.cpp
>  Clang :: Modules/submodules-merge-defs.cpp
>  Clang :: PCH/cxx-key-functions.cpp
>  Clang :: PCH/cxx-templates.cpp
>
> (failing as of r246534)
>
> You can see these failing on clang-x64-ninja-win7 bot but you did not get
> e-mail since it was masked by other test failing before them:
>
> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/4522
>
> or on Takumi bot:
>
> http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/2923
>
> The bots do not seem to printout details, so here is debug stack dump with
> symbols for the three tests failing. The fourth one prints huge AST.
>
> Could you have a look?
>
>
>   FAIL: Clang :: Modules/cxx-templates.cpp (4128 of 23311)
> TEST 'Clang :: Modules/cxx-templates.cpp' FAILED
> 
>Script:
>--
>rm -rf
> C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
>not C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1
> -internal-isystem C:\llvm-clean\msvc\RELWITHDEB
>INFO\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
> -fmodules -fimplicit-module-maps -fno-modules-error-recov
>ery
> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
> -I C:\
>llvm-clean\tools\clang\test\Modules/Inputs
> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -std=c++11 -ast
>-dump-lookups | C:/llvm-clean/msvc/RELWITHDEBINFO/bin\FileCheck.EXE
> C:\llvm-clean\tools\clang\test\Modul
>es\cxx-templates.cpp --check-prefix=CHECK-GLOBAL
>not C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1
> -internal-isystem C:\llvm-clean\msvc\RELWITHDEB
>INFO\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
> -fmodules -fimplicit-module-maps -fno-modules-error-recov
>ery
> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
> -I C:\
>llvm-clean\tools\clang\test\Modules/Inputs
> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -std=c++11 -ast
>-dump-lookups -ast-dump-filter N |
> C:/llvm-clean/msvc/RELWITHDEBINFO/bin\FileCheck.EXE C:\llvm-clean\too
>ls\clang\test\Modules\cxx-templates.cpp --check-prefix=CHECK-NAMESPACE-N
>not C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1
> -internal-isystem C:\llvm-clean\msvc\RELWITHDEB
>INFO\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
> -fmodules -fimplicit-module-maps -fno-modules-error-recov
>ery
> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
> -I C:\
>llvm-clean\tools\clang\test\Modules/Inputs
> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -std=c++11 -ast
>-dump -ast-dump-filter SomeTemplate |
> C:/llvm-clean/msvc/RELWITHDEBINFO/bin\FileCheck.EXE C:\llvm-clean\
>tools\clang\test\Modules\cxx-templates.cpp --check-prefix=CHECK-DUMP
>C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1 -internal-isystem
> C:\llvm-clean\msvc\RELWITHDEBINFO
>\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
> -fmodules -fimplicit-module-maps -fno-modules-error-recovery
>
>  
> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
> -I C:\llvm
>-clean\tools\clang\test\Modules/Inputs
> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -verify -std=c++11
>C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1 -internal-isystem
> C:\llvm-clean\msvc\RELWITHDEBINFO
>\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
> -fmodules -fimplicit-module-maps -fno-modules-error-recovery
>
>  
> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
> -I C:\llvm
>-clean\tools\clang\test\Modules/Inputs
> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -verify -std=c++11
>-DEARLY_IMPORT
>--
>Exit Code: 2
>
>Command Output (stdout):
>--
>Command 0: "rm" "-rf"
> "C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp"
>Command 0 Result: 0
>Command 0 Output:
>
>
>Command 0 Stderr:
>
>
>Command 1: "not" "C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE"
> "-cc1" "-internal-isystem" "C:\llvm-c
>lean\msvc\RELWITHDEBINFO\bin\..\lib\clang\3.8.0\include"
> "-nostdsysteminc" "-x" "objective-c++" "-fmodules" "-fimplicit-module
>-maps" "-fno-modules-error-recovery"
> "-fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-t
>emplates.cpp.tmp" "-I" "C:\llvm-clean\

Re: r246497 - [modules] Rework serialized DeclContext lookup table management. Instead of

2015-09-01 Thread İsmail Dönmez via cfe-commits
Hi,

On Tue, Sep 1, 2015 at 1:17 AM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Mon Aug 31 17:17:11 2015
> New Revision: 246497
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246497&view=rev
> Log:
> [modules] Rework serialized DeclContext lookup table management. Instead of
> walking the loaded ModuleFiles looking for lookup tables for the context, 
> store
> them all in one place, and merge them together if we find we have too many
> (currently, more than 4). If we do merge, include the merged form in our
> serialized lookup table, so that downstream readers never need to look at our
> imports' tables.
>
> This gives a huge performance improvement to builds with very large numbers of
> modules (in some cases, more than a 2x speedup was observed).
>
> Added:
> cfe/trunk/lib/Serialization/MultiOnDiskHashTable.h

This doesn't seem to compile with VS2015:

FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP
/DWIN32 /D_WINDOWS   -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
-wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503
-wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610
-wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389
-wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4324 -w14062 -we4238 /W4
/Zc:inline /Zc:sizedDealloc- /MT /O2 /Ob2
-Itools\clang\lib\Serialization -I..\tools\clang\lib\Serialization
-I..\tools\clang\include -Itools\clang\include -Iinclude -I..\include
  -UNDEBUG  /EHs-c- /GR- /showIncludes -DCLANG_ENABLE_ARCMT
-DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER
-DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
/Fotools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\ASTReader.cpp.obj
/Fdtools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\
/FS -c ..\tools\clang\lib\Serialization\ASTReader.cpp
c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
error C2065: 'Files': undeclared identifier
c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(111):
note: while compiling class template member function 'void
clang::serialization::MultiOnDiskHashTable::removeOverriddenTables(void)'
c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(243):
note: see reference to function template instantiation 'void
clang::serialization::MultiOnDiskHashTable::removeOverriddenTables(void)'
being compiled
c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\ASTReaderInternals.h(114):
note: see reference to class template instantiation
'clang::serialization::MultiOnDiskHashTable'
being compiled
c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
error C2228: left of '.count' must have class/struct/union
c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
note: type is 'unknown-type'
ninja: build stopped: subcommand failed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11361: [OpenMP] Target directive host codegen

2015-09-01 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Seems good to me, but it would be good if John McCall could look at the patch.


http://reviews.llvm.org/D11361



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


Re: [PATCH] D12512: [libcxxabi] Manually align pointers in __cxa_allocate_exception - Fixes PR24604

2015-09-01 Thread Joerg Sonnenberger via cfe-commits
joerg added a subscriber: joerg.
joerg requested changes to this revision.
joerg added a reviewer: joerg.
joerg added a comment.
This revision now requires changes to proceed.

Please don't commit this as is. Many platforms have posix_memalign or 
equivalent, which makes this both simpler and potentially without wasting 
memory. Compare e.g. http://reviews.llvm.org/D12001.


http://reviews.llvm.org/D12512



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


Re: [PATCH] D12148: [ARM] Allow passing/returning of __fp16 arguments

2015-09-01 Thread Oliver Stannard via cfe-commits
olista01 added a comment.

Ping?


http://reviews.llvm.org/D12148



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


RE: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

2015-09-01 Thread Daniel Marjamäki via cfe-commits

Hello!

> The checker isn't currently path sensitive as it doesn't pay attention
> to control flow graphs or how pointer values flow through a function
> body. I suppose this is a matter of scope more than anything; I see a
> logical extension of this functionality being with local variables as
> well as parameters. So, for instance:
>
>void f(int *p) {
>  int *i = p;
>  std::cout << *i;
>}

Imho that path analysis is not very interesting. The "p" can't be const until 
we see that "i" is const.

> This is true, for the current design of the patch, static analysis is
> less useful because the path sensitivity doesn't matter. But that also
> suggests if we wanted to add such a thing to the static analyzer
> someday, we'd have two ways of getting the same information if we
> stuck this in the frontend. It seems more logical to me to set this up
> as a static analysis checker so that we can extend it to be path
> sensitive under the same flag.

I wish we would have had this discussion earlier. Now I am not eager to rewrite 
it. for information this design has passed dev without comments:
http://lists.llvm.org/pipermail/cfe-dev/2015-August/044547.html

do you want that Wunused-parameter is moved from the frontend too? otherwise 
there will be similar path-sensitive analysis in the frontend anyway.

if we talk about the user interface.. imho it would be nice that this is a 
compiler warning. the analysis is quick and there should be little noise.

> Btw, since I forgot to mention it before, I think this is a great idea
> in general, thank you for working on it! :-)

Thanks! This is appreciated.

Best regards,
Daniel Marjamäki

..
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile: +46 (0)709 12 42 62
E-mail: daniel.marjam...@evidente.se

www.evidente.se


Från: Aaron Ballman [aaron.ball...@gmail.com]
Skickat: den 31 augusti 2015 21:20
Till: reviews+d12359+public+799c9f67cbbb7...@reviews.llvm.org
Kopia: Daniel Marjamäki; stephan.bergmann.second...@googlemail.com; cfe-commits
Ämne: Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer 
parameter can be const

On Mon, Aug 31, 2015 at 2:58 PM, Daniel Marjamäki
 wrote:
> danielmarjamaki added a comment.
>
> In http://reviews.llvm.org/D12359#236334, @aaron.ballman wrote:
>
>> I have concerns about this being a frontend warning. The true positive rate 
>> seems rather high given the benign nature of the diagnostic, and the false 
>> negative rate is quite high. This seems like it would make more sense as a 
>> path-sensitive static analyzer warning instead of a frontend warning, as 
>> that would justify the slightly high true positive rate, and rectify quite a 
>> bit of the false negative rate.
>
>
> I don't understand. The checker is path sensitive, isn't it? Do you see some 
> problem that I don't?

> The checker isn't currently path sensitive as it doesn't pay attention
> to control flow graphs or how pointer values flow through a function
> body. I suppose this is a matter of scope more than anything; I see a
> logical extension of this functionality being with local variables as
> well as parameters. So, for instance:

void f(int *p) {
  int *i = p;
  std::cout << *i;
}

I think code like the above should tell the user that both p and i can be const.

> It will warn if there is no write anywhere in the function. Except as I 
> wrote, for some cases where #ifdef is used, but moving it to static analysis 
> won't help.

This is true, for the current design of the patch, static analysis is
less useful because the path sensitivity doesn't matter. But that also
suggests if we wanted to add such a thing to the static analyzer
someday, we'd have two ways of getting the same information if we
stuck this in the frontend. It seems more logical to me to set this up
as a static analysis checker so that we can extend it to be path
sensitive under the same flag.

>
>> Have you tried running this over the Clang and LLVM code bases? How many 
>> diagnostics does it produce?
>
>
> Not yet. I'll do that.
>
>
> 
> Comment at: test/Sema/warn-nonconst-parameter.c:8
> @@ +7,3 @@
> +//
> +// It does not warn about pointers to records or function pointers.
> +
> 
> aaron.ballman wrote:
>> How does it handle cases like:
>>
>> void g(int);
>> void f(volatile int *p) {
>>   int j = *p; // Should not warn
>>   int i = p[0]; // Should not warn
>>   g(*p); // Should not warn
>> }
>>
>> void h(int *p) {
>>   int i = p ? *p : 0; // Should warn
>> }
>>
> ok interesting. I have never seen a volatile pointer argument before. but 
> technically I believe we should warn about f(). the function only reads p. 
> maybe for stylistic reasons it would look weird to say that it's both 
> volatile and const, is that why w

Re: [PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-09-01 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 33678.
andreybokhanko added a comment.

Reid, thanks for looking into this!

As I discovered, MS compiler transforms __stdcall to __thiscall for all 
structors (not only virtual ones) in 32 bit mode. In 64 bit mode, it transforms 
__stdcall to __cdecl for everything.

Clang already does the same in 64 bit mode; my updated patch makes us transform 
__stdcall to __thiscall for structors in 32 bit mode in MSVC environment.

Please re-review.

Yours,
Andrey


http://reviews.llvm.org/D12402

Files:
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp

Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -2269,8 +2269,11 @@
 
   // Adjust the default free function calling convention to the default method
   // calling convention.
+  bool is_ctor_or_dtor =
+  (Entity.getNameKind() == DeclarationName::CXXConstructorName) ||
+  (Entity.getNameKind() == DeclarationName::CXXDestructorName);
   if (T->isFunctionType())
-adjustMemberFunctionCC(T, /*IsStatic=*/false);
+adjustMemberFunctionCC(T, /*IsStatic=*/false, is_ctor_or_dtor);
 
   return Context.getMemberPointerType(T, Class.getTypePtr());
 }
@@ -5842,24 +5845,35 @@
   return false;
 }
 
-void Sema::adjustMemberFunctionCC(QualType &T, bool IsStatic) {
+void Sema::adjustMemberFunctionCC(QualType &T, bool IsStatic,
+  bool IsCtorOrDtor) {
   FunctionTypeUnwrapper Unwrapped(*this, T);
   const FunctionType *FT = Unwrapped.get();
   bool IsVariadic = (isa(FT) &&
  cast(FT)->isVariadic());
-
-  // Only adjust types with the default convention.  For example, on Windows we
-  // should adjust a __cdecl type to __thiscall for instance methods, and a
-  // __thiscall type to __cdecl for static methods.
   CallingConv CurCC = FT->getCallConv();
-  CallingConv FromCC =
-  Context.getDefaultCallingConvention(IsVariadic, IsStatic);
-  CallingConv ToCC = Context.getDefaultCallingConvention(IsVariadic, !IsStatic);
-  if (CurCC != FromCC || FromCC == ToCC)
-return;
+  CallingConv ToCC;
 
-  if (hasExplicitCallingConv(T))
-return;
+  // MS compiler transforms __stdcall in ctors/dtors to __thiscall in 32 bit
+  // mode. We should do the same.
+  if ((CurCC == CC_X86StdCall) && IsCtorOrDtor &&
+  (Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment() &&
+   Context.getTargetInfo().getTriple().isArch32Bit()))
+ToCC = CC_X86ThisCall;
+  // Default adjustment.
+  else {
+// Only adjust types with the default convention.  For example, on Windows
+// we should adjust a __cdecl type to __thiscall for instance methods, and a
+// __thiscall type to __cdecl for static methods.
+CallingConv FromCC =
+Context.getDefaultCallingConvention(IsVariadic, IsStatic);
+ToCC = Context.getDefaultCallingConvention(IsVariadic, !IsStatic);
+if (CurCC != FromCC || FromCC == ToCC)
+  return;
+
+if (hasExplicitCallingConv(T))
+  return;
+  }
 
   FT = Context.adjustFunctionType(FT, FT->getExtInfo().withCallingConv(ToCC));
   QualType Wrapped = Unwrapped.wrap(*this, FT);
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -351,6 +351,11 @@
   getName().OperatorFunctionId.Operator));
 }
 
+bool Declarator::isCtorOrDtor() {
+  return (getName().getKind() == UnqualifiedId::IK_ConstructorName) ||
+ (getName().getKind() == UnqualifiedId::IK_DestructorName);
+}
+
 bool DeclSpec::hasTagDefinition() const {
   if (!TypeSpecOwned)
 return false;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7219,7 +7219,7 @@
   << DeclSpec::getSpecifierName(TSCS);
 
   if (D.isFirstDeclarationOfMember())
-adjustMemberFunctionCC(R, D.isStaticMember());
+adjustMemberFunctionCC( R, D.isStaticMember(), D.isCtorOrDtor());
 
   bool isFriend = false;
   FunctionTemplateDecl *FunctionTemplate = nullptr;
Index: include/clang/Sema/DeclSpec.h
===
--- include/clang/Sema/DeclSpec.h
+++ include/clang/Sema/DeclSpec.h
@@ -2208,6 +2208,9 @@
   /// redeclaration time if the decl is static.
   bool isStaticMember();
 
+  /// Returns true if this declares a constructor or a destructor.
+  bool isCtorOrDtor();
+
   void setRedeclaration(bool Val) { Redeclaration = Val; }
   bool isRedeclaration() const { return Redeclaration; }
 };
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -2915,7 +2915,7 @@
   /// Adjust the calling convention o

Re: r246497 - [modules] Rework serialized DeclContext lookup table management. Instead of

2015-09-01 Thread Rafael Espíndola via cfe-commits
Any chance this is what caused the following leak?

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/8340/steps/check-clang%20asan/logs/stdio

Cheers,
Rafael


On 31 August 2015 at 18:17, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Mon Aug 31 17:17:11 2015
> New Revision: 246497
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246497&view=rev
> Log:
> [modules] Rework serialized DeclContext lookup table management. Instead of
> walking the loaded ModuleFiles looking for lookup tables for the context, 
> store
> them all in one place, and merge them together if we find we have too many
> (currently, more than 4). If we do merge, include the merged form in our
> serialized lookup table, so that downstream readers never need to look at our
> imports' tables.
>
> This gives a huge performance improvement to builds with very large numbers of
> modules (in some cases, more than a 2x speedup was observed).
>
> Added:
> cfe/trunk/lib/Serialization/MultiOnDiskHashTable.h
> Modified:
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/include/clang/Serialization/ASTWriter.h
> cfe/trunk/include/clang/Serialization/Module.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTReaderInternals.h
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> cfe/trunk/lib/Serialization/Module.cpp
> cfe/trunk/test/Modules/cxx-templates.cpp
> cfe/trunk/test/Modules/merge-using-decls.cpp
>
> Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=246497&r1=246496&r2=246497&view=diff
> ==
> --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Mon Aug 31 17:17:11 
> 2015
> @@ -1530,4 +1530,23 @@ namespace clang {
>}
>  } // end namespace clang
>
> +namespace llvm {
> +  template <> struct DenseMapInfo {
> +static clang::serialization::DeclarationNameKey getEmptyKey() {
> +  return clang::serialization::DeclarationNameKey(-1, 1);
> +}
> +static clang::serialization::DeclarationNameKey getTombstoneKey() {
> +  return clang::serialization::DeclarationNameKey(-1, 2);
> +}
> +static unsigned
> +getHashValue(const clang::serialization::DeclarationNameKey &Key) {
> +  return Key.getHash();
> +}
> +static bool isEqual(const clang::serialization::DeclarationNameKey &L,
> +const clang::serialization::DeclarationNameKey &R) {
> +  return L == R;
> +}
> +  };
> +}
> +
>  #endif
>
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=246497&r1=246496&r2=246497&view=diff
> ==
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Aug 31 17:17:11 2015
> @@ -282,9 +282,8 @@ class ReadMethodPoolVisitor;
>
>  namespace reader {
>class ASTIdentifierLookupTrait;
> -  /// \brief The on-disk hash table used for the DeclContext's Name lookup 
> table.
> -  typedef llvm::OnDiskIterableChainedHashTable
> -ASTDeclContextNameLookupTable;
> +  /// \brief The on-disk hash table(s) used for DeclContext name lookup.
> +  struct DeclContextLookupTable;
>  }
>
>  } // end namespace serialization
> @@ -507,6 +506,10 @@ private:
>/// \brief Map from the TU to its lexical contents from each module file.
>std::vector> TULexicalDecls;
>
> +  /// \brief Map from a DeclContext to its lookup tables.
> +  llvm::DenseMap + serialization::reader::DeclContextLookupTable> Lookups;
> +
>// Updates for visible decls can occur for other contexts than just the
>// TU, and when we read those update records, the actual context may not
>// be available yet, so have this pending map using the ID as a key. It
> @@ -514,7 +517,6 @@ private:
>struct PendingVisibleUpdate {
>  ModuleFile *Mod;
>  const unsigned char *Data;
> -unsigned BucketOffset;
>};
>typedef SmallVector DeclContextVisibleUpdates;
>
> @@ -1089,6 +1091,10 @@ public:
>  Visit(GetExistingDecl(ID));
>}
>
> +  /// \brief Get the loaded lookup tables for \p Primary, if any.
> +  const serialization::reader::DeclContextLookupTable *
> +  getLoadedLookupTables(DeclContext *Primary) const;
> +
>  private:
>struct ImportedModule {
>  ModuleFile *Mod;
> @@ -1870,6 +1876,13 @@ public:
>/// Note: overrides method in ExternalASTSource
>Module *getModule(unsigned ID) override;
>
> +  /// \brief 

Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer parameter can be const

2015-09-01 Thread Aaron Ballman via cfe-commits
On Tue, Sep 1, 2015 at 8:15 AM, Daniel Marjamäki
 wrote:
>
> Hello!
>
>> The checker isn't currently path sensitive as it doesn't pay attention
>> to control flow graphs or how pointer values flow through a function
>> body. I suppose this is a matter of scope more than anything; I see a
>> logical extension of this functionality being with local variables as
>> well as parameters. So, for instance:
>>
>>void f(int *p) {
>>  int *i = p;
>>  std::cout << *i;
>>}
>
> Imho that path analysis is not very interesting. The "p" can't be const until 
> we see that "i" is const.

Correct, but from the user's perspective, why are we not telling them
both can be const?

>> This is true, for the current design of the patch, static analysis is
>> less useful because the path sensitivity doesn't matter. But that also
>> suggests if we wanted to add such a thing to the static analyzer
>> someday, we'd have two ways of getting the same information if we
>> stuck this in the frontend. It seems more logical to me to set this up
>> as a static analysis checker so that we can extend it to be path
>> sensitive under the same flag.
>
> I wish we would have had this discussion earlier. Now I am not eager to 
> rewrite it. for information this design has passed dev without comments:
> http://lists.llvm.org/pipermail/cfe-dev/2015-August/044547.html

I'm very sorry I didn't see this thread until now. :-( I'm adding
Richard for his thoughts on the subject as well.

> do you want that Wunused-parameter is moved from the frontend too? otherwise 
> there will be similar path-sensitive analysis in the frontend anyway.

I think that's a different beast entirely.

void f(int *p) {
  int *i = p; // is p really considered unused just because i is unused?
}

> if we talk about the user interface.. imho it would be nice that this is a 
> compiler warning. the analysis is quick and there should be little noise.

I'm not certain about the performance of the analysis (I suspect it's
relatively cheap though), but we do not usually want off-by-default
warnings in the frontend, and I suspect that this analysis would have
to be off by default due to the chattiness on well-formed code.

Btw, since this doesn't require inter-procedural analysis, I think
this most likely sits in clangAnalysis instead of
clangStaticAnalyzerCheckers. So it would behave much like our
reachable code warnings.

~Aaron

>
>> Btw, since I forgot to mention it before, I think this is a great idea
>> in general, thank you for working on it! :-)
>
> Thanks! This is appreciated.
>
> Best regards,
> Daniel Marjamäki
>
> ..
> Daniel Marjamäki Senior Engineer
> Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden
>
> Mobile: +46 (0)709 12 42 62
> E-mail: daniel.marjam...@evidente.se
>
> www.evidente.se
>
> 
> Från: Aaron Ballman [aaron.ball...@gmail.com]
> Skickat: den 31 augusti 2015 21:20
> Till: reviews+d12359+public+799c9f67cbbb7...@reviews.llvm.org
> Kopia: Daniel Marjamäki; stephan.bergmann.second...@googlemail.com; 
> cfe-commits
> Ämne: Re: [PATCH] D12359: New warning -Wnonconst-parameter when a pointer 
> parameter can be const
>
> On Mon, Aug 31, 2015 at 2:58 PM, Daniel Marjamäki
>  wrote:
>> danielmarjamaki added a comment.
>>
>> In http://reviews.llvm.org/D12359#236334, @aaron.ballman wrote:
>>
>>> I have concerns about this being a frontend warning. The true positive rate 
>>> seems rather high given the benign nature of the diagnostic, and the false 
>>> negative rate is quite high. This seems like it would make more sense as a 
>>> path-sensitive static analyzer warning instead of a frontend warning, as 
>>> that would justify the slightly high true positive rate, and rectify quite 
>>> a bit of the false negative rate.
>>
>>
>> I don't understand. The checker is path sensitive, isn't it? Do you see some 
>> problem that I don't?
>
>> The checker isn't currently path sensitive as it doesn't pay attention
>> to control flow graphs or how pointer values flow through a function
>> body. I suppose this is a matter of scope more than anything; I see a
>> logical extension of this functionality being with local variables as
>> well as parameters. So, for instance:
>
> void f(int *p) {
>   int *i = p;
>   std::cout << *i;
> }
>
> I think code like the above should tell the user that both p and i can be 
> const.
>
>> It will warn if there is no write anywhere in the function. Except as I 
>> wrote, for some cases where #ifdef is used, but moving it to static analysis 
>> won't help.
>
> This is true, for the current design of the patch, static analysis is
> less useful because the path sensitivity doesn't matter. But that also
> suggests if we wanted to add such a thing to the static analyzer
> someday, we'd have two ways of getting the same information if we
> stuck this in the 

Re: r246497 - [modules] Rework serialized DeclContext lookup table management. Instead of

2015-09-01 Thread Aaron Ballman via cfe-commits
On Tue, Sep 1, 2015 at 4:43 AM, İsmail Dönmez
 wrote:
> Hi,
>
> On Tue, Sep 1, 2015 at 1:17 AM, Richard Smith via cfe-commits
>  wrote:
>> Author: rsmith
>> Date: Mon Aug 31 17:17:11 2015
>> New Revision: 246497
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246497&view=rev
>> Log:
>> [modules] Rework serialized DeclContext lookup table management. Instead of
>> walking the loaded ModuleFiles looking for lookup tables for the context, 
>> store
>> them all in one place, and merge them together if we find we have too many
>> (currently, more than 4). If we do merge, include the merged form in our
>> serialized lookup table, so that downstream readers never need to look at our
>> imports' tables.
>>
>> This gives a huge performance improvement to builds with very large numbers 
>> of
>> modules (in some cases, more than a 2x speedup was observed).
>>
>> Added:
>> cfe/trunk/lib/Serialization/MultiOnDiskHashTable.h
>
> This doesn't seem to compile with VS2015:
>
> FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP
> /DWIN32 /D_WINDOWS   -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
> -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503
> -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610
> -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389
> -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4324 -w14062 -we4238 /W4
> /Zc:inline /Zc:sizedDealloc- /MT /O2 /Ob2
> -Itools\clang\lib\Serialization -I..\tools\clang\lib\Serialization
> -I..\tools\clang\include -Itools\clang\include -Iinclude -I..\include
>   -UNDEBUG  /EHs-c- /GR- /showIncludes -DCLANG_ENABLE_ARCMT
> -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER
> -DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE
> -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
> -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> /Fotools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\ASTReader.cpp.obj
> /Fdtools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\
> /FS -c ..\tools\clang\lib\Serialization\ASTReader.cpp
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
> error C2065: 'Files': undeclared identifier
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(111):
> note: while compiling class template member function 'void
> clang::serialization::MultiOnDiskHashTable::removeOverriddenTables(void)'
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(243):
> note: see reference to function template instantiation 'void
> clang::serialization::MultiOnDiskHashTable::removeOverriddenTables(void)'
> being compiled
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\ASTReaderInternals.h(114):
> note: see reference to class template instantiation
> 'clang::serialization::MultiOnDiskHashTable'
> being compiled
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
> error C2228: left of '.count' must have class/struct/union
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
> note: type is 'unknown-type'
> ninja: build stopped: subcommand failed.

I have reverted r246497 (which required also reverting r246524 and
r246521 to avoid merge conflicts) to get back to green. Commit was
r246546.

I'm not certain why MSVC is falling over on this code, but I suspect
compiler bug. If anyone has a reduced testcase (which I may spend some
time on if I have a moment), I would be happy to report it to
Microsoft.

~Aaron

> ___
> 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


r246546 - Reverting r246497 (which requires also reverting r246524 and r246521 to avoid merge conflicts). It broke the build on MSVC 2015. It also broke an MSVC 2013 bot with testing issues.

2015-09-01 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Sep  1 08:24:39 2015
New Revision: 246546

URL: http://llvm.org/viewvc/llvm-project?rev=246546&view=rev
Log:
Reverting r246497 (which requires also reverting r246524 and r246521 to avoid 
merge conflicts). It broke the build on MSVC 2015. It also broke an MSVC 2013 
bot with testing issues.

llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
error C2065: 'Files': undeclared identifier

http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/2917

Removed:
cfe/trunk/lib/Serialization/MultiOnDiskHashTable.h
Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderInternals.h
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/lib/Serialization/Module.cpp
cfe/trunk/test/Modules/cxx-templates.cpp
cfe/trunk/test/Modules/merge-using-decls.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=246546&r1=246545&r2=246546&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Tue Sep  1 08:24:39 2015
@@ -1530,23 +1530,4 @@ namespace clang {
   }
 } // end namespace clang
 
-namespace llvm {
-  template <> struct DenseMapInfo {
-static clang::serialization::DeclarationNameKey getEmptyKey() {
-  return clang::serialization::DeclarationNameKey(-1, 1);
-}
-static clang::serialization::DeclarationNameKey getTombstoneKey() {
-  return clang::serialization::DeclarationNameKey(-1, 2);
-}
-static unsigned
-getHashValue(const clang::serialization::DeclarationNameKey &Key) {
-  return Key.getHash();
-}
-static bool isEqual(const clang::serialization::DeclarationNameKey &L,
-const clang::serialization::DeclarationNameKey &R) {
-  return L == R;
-}
-  };
-}
-
 #endif

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=246546&r1=246545&r2=246546&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Sep  1 08:24:39 2015
@@ -282,8 +282,9 @@ class ReadMethodPoolVisitor;
 
 namespace reader {
   class ASTIdentifierLookupTrait;
-  /// \brief The on-disk hash table(s) used for DeclContext name lookup.
-  struct DeclContextLookupTable;
+  /// \brief The on-disk hash table used for the DeclContext's Name lookup 
table.
+  typedef llvm::OnDiskIterableChainedHashTable
+ASTDeclContextNameLookupTable;
 }
 
 } // end namespace serialization
@@ -506,10 +507,6 @@ private:
   /// \brief Map from the TU to its lexical contents from each module file.
   std::vector> TULexicalDecls;
 
-  /// \brief Map from a DeclContext to its lookup tables.
-  llvm::DenseMap Lookups;
-
   // Updates for visible decls can occur for other contexts than just the
   // TU, and when we read those update records, the actual context may not
   // be available yet, so have this pending map using the ID as a key. It
@@ -517,6 +514,7 @@ private:
   struct PendingVisibleUpdate {
 ModuleFile *Mod;
 const unsigned char *Data;
+unsigned BucketOffset;
   };
   typedef SmallVector DeclContextVisibleUpdates;
 
@@ -1091,10 +1089,6 @@ public:
 Visit(GetExistingDecl(ID));
   }
 
-  /// \brief Get the loaded lookup tables for \p Primary, if any.
-  const serialization::reader::DeclContextLookupTable *
-  getLoadedLookupTables(DeclContext *Primary) const;
-
 private:
   struct ImportedModule {
 ModuleFile *Mod;
@@ -1876,13 +1870,6 @@ public:
   /// Note: overrides method in ExternalASTSource
   Module *getModule(unsigned ID) override;
 
-  /// \brief Retrieve the module file with a given local ID within the 
specified
-  /// ModuleFile.
-  ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID);
-
-  /// \brief Get an ID for the given module file.
-  unsigned getModuleFileID(ModuleFile *M);
-
   /// \brief Return a descriptor for the corresponding module.
   llvm::Optional getSourceDescriptor(unsigned ID) 
override;
   /// \brief Return a descriptor for the module.

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=246546&r1=246545&r2=246546&view=diff
==
--- cfe/trunk

Re: [PATCH] D12148: [ARM] Allow passing/returning of __fp16 arguments

2015-09-01 Thread James Molloy via cfe-commits
jmolloy added a comment.

This looks alright to me, but I'd like to wait for someone more familiar with 
Clang to approve it.


http://reviews.llvm.org/D12148



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


[PATCH] D12530: Fix several corner cases for loop-convert check.

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

Reduced the amount of wrong conversions of this check.

http://reviews.llvm.org/D12530

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertUtils.cpp
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp

Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -387,6 +387,14 @@
 
 namespace Nesting {
 
+void g(S::iterator it);
+void const_g(S::const_iterator it);
+class Foo {
+ public:
+  void g(S::iterator it);
+  void const_g(S::const_iterator it);
+};
+
 void f() {
   const int N = 10;
   const int M = 15;
@@ -454,6 +462,48 @@
   // CHECK-FIXES: for (const auto & elem : NestS) {
   // CHECK-FIXES-NEXT: for (S::const_iterator SI = (elem).begin(), SE = (elem).end(); SI != SE; ++SI) {
   // CHECK-FIXES-NEXT: printf("%d", *SI);
+
+  for (Nested::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
+const S &s = *I;
+for (S::const_iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) {
+  printf("%d", *SI);
+  const_g(SI);
+}
+  }
+  // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (const auto & s : NestS) {
+
+  for (Nested::iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
+S &s = *I;
+for (S::iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) {
+  printf("%d", *SI);
+  g(SI);
+}
+  }
+  // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & s : NestS) {
+
+  Foo foo;
+  for (Nested::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
+const S &s = *I;
+for (S::const_iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) {
+  printf("%d", *SI);
+  foo.const_g(SI);
+}
+  }
+  // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (const auto & s : NestS) {
+
+  for (Nested::iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
+S &s = *I;
+for (S::iterator SI = s.begin(), SE = s.end(); SI != SE; ++SI) {
+  printf("%d", *SI);
+  foo.g(SI);
+}
+  }
+  // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
+  // CHECK-FIXES: for (auto & s : NestS) {
+
 }
 
 } // namespace Nesting
Index: test/clang-tidy/modernize-loop-convert-basic.cpp
===
--- test/clang-tidy/modernize-loop-convert-basic.cpp
+++ test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -427,6 +427,27 @@
   }
 };
 
+void foo(S::iterator it) {}
+class Foo {public: void bar(S::iterator it); };
+
+void iterator_used() {
+  S s;
+  Foo fo;
+
+  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
+foo(it);
+  }
+
+  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
+fo.bar(it);
+  }
+
+  S::iterator ret;
+  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
+ret = it;
+  }
+}
+
 } // namespace Iterator
 
 namespace PseudoArray {
@@ -494,12 +515,12 @@
   for (auto i = 0; i < v.size(); ++i) {
   }
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : v) {
+  // CHECK-FIXES: for (const auto & elem : v) {
 
   for (auto i = 0; i < v.size(); ++i)
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : v)
+  // CHECK-FIXES: for (const auto & elem : v)
 }
 
 struct NoBeginEnd {
@@ -509,15 +530,15 @@
 struct NoConstBeginEnd {
   NoConstBeginEnd();
   unsigned size() const;
-  unsigned begin();
-  unsigned end();
+  unsigned* begin();
+  unsigned* end();
 };
 
 struct ConstBeginEnd {
   ConstBeginEnd();
   unsigned size() const;
-  unsigned begin() const;
-  unsigned end() const;
+  unsigned* begin() const;
+  unsigned* end() const;
 };
 
 // Shouldn't transform pseudo-array uses if the container doesn't provide
@@ -535,13 +556,32 @@
   for (unsigned i = 0, e = CBE.size(); i < e; ++i) {
   }
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : CBE) {
+  // CHECK-FIXES: for (const auto & elem : CBE) {
 
   const ConstBeginEnd const_CBE;
   for (unsigned i = 0, e = const_CBE.size(); i < e; ++i) {
   }
   // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
-  // CHECK-FIXES: for (auto & elem : const_CBE) {
+  // CHECK-FIXES: for (const auto & elem : const_CBE) {
+}
+
+struct DerefByValue {
+  DerefByValue();
+  struct iter { unsigned operator*(); };
+  unsigned size() const;
+  iter begin();
+  iter end();
+  unsigned operator[](int);
+};
+
+void DerefByValueTest() {
+ 

Re: [PATCH] D12530: Fix several corner cases for loop-convert check.

2015-09-01 Thread Manuel Klimek via cfe-commits
klimek added a comment.

Nice!



Comment at: clang-tidy/modernize/LoopConvertCheck.cpp:378
@@ +377,3 @@
+  for (const auto &U : Usages) {
+if (!U.E->isRValue())
+  return false;

(not necessarily in this CL) please rename E to Expression or similar; I'm fine 
with one-letter variables for small scopes, but struct scopes are basically 
infinite.


Comment at: test/clang-tidy/modernize-loop-convert-basic.cpp:437
@@ +436,3 @@
+
+  for (S::iterator it = s.begin(), e = s.end(); it != e; ++it) {
+foo(it);

Use LLVM coding conventions for iterators (I, E) as above.


Comment at: test/clang-tidy/modernize-loop-convert-basic.cpp:448
@@ +447,3 @@
+ret = it;
+  }
+}

This test seems to be missing the it.insert(0) case that was removed from the 
"unsupported"  comment, if I'm not missing something.


Comment at: test/clang-tidy/modernize-loop-convert-basic.cpp:540-541
@@ -518,4 +539,4 @@
   unsigned size() const;
-  unsigned begin() const;
-  unsigned end() const;
+  unsigned* begin() const;
+  unsigned* end() const;
 };

Isn't it important that it's a pointer to an unsigned const, not that the 
iterator method is const?


http://reviews.llvm.org/D12530



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


r246548 - Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.

2015-09-01 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Sep  1 09:49:24 2015
New Revision: 246548

URL: http://llvm.org/viewvc/llvm-project?rev=246548&view=rev
Log:
Add a new frontend warning for referencing members from the handler of a 
constructor or destructor function-try-block, which is UB in C++.

This corresponds to the CERT secure coding rule ERR53-CPP.

Added:
cfe/trunk/test/SemaCXX/cdtor-fn-try-block.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaObjCXX/delay-parsing-func-tryblock.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=246548&r1=246547&r2=246548&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep  1 09:49:24 
2015
@@ -5674,6 +5674,9 @@ def err_throw_incomplete_ptr : Error<
   "cannot throw pointer to object of incomplete type %0">;
 def err_return_in_constructor_handler : Error<
   "return in the catch of a function try block of a constructor is illegal">;
+def warn_cdtor_function_try_handler_mem_expr : Warning<
+  "cannot refer to a non-static member from the handler of a "
+  "%select{constructor|destructor}0 function try block">, InGroup;
 
 let CategoryName = "Lambda Issue" in {
   def err_capture_more_than_once : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=246548&r1=246547&r2=246548&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Sep  1 09:49:24 2015
@@ -3679,19 +3679,23 @@ public:
   ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
  SourceLocation TemplateKWLoc,
  LookupResult &R,
-const TemplateArgumentListInfo *TemplateArgs);
+const TemplateArgumentListInfo *TemplateArgs,
+ const Scope *S);
   ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS,
  SourceLocation TemplateKWLoc,
  LookupResult &R,
 const TemplateArgumentListInfo *TemplateArgs,
- bool IsDefiniteInstance);
+ bool IsDefiniteInstance,
+ const Scope *S);
   bool UseArgumentDependentLookup(const CXXScopeSpec &SS,
   const LookupResult &R,
   bool HasTrailingLParen);
 
-  ExprResult BuildQualifiedDeclarationNameExpr(
-  CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo,
-  bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr);
+  ExprResult
+  BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
+const DeclarationNameInfo &NameInfo,
+bool IsAddressOfOperand, const Scope *S,
+TypeSourceInfo **RecoveryTSI = nullptr);
 
   ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
SourceLocation TemplateKWLoc,
@@ -3808,6 +3812,7 @@ public:
   CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
   NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo,
   const TemplateArgumentListInfo *TemplateArgs,
+  const Scope *S,
   ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
 
   ExprResult
@@ -3816,6 +3821,7 @@ public:
SourceLocation TemplateKWLoc,
NamedDecl *FirstQualifierInScope, LookupResult &R,
const TemplateArgumentListInfo *TemplateArgs,
+   const Scope *S,
bool SuppressQualifierCheck = false,
ActOnMemberAccessExtraArgs *ExtraArgs = nullptr);
 

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=246548&r1=246547&r2=246548&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep  1 09:49:24 2015
@@ -1022,7 +1022,

Re: [PATCH] D12301: [PATCH] New checker for UB in handler of a function-try-block

2015-09-01 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thanks! I've made those changes and commit in r246548, along with an updated 
test case for ObjC++ that I had previously missed.


http://reviews.llvm.org/D12301



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


Re: [PATCH] D12530: Fix several corner cases for loop-convert check.

2015-09-01 Thread Angel Garcia via cfe-commits
angelgarcia marked 2 inline comments as done.


Comment at: test/clang-tidy/modernize-loop-convert-basic.cpp:448
@@ +447,3 @@
+ret = it;
+  }
+}

klimek wrote:
> This test seems to be missing the it.insert(0) case that was removed from the 
> "unsupported"  comment, if I'm not missing something.
It was in the test 'modernize-loop-convert-negative.cpp'. I moved these ones 
there as well.


Comment at: test/clang-tidy/modernize-loop-convert-basic.cpp:540-541
@@ -518,4 +539,4 @@
   unsigned size() const;
-  unsigned begin() const;
-  unsigned end() const;
+  unsigned* begin() const;
+  unsigned* end() const;
 };

klimek wrote:
> Isn't it important that it's a pointer to an unsigned const, not that the 
> iterator method is const?
The important thing is that the check now adds a "const" whenever it is safe to 
do it. I changed the return type to a pointer just to be more consistent with 
what an iterator is supposed to be. It isn't important at all in this case.


http://reviews.llvm.org/D12530



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


Re: [PATCH] D12530: Fix several corner cases for loop-convert check.

2015-09-01 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 33690.
angelgarcia added a comment.

Renamed Usage::E, moved some tests and other fixes.


http://reviews.llvm.org/D12530

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tidy/modernize/LoopConvertUtils.h
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-negative.cpp

Index: test/clang-tidy/modernize-loop-convert-negative.cpp
===
--- test/clang-tidy/modernize-loop-convert-negative.cpp
+++ test/clang-tidy/modernize-loop-convert-negative.cpp
@@ -3,91 +3,92 @@
 #include "structures.h"
 
 // CHECK-FIXES-NOT: for ({{.*[^:]:[^:].*}})
+// CHECK-MESSAGES-NOT: modernize-loop-convert
 
 namespace Negative {
 
 const int N = 6;
 int arr[N] = {1, 2, 3, 4, 5, 6};
 int (*pArr)[N] = &arr;
-int sum = 0;
+int Sum = 0;
 
-// Checks for the index start and end:
-void indexStartAndEnd() {
-  for (int i = 0; i < N + 1; ++i)
-sum += arr[i];
+// Checks for the Index start and end:
+void IndexStartAndEnd() {
+  for (int I = 0; I < N + 1; ++I)
+Sum += arr[I];
 
-  for (int i = 0; i < N - 1; ++i)
-sum += arr[i];
+  for (int I = 0; I < N - 1; ++I)
+Sum += arr[I];
 
-  for (int i = 1; i < N; ++i)
-sum += arr[i];
+  for (int I = 1; I < N; ++I)
+Sum += arr[I];
 
-  for (int i = 1; i < N; ++i)
-sum += arr[i];
+  for (int I = 1; I < N; ++I)
+Sum += arr[I];
 
-  for (int i = 0;; ++i)
-sum += (*pArr)[i];
+  for (int I = 0;; ++I)
+Sum += (*pArr)[I];
 }
 
 // Checks for invalid increment steps:
 void increment() {
-  for (int i = 0; i < N; --i)
-sum += arr[i];
+  for (int I = 0; I < N; --I)
+Sum += arr[I];
 
-  for (int i = 0; i < N; i)
-sum += arr[i];
+  for (int I = 0; I < N; I)
+Sum += arr[I];
 
-  for (int i = 0; i < N;)
-sum += arr[i];
+  for (int I = 0; I < N;)
+Sum += arr[I];
 
-  for (int i = 0; i < N; i += 2)
-sum++;
+  for (int I = 0; I < N; I += 2)
+Sum++;
 }
 
-// Checks to make sure that the index isn't used outside of the array:
-void indexUse() {
-  for (int i = 0; i < N; ++i)
-arr[i] += 1 + i;
+// Checks to make sure that the Index isn't used outside of the array:
+void IndexUse() {
+  for (int I = 0; I < N; ++I)
+arr[I] += 1 + I;
 }
 
 // Check for loops that don't mention arrays
 void noArray() {
-  for (int i = 0; i < N; ++i)
-sum += i;
+  for (int I = 0; I < N; ++I)
+Sum += I;
 
-  for (int i = 0; i < N; ++i) {
+  for (int I = 0; I < N; ++I) {
   }
 
-  for (int i = 0; i < N; ++i)
+  for (int I = 0; I < N; ++I)
 ;
 }
 
 // Checks for incorrect loop variables.
 void mixedVariables() {
   int badIndex;
-  for (int i = 0; badIndex < N; ++i)
-sum += arr[i];
+  for (int I = 0; badIndex < N; ++I)
+Sum += arr[I];
 
-  for (int i = 0; i < N; ++badIndex)
-sum += arr[i];
+  for (int I = 0; I < N; ++badIndex)
+Sum += arr[I];
 
-  for (int i = 0; badIndex < N; ++badIndex)
-sum += arr[i];
+  for (int I = 0; badIndex < N; ++badIndex)
+Sum += arr[I];
 
-  for (int i = 0; badIndex < N; ++badIndex)
-sum += arr[badIndex];
+  for (int I = 0; badIndex < N; ++badIndex)
+Sum += arr[badIndex];
 }
 
-// Checks for multiple arrays indexed.
+// Checks for multiple arrays Indexed.
 void multipleArrays() {
   int badArr[N];
 
-  for (int i = 0; i < N; ++i)
-sum += arr[i] + badArr[i];
+  for (int I = 0; I < N; ++I)
+Sum += arr[I] + badArr[I];
 
-  for (int i = 0; i < N; ++i) {
-int k = badArr[i];
-sum += arr[i] + k;
+  for (int I = 0; I < N; ++I) {
+int K = badArr[I];
+Sum += arr[I] + K;
   }
 }
 
@@ -99,22 +100,22 @@
 struct HasIndirectArr {
   HasArr HA;
   void implicitThis() {
-for (int i = 0; i < N; ++i) {
-  printf("%d", HA.Arr[i]);
+for (int I = 0; I < N; ++I) {
+  printf("%d", HA.Arr[I]);
 }
 
-for (int i = 0; i < N; ++i) {
-  printf("%d", HA.ValArr[i].x);
+for (int I = 0; I < N; ++I) {
+  printf("%d", HA.ValArr[I].x);
 }
   }
 
   void explicitThis() {
-for (int i = 0; i < N; ++i) {
-  printf("%d", this->HA.Arr[i]);
+for (int I = 0; I < N; ++I) {
+  printf("%d", this->HA.Arr[I]);
 }
 
-for (int i = 0; i < N; ++i) {
-  printf("%d", this->HA.ValArr[i].x);
+for (int I = 0; I < N; ++I) {
+  printf("%d", this->HA.ValArr[I].x);
 }
   }
 };
@@ -133,101 +134,117 @@
 
 void notBeginOrEnd() {
   BadBeginEnd Bad;
-  for (T::iterator i = Bad.notBegin(), e = Bad.end(); i != e; ++i)
-int k = *i;
+  for (T::iterator I = Bad.notBegin(), E = Bad.end();  I != E; ++I)
+int K = *I;
 
-  for (T::iterator i = Bad.begin(), e = Bad.notEnd(); i != e; ++i)
-int k = *i;
+  for (T::iterator I = Bad.begin(), E = Bad.notEnd();  I != E; ++I)
+int K = *I;
 }
 
 void badLoopShapes() {
-  for (T::iterator i = t.begin(), e = t.end(), f = e; i != e; ++i)
-int k = *i;
+  for (T::iterat

Re: [PATCH] D12512: [libcxxabi] Manually align pointers in __cxa_allocate_exception - Fixes PR24604

2015-09-01 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

In http://reviews.llvm.org/D12512#236988, @majnemer wrote:

> In http://reviews.llvm.org/D12512#236987, @EricWF wrote:
>
> > In http://reviews.llvm.org/D12512#236984, @majnemer wrote:
> >
> > > Wouldn't this change be problematic if you threw to code which was 
> > > statically linked with a prior version of libcxxabi?
> >
> >
> > How do you mean? As in you have two different versions of libc++abi linked 
> > into one executable? If so your already in bad shape.
>
>
> Say you have two binaries, foo.exe and bar.so.  Foo.exe statically links 
> against an older libc++abi and bar.so links against a newer libc++abi.  In 
> this instance, our program has two copies of libc++abi statically linked with 
> no ill effects and such a scenario was supported before this patch (at least 
> AFAICT).
>
> However, we might have problems after this patch if foo.exe is linked against 
> a newer static library than bar.so


I don't think that is/was supported. The abi library holds some global state, 
which wouldn't be shared between the two instances of it.


http://reviews.llvm.org/D12512



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


Re: [PATCH] D12530: Fix several corner cases for loop-convert check.

2015-09-01 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: test/clang-tidy/modernize-loop-convert-basic.cpp:448
@@ +447,3 @@
+ret = it;
+  }
+}

angelgarcia wrote:
> klimek wrote:
> > This test seems to be missing the it.insert(0) case that was removed from 
> > the "unsupported"  comment, if I'm not missing something.
> It was in the test 'modernize-loop-convert-negative.cpp'. I moved these ones 
> there as well.
Why is that case removed from the unsupported list then?


Comment at: test/clang-tidy/modernize-loop-convert-basic.cpp:519-521
@@ -518,5 +518,5 @@
   unsigned size() const;
-  unsigned begin() const;
-  unsigned end() const;
+  unsigned* begin() const;
+  unsigned* end() const;
 };
 

That makes sense.


http://reviews.llvm.org/D12530



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


Re: [PATCH] D12530: Fix several corner cases for loop-convert check.

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

Learned that I need to learn to read, because the deleted comment was just 
duplicated.
Looks good, great first step towards making this significantly more useful :)


http://reviews.llvm.org/D12530



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


[clang-tools-extra] r246550 - Fix several corner cases for loop-convert check.

2015-09-01 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Tue Sep  1 10:05:15 2015
New Revision: 246550

URL: http://llvm.org/viewvc/llvm-project?rev=246550&view=rev
Log:
Fix several corner cases for loop-convert check.

Summary: Reduced the amount of wrong conversions of this check.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.h
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-negative.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=246550&r1=246549&r2=246550&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Tue Sep  
1 10:05:15 2015
@@ -364,6 +364,23 @@ static bool isDirectMemberExpr(const Exp
   return false;
 }
 
+/// \brief Returns true when it can be guaranteed that the elements of the
+/// container are not being modified.
+static bool usagesAreConst(const UsageResult &Usages) {
+  // FIXME: Make this function more generic.
+  return Usages.empty();
+}
+
+/// \brief Returns true if the elements of the container are never accessed
+/// by reference.
+static bool usagesReturnRValues(const UsageResult &Usages) {
+  for (const auto &U : Usages) {
+if (!U.Expression->isRValue())
+  return false;
+  }
+  return true;
+}
+
 LoopConvertCheck::LoopConvertCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context), TUInfo(new TUTrackingInfo),
   MinConfidence(StringSwitch(
@@ -452,7 +469,8 @@ void LoopConvertCheck::doConversion(
   StringRef MaybeDereference = ContainerNeedsDereference ? "*" : "";
   std::string TypeString = AutoRefType.getAsString();
   std::string Range = ("(" + TypeString + " " + VarName + " : " +
-   MaybeDereference + ContainerString + ")").str();
+   MaybeDereference + ContainerString + ")")
+  .str();
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getTokenRange(ParenRange), Range);
   TUInfo->getGeneratedDecls().insert(make_pair(TheLoop, VarName));
@@ -464,7 +482,7 @@ void LoopConvertCheck::doConversion(
 StringRef LoopConvertCheck::checkRejections(ASTContext *Context,
 const Expr *ContainerExpr,
 const ForStmt *TheLoop) {
-  // If we already modified the reange of this for loop, don't do any further
+  // If we already modified the range of this for loop, don't do any further
   // updates on this iteration.
   if (TUInfo->getReplacedVars().count(TheLoop))
 return "";
@@ -525,6 +543,18 @@ void LoopConvertCheck::findAndVerifyUsag
 if (!getReferencedVariable(ContainerExpr) &&
 !isDirectMemberExpr(ContainerExpr))
   ConfidenceLevel.lowerTo(Confidence::CL_Risky);
+  } else if (FixerKind == LFK_PseudoArray) {
+if (!DerefByValue && !DerefByConstRef) {
+  const UsageResult &Usages = Finder.getUsages();
+  if (usagesAreConst(Usages)) {
+// FIXME: check if the type is trivially copiable.
+DerefByConstRef = true;
+  } else if (usagesReturnRValues(Usages)) {
+// If the index usages (dereference, subscript, at) return RValues,
+// then we should not use a non-const reference.
+DerefByValue = true;
+  }
+}
   }
 
   StringRef ContainerString = checkRejections(Context, ContainerExpr, TheLoop);

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp?rev=246550&r1=246549&r2=246550&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.cpp Tue Sep  
1 10:05:15 2015
@@ -425,12 +425,8 @@ ForLoopIndexUseVisitor::ForLoopIndexUseV
   ConfidenceLevel(Confidence::CL_Safe), NextStmtParent(nullptr),
   CurrStmtParent(nullptr), ReplaceWithAliasUse(false),
   AliasFromForInit(false) {
-  if (ContainerExpr) {
+  if (ContainerExpr)
 addComponent(ContainerExpr);
-FoldingSetNodeID ID;
-const Expr *E = ContainerExpr->IgnoreParenImpCasts();
-E->Profile(ID, *Context, true);
-  }
 }
 
 bool ForLoopIndexUseVisitor::findAndVerifyUsages(const Stmt *Body) {
@@ -521,

Re: [clang-tools-extra] r245683 - Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput.

2015-09-01 Thread Alexander Kornienko via cfe-commits
Looks like this patch broke handling of multiple files:
https://llvm.org/PR24637

Can you take a look at this?

On Fri, Aug 21, 2015 at 12:56 PM, Yaron Keren  wrote:

> Whenever is any special character in the filename, such as space or
> backslash (Windows), some examples:
>
> On Windows:
> --- ".\\a.cpp"  2015-08-21 00:22:57.885370200 +0300
> +++ b.cpp   2015-08-21 01:05:28.726269900 +0300
>
> --- ./a.cpp 2015-08-21 00:22:57.885370200 +0300
> +++ b.cpp   2015-08-21 01:05:28.726269900 +0300
>
> --- "a a.cpp"   2015-08-21 00:22:57.885370200 +0300
> +++ b.cpp   2015-08-21 01:05:28.726269900 +0300
>
> On Linux:
> ~$ diff -U0 ./a.cpp b\ b.cpp
> --- ./a.cpp 2015-08-14 00:27:03.569276652 +0300
> +++ "b b.cpp"   2015-08-21 13:54:26.787896719 +0300
>
> filename with space will break current clang-tidy-diff.py on all
> platforms, the regular expression does not match quotes.
> There is surely some Python package to process filenames correctly if this
> ever become a problem.
>
>
> 2015-08-21 13:37 GMT+03:00 Alexander Kornienko :
>
>> On Fri, Aug 21, 2015 at 11:27 AM, Yaron Keren via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: yrnkrn
>>> Date: Fri Aug 21 04:27:24 2015
>>> New Revision: 245683
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=245683&view=rev
>>> Log:
>>> Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput
>>
>>
>> Out of curiosity, when does this happen? (I mean quotes around the file
>> name)
>>
>>
>>>
>>>
>>
>>> Modified:
>>> clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>>>
>>> Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=245683&r1=245682&r2=245683&view=diff
>>>
>>> ==
>>> --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
>>> +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Aug
>>> 21 04:27:24 2015
>>> @@ -67,7 +67,7 @@ def main():
>>>filename = None
>>>lines_by_file = {}
>>>for line in sys.stdin:
>>> -match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
>>> +match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p,
>>> line)
>>>  if match:
>>>filename = match.group(2)
>>>  if filename == None:
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12402: PR24595: clang-cl fails to compile vswriter.h header from Windows SDK 8.1 in 32 bit mode

2015-09-01 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/Sema/SemaType.cpp:2272
@@ -2271,1 +2271,3 @@
   // calling convention.
+  bool is_ctor_or_dtor =
+  (Entity.getNameKind() == DeclarationName::CXXConstructorName) ||

s/is_ctor_or_dtor/IsCtorOrDtor/, it's the local variable convention.


Comment at: lib/Sema/SemaType.cpp:5857-5858
@@ -5860,3 +5856,4 @@
 
-  if (hasExplicitCallingConv(T))
-return;
+  // MS compiler transforms __stdcall in ctors/dtors to __thiscall in 32 bit
+  // mode. We should do the same.
+  if ((CurCC == CC_X86StdCall) && IsCtorOrDtor &&

I think a more accurate statement would be that MSVC ignores explicit calling 
convention attributes on structors in all modes. Compile this example with MSVC 
for x64:
  struct HVA {
double a, b, c, d;
  };
  struct A {
__vectorcall A(HVA x);
double f;
  };
  A::A(HVA x) : f(x.a + x.b + x.c + x.d) {}
Note the warning:
  warning C4166: illegal calling convention for constructor/destructor
And HVA is passed indirectly instead of in XMM0-3.

You should consider adding a warning like this when we adjust structor 
conventions from something other than `__stdcall`. MSVC doesn't appear to warn 
on `__stdcall` structors, probably because it is used accidentally in places 
like vswriter.h.


Comment at: lib/Sema/SemaType.cpp:5860
@@ +5859,3 @@
+  if ((CurCC == CC_X86StdCall) && IsCtorOrDtor &&
+  (Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment() &&
+   Context.getTargetInfo().getTriple().isArch32Bit()))

A better test for if we should treat structors specially would be:
  Context.getTargetInfo().getCXXABI().isMicrosoft()

It's really the MSVC C++ ABI that requires that structors have special 
conventions. I think it has to do with exception handling.


Comment at: lib/Sema/SemaType.cpp:5868
@@ +5867,3 @@
+// __thiscall type to __cdecl for static methods.
+CallingConv FromCC =
+Context.getDefaultCallingConvention(IsVariadic, IsStatic);

In hindsight, a better name for this variable would be `DefaultCC`.


Comment at: lib/Sema/SemaType.cpp:5871-5875
@@ +5870,7 @@
+ToCC = Context.getDefaultCallingConvention(IsVariadic, !IsStatic);
+if (CurCC != FromCC || FromCC == ToCC)
+  return;
+
+if (hasExplicitCallingConv(T))
+  return;
+  }

I think it would be better to wrap both ifs here in `if (!IsCtorOrDtor)`. We 
should always adjust ctors and dtors.


http://reviews.llvm.org/D12402



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


Re: r246548 - Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.

2015-09-01 Thread Renato Golin via cfe-commits
On 1 September 2015 at 15:49, Aaron Ballman via cfe-commits
 wrote:
> Author: aaronballman
> Date: Tue Sep  1 09:49:24 2015
> New Revision: 246548
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246548&view=rev
> Log:
> Add a new frontend warning for referencing members from the handler of a 
> constructor or destructor function-try-block, which is UB in C++.

Hi Aaron,

Could this be yours?

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/3246

Seems like bad codegen, possibly a 32-bit issue? This is ok on the
AArch64 bots, have you seen any problem in x86-32 ones?

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


Re: [PATCH] D12445: [Static Analyzer] Remove sinks from nullability checks.

2015-09-01 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 33704.
xazax.hun added a comment.

Made sure that inlined defensive checks do not generate false positives.


http://reviews.llvm.org/D12445

Files:
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  test/Analysis/nullability.mm

Index: test/Analysis/nullability.mm
===
--- test/Analysis/nullability.mm
+++ test/Analysis/nullability.mm
@@ -179,3 +179,65 @@
   takesNullable(p);
   takesNonnull(p);
 }
+
+void onlyReportFirstPreconditionViolationOnPath() {
+  Dummy *p = returnsNullable();
+  takesNonnull(p); // expected-warning {{}}
+  takesNonnull(p); // No warning.
+  // The first warning was not a sink. The analysis expected to continue.
+  int i = 0;
+  i = 5 / i; // expected-warning {{Division by zero}}
+  (void)i;
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolatedInTopFunc(
+Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolated(Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+void testPreconditionViolationInInlinedFunction(Dummy *p) {
+  doNotWarnWhenPreconditionIsViolated(p);
+}
+
+void inlinedNullable(Dummy *_Nullable p) {
+  if (p) return;
+}
+void inlinedNonnull(Dummy *_Nonnull p) {
+  if (p) return;
+}
+void inlinedUnspecified(Dummy *p) {
+  if (p) return;
+}
+
+Dummy *_Nonnull testDefensiveInlineChecks(Dummy * p) {
+  switch (getRandom()) {
+  case 1: inlinedNullable(p); break;
+  case 2: inlinedNonnull(p); break;
+  case 3: inlinedUnspecified(p); break;
+  }
+  if (getRandom())
+takesNonnull(p);
+  return p;
+}
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -161,6 +161,16 @@
 const MemRegion *Region;
   };
 
+  /// When any of the nonnull arguments of the analyzed function is null, do not
+  /// report anything and turn off the check.
+  ///
+  /// When \p SuppressPath is set to true, no more bugs will be reported on this
+  /// path by this checker.
+  void reportBugConditionally(ErrorKind Error, ExplodedNode *N,
+  const MemRegion *Region, CheckerContext &C,
+  const Stmt *ValueExpr = nullptr,
+  bool SuppressPath = false) const;
+
   void reportBug(ErrorKind Error, ExplodedNode *N, const MemRegion *Region,
  BugReporter &BR, const Stmt *ValueExpr = nullptr) const {
 if (!BT)
@@ -220,6 +230,13 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(NullabilityMap, const MemRegion *,
NullabilityState)
 
+// If the nullability precondition of a function is violated, we should not
+// report nullability related issues on that path. For this reason once a
+// precondition is not met on a path, this checker will be esentially turned off
+// for the rest of the analysis. We do not want to generate a sink node however,
+// so this checker would not lead to reduced coverage.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(PreconditionViolated, bool)
+
 enum class NullConstraint { IsNull, IsNotNull, Unknown };
 
 static NullConstraint getNullConstraint(DefinedOrUnknownSVal Val,
@@ -302,6 +319,76 @@
   return Nullability::Unspecified;
 }
 
+template 
+static ProgramStateRef
+checkParamsForPreconditionViolation(const ParamVarDeclRange &Params,
+ProgramStateRef State,
+const LocationContext *LocCtxt) {
+  for (const auto *ParamDecl : Params) {
+if (ParamDecl->isParameterPack())
+  break;
+
+if (getNullabilityAnnotation(ParamDecl->getType()) != Nullability::Nonnull)
+  continue;
+
+auto RegVal = State->getLValue(ParamDecl, LocCtxt)
+  .template getAs();
+if (!RegVal)
+  continue;
+
+auto ParamValue = State->getSVal(RegVal->getRegion())
+  .template getAs();
+if (!ParamValue)
+  continue;
+
+if (getNullConstraint(*ParamValue, State) == NullConstraint::IsNull) {
+  return State->set(true);
+}
+  }
+  return State;
+}
+
+static ProgramStateRef
+checkPreconditionViolation(ProgramStateRef State,
+   const LocationContext *LocCtxt) {
+  const Decl *D = LocCtxt->getDecl();
+  if (!D)
+return State;
+
+  if (const auto *BlockD = dyn_cast(D)) {
+return checkParamsForPreconditionViolation(BlockD->parameters(), State,
+   

Builder clang-mergefunc-x86_64-freebsd?

2015-09-01 Thread Galina Kistanova via cfe-commits
Hello everyone,

Is anyone interesting in our existing builder
clang-mergefunc-x86_64-freebsd?
http://lab.llvm.org:8011/builders/clang-mergefunc-x86_64-freebsd

I do not see any activity on it, if no one use it I will remove it.
Please speak up if you need this builder!

Thanks

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


Re: r246548 - Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.

2015-09-01 Thread Aaron Ballman via cfe-commits
On Tue, Sep 1, 2015 at 12:43 PM, Renato Golin  wrote:
> On 1 September 2015 at 15:49, Aaron Ballman via cfe-commits
>  wrote:
>> Author: aaronballman
>> Date: Tue Sep  1 09:49:24 2015
>> New Revision: 246548
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=246548&view=rev
>> Log:
>> Add a new frontend warning for referencing members from the handler of a 
>> constructor or destructor function-try-block, which is UB in C++.
>
> Hi Aaron,
>
> Could this be yours?
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/3246
>
> Seems like bad codegen, possibly a 32-bit issue? This is ok on the
> AArch64 bots, have you seen any problem in x86-32 ones?

It seems unlikely as this shouldn't effect codegen. None of the other
bots seem to be red because it either. FWIW, my tests were 32-bit x86
on Windows 10 with MSVC 2015.

This was the only failure report I've received thus far, but I'll
definitely keep my eyes open to see if there's a pattern somewhere.

~Aaron

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


Re: [PATCH] D12381: [Static Analyzer] Merge the Objective-C Generics Checker into Dynamic Type Propagation checker.

2015-09-01 Thread Gábor Horváth via cfe-commits
xazax.hun marked an inline comment as not done.


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:81
@@ +80,3 @@
+initBugType();
+SmallString<64> Buf;
+llvm::raw_svector_ostream OS(Buf);

zaks.anna wrote:
> How do we know that the string is big enough?
When the string is not big enough, there will be an allocation. So this is not 
a correctness issue. However I checked that, and the error messages tend to be 
very long. I could either increase the size of this smallstring to something 
like 150 which should be enough for the common of the cases, or I could just 
make it a string. Which one do you prefer?


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:179
@@ -178,3 @@
-  // We only track dynamic type info for regions.
-  const MemRegion *ToR = C.getSVal(CastE).getAsRegion();
-  if (!ToR)

zaks.anna wrote:
> This line used to be unconditional and now, it's only executed if we are 
> casting between ObjC Types.
It should not be a problem. The code bellow only executes for bitcasts, and 
getBetterObjCType only returns a valid value, when the cast was between Obj-C 
types.


Comment at: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:407
@@ +406,3 @@
+// Clean up the states stored by the generics checker.
+void DynamicTypePropagation::checkDeadSymbols(SymbolReaper &SR,
+  CheckerContext &C) const {

zaks.anna wrote:
> Do you know if the info tracked by the DynamicTypeInfo checker gets cleaned 
> up for dead symbols?
That information is stored in DynamicTypeMap which is populated in 
lib/StaticAnalyzer/Core/ProgramState.cpp

I could not find any cleanup code. What do you think, what would be the best 
way to do the cleanup. Exposing a removeDynamicTypeInfo method from the 
ProgramState does not seem to be elegant, but it would work.


http://reviews.llvm.org/D12381



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


Re: r246548 - Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.

2015-09-01 Thread Renato Golin via cfe-commits
On 1 September 2015 at 18:15, Aaron Ballman  wrote:
> It seems unlikely as this shouldn't effect codegen. None of the other
> bots seem to be red because it either. FWIW, my tests were 32-bit x86
> on Windows 10 with MSVC 2015.

Ok, I cleared the stage2 build directory, let's see how this build goes...

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/3248

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


Re: [PATCH] D12262: [OpenMP] Capture global variables in target regions.

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

Rebase on top of the last changes in http://reviews.llvm.org/D11361.


http://reviews.llvm.org/D12262

Files:
  include/clang/Basic/OpenMPKinds.h
  include/clang/Sema/Sema.h
  lib/Basic/OpenMPKinds.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_codegen_global_capture.cpp

Index: test/OpenMP/target_codegen_global_capture.cpp
===
--- /dev/null
+++ test/OpenMP/target_codegen_global_capture.cpp
@@ -0,0 +1,186 @@
+// 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: [[GA:@.+]] = global double 1.00e+00
+// CHECK-DAG: [[GB:@.+]] = global double 2.00e+00
+// CHECK-DAG: [[GC:@.+]] = global double 3.00e+00
+// CHECK-DAG: [[GD:@.+]] = global double 4.00e+00
+// CHECK-DAG: [[FA:@.+]] = internal global float 5.00e+00
+// CHECK-DAG: [[FB:@.+]] = internal global float 6.00e+00
+// CHECK-DAG: [[FC:@.+]] = internal global float 7.00e+00
+// CHECK-DAG: [[FD:@.+]] = internal global float 8.00e+00
+// CHECK-DAG: [[BA:@.+]] = internal global float 9.00e+00
+// CHECK-DAG: [[BB:@.+]] = internal global float 1.00e+01
+// CHECK-DAG: [[BC:@.+]] = internal global float 1.10e+01
+// CHECK-DAG: [[BD:@.+]] = internal global float 1.20e+01
+double Ga = 1.0;
+double Gb = 2.0;
+double Gc = 3.0;
+double Gd = 4.0;
+
+// CHECK: define {{.*}} @{{.*}}foo{{.*}}(
+// CHECK-SAME: i16 {{[^,]*}}[[A:%[^,]+]],
+// CHECK-SAME: i16 {{[^,]*}}[[B:%[^,]+]],
+// CHECK-SAME: i16 {{[^,]*}}[[C:%[^,]+]],
+// CHECK-SAME: i16 {{[^,]*}}[[D:%[^,]+]])
+// CHECK: [[LA:%.+]] = alloca i16
+// CHECK: [[LB:%.+]] = alloca i16
+// CHECK: [[LC:%.+]] = alloca i16
+// CHECK: [[LD:%.+]] = alloca i16
+int foo(short a, short b, short c, short d){
+  static float Sa = 5.0;
+  static float Sb = 6.0;
+  static float Sc = 7.0;
+  static float Sd = 8.0;
+
+  // CHECK-DAG: [[REFB:%.+]] = bitcast i16* [[LB]] to i8*
+  // CHECK-DAG: store i8* [[REFB]], i8** [[GEPB:%.+]]
+  // CHECK-DAG: [[REFC:%.+]] = bitcast i16* [[LC]] to i8*
+  // CHECK-DAG: store i8* [[REFC]], i8** [[GEPC:%.+]]
+  // CHECK-DAG: [[REFD:%.+]] = bitcast i16* [[LD]] to i8*
+  // CHECK-DAG: store i8* [[REFD]], i8** [[GEPD:%.+]]
+  // CHECK-DAG: store i8* bitcast (double* [[GB]] to i8*), i8** [[GEPGB:%.+]]
+  // CHECK-DAG: store i8* bitcast (double* [[GC]] to i8*), i8** [[GEPGC:%.+]]
+  // CHECK-DAG: store i8* bitcast (double* [[GD]] to i8*), i8** [[GEPGD:%.+]]
+  // CHECK-DAG: store i8* bitcast (float* [[FB]] to i8*), i8** [[GEPFB:%.+]]
+  // CHECK-DAG: store i8* bitcast (float* [[FC]] to i8*), i8** [[GEPFC:%.+]]
+  // CHECK-DAG: store i8* bitcast (float* [[FD]] to i8*), i8** [[GEPFD:%.+]]
+  // CHECK-DAG: [[GEPB]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPC]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPD]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPGB]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPGC]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPGD]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPFB]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPFC]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK-DAG: [[GEPFD]] = getelementptr inbounds [9 x i8*], [9 x i8*]* %{{.+}}, i32 0, i32 {{.+}}
+  // CHECK: call i32 @__tgt_target
+  // CHECK: call void [[OFFLOADF:@.+]](
+  // Capture b, Gb, Sb, Gc, c, Sc, d, Gd, Sd
+  #pragma omp target if(Ga>0.0 && a>0 && Sa>0.0)
+  {
+b += 1;
+Gb += 1.0;
+Sb += 1.0;
+
+
+// CHECK: define internal void [[PARF:@.+]](i32* %{{.*}}, i32* %{{.*}},
+// CHECK: define internal void [[OFFLOADF]](
+
+// CHECK: alloca [[CCAPTY:%.+]],
+// CHECK: [[CAP:%.+]] = alloca [[CAPTY:%.+]],
+// CHECK: getelementptr inbounds [[CAPTY]], [[CAPTY]]* [[CAP]], i32 0, i32
+// CHECK: getelementptr inbounds [[CAPTY]], [[CAPTY]]* [[CAP]], i32 0, i32
+// CHECK: get

Re: [PATCH] D12262: [OpenMP] Capture global variables in target regions.

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


Comment at: lib/Sema/SemaOpenMP.cpp:702
@@ +701,3 @@
+  return true;
+}
+  }

Alexey, after rebasing this patch with the latest changes, I started having a 
regression related with how `DSAStack->hasDirective` works. In my understanding 
it requires that a valid scope exists in the stack, or alternatively  that 2 or 
more entries exist in the stack. In some cases `DSAStack->hasDirective` was 
being called with only one entry causing the iterators in there not to work 
properly. The fix for that was adding `DSAStack->getCurScope()`. It seems to be 
a harmless change, but still wanted to make sure you agree with that.

Thanks!


http://reviews.llvm.org/D12262



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


Re: [PATCH] D11664: [CUDA] Implemented additional processing steps needed to link with CUDA libdevice bitcode.

2015-09-01 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

The ternary is a bit ugly, but LGTM. :)

-eric


http://reviews.llvm.org/D11664



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


Re: [PATCH] D11664: [CUDA] Implemented additional processing steps needed to link with CUDA libdevice bitcode.

2015-09-01 Thread Artem Belevich via cfe-commits
tra updated the summary for this revision.
tra updated this revision to Diff 33713.
tra added a comment.

Updated the patch to use bitcode linker to perform selective linking and 
internalizing.
Removed Internalize+GDCE passes.


http://reviews.llvm.org/D11664

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CodeGenAction.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCUDA/Inputs/device-code.ll
  test/CodeGenCUDA/link-device-bitcode.cu

Index: test/CodeGenCUDA/link-device-bitcode.cu
===
--- /dev/null
+++ test/CodeGenCUDA/link-device-bitcode.cu
@@ -0,0 +1,61 @@
+// Test for linking with CUDA's libdevice as outlined in
+// http://llvm.org/docs/NVPTXUsage.html#linking-with-libdevice
+//
+// REQUIRES: nvptx-registered-target
+//
+// Prepare bitcode file to link with
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -emit-llvm-bc -o %t.bc \
+// RUN:%S/Inputs/device-code.ll
+//
+// Make sure function in device-code gets linked in and internalized.
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fcuda-is-device \
+// RUN:-mlink-bitcode-file %t.bc -fcuda-uses-libdevice -emit-llvm \
+// RUN:-disable-llvm-passes -o - %s \
+// RUN:| FileCheck %s -check-prefix CHECK-IR
+//
+// Make sure function in device-code gets linked but is not internalized
+// without -fcuda-uses-libdevice
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fcuda-is-device \
+// RUN:-mlink-bitcode-file %t.bc -emit-llvm \
+// RUN:-disable-llvm-passes -o - %s \
+// RUN:| FileCheck %s -check-prefix CHECK-IR-NLD
+//
+// NVVMReflect is a target-specific pass runs after -emit-llvm prints
+// IR, so we need to check NVPTX to make sure that the pass did happen
+// and __nvvm_reflect calls were eliminated.
+// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fcuda-is-device \
+// RUN:-mlink-bitcode-file %t.bc -fcuda-uses-libdevice -S -o - %s \
+// RUN:| FileCheck %s -check-prefix CHECK-PTX
+
+#include "Inputs/cuda.h"
+
+__device__ float device_mul_or_add(float a, float b);
+extern "C" __device__ double __nv_sin(double x);
+extern "C" __device__ double __nv_exp(double x);
+
+// CHECK-IR-LABEL: define void @_Z26should_not_be_internalizedPf(
+// CHECK-PTX-LABEL: .visible .func _Z26should_not_be_internalizedPf(
+__device__ void should_not_be_internalized(float *data) {}
+
+// Make sure kernel call has not been internalized.
+// CHECK-IR-LABEL: define void @_Z6kernelPfS_
+// CHECK-PTX-LABEL: .visible .entry _Z6kernelPfS_(
+__global__ __attribute__((used)) void kernel(float *out, float *in) {
+  *out = device_mul_or_add(in[0], in[1]);
+  *out += __nv_exp(__nv_sin(*out));
+  should_not_be_internalized(out);
+}
+
+// Make sure device_mul_or_add() is present in IR, is internal and
+// calls __nvvm_reflect().
+// CHECK-IR-LABEL: define internal float @_Z17device_mul_or_addff(
+// CHECK-IR-NLD-LABEL: define float @_Z17device_mul_or_addff(
+// CHECK-IR: call i32 @__nvvm_reflect
+// CHECK-IR: ret float
+
+// By the time device_mul_or_add() makes it to PTX, __nvvm_reflect references
+// should be gone.
+// CHECK-PTX-NOT: .visible
+// CHECK-PTX-LABEL: .func  (.param .b32 func_retval0) _Z17device_mul_or_addff(
+// CHECK-PTX-NOT: __nvvm_reflect
+// CHECK-PTX: ret;
Index: test/CodeGenCUDA/Inputs/device-code.ll
===
--- /dev/null
+++ test/CodeGenCUDA/Inputs/device-code.ll
@@ -0,0 +1,38 @@
+; Simple bit of IR to mimic CUDA's libdevice. We want to be
+; able to link with it and we need to make sure all __nvvm_reflect
+; calls are eliminated by the time PTX has been produced.
+
+target triple = "nvptx-unknown-cuda"
+
+declare i32 @__nvvm_reflect(i8*)
+
+@"$str" = private addrspace(1) constant [8 x i8] c"USE_MUL\00"
+
+define void @unused_subfunc(float %a) {
+   ret void
+}
+
+define void @used_subfunc(float %a) {
+   ret void
+}
+
+define float @_Z17device_mul_or_addff(float %a, float %b) {
+  %reflect = call i32 @__nvvm_reflect(i8* addrspacecast (i8 addrspace(1)* getelementptr inbounds ([8 x i8], [8 x i8] addrspace(1)* @"$str", i32 0, i32 0) to i8*))
+  %cmp = icmp ne i32 %reflect, 0
+  br i1 %cmp, label %use_mul, label %use_add
+
+use_mul:
+  %ret1 = fmul float %a, %b
+  br label %exit
+
+use_add:
+  %ret2 = fadd float %a, %b
+  br label %exit
+
+exit:
+  %ret = phi float [%ret1, %use_mul], [%ret2, %use_add]
+
+  call void @used_subfunc(float %ret)
+
+  ret float %ret
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1406,6 +1406,9 @@
   if (Args.hasArg(OPT_fcuda_is_device))
 Opts.CUDAIsDevice = 1;
 
+  if (Args.hasArg(OPT_fcuda_uses_libdevice))
+Opts.CUDAUsesLibDevice = 1;
+
   if (Args.hasArg(OPT_fcuda_allow_host_calls_from_host_device))
 Opts.CUDAAllowHostCallsFromHostDevi

Re: r246548 - Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.

2015-09-01 Thread Renato Golin via cfe-commits
On 1 September 2015 at 18:17, Renato Golin  wrote:
> Ok, I cleared the stage2 build directory, let's see how this build goes...
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/3248

Nah, there is something definitely wrong with that. I'll bisect here
to make sure it wasn't your patch.

For now, the other buildbots should cover for the other breakages, so
we can keep this one failing until we're sure of it.

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


r246565 - Pull initFeatureMap out of line now that it's used in multiple places.

2015-09-01 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Sep  1 13:13:20 2015
New Revision: 246565

URL: http://llvm.org/viewvc/llvm-project?rev=246565&view=rev
Log:
Pull initFeatureMap out of line now that it's used in multiple places.

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=246565&r1=246564&r2=246565&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Sep  1 13:13:20 2015
@@ -746,15 +746,7 @@ public:
   /// \return False on error (invalid features).
   virtual bool initFeatureMap(llvm::StringMap &Features,
   DiagnosticsEngine &Diags, StringRef CPU,
-  std::vector &FeatureVec) const {
-for (const auto &F : FeatureVec) {
-  const char *Name = F.c_str();
-  // Apply the feature via the target.
-  bool Enabled = Name[0] == '+';
-  setFeatureEnabled(Features, Name + 1, Enabled);
-}
-return true;
-  }
+  std::vector &FeatureVec) const;
 
   /// \brief Get the ABI currently in use.
   virtual StringRef getABI() const { return StringRef(); }

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=246565&r1=246564&r2=246565&view=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Tue Sep  1 13:13:20 2015
@@ -311,6 +311,18 @@ void TargetInfo::adjust(const LangOption
   }
 }
 
+bool TargetInfo::initFeatureMap(llvm::StringMap &Features,
+DiagnosticsEngine &Diags, StringRef CPU,
+std::vector &FeatureVec) const {
+  for (const auto &F : FeatureVec) {
+const char *Name = F.c_str();
+// Apply the feature via the target.
+bool Enabled = Name[0] == '+';
+setFeatureEnabled(Features, Name + 1, Enabled);
+  }
+  return true;
+}
+
 
//===--===//
 
 


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


Re: [PATCH] D11815: Pass subtarget feature "force-align-stack"

2015-09-01 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

In http://reviews.llvm.org/D11815#236368, @vkalintiris wrote:

> In http://reviews.llvm.org/D11815#235394, @ahatanak wrote:
>
> >
>




> For example, on a Mips target, where the O32 ABI requires either way an 
> 8-byte alignment, we would generate redundant code for realigning the stack 
> to a 4-byte alignment if a function contains objects with maximum alignment 
> of 4-bytes (see attached files to get an idea).


I wonder if there is a target or a use case that requires or prefers realigning 
the stack to an alignment that is smaller than the default stack alignment.  If 
there is no such target or use case, I think we can just using the existing 
attribute StackAlignment (with value 0) rather than adding a new function 
attribute "stackrealign", which will ensure the stack is at least aligned to 
the default value and force realigning the stack.


http://reviews.llvm.org/D11815



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


Re: r246548 - Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.

2015-09-01 Thread Aaron Ballman via cfe-commits
On Tue, Sep 1, 2015 at 2:10 PM, Renato Golin  wrote:
> On 1 September 2015 at 18:17, Renato Golin  wrote:
>> Ok, I cleared the stage2 build directory, let's see how this build goes...
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/3248
>
> Nah, there is something definitely wrong with that. I'll bisect here
> to make sure it wasn't your patch.
>
> For now, the other buildbots should cover for the other breakages, so
> we can keep this one failing until we're sure of it.

I just got a notice for a similar failure:
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2130

Could this be some ARM-specific issue?

What's really weird is, the only practical change in this was to
Sema::BuildMemberReferenceExpr() to issue a warning diagnostic (and
not early return, continue as-normal). The rest of the changes were to
thread Scope * from the parser into Sema to accommodate. Very strange.

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


Re: [PATCH] D12247: [libc++] remove possible trailing padding from aligned_storage

2015-09-01 Thread Yiran Wang via cfe-commits
yiranwang added a comment.

Thanks for testing.
There is proof as the following, given that alignment of _Aligner is _Align 
(the whole purpose of _Aligner here, which we do not want to double check), and 
for any type, the "sizeof" is always multiple of "alignof", this change should 
be ABI compatible.
Are we good to go?


http://reviews.llvm.org/D12247



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


Re: r246548 - Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.

2015-09-01 Thread Renato Golin via cfe-commits
On 1 September 2015 at 19:23, Aaron Ballman  wrote:
> On Tue, Sep 1, 2015 at 2:10 PM, Renato Golin  wrote:
>> On 1 September 2015 at 18:17, Renato Golin  wrote:
>>> Ok, I cleared the stage2 build directory, let's see how this build goes...
>>>
>>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/3248
>>
>> Nah, there is something definitely wrong with that. I'll bisect here
>> to make sure it wasn't your patch.
>>
>> For now, the other buildbots should cover for the other breakages, so
>> we can keep this one failing until we're sure of it.
>
> I just got a notice for a similar failure:
> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2130
>
> Could this be some ARM-specific issue?
>
> What's really weird is, the only practical change in this was to
> Sema::BuildMemberReferenceExpr() to issue a warning diagnostic (and
> not early return, continue as-normal). The rest of the changes were to
> thread Scope * from the parser into Sema to accommodate. Very strange.

It could. I'm suspecting that this is related to the class alignment
problem that plagues ARM for at least one year.

If I'm right, than this is not a code gen fault at all, but a
misaligned structure in Clang that is getting the wrong value.

Ahmed and Reid could maye shed some light.

cheers,
--renato

PS: I'll continue to bisect anyway.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r246573 - Fix typo in test

2015-09-01 Thread Eli Bendersky via cfe-commits
Author: eliben
Date: Tue Sep  1 13:56:19 2015
New Revision: 246573

URL: http://llvm.org/viewvc/llvm-project?rev=246573&view=rev
Log:
Fix typo in test

Modified:
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=246573&r1=246572&r2=246573&view=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Tue Sep  1 13:56:19 2015
@@ -1,8 +1,8 @@
-/PtrDiffType / RUN: %clang_cc1 -E -dM -x assembler-with-cpp < /dev/null | 
FileCheck -check-prefix ASM %s
+// RUN: %clang_cc1 -E -dM -x assembler-with-cpp < /dev/null | FileCheck 
-check-prefix ASM %s
 //
 // ASM:#define __ASSEMBLER__ 1
 //
-// 
+//
 // RUN: %clang_cc1 -fblocks -E -dM < /dev/null | FileCheck -check-prefix 
BLOCKS %s
 //
 // BLOCKS:#define __BLOCKS__ 1


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


Re: r246548 - Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.

2015-09-01 Thread Aaron Ballman via cfe-commits
On Tue, Sep 1, 2015 at 2:32 PM, Renato Golin  wrote:
> On 1 September 2015 at 19:23, Aaron Ballman  wrote:
>> On Tue, Sep 1, 2015 at 2:10 PM, Renato Golin  wrote:
>>> On 1 September 2015 at 18:17, Renato Golin  wrote:
 Ok, I cleared the stage2 build directory, let's see how this build goes...

 http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/3248
>>>
>>> Nah, there is something definitely wrong with that. I'll bisect here
>>> to make sure it wasn't your patch.
>>>
>>> For now, the other buildbots should cover for the other breakages, so
>>> we can keep this one failing until we're sure of it.
>>
>> I just got a notice for a similar failure:
>> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2130
>>
>> Could this be some ARM-specific issue?
>>
>> What's really weird is, the only practical change in this was to
>> Sema::BuildMemberReferenceExpr() to issue a warning diagnostic (and
>> not early return, continue as-normal). The rest of the changes were to
>> thread Scope * from the parser into Sema to accommodate. Very strange.
>
> It could. I'm suspecting that this is related to the class alignment
> problem that plagues ARM for at least one year.
>
> If I'm right, than this is not a code gen fault at all, but a
> misaligned structure in Clang that is getting the wrong value.

Like a parameter/local misalignment?

> Ahmed and Reid could maye shed some light.
>
> cheers,
> --renato
>
> PS: I'll continue to bisect anyway.

Thank you for this!

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


Re: [clang-tools-extra] r245683 - Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput.

2015-09-01 Thread Yaron Keren via cfe-commits
Hi,

In the other thread (search for ... 0ca9a2b from bartek-w) he provided a
regex with two more changes beyond adding \n.
Here are all three regexes:

pre-r245683
 match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
r245683
 match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p, line)
bartek-w
 match = re.search('^+++\ \"?(.?/){%s}([^ \t\"\n])' % args.p, line)

in bartek-w version, + are not escaped which I do not understand why as +
is a special character in Python regex (see
https://docs.python.org/2/library/re.html) and  and the star after [^
\t\"\n] is missing.
Not wishing to break any working code I asked for the broken diff example
to test against before comitting and so far didn't get a reply.

Anyhow, adding the \n is safe and I've commited it now on r246575 but I'm
still not clear about the other two regex changes.
I'll update the bug report accordingly.

Yaron



2015-09-01 18:52 GMT+03:00 Alexander Kornienko :
>
> Looks like this patch broke handling of multiple files:
https://llvm.org/PR24637
>
> Can you take a look at this?
>
> On Fri, Aug 21, 2015 at 12:56 PM, Yaron Keren 
wrote:
>>
>> Whenever is any special character in the filename, such as space or
backslash (Windows), some examples:
>>
>> On Windows:
>> --- ".\\a.cpp"  2015-08-21 00:22:57.885370200 +0300
>> +++ b.cpp   2015-08-21 01:05:28.726269900 +0300
>>
>> --- ./a.cpp 2015-08-21 00:22:57.885370200 +0300
>> +++ b.cpp   2015-08-21 01:05:28.726269900 +0300
>>
>> --- "a a.cpp"   2015-08-21 00:22:57.885370200 +0300
>> +++ b.cpp   2015-08-21 01:05:28.726269900 +0300
>>
>> On Linux:
>> ~$ diff -U0 ./a.cpp b\ b.cpp
>> --- ./a.cpp 2015-08-14 00:27:03.569276652 +0300
>> +++ "b b.cpp"   2015-08-21 13:54:26.787896719 +0300
>>
>> filename with space will break current clang-tidy-diff.py on all
platforms, the regular expression does not match quotes.
>> There is surely some Python package to process filenames correctly if
this ever become a problem.
>>
>>
>> 2015-08-21 13:37 GMT+03:00 Alexander Kornienko :
>>>
>>> On Fri, Aug 21, 2015 at 11:27 AM, Yaron Keren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

 Author: yrnkrn
 Date: Fri Aug 21 04:27:24 2015
 New Revision: 245683

 URL: http://llvm.org/viewvc/llvm-project?rev=245683&view=rev
 Log:
 Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput
>>>
>>>
>>> Out of curiosity, when does this happen? (I mean quotes around the file
name)
>>>




 Modified:
 clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py

 Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
 URL:
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=245683&r1=245682&r2=245683&view=diff

==
 --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
(original)
 +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri Aug
21 04:27:24 2015
 @@ -67,7 +67,7 @@ def main():
filename = None
lines_by_file = {}
for line in sys.stdin:
 -match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
 +match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p,
line)
  if match:
filename = match.group(2)
  if filename == None:


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


[clang-tools-extra] r246575 - Add \n to the regex in clang-tidy-diff.py in order to fix http://llvm.org/PR24637,

2015-09-01 Thread Yaron Keren via cfe-commits
Author: yrnkrn
Date: Tue Sep  1 14:08:17 2015
New Revision: 246575

URL: http://llvm.org/viewvc/llvm-project?rev=246575&view=rev
Log:
Add \n to the regex in clang-tidy-diff.py in order to fix 
http://llvm.org/PR24637,
git usecase for multiple files diff.


Modified:
clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py

Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=246575&r1=246574&r2=246575&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Tue Sep  1 
14:08:17 2015
@@ -67,7 +67,7 @@ def main():
   filename = None
   lines_by_file = {}
   for line in sys.stdin:
-match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p, line)
+match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.p, line)
 if match:
   filename = match.group(2)
 if filename == None:


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


Re: [PATCH] D12453: [CUDA] Allow function overloads based on host/device attributes.

2015-09-01 Thread Eli Bendersky via cfe-commits
eliben accepted this revision.
eliben added a comment.
This revision is now accepted and ready to land.

The CUDA parts look very good. Someone else should approve the 
overloading-related logic



Comment at: include/clang/Sema/Sema.h:8605
@@ +8604,3 @@
+
+  CUDAFunctionPreference IdentifyCUDAPreference(const FunctionDecl *Caller,
+const FunctionDecl *Callee);

Document this function

[I realize the other CUDA functions are not documented here :-(, but hey this 
is new code so it should follow the rules]


Comment at: lib/Sema/SemaCUDA.cpp:98
@@ +97,3 @@
+  assert(Callee && "Callee must be valid.");
+  CUDAFunctionTarget CallerTarget =
+ Caller ? IdentifyCUDATarget(Caller) : Sema::CFT_Host,

Yes, I believe this is the accepted style when comparing pointers for 
null-ness. 


Comment at: lib/Sema/SemaCUDA.cpp:106
@@ +105,3 @@
+
+  // (a) Can't call global from global until we support dynamic execution.
+  if (CalleeTarget == CFT_Global &&

Not just global from global. global from device too, right? As for global from 
HD, the CUDA guide forbids it


Comment at: lib/Sema/SemaChecking.cpp:529
@@ -528,3 +528,3 @@
   // of the arch we are compiling for.
-  if (BuiltinID >= Builtin::FirstTSBuiltin) {
+  if (Context.BuiltinInfo.isTSBuiltin(BuiltinID)) {
 switch (Context.getTargetInfo().getTriple().getArch()) {

Is this part related to this patch?


http://reviews.llvm.org/D12453



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


Re: r246546 - Reverting r246497 (which requires also reverting r246524 and r246521 to avoid merge conflicts). It broke the build on MSVC 2015. It also broke an MSVC 2013 bot with testing issues.

2015-09-01 Thread Yaron Keren via cfe-commits
Thanks!


2015-09-01 16:24 GMT+03:00 Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org>:

> Author: aaronballman
> Date: Tue Sep  1 08:24:39 2015
> New Revision: 246546
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246546&view=rev
> Log:
> Reverting r246497 (which requires also reverting r246524 and r246521 to
> avoid merge conflicts). It broke the build on MSVC 2015. It also broke an
> MSVC 2013 bot with testing issues.
>
> llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
> error C2065: 'Files': undeclared identifier
>
> http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/2917
>
> Removed:
> cfe/trunk/lib/Serialization/MultiOnDiskHashTable.h
> Modified:
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/include/clang/Serialization/ASTWriter.h
> cfe/trunk/include/clang/Serialization/Module.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTReaderInternals.h
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> cfe/trunk/lib/Serialization/Module.cpp
> cfe/trunk/test/Modules/cxx-templates.cpp
> cfe/trunk/test/Modules/merge-using-decls.cpp
>
> Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=246546&r1=246545&r2=246546&view=diff
>
> ==
> --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Tue Sep  1
> 08:24:39 2015
> @@ -1530,23 +1530,4 @@ namespace clang {
>}
>  } // end namespace clang
>
> -namespace llvm {
> -  template <> struct
> DenseMapInfo {
> -static clang::serialization::DeclarationNameKey getEmptyKey() {
> -  return clang::serialization::DeclarationNameKey(-1, 1);
> -}
> -static clang::serialization::DeclarationNameKey getTombstoneKey() {
> -  return clang::serialization::DeclarationNameKey(-1, 2);
> -}
> -static unsigned
> -getHashValue(const clang::serialization::DeclarationNameKey &Key) {
> -  return Key.getHash();
> -}
> -static bool isEqual(const clang::serialization::DeclarationNameKey &L,
> -const clang::serialization::DeclarationNameKey
> &R) {
> -  return L == R;
> -}
> -  };
> -}
> -
>  #endif
>
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=246546&r1=246545&r2=246546&view=diff
>
> ==
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Sep  1 08:24:39
> 2015
> @@ -282,8 +282,9 @@ class ReadMethodPoolVisitor;
>
>  namespace reader {
>class ASTIdentifierLookupTrait;
> -  /// \brief The on-disk hash table(s) used for DeclContext name lookup.
> -  struct DeclContextLookupTable;
> +  /// \brief The on-disk hash table used for the DeclContext's Name
> lookup table.
> +  typedef
> llvm::OnDiskIterableChainedHashTable
> +ASTDeclContextNameLookupTable;
>  }
>
>  } // end namespace serialization
> @@ -506,10 +507,6 @@ private:
>/// \brief Map from the TU to its lexical contents from each module
> file.
>std::vector> TULexicalDecls;
>
> -  /// \brief Map from a DeclContext to its lookup tables.
> -  llvm::DenseMap - serialization::reader::DeclContextLookupTable> Lookups;
> -
>// Updates for visible decls can occur for other contexts than just the
>// TU, and when we read those update records, the actual context may not
>// be available yet, so have this pending map using the ID as a key. It
> @@ -517,6 +514,7 @@ private:
>struct PendingVisibleUpdate {
>  ModuleFile *Mod;
>  const unsigned char *Data;
> +unsigned BucketOffset;
>};
>typedef SmallVector DeclContextVisibleUpdates;
>
> @@ -1091,10 +1089,6 @@ public:
>  Visit(GetExistingDecl(ID));
>}
>
> -  /// \brief Get the loaded lookup tables for \p Primary, if any.
> -  const serialization::reader::DeclContextLookupTable *
> -  getLoadedLookupTables(DeclContext *Primary) const;
> -
>  private:
>struct ImportedModule {
>  ModuleFile *Mod;
> @@ -1876,13 +1870,6 @@ public:
>/// Note: overrides method in ExternalASTSource
>Module *getModule(unsigned ID) override;
>
> -  /// \brief Retrieve the module file with a given local ID within the
> specified
> -  /// ModuleFile.
> -  ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID);
> -
> -  /// \brief Get an ID for the given module file.
> -  unsigned getModuleFileID(ModuleFile *M);
> -
>/// \brief Return a descriptor for the corresponding module

Re: r246534 - [modules] When emitting line tables, only emit filenames that are actually referenced by the entries that we emit.

2015-09-01 Thread Richard Smith via cfe-commits
On Tue, Sep 1, 2015 at 1:12 AM, NAKAMURA Takumi 
wrote:

> FYI,
>
> MultiOnDiskHashTable.h:108   delete T;
> It is crashing.
>
> Modules/cxx-templates.cpp can fail if target is i686-pc-win32.
>

Does this happen when building with Clang, or just when building with MSVC?


> On Tue, Sep 1, 2015 at 5:09 PM Yaron Keren via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hi Richard,
>>
>> Since yesterday I see several clang test failures which *may* be related
>> to the series of patches of modules you comitted. These are:
>>  Clang :: Modules/cxx-templates.cpp
>>  Clang :: Modules/submodules-merge-defs.cpp
>>  Clang :: PCH/cxx-key-functions.cpp
>>  Clang :: PCH/cxx-templates.cpp
>>
>> (failing as of r246534)
>>
>> You can see these failing on clang-x64-ninja-win7 bot but you did not get
>> e-mail since it was masked by other test failing before them:
>>
>> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/4522
>>
>> or on Takumi bot:
>>
>> http://bb.pgr.jp/builders/ninja-clang-i686-msc18-R/builds/2923
>>
>> The bots do not seem to printout details, so here is debug stack dump
>> with symbols for the three tests failing. The fourth one prints huge AST.
>>
>> Could you have a look?
>>
>>
>>   FAIL: Clang :: Modules/cxx-templates.cpp (4128 of 23311)
>> TEST 'Clang :: Modules/cxx-templates.cpp' FAILED
>> 
>>Script:
>>--
>>rm -rf
>> C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
>>not C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1
>> -internal-isystem C:\llvm-clean\msvc\RELWITHDEB
>>INFO\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
>> -fmodules -fimplicit-module-maps -fno-modules-error-recov
>>ery
>> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
>> -I C:\
>>llvm-clean\tools\clang\test\Modules/Inputs
>> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -std=c++11 -ast
>>-dump-lookups | C:/llvm-clean/msvc/RELWITHDEBINFO/bin\FileCheck.EXE
>> C:\llvm-clean\tools\clang\test\Modul
>>es\cxx-templates.cpp --check-prefix=CHECK-GLOBAL
>>not C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1
>> -internal-isystem C:\llvm-clean\msvc\RELWITHDEB
>>INFO\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
>> -fmodules -fimplicit-module-maps -fno-modules-error-recov
>>ery
>> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
>> -I C:\
>>llvm-clean\tools\clang\test\Modules/Inputs
>> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -std=c++11 -ast
>>-dump-lookups -ast-dump-filter N |
>> C:/llvm-clean/msvc/RELWITHDEBINFO/bin\FileCheck.EXE C:\llvm-clean\too
>>ls\clang\test\Modules\cxx-templates.cpp
>> --check-prefix=CHECK-NAMESPACE-N
>>not C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1
>> -internal-isystem C:\llvm-clean\msvc\RELWITHDEB
>>INFO\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
>> -fmodules -fimplicit-module-maps -fno-modules-error-recov
>>ery
>> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
>> -I C:\
>>llvm-clean\tools\clang\test\Modules/Inputs
>> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -std=c++11 -ast
>>-dump -ast-dump-filter SomeTemplate |
>> C:/llvm-clean/msvc/RELWITHDEBINFO/bin\FileCheck.EXE C:\llvm-clean\
>>tools\clang\test\Modules\cxx-templates.cpp --check-prefix=CHECK-DUMP
>>C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1 -internal-isystem
>> C:\llvm-clean\msvc\RELWITHDEBINFO
>>\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
>> -fmodules -fimplicit-module-maps -fno-modules-error-recovery
>>
>>  
>> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
>> -I C:\llvm
>>-clean\tools\clang\test\Modules/Inputs
>> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -verify -std=c++11
>>C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE -cc1 -internal-isystem
>> C:\llvm-clean\msvc\RELWITHDEBINFO
>>\bin\..\lib\clang\3.8.0\include -nostdsysteminc -x objective-c++
>> -fmodules -fimplicit-module-maps -fno-modules-error-recovery
>>
>>  
>> -fmodules-cache-path=C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp
>> -I C:\llvm
>>-clean\tools\clang\test\Modules/Inputs
>> C:\llvm-clean\tools\clang\test\Modules\cxx-templates.cpp -verify -std=c++11
>>-DEARLY_IMPORT
>>--
>>Exit Code: 2
>>
>>Command Output (stdout):
>>--
>>Command 0: "rm" "-rf"
>> "C:\llvm-clean\msvc\tools\clang\test\Modules\Output\cxx-templates.cpp.tmp"
>>Command 0 Result: 0
>>Command 0 Output:
>>
>>
>>Command 0 Stderr:
>>
>>
>>Command 1: "not" "C:/llvm-clean/msvc/RELWITHDEBINFO/bin/clang.EXE"
>> "-cc1" "-internal-isystem" "C:\llvm-c
>>lean\msvc\RELWITHDEBINFO\bin\..\l

Re: r246548 - Add a new frontend warning for referencing members from the handler of a constructor or destructor function-try-block, which is UB in C++.

2015-09-01 Thread Renato Golin via cfe-commits
On 1 September 2015 at 20:09, Aaron Ballman  wrote:
> Like a parameter/local misalignment?

Yes, I think due to placement new for inherited classes, ignoring the
padding between the base class and the inherited extra.

Anyway, it's not your commit, as I just got a failure on my other box
with 246547, which "passed" on the buildbot.

Ahmed, I think we have another of those issues... :)

I'll let the bot broken, as it'll come back again and "stop" failing
in its own... :/

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


Re: [clang-tools-extra] r245683 - Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput.

2015-09-01 Thread Alexander Kornienko via cfe-commits
Thank you for the update!
On 1 Sep 2015 21:10, "Yaron Keren"  wrote:

> Hi,
>
> In the other thread (search for ... 0ca9a2b from bartek-w) he provided a
> regex with two more changes beyond adding \n.
> Here are all three regexes:
>
> pre-r245683
>  match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
> r245683
>  match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p, line)
> bartek-w
>  match = re.search('^+++\ \"?(.?/){%s}([^ \t\"\n])' % args.p, line)
>
> in bartek-w version, + are not escaped which I do not understand why as +
> is a special character in Python regex (see
> https://docs.python.org/2/library/re.html) and  and the star after [^
> \t\"\n] is missing.
> Not wishing to break any working code I asked for the broken diff example
> to test against before comitting and so far didn't get a reply.
>
> Anyhow, adding the \n is safe and I've commited it now on r246575 but I'm
> still not clear about the other two regex changes.
> I'll update the bug report accordingly.
>
> Yaron
>
>
>
> 2015-09-01 18:52 GMT+03:00 Alexander Kornienko :
> >
> > Looks like this patch broke handling of multiple files:
> https://llvm.org/PR24637
> >
> > Can you take a look at this?
> >
> > On Fri, Aug 21, 2015 at 12:56 PM, Yaron Keren 
> wrote:
> >>
> >> Whenever is any special character in the filename, such as space or
> backslash (Windows), some examples:
> >>
> >> On Windows:
> >> --- ".\\a.cpp"  2015-08-21 00:22:57.885370200 +0300
> >> +++ b.cpp   2015-08-21 01:05:28.726269900 +0300
> >>
> >> --- ./a.cpp 2015-08-21 00:22:57.885370200 +0300
> >> +++ b.cpp   2015-08-21 01:05:28.726269900 +0300
> >>
> >> --- "a a.cpp"   2015-08-21 00:22:57.885370200 +0300
> >> +++ b.cpp   2015-08-21 01:05:28.726269900 +0300
> >>
> >> On Linux:
> >> ~$ diff -U0 ./a.cpp b\ b.cpp
> >> --- ./a.cpp 2015-08-14 00:27:03.569276652 +0300
> >> +++ "b b.cpp"   2015-08-21 13:54:26.787896719 +0300
> >>
> >> filename with space will break current clang-tidy-diff.py on all
> platforms, the regular expression does not match quotes.
> >> There is surely some Python package to process filenames correctly if
> this ever become a problem.
> >>
> >>
> >> 2015-08-21 13:37 GMT+03:00 Alexander Kornienko :
> >>>
> >>> On Fri, Aug 21, 2015 at 11:27 AM, Yaron Keren via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
>  Author: yrnkrn
>  Date: Fri Aug 21 04:27:24 2015
>  New Revision: 245683
> 
>  URL: http://llvm.org/viewvc/llvm-project?rev=245683&view=rev
>  Log:
>  Tweak clang-tidy-diff.py to recognize "filename" in the diff ourput
> >>>
> >>>
> >>> Out of curiosity, when does this happen? (I mean quotes around the
> file name)
> >>>
> 
> 
> 
> 
>  Modified:
>  clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> 
>  Modified: clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
>  URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py?rev=245683&r1=245682&r2=245683&view=diff
> 
> ==
>  --- clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py
> (original)
>  +++ clang-tools-extra/trunk/clang-tidy/tool/clang-tidy-diff.py Fri
> Aug 21 04:27:24 2015
>  @@ -67,7 +67,7 @@ def main():
> filename = None
> lines_by_file = {}
> for line in sys.stdin:
>  -match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
>  +match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\"]*)' % args.p,
> line)
>   if match:
> filename = match.group(2)
>   if filename == None:
> 
> 
>  ___
>  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


Move createEliminateAvailableExternallyPass earlier

2015-09-01 Thread Yaron Keren via cfe-commits
Following the discussion on cfe-dev, this
moves createEliminateAvailableExternallyPass earlier in the pass pipeline
to save running many ModulePasses on available external functions that are
thrown away anyhow.
Index: lib/Transforms/IPO/PassManagerBuilder.cpp
===
--- lib/Transforms/IPO/PassManagerBuilder.cpp   (revision 246535)
+++ lib/Transforms/IPO/PassManagerBuilder.cpp   (working copy)
@@ -331,6 +331,19 @@
   // we must insert a no-op module pass to reset the pass manager.
   MPM.add(createBarrierNoopPass());
 
+  if (!DisableUnitAtATime && OptLevel > 1 && !PrepareForLTO) {
+// Remove avail extern fns and globals definitions if we aren't
+// compiling an object file for later LTO. For LTO we want to preserve
+// these so they are eligible for inlining at link-time. Note if they
+// are unreferenced they will be removed by GlobalDCE later, so
+// this only impacts referenced available externally globals.
+// Eventually they will be suppressed during codegen, but eliminating
+// here enables more opportunity for GlobalDCE as it may make
+// globals referenced by available external functions dead
+// and saves running remaining passes on the eliminated functions.
+MPM.add(createEliminateAvailableExternallyPass());
+  }
+
   if (EnableNonLTOGlobalsModRef)
 // We add a fresh GlobalsModRef run at this point. This is particularly
 // useful as the above will have inlined, DCE'ed, and function-attr
@@ -438,17 +451,6 @@
 // GlobalOpt already deletes dead functions and globals, at -O2 try a
 // late pass of GlobalDCE.  It is capable of deleting dead cycles.
 if (OptLevel > 1) {
-  if (!PrepareForLTO) {
-// Remove avail extern fns and globals definitions if we aren't
-// compiling an object file for later LTO. For LTO we want to preserve
-// these so they are eligible for inlining at link-time. Note if they
-// are unreferenced they will be removed by GlobalDCE below, so
-// this only impacts referenced available externally globals.
-// Eventually they will be suppressed during codegen, but eliminating
-// here enables more opportunity for GlobalDCE as it may make
-// globals referenced by available external functions dead.
-MPM.add(createEliminateAvailableExternallyPass());
-  }
   MPM.add(createGlobalDCEPass()); // Remove dead fns and globals.
   MPM.add(createConstantMergePass()); // Merge dup global constants
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r246497 - [modules] Rework serialized DeclContext lookup table management. Instead of

2015-09-01 Thread Richard Smith via cfe-commits
On Tue, Sep 1, 2015 at 6:26 AM, Aaron Ballman 
wrote:

> On Tue, Sep 1, 2015 at 4:43 AM, İsmail Dönmez
>  wrote:
> > Hi,
> >
> > On Tue, Sep 1, 2015 at 1:17 AM, Richard Smith via cfe-commits
> >  wrote:
> >> Author: rsmith
> >> Date: Mon Aug 31 17:17:11 2015
> >> New Revision: 246497
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=246497&view=rev
> >> Log:
> >> [modules] Rework serialized DeclContext lookup table management.
> Instead of
> >> walking the loaded ModuleFiles looking for lookup tables for the
> context, store
> >> them all in one place, and merge them together if we find we have too
> many
> >> (currently, more than 4). If we do merge, include the merged form in our
> >> serialized lookup table, so that downstream readers never need to look
> at our
> >> imports' tables.
> >>
> >> This gives a huge performance improvement to builds with very large
> numbers of
> >> modules (in some cases, more than a 2x speedup was observed).
> >>
> >> Added:
> >> cfe/trunk/lib/Serialization/MultiOnDiskHashTable.h
> >
> > This doesn't seem to compile with VS2015:
> >
> > FAILED: C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe   /nologo /TP
> > /DWIN32 /D_WINDOWS   -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291
> > -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503
> > -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610
> > -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389
> > -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4324 -w14062 -we4238 /W4
> > /Zc:inline /Zc:sizedDealloc- /MT /O2 /Ob2
> > -Itools\clang\lib\Serialization -I..\tools\clang\lib\Serialization
> > -I..\tools\clang\include -Itools\clang\include -Iinclude -I..\include
> >   -UNDEBUG  /EHs-c- /GR- /showIncludes -DCLANG_ENABLE_ARCMT
> > -DCLANG_ENABLE_OBJC_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER
> > -DGTEST_HAS_RTTI=0 -D_CRT_NONSTDC_NO_DEPRECATE
> > -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
> > -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
> > -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
> > -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> >
> /Fotools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\ASTReader.cpp.obj
> > /Fdtools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\
> > /FS -c ..\tools\clang\lib\Serialization\ASTReader.cpp
> >
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
> > error C2065: 'Files': undeclared identifier
> >
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(111):
> > note: while compiling class template member function 'void
> >
> clang::serialization::MultiOnDiskHashTable::removeOverriddenTables(void)'
> >
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(243):
> > note: see reference to function template instantiation 'void
> >
> clang::serialization::MultiOnDiskHashTable::removeOverriddenTables(void)'
> > being compiled
> >
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\ASTReaderInternals.h(114):
> > note: see reference to class template instantiation
> >
> 'clang::serialization::MultiOnDiskHashTable'
> > being compiled
> >
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
> > error C2228: left of '.count' must have class/struct/union
> >
> c:\cygwin64\home\ismail\src\llvm\tools\clang\lib\serialization\MultiOnDiskHashTable.h(117):
> > note: type is 'unknown-type'
> > ninja: build stopped: subcommand failed.
>
> I have reverted r246497 (which required also reverting r246524 and
> r246521 to avoid merge conflicts) to get back to green. Commit was
> r246546.
>
> I'm not certain why MSVC is falling over on this code, but I suspect
> compiler bug. If anyone has a reduced testcase (which I may spend some
> time on if I have a moment), I would be happy to report it to
> Microsoft.


It's two compiler bugs.

In MSVC 2013, providing a move constructor apparently doesn't suppress the
implicit generation of copy operations in some cases. In particular, given:

  struct X { X(); X(X&&); X &operator=(X&&); ~X(); };
  struct Y { X x; };

... Y is copyable (and in my case, copying it led to a use-after-free,
because X had the equivalent of a pointer member).

In MSVC 2015, it appears that implicit lambda capture doesn't work reliably
inside a member function of a class template. The testcase looks something
like:

template struct S {
  typedef T type;
  type f() {
type n;
[&] { ++n; }();
return n;
  }
};
int k = S().f();

... though I don't know if that's enough to reproduce the rejects-valid.

Anyway, these are hopefully both worked around in r246582.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r246582 - Re-commit r246497 (and dependent changes r246524 and r246521), reverted in

2015-09-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep  1 15:35:42 2015
New Revision: 246582

URL: http://llvm.org/viewvc/llvm-project?rev=246582&view=rev
Log:
Re-commit r246497 (and dependent changes r246524 and r246521), reverted in
r246546, with a workaround for an MSVC 2013 miscompile and an MSVC 2015
rejects-valid.

Original commit message:

[modules] Rework serialized DeclContext lookup table management. Instead of
walking the loaded ModuleFiles looking for lookup tables for the context, store
them all in one place, and merge them together if we find we have too many
(currently, more than 4). If we do merge, include the merged form in our
serialized lookup table, so that downstream readers never need to look at our
imports' tables.

This gives a huge performance improvement to builds with very large numbers of
modules (in some cases, more than a 2x speedup was observed).

Added:
cfe/trunk/lib/Serialization/MultiOnDiskHashTable.h
  - copied, changed from r246545, 
cfe/trunk/lib/Serialization/MultiOnDiskHashTable.h
Modified:
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderInternals.h
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/lib/Serialization/Module.cpp
cfe/trunk/test/Modules/cxx-templates.cpp
cfe/trunk/test/Modules/merge-using-decls.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=246582&r1=246581&r2=246582&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Tue Sep  1 15:35:42 2015
@@ -1530,4 +1530,23 @@ namespace clang {
   }
 } // end namespace clang
 
+namespace llvm {
+  template <> struct DenseMapInfo {
+static clang::serialization::DeclarationNameKey getEmptyKey() {
+  return clang::serialization::DeclarationNameKey(-1, 1);
+}
+static clang::serialization::DeclarationNameKey getTombstoneKey() {
+  return clang::serialization::DeclarationNameKey(-1, 2);
+}
+static unsigned
+getHashValue(const clang::serialization::DeclarationNameKey &Key) {
+  return Key.getHash();
+}
+static bool isEqual(const clang::serialization::DeclarationNameKey &L,
+const clang::serialization::DeclarationNameKey &R) {
+  return L == R;
+}
+  };
+}
+
 #endif

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=246582&r1=246581&r2=246582&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Sep  1 15:35:42 2015
@@ -282,9 +282,8 @@ class ReadMethodPoolVisitor;
 
 namespace reader {
   class ASTIdentifierLookupTrait;
-  /// \brief The on-disk hash table used for the DeclContext's Name lookup 
table.
-  typedef llvm::OnDiskIterableChainedHashTable
-ASTDeclContextNameLookupTable;
+  /// \brief The on-disk hash table(s) used for DeclContext name lookup.
+  struct DeclContextLookupTable;
 }
 
 } // end namespace serialization
@@ -507,6 +506,10 @@ private:
   /// \brief Map from the TU to its lexical contents from each module file.
   std::vector> TULexicalDecls;
 
+  /// \brief Map from a DeclContext to its lookup tables.
+  llvm::DenseMap Lookups;
+
   // Updates for visible decls can occur for other contexts than just the
   // TU, and when we read those update records, the actual context may not
   // be available yet, so have this pending map using the ID as a key. It
@@ -514,7 +517,6 @@ private:
   struct PendingVisibleUpdate {
 ModuleFile *Mod;
 const unsigned char *Data;
-unsigned BucketOffset;
   };
   typedef SmallVector DeclContextVisibleUpdates;
 
@@ -1089,6 +1091,10 @@ public:
 Visit(GetExistingDecl(ID));
   }
 
+  /// \brief Get the loaded lookup tables for \p Primary, if any.
+  const serialization::reader::DeclContextLookupTable *
+  getLoadedLookupTables(DeclContext *Primary) const;
+
 private:
   struct ImportedModule {
 ModuleFile *Mod;
@@ -1870,6 +1876,13 @@ public:
   /// Note: overrides method in ExternalASTSource
   Module *getModule(unsigned ID) override;
 
+  /// \brief Retrieve the module file with a given local ID within the 
specified
+  /// ModuleFile.
+  ModuleFile *getLocalModuleFile(ModuleFile &M, unsigned ID);
+
+  /// \brief Get an ID for the given module file.
+  unsigned getModuleFileID(ModuleFile *M);
+
   ///

Re: [PATCH] D12445: [Static Analyzer] Remove sinks from nullability checks.

2015-09-01 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:166
@@ +165,3 @@
+  /// report anything and turn off the check.
+  ///
+  /// When \p SuppressPath is set to true, no more bugs will be reported on 
this

It is still not clear what the condition is..
More context in the name would be better; for example, how about 
reportBugIfNotOnDefensiveCodePath or reportBugIfPreconditionHolds


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:374
@@ +373,3 @@
+  ProgramStateRef OriginalState = N->getState();
+  if (OriginalState->get())
+return;

Shouldn't this be part of checkPreconditionViolation?



Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:806
@@ -690,1 +805,3 @@
 
+  ProgramStateRef State = C.getState();
+  if (State->get())

Maybe we should only check these at the time the bug is about to be reported.. 

That way the code would be less error prone..


http://reviews.llvm.org/D12445



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


Re: [PATCH] D9040: [analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).

2015-09-01 Thread Антон Ярцев via cfe-commits
ayartsev added a comment.

Ping


http://reviews.llvm.org/D9040



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


Re: Move createEliminateAvailableExternallyPass earlier

2015-09-01 Thread Teresa Johnson via cfe-commits
Hi Yaron,

Thanks, moving it earlier in general seems ok to me. I originally put
this right before the GlobalDCE calls because it was somewhat related.
I wonder if the createEliminateAvailableExternallyPass call for the
LTO pipeline should similarly be moved up closer to inlining, perhaps
after any IP alias analysis passes? Hopefully someone more familiar
with the passes than I will comment on how early we can do this.

Teresa

On Tue, Sep 1, 2015 at 1:32 PM, Yaron Keren via cfe-commits
 wrote:
> Following the discussion on cfe-dev, this moves
> createEliminateAvailableExternallyPass earlier in the pass pipeline to save
> running many ModulePasses on available external functions that are thrown
> away anyhow.
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>



-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9040: [analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).

2015-09-01 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:523
@@ -510,2 +522,3 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(ReallocPairs, SymbolRef, ReallocPair)
+REGISTER_MAP_WITH_PROGRAMSTATE(ReallocSizeZeroFlag, SymbolRef, ReallocSizeZero)
 

I do not think this is related to my question.

You add a map from a symbol to a "flag" here; not really a flag but the empty 
struct ReallocSizeZero. The only ways this is used is to set in the state that 
the symbol is zero realloced or query if the specific symbol is zero realloced. 
It seems that using the set of zero realloced symbols would be the right data 
structure here.

Why do we need the extra complexity of the map and the empty struct?


http://reviews.llvm.org/D9040



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


r246589 - Make trunk release notes point to 3.7, not 3.6

2015-09-01 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Sep  1 16:13:14 2015
New Revision: 246589

URL: http://llvm.org/viewvc/llvm-project?rev=246589&view=rev
Log:
Make trunk release notes point to 3.7, not 3.6

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=246589&r1=246588&r2=246589&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Sep  1 16:13:14 2015
@@ -11,8 +11,8 @@ Written by the `LLVM Team `_.
+   prefer the `Clang 3.7 Release Notes
+   `_.
 
 Introduction
 


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


r246591 - [MS ABI] Switch to the CRC implementation in LLVM

2015-09-01 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Sep  1 16:24:07 2015
New Revision: 246591

URL: http://llvm.org/viewvc/llvm-project?rev=246591&view=rev
Log:
[MS ABI] Switch to the CRC implementation in LLVM

We now have an implementation of the CRC in LLVM's libSupport.  Let's
consolidate around that one.

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

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=246591&r1=246590&r2=246591&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Tue Sep  1 16:24:07 2015
@@ -28,6 +28,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/JamCRC.h"
 
 using namespace clang;
 
@@ -2696,28 +2697,6 @@ void MicrosoftMangleContextImpl::mangleS
   // N.B. The length is in terms of bytes, not characters.
   Mangler.mangleNumber(SL->getByteLength() + SL->getCharByteWidth());
 
-  // We will use the "Rocksoft^tm Model CRC Algorithm" to describe the
-  // properties of our CRC:
-  //   Width  : 32
-  //   Poly   : 04C11DB7
-  //   Init   : 
-  //   RefIn  : True
-  //   RefOut : True
-  //   XorOut : 
-  //   Check  : 340BC6D9
-  uint32_t CRC = 0xU;
-
-  auto UpdateCRC = [&CRC](char Byte) {
-for (unsigned i = 0; i < 8; ++i) {
-  bool Bit = CRC & 0x8000U;
-  if (Byte & (1U << i))
-Bit = !Bit;
-  CRC <<= 1;
-  if (Bit)
-CRC ^= 0x04C11DB7U;
-}
-  };
-
   auto GetLittleEndianByte = [&Mangler, &SL](unsigned Index) {
 unsigned CharByteWidth = SL->getCharByteWidth();
 uint32_t CodeUnit = SL->getCodeUnit(Index / CharByteWidth);
@@ -2733,22 +2712,19 @@ void MicrosoftMangleContextImpl::mangleS
   };
 
   // CRC all the bytes of the StringLiteral.
+  llvm::JamCRC JC;
   for (unsigned I = 0, E = SL->getByteLength(); I != E; ++I)
-UpdateCRC(GetLittleEndianByte(I));
+JC.update(GetLittleEndianByte(I));
 
   // The NUL terminator byte(s) were not present earlier,
   // we need to manually process those bytes into the CRC.
   for (unsigned NullTerminator = 0; NullTerminator < SL->getCharByteWidth();
++NullTerminator)
-UpdateCRC('\x00');
-
-  // The literature refers to the process of reversing the bits in the final 
CRC
-  // output as "reflection".
-  CRC = llvm::reverseBits(CRC);
+JC.update('\x00');
 
   // : The CRC is encoded utilizing the standard number mangling
   // scheme.
-  Mangler.mangleNumber(CRC);
+  Mangler.mangleNumber(JC.getCRC());
 
   // : The mangled name also contains the first 32 _characters_
   // (including null-terminator bytes) of the StringLiteral.


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


Re: [PATCH] D12445: [Static Analyzer] Remove sinks from nullability checks.

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


Comment at: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:806
@@ -690,1 +805,3 @@
 
+  ProgramStateRef State = C.getState();
+  if (State->get())

zaks.anna wrote:
> Maybe we should only check these at the time the bug is about to be 
> reported.. 
> 
> That way the code would be less error prone..
This is checked before error reporting as well.
The purpose of this check at the beginning of the callbacks is optimization 
only.


http://reviews.llvm.org/D12445



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


Re: [PATCH] D12445: [Static Analyzer] Remove sinks from nullability checks.

2015-09-01 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 33728.
xazax.hun marked 2 inline comments as done.
xazax.hun added a comment.

Style fixes according to the review.


http://reviews.llvm.org/D12445

Files:
  lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  test/Analysis/nullability.mm

Index: test/Analysis/nullability.mm
===
--- test/Analysis/nullability.mm
+++ test/Analysis/nullability.mm
@@ -179,3 +179,65 @@
   takesNullable(p);
   takesNonnull(p);
 }
+
+void onlyReportFirstPreconditionViolationOnPath() {
+  Dummy *p = returnsNullable();
+  takesNonnull(p); // expected-warning {{}}
+  takesNonnull(p); // No warning.
+  // The first warning was not a sink. The analysis expected to continue.
+  int i = 0;
+  i = 5 / i; // expected-warning {{Division by zero}}
+  (void)i;
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolatedInTopFunc(
+Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+Dummy *_Nonnull doNotWarnWhenPreconditionIsViolated(Dummy *_Nonnull p) {
+  if (!p) {
+Dummy *ret =
+0; // avoid compiler warning (which is not generated by the analyzer)
+if (getRandom())
+  return ret; // no warning
+else
+  return p; // no warning
+  } else {
+return p;
+  }
+}
+
+void testPreconditionViolationInInlinedFunction(Dummy *p) {
+  doNotWarnWhenPreconditionIsViolated(p);
+}
+
+void inlinedNullable(Dummy *_Nullable p) {
+  if (p) return;
+}
+void inlinedNonnull(Dummy *_Nonnull p) {
+  if (p) return;
+}
+void inlinedUnspecified(Dummy *p) {
+  if (p) return;
+}
+
+Dummy *_Nonnull testDefensiveInlineChecks(Dummy * p) {
+  switch (getRandom()) {
+  case 1: inlinedNullable(p); break;
+  case 2: inlinedNonnull(p); break;
+  case 3: inlinedUnspecified(p); break;
+  }
+  if (getRandom())
+takesNonnull(p);
+  return p;
+}
Index: lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -161,6 +161,16 @@
 const MemRegion *Region;
   };
 
+  /// When any of the nonnull arguments of the analyzed function is null, do not
+  /// report anything and turn off the check.
+  ///
+  /// When \p SuppressPath is set to true, no more bugs will be reported on this
+  /// path by this checker.
+  void reportBugIfPreconditionHolds(ErrorKind Error, ExplodedNode *N,
+const MemRegion *Region, CheckerContext &C,
+const Stmt *ValueExpr = nullptr,
+bool SuppressPath = false) const;
+
   void reportBug(ErrorKind Error, ExplodedNode *N, const MemRegion *Region,
  BugReporter &BR, const Stmt *ValueExpr = nullptr) const {
 if (!BT)
@@ -220,6 +230,13 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(NullabilityMap, const MemRegion *,
NullabilityState)
 
+// If the nullability precondition of a function is violated, we should not
+// report nullability related issues on that path. For this reason once a
+// precondition is not met on a path, this checker will be esentially turned off
+// for the rest of the analysis. We do not want to generate a sink node however,
+// so this checker would not lead to reduced coverage.
+REGISTER_TRAIT_WITH_PROGRAMSTATE(PreconditionViolated, bool)
+
 enum class NullConstraint { IsNull, IsNotNull, Unknown };
 
 static NullConstraint getNullConstraint(DefinedOrUnknownSVal Val,
@@ -302,6 +319,82 @@
   return Nullability::Unspecified;
 }
 
+template 
+static bool
+checkParamsForPreconditionViolation(const ParamVarDeclRange &Params,
+ProgramStateRef State,
+const LocationContext *LocCtxt) {
+  for (const auto *ParamDecl : Params) {
+if (ParamDecl->isParameterPack())
+  break;
+
+if (getNullabilityAnnotation(ParamDecl->getType()) != Nullability::Nonnull)
+  continue;
+
+auto RegVal = State->getLValue(ParamDecl, LocCtxt)
+  .template getAs();
+if (!RegVal)
+  continue;
+
+auto ParamValue = State->getSVal(RegVal->getRegion())
+  .template getAs();
+if (!ParamValue)
+  continue;
+
+if (getNullConstraint(*ParamValue, State) == NullConstraint::IsNull) {
+  return true;
+}
+  }
+  return false;
+}
+
+static bool checkPreconditionViolation(ProgramStateRef State, ExplodedNode *N,
+   CheckerContext &C) {
+  if (State->get())
+return true;
+
+  const LocationContext *LocCtxt = C.getLocationContext();
+  const Decl *D = LocCtxt->getDecl();
+  if (!D)
+return false;
+
+  if (const auto *BlockD = dy

[PATCH] D12541: [Sparc][Shave]: Empower the toolchain formerly known as SHAVE to do more.

2015-09-01 Thread Douglas Katzman via cfe-commits
dougk created this revision.
dougk added reviewers: jyknight, chandlerc.
dougk added a subscriber: cfe-commits.
Herald added a subscriber: jyknight.

Rename SHAVE toolchain to  Myriad toolchain.
Run the Myriad linker whenever the vendor [sic] is Myriad.
Also recognize RTEMS as the OS, and do something special for that.

(work-in-progress)

http://reviews.llvm.org/D12541

Files:
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h

Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -792,6 +792,17 @@
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
+
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+public:
+  Linker(const ToolChain &TC) : GnuTool("shave::Linker", "ld", TC) {}
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
 } // end namespace SHAVE
 
 } // end namespace tools
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9651,3 +9651,78 @@
   C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Exec),
   CmdArgs, Inputs));
 }
+
+void tools::SHAVE::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output,
+const InputInfoList &Inputs,
+const ArgList &Args,
+const char *LinkingOutput) const {
+  const auto &TC =
+  static_cast(getToolChain());
+  const llvm::Triple &T = TC.getTriple();
+  ArgStringList CmdArgs;
+
+  SmallString<128> CrtObjDir;
+  TC.getCompilerSupportDir(CrtObjDir);
+
+  CmdArgs.push_back("-EL"); // Endianness = little
+
+  // The remaining logic is mostly like gnutools::Linker::ConstructJob,
+  // but we never pass through a --sysroot option and various other bits.
+  // For example, there are no sanitizers (yet) nor gold linker.
+
+  // Silence warning for "clang -g foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  // and for "clang -w foo.o -o foo". Other warning options are already
+  // handled somewhere else.
+  Args.ClaimAllArgs(options::OPT_w);
+  if (Args.hasArg(options::OPT_s)) // Pass the 'strip' option.
+CmdArgs.push_back("-s");
+
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  if (T.getOS() == llvm::Triple::RTEMS) {
+SmallString<128> Path1(CrtObjDir), Path2(CrtObjDir);
+llvm::sys::path::append(Path1, "crti.o");
+llvm::sys::path::append(Path2, "crtbegin.o");
+CmdArgs.push_back(Args.MakeArgString(Path1));
+CmdArgs.push_back(Args.MakeArgString(Path2));
+  }
+
+  Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
+options::OPT_e, options::OPT_s, options::OPT_t,
+options::OPT_Z_Flag, options::OPT_r});
+
+  // The linker doesn't use these builtin paths unless directed to.
+  SmallString<128> LibDir;
+  TC.getBuiltinLibDir(LibDir);
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibDir));
+  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + CrtObjDir));
+
+  AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
+
+  if (T.getOS() == llvm::Triple::RTEMS) {
+CmdArgs.push_back("--start-group");
+CmdArgs.push_back("-lg");
+CmdArgs.push_back("-lrtemscpu");
+CmdArgs.push_back("-lrtemsbsp");
+CmdArgs.push_back("--end-group");
+  }
+  CmdArgs.push_back("-lgcc");
+  if (C.getDriver().CCCIsCXX())
+CmdArgs.push_back("-lstdc++");
+
+  if (T.getOS() == llvm::Triple::RTEMS) {
+SmallString<128> Path1(CrtObjDir), Path2(CrtObjDir);
+llvm::sys::path::append(Path1, "crtend.o");
+llvm::sys::path::append(Path2, "crtn.o");
+CmdArgs.push_back(Args.MakeArgString(Path1));
+CmdArgs.push_back(Args.MakeArgString(Path2));
+  }
+
+  std::string Exec =
+  Args.MakeArgString(TC.GetProgramPath("sparc-myriad-elf-ld"));
+  C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Exec),
+  CmdArgs, Inputs));
+}
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -101,7 +101,8 @@
   public:
 GCCInstallationDetector() : IsValid(false) {}
 void init(const Driver &D, const llvm::Triple &TargetTriple,
-  const llvm::opt::ArgList &Args);
+  const llvm::opt::ArgList &A

Re: [PATCH] D9040: [analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).

2015-09-01 Thread Антон Ярцев via cfe-commits
ayartsev updated this revision to Diff 33740.

http://reviews.llvm.org/D9040

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  test/Analysis/malloc.c

Index: test/Analysis/malloc.c
===
--- test/Analysis/malloc.c
+++ test/Analysis/malloc.c
@@ -263,21 +263,21 @@
 
 void CheckUseZeroAllocated7() {
   int *p = realloc(0, 0);
-  *p = 1; //TODO: warn about use of zero-allocated memory
+  *p = 1; // expected-warning {{Use of zero-allocated memory}}
   free(p);
 }
 
 void CheckUseZeroAllocated8() {
   int *p = malloc(8);
   int *q = realloc(p, 0);
-  *q = 1; //TODO: warn about use of zero-allocated memory
+  *q = 1; // expected-warning {{Use of zero-allocated memory}}
   free(q);
 }
 
 void CheckUseZeroAllocated9() {
   int *p = realloc(0, 0);
   int *q = realloc(p, 0);
-  *q = 1; //TODO: warn about use of zero-allocated memory
+  *q = 1; // expected-warning {{Use of zero-allocated memory}}
   free(q);
 }
 
@@ -307,6 +307,34 @@
   free(p);
 }
 
+void CheckUseZeroReallocatedPathNoWarn(_Bool b) {
+  int s = 0;
+  if (b)
+s= 10;
+
+  char *p = malloc(8);
+  char *q = realloc(p, s);
+
+  if (b)
+*q = 1; // no warning
+
+  free(q);
+}
+
+void CheckUseZeroReallocatedPathWarn(_Bool b) {
+  int s = 10;
+  if (b)
+s= 0;
+
+  char *p = malloc(8);
+  char *q = realloc(p, s);
+
+  if (b)
+*q = 1; // expected-warning {{Use of zero-allocated memory}}
+
+  free(q);
+}
+
 // This case tests that storing malloc'ed memory to a static variable which is
 // then returned is not leaked.  In the absence of known contracts for functions
 // or inter-procedural analysis, this is a conservative answer.
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -508,6 +508,7 @@
 
 REGISTER_MAP_WITH_PROGRAMSTATE(RegionState, SymbolRef, RefState)
 REGISTER_MAP_WITH_PROGRAMSTATE(ReallocPairs, SymbolRef, ReallocPair)
+REGISTER_SET_WITH_PROGRAMSTATE(ReallocSizeZeroSymbols, SymbolRef)
 
 // A map from the freed symbol to the symbol representing the return value of 
 // the free function.
@@ -891,15 +892,19 @@
   return State;
 
 const RefState *RS = State->get(Sym);
-if (!RS)
-  return State; // TODO: change to assert(RS); after realloc() will 
-// guarantee have a RegionState attached.
-
-if (!RS->isAllocated())
-  return State;
-
-return TrueState->set(Sym,
-   RefState::getAllocatedOfSizeZero(RS));
+if (RS) {
+  if (RS->isAllocated())
+return TrueState->set(Sym,
+  RefState::getAllocatedOfSizeZero(RS));
+  else
+return State;
+} else {
+  // Case of zero-size realloc. Historically 'realloc(ptr, 0)' is treated as
+  // 'free(ptr)' and the returned value from 'realloc(ptr, 0)' is not
+  // tracked. Add zero-reallocated Sym to the state to catch references
+  // to zero-allocated memory.
+  return TrueState->add(Sym);
+}
   }
 
   // Assume the value is non-zero going forward.
@@ -1487,6 +1492,9 @@
 Optional
 MallocChecker::getCheckIfTracked(CheckerContext &C, SymbolRef Sym,
  bool IsALeakCheck) const {
+  if (C.getState()->contains(Sym))
+return CK_MallocChecker;
+
   const RefState *RS = C.getState()->get(Sym);
   assert(RS);
   return getCheckIfTracked(RS->getAllocationFamily(), IsALeakCheck);
@@ -1929,7 +1937,7 @@
   }
 
   if (PrtIsNull && SizeIsZero)
-return nullptr;
+return State;
 
   // Get the from and to pointer symbols as in toPtr = realloc(fromPtr, size).
   assert(!PrtIsNull);
@@ -2291,10 +2299,14 @@
 void MallocChecker::checkUseZeroAllocated(SymbolRef Sym, CheckerContext &C,
   const Stmt *S) const {
   assert(Sym);
-  const RefState *RS = C.getState()->get(Sym);
 
-  if (RS && RS->isAllocatedOfSizeZero())
-ReportUseZeroAllocated(C, RS->getStmt()->getSourceRange(), Sym);
+  if (const RefState *RS = C.getState()->get(Sym)) {
+if (RS->isAllocatedOfSizeZero())
+  ReportUseZeroAllocated(C, RS->getStmt()->getSourceRange(), Sym);
+  }
+  else if (C.getState()->contains(Sym)) {
+ReportUseZeroAllocated(C, S->getSourceRange(), Sym);
+  }
 }
 
 bool MallocChecker::checkDoubleDelete(SymbolRef Sym, CheckerContext &C) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D9040: [analyzer] Make realloc(ptr, 0) handling equivalent to malloc(0).

2015-09-01 Thread Антон Ярцев via cfe-commits
ayartsev added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/MallocChecker.cpp:523
@@ -510,2 +522,3 @@
 REGISTER_MAP_WITH_PROGRAMSTATE(ReallocPairs, SymbolRef, ReallocPair)
+REGISTER_MAP_WITH_PROGRAMSTATE(ReallocSizeZeroFlag, SymbolRef, ReallocSizeZero)
 

zaks.anna wrote:
> I do not think this is related to my question.
> 
> You add a map from a symbol to a "flag" here; not really a flag but the empty 
> struct ReallocSizeZero. The only ways this is used is to set in the state 
> that the symbol is zero realloced or query if the specific symbol is zero 
> realloced. It seems that using the set of zero realloced symbols would be the 
> right data structure here.
> 
> Why do we need the extra complexity of the map and the empty struct?
Got it! Updated the patch.


http://reviews.llvm.org/D9040



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


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-09-01 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/CodeGen/CGCXX.cpp:42-44
@@ -33,1 +41,5 @@
 bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
+  // If sanitizing memory to check for use-after-dtor, do not emit as
+  // an alias, unless it has no fields or has only fields with non-trivial
+  // destructors.
+  if (getCodeGenOpts().SanitizeMemoryUseAfterDtor &&

I assume the rationale here is that the field and base class destructors will 
mark their storage as destroyed, so there's nothing else to mark? This may mean 
that vptrs and padding bytes don't get marked as destroyed, is that OK?


Comment at: lib/CodeGen/CGCXX.cpp:45-47
@@ +44,5 @@
+  // destructors.
+  if (getCodeGenOpts().SanitizeMemoryUseAfterDtor &&
+  HasFieldWithTrivialDestructor(*this, D->getParent()))
+return true;
+

This check seems to be redundant, since `TryEmitDefinitionAsAlias` checks the 
same thing. Remove this copy?


Comment at: lib/CodeGen/CGCXX.cpp:135
@@ +134,3 @@
+  cast(AliasDecl.getDecl())->getCanonicalDecl();
+  assert(isa(MD));
+  if (getCodeGenOpts().SanitizeMemoryUseAfterDtor &&

This function isn't (or wasn't) specific to destructors; I think you should be 
checking for this as part of your `if` below rather than asserting it.


Comment at: lib/CodeGen/CGCXX.cpp:136-138
@@ +135,5 @@
+  assert(isa(MD));
+  if (getCodeGenOpts().SanitizeMemoryUseAfterDtor &&
+  HasFieldWithTrivialDestructor(*this, MD->getParent()))
+return true;
+

Please reorder this after the quicker, higher-level checks below. (Maybe move 
it to just before we create the mangled name?)


Comment at: lib/CodeGen/CGClass.cpp:1334-1335
@@ -1338,1 +1333,4 @@
 {
+  if (Field->getType()->isPointerType())
+return true;
+

This appears redundant; we'd return `true` for pointers on line 1341 anyway. 
(`getBaseElementType` only strips off array types, not pointer types).


Comment at: lib/CodeGen/CGClass.cpp:1549
@@ +1548,3 @@
+
+  // Nothing to poison
+  if (Layout.getFieldCount() == 0)

Add full stop.


Comment at: lib/CodeGen/CGClass.cpp:1554
@@ +1553,3 @@
+  // Iterate over fields declared in this class, and count all fields,
+  // including inherited from base classes.
+  unsigned totalFields = 0;

You're only counting the direct fields here, not the inherited ones.


Comment at: lib/CodeGen/CGClass.cpp:1555-1558
@@ +1554,6 @@
+  // including inherited from base classes.
+  unsigned totalFields = 0;
+  for (auto *Field : Dtor->getParent()->fields()) {
+(void)Field;
+totalFields += 1;
+  }

unsigned totalFields = std::distance(Dtor->getParent()->field_begin(),
 Dtor->getParent()->field_end());


Comment at: lib/CodeGen/CGClass.cpp:1567
@@ +1566,3 @@
+  unsigned inheritedFields = totalFields - Layout.getFieldCount();
+  // todo: don't use iterator for accessing fields
+  RecordDecl::field_iterator Field;

todo -> TODO (or FIXME)


Comment at: lib/CodeGen/CGClass.cpp:1621
@@ +1620,3 @@
+
+  if (layoutEndOffset >= Layout.getFieldCount() - 1) {
+PoisonSize = Layout.getNonVirtualSize().getQuantity() -

I think this is off by one. `layoutEndOffset` is the index of the first field 
that is not poisoned, so this will trigger if we're poisoning up to, but not 
including, the last field, as well as triggering if we're poisoning the last 
field.


Comment at: lib/CodeGen/CGClass.cpp:1644-1645
@@ +1643,4 @@
+  CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
+  // Prevent the current stack frame from disappearing from the stack 
trace.
+  CGF.CurFn->addFnAttr("disable-tail-calls", "true");
+

Maybe do this once in `Emit` (if you poison anything) rather than doing it 
every time you emit a poison call?


Comment at: lib/CodeGen/CGClass.cpp:1722
@@ -1660,1 +1721,3 @@
 
+  if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor &&
+  SanOpts.has(SanitizerKind::Memory))

Please add a comment here. "Mark the lifetime of fields as ending after field 
destructors run and before we destroy base classes." or similar.


http://reviews.llvm.org/D12022



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


r246596 - Migrate the target attribute parsing code into an extension off of

2015-09-01 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Sep  1 17:03:58 2015
New Revision: 246596

URL: http://llvm.org/viewvc/llvm-project?rev=246596&view=rev
Log:
Migrate the target attribute parsing code into an extension off of
the main attribute and cache the results so we don't have to parse
a single attribute more than once.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=246596&r1=246595&r2=246596&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Sep  1 17:03:58 2015
@@ -1315,9 +1315,54 @@ def Pascal : InheritableAttr {
 
 def Target : InheritableAttr {
   let Spellings = [GCC<"target">];
-  let Args = [StringArgument<"features">];
+  let Args = [StringArgument<"featuresStr">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [TargetDocs];
+  let AdditionalMembers = [{
+StringRef CPU;
+std::vector Features;
+bool Parsed;
+StringRef getCPU() {
+   if (!Parsed)
+ parse();
+   return CPU;
+}
+std::vector &getFeatures() {
+   if (!Parsed)
+ parse();
+   return Features;
+}
+void parse() {
+  StringRef FeaturesStr = getFeaturesStr();
+  SmallVector AttrFeatures;
+  FeaturesStr.split(AttrFeatures, ",");
+
+  // Grab the various features and prepend a "+" to turn on the feature to
+  // the backend and add them to our existing set of features.
+  for (auto &Feature : AttrFeatures) {
+// Go ahead and trim whitespace rather than either erroring or
+// accepting it weirdly.
+Feature = Feature.trim();
+
+// While we're here iterating check for a different target cpu.
+if (Feature.startswith("arch="))
+  CPU = Feature.split("=").second.trim();
+else if (Feature.startswith("tune="))
+  // We don't support cpu tuning this way currently.
+  ;
+else if (Feature.startswith("fpmath="))
+  // TODO: Support the fpmath option this way. It will require checking
+  // overall feature validity for the function with the rest of the
+  // attributes on the function.
+  ;
+else if (Feature.startswith("no-"))
+  Features.push_back("-" + Feature.split("-").second.str());
+else
+  Features.push_back("+" + Feature.str());
+  }
+  Parsed = true;
+}
+  }];
 }
 
 def TransparentUnion : InheritableAttr {

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=246596&r1=246595&r2=246596&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Sep  1 17:03:58 2015
@@ -1499,40 +1499,19 @@ void CodeGenModule::ConstructAttributeLi
 const FunctionDecl *FD = dyn_cast_or_null(TargetDecl);
 if (FD && FD->hasAttr()) {
   llvm::StringMap FeatureMap;
-  const auto *TD = FD->getAttr();
+  auto *TD = FD->getAttr();
 
   // Make a copy of the features as passed on the command line.
   std::vector FnFeatures =
   getTarget().getTargetOpts().FeaturesAsWritten;
 
-  // Grab the target attribute string.
-  StringRef FeaturesStr = TD->getFeatures();
-  SmallVector AttrFeatures;
-  FeaturesStr.split(AttrFeatures, ",");
+  std::vector &AttrFeatures = TD->getFeatures();
+  std::copy(AttrFeatures.begin(), AttrFeatures.end(),
+std::back_inserter(FnFeatures));
 
-  // Grab the various features and prepend a "+" to turn on the feature to
-  // the backend and add them to our existing set of features.
-  for (auto &Feature : AttrFeatures) {
-// Go ahead and trim whitespace rather than either erroring or
-// accepting it weirdly.
-Feature = Feature.trim();
+  if (TD->getCPU() != "")
+   TargetCPU = TD->getCPU();
 
-// While we're here iterating check for a different target cpu.
-if (Feature.startswith("arch="))
-  TargetCPU = Feature.split("=").second.trim();
-else if (Feature.startswith("tune="))
-  // We don't support cpu tuning this way currently.
-  ;
-else if (Feature.startswith("fpmath="))
-  // TODO: Support the fpmath option this way. It will require checking
-  // overall feature validity for the function with the rest of the
-  // attributes on the function.
-  ;
-else if (Feature.startswith("no-"))
-  FnFeatures.push_back("-" + Feature.split("-").second.str());
-else
-  FnFeatures.push_back("+" + Feature.str());
-  }
   // Now populate the feature map, first with the TargetCPU 

r246595 - Use hasAttr, not getAttr if we're just checking for presence.

2015-09-01 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Sep  1 17:03:56 2015
New Revision: 246595

URL: http://llvm.org/viewvc/llvm-project?rev=246595&view=rev
Log:
Use hasAttr, not getAttr if we're just checking for presence.

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

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=246595&r1=246594&r2=246595&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Sep  1 17:03:56 2015
@@ -1497,7 +1497,7 @@ void CodeGenModule::ConstructAttributeLi
 // parse that and add it to the feature set.
 StringRef TargetCPU = getTarget().getTargetOpts().CPU;
 const FunctionDecl *FD = dyn_cast_or_null(TargetDecl);
-if (FD && FD->getAttr()) {
+if (FD && FD->hasAttr()) {
   llvm::StringMap FeatureMap;
   const auto *TD = FD->getAttr();
 


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


Re: [PATCH] D12453: [CUDA] Allow function overloads based on host/device attributes.

2015-09-01 Thread Artem Belevich via cfe-commits
tra updated the summary for this revision.
tra updated this revision to Diff 33741.
tra marked an inline comment as done.
tra added a comment.

Removed builtin-related changes(http://reviews.llvm.org/D12122). Will commit 
them separately.
Added more test cases.
Addressed eliben@'s comments.


http://reviews.llvm.org/D12453

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/CC1Options.td
  include/clang/Sema/Sema.h
  lib/AST/ItaniumMangle.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  test/CodeGenCUDA/function-overload.cu
  test/SemaCUDA/function-overload.cu

Index: test/SemaCUDA/function-overload.cu
===
--- /dev/null
+++ test/SemaCUDA/function-overload.cu
@@ -0,0 +1,186 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// Make sure we handle target overloads correctly.
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu \
+// RUN:-fsyntax-only -fcuda-target-overloads -verify %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda \
+// RUN:-fsyntax-only -fcuda-target-overloads -fcuda-is-device -verify %s
+
+// Check target overloads handling with disabled call target checks.
+// RUN: %clang_cc1 -DNOCHECKS -triple x86_64-unknown-linux-gnu -fsyntax-only \
+// RUN:-fcuda-disable-target-call-checks -fcuda-target-overloads -verify %s
+// RUN: %clang_cc1 -DNOCHECKS -triple nvptx64-nvidia-cuda -fsyntax-only \
+// RUN:-fcuda-disable-target-call-checks -fcuda-target-overloads \
+// RUN:-fcuda-is-device -verify %s
+
+#include "Inputs/cuda.h"
+
+typedef int (*fp_t)(void);
+typedef void (*gp_t)(void);
+
+__device__ int dhhd(void) { return 2; }
+__host__ int dhhd(void) { return 1; } // expected-note {{previous definition is here}}
+int dhhd(void) { return 1; } // expected-error {{redefinition of 'dhhd'}}
+__host__ __device__ int dhhd(void) { return 3; }
+
+__host__ int hhd(void) { return 4; }
+__host__ __device__ int dhd(void) { return 5; }
+
+__device__ int dhd(void) { return 6; }
+__host__ __device__ int hhd(void) { return 7; }
+
+__device__ int d(void) { return 8; }
+__host__ int h(void) { return 9; }
+__global__ void g(void) {}
+
+extern "C" __device__ int chd(void) {return 10;}
+extern "C" __host__ int chd(void) {return 11;} // expected-note {{previous definition is here}}
+extern "C" int chd(void) {return 11;} // expected-error {{redefinition of 'chd'}}
+extern "C" __host__ __device__ int chd(void) {return 12;} // expected-note {{previous definition is here}}
+extern "C" __host__ __device__ int chd(void) {return 13;} // expected-error {{redefinition of 'chd'}}
+
+__host__ void hostf(void) {
+  fp_t dhddp = dhhd;
+  fp_t hhdp = hhd;
+  fp_t dhdp = dhd;
+  gp_t gp = g;
+  fp_t dp = d;
+#if !defined(NOCHECKS)
+  // expected-error@-2 {{reference to __device__ function 'd' in __host__ function}}
+  // expected-note@33 {{'d' declared here}}
+#endif
+  fp_t hp = h;
+
+  dhhd();
+  hhd();
+  dhd();
+  chd();
+  d();
+#if !defined(NOCHECKS)
+  // expected-error@-2 {{no matching function for call to 'd'}}
+  // expected-note@33 {{candidate function not viable: call to __device__ function from __host__ function}}
+#endif
+  h();
+
+  g(); // expected-error {{call to global function g not configured}}
+  g<<<0,0>>>();
+}
+
+__device__ void devicef(void) {
+  fp_t dhddp = dhhd;
+  fp_t hhdp = hhd;
+  fp_t dhdp = dhd;
+  gp_t gp = g; // expected-error {{reference to __global__ function 'g' in __device__ function}}
+   // expected-note@35 {{'g' declared here}}
+  fp_t dp = d;
+  fp_t hp = h;
+#if !defined(NOCHECKS)
+  // expected-error@-2 {{reference to __host__ function 'h' in __device__ function}}
+  // expected-note@34 {{'h' declared here}}
+#endif
+
+  dhhd();
+  hhd();
+  dhd();
+  chd();
+  d();
+  h();
+  g();
+#if !defined(NOCHECKS)
+  // expected-error@-3 {{no matching function for call to 'h'}}
+  // expected-note@34 {{candidate function not viable: call to __host__ function from __device__ function}}
+#endif
+  // expected-error@-5 {{no matching function for call to 'g'}}
+  // expected-note@35 {{candidate function not viable: call to __global__ function from __device__ function}}
+  g<<<0,0>>>();
+  // expected-error@-1 {{reference to __global__ function 'g' in __device__ function}}
+  // expected-note@35 {{'g' declared here}}
+}
+
+__global__ void globalf(void) {
+  fp_t dhddp = dhhd;
+  fp_t hhdp = hhd;
+  fp_t dhdp = dhd;
+  gp_t gp = g; // expected-error {{reference to __global__ function 'g' in __global__ function}}
+   // expected-note@35 {{'g' declared here}}
+  fp_t dp = d;
+  fp_t hp = h;
+#if !defined(NOCHECKS)
+  // expected-error@-2 {{reference to __host__ function 'h' in __global__ function}}
+  // expected-note@34 {{'h' declared here}}
+#endif
+
+  dhhd();
+  hhd();
+  dhd();
+  chd();
+  d();
+  h();
+#if !defined(NOCHECKS)
+  // expected-error@-2 {{no m

Re: [PATCH] D12453: [CUDA] Allow function overloads based on host/device attributes.

2015-09-01 Thread Artem Belevich via cfe-commits
tra marked 2 inline comments as done.


Comment at: lib/Sema/SemaCUDA.cpp:106
@@ +105,3 @@
+
+  // (a) Can't call global from global until we support dynamic execution.
+  if (CalleeTarget == CFT_Global &&

eliben wrote:
> Not just global from global. global from device too, right? As for global 
> from HD, the CUDA guide forbids it
I'll update the comment.

As for HD->G, nvcc happily compiles following code:

```
__global__ void kernel() {}
__host__ __device__ void foo() {
#if !defined(__CUDA_ARCH__)
  kernel<<<0,0>>>();
#endif
}

```

Nvcc does produce an error for HD->G call during device compilation (the error 
actually complains about D->G or G->G calling). This patch matches nvcc 
behavior.


Comment at: lib/Sema/SemaChecking.cpp:529
@@ -528,3 +528,3 @@
   // of the arch we are compiling for.
-  if (BuiltinID >= Builtin::FirstTSBuiltin) {
+  if (Context.BuiltinInfo.isTSBuiltin(BuiltinID)) {
 switch (Context.getTargetInfo().getTriple().getArch()) {

eliben wrote:
> Is this part related to this patch?
It's part of D12122 which broke some of your team's tests and got rolled back.
It's a prerequisite for overloads to work (otherwise anything that uses a 
builtin would violate calling convention either during device or during host 
compilation) and it also needs to be hidden behind some option so it does not 
break your tests again.

I think I can commit it separately after the overload patch. Overloading will 
not work with builtins until then, but I don't think it's a big deal as there 
are no users yet.



http://reviews.llvm.org/D12453



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


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-09-01 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/CodeGen/CGCXX.cpp:42-44
@@ -33,1 +41,5 @@
 bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
+  // If sanitizing memory to check for use-after-dtor, do not emit as
+  // an alias, unless it has no fields or has only fields with non-trivial
+  // destructors.
+  if (getCodeGenOpts().SanitizeMemoryUseAfterDtor &&

rsmith wrote:
> I assume the rationale here is that the field and base class destructors will 
> mark their storage as destroyed, so there's nothing else to mark? This may 
> mean that vptrs and padding bytes don't get marked as destroyed, is that OK?
Yes, each (sub-)object poisons its storage in the base destructor, and only 
does it for fields that don't have their own destructors to avoid 
double-poisoning.

Poisoning vptr would be interesting. Yes, current implementation fails to do 
this. Padding - less so, but it would make the tool a little bit more 
predictable.


http://reviews.llvm.org/D12022



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-01 Thread Evgeniy Stepanov via cfe-commits
eugenis set the repository for this revision to rL LLVM.
eugenis updated this revision to Diff 33746.
eugenis marked an inline comment as done.

Repository:
  rL LLVM

http://reviews.llvm.org/D12087

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGen/always-inline.c
  test/CodeGen/always_inline.c
  test/CodeGen/alwaysinline-unused.c
  test/CodeGen/alwaysinline.c
  test/CodeGen/function-attributes.c
  test/CodeGen/pr9614.c
  test/CodeGenCXX/alwaysinline.cpp
  test/Frontend/optimization-remark-line-directive.c
  test/Frontend/optimization-remark.c
  test/Modules/cxx-irgen.cpp

Index: test/Modules/cxx-irgen.cpp
===
--- test/Modules/cxx-irgen.cpp
+++ test/Modules/cxx-irgen.cpp
@@ -26,14 +26,14 @@
   };
 }
 
-// CHECK-DAG: define available_externally hidden {{.*}}{{signext i32|i32}} @_ZN1SIiE1gEv({{.*}} #[[ALWAYS_INLINE:.*]] align
+// CHECK-DAG: define internal i32 @_ZN1SIiE1gEv.inlinefunction() #[[ALWAYS_INLINE:.*]] align
 int a = S::g();
 
 int b = h();
 
 // CHECK-DAG: define linkonce_odr {{.*}}{{signext i32|i32}} @_Z3minIiET_S0_S0_(i32
 int c = min(1, 2);
-// CHECK: define available_externally {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align
+// CHECK-DAG: define internal {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv.inlinefunction() #[[ALWAYS_INLINE]] align
 
 namespace ImplicitSpecialMembers {
   // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_(
Index: test/Frontend/optimization-remark.c
===
--- test/Frontend/optimization-remark.c
+++ test/Frontend/optimization-remark.c
@@ -32,6 +32,8 @@
 // CHECK-NOT: !llvm.dbg.cu = !{
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+2 {{foo.inlinefunction should always be inlined}}
+// expected-remark@+1 {{foo.inlinefunction inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
 float foz(int x, int y) __attribute__((noinline));
@@ -45,7 +47,7 @@
 // expected-remark@+5 {{foz will not be inlined into bar}}
 // expected-remark@+4 {{foz should never be inlined}}
 // expected-remark@+3 {{foz will not be inlined into bar}}
-// expected-remark@+2 {{foo should always be inlined}}
-// expected-remark@+1 {{foo inlined into bar}}
+// expected-remark@+2 {{foo.inlinefunction should always be inlined}}
+// expected-remark@+1 {{foo.inlinefunction inlined into bar}}
   return foo(j, j - 2) * foz(j - 2, j);
 }
Index: test/Frontend/optimization-remark-line-directive.c
===
--- test/Frontend/optimization-remark-line-directive.c
+++ test/Frontend/optimization-remark-line-directive.c
@@ -5,8 +5,9 @@
 // RUN: %clang_cc1 %s -Rpass=inline -gline-tables-only -dwarf-column-info -emit-llvm-only -verify
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+1 {{foo.inlinefunction inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
-// expected-remark@+2 {{foo inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
+// expected-remark@+2 {{foo.inlinefunction inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
 #line 1230 "/bad/path/to/original.c"
 int bar(int j) { return foo(j, j - 2); }
Index: test/CodeGenCXX/alwaysinline.cpp
===
--- /dev/null
+++ test/CodeGenCXX/alwaysinline.cpp
@@ -0,0 +1,68 @@
+// Test different kinds of alwaysinline *structor definitions.
+
+// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+struct A1 {
+  __attribute__((__always_inline__)) A1() {}
+  __attribute__((__always_inline__)) ~A1() {}
+};
+
+void g1() {
+  A1 a1;
+}
+
+struct A2 {
+  inline __attribute__((__always_inline__)) A2() {}
+  inline __attribute__((__always_inline__)) ~A2() {}
+};
+
+void g2() {
+  A2 a2;
+}
+
+struct A3 {
+  inline __attribute__((gnu_inline, __always_inline__)) A3() {}
+  inline __attribute__((gnu_inline, __always_inline__)) ~A3() {}
+};
+
+void g3() {
+  A3 a3;
+}
+
+// CHECK-DAG: define internal void @_ZN2A1C1Ev.inlinefunction(%struct.A1* %this) unnamed_addr #[[AI:[01-9]+]]
+// CHECK-DAG: define internal void @_ZN2A1C2Ev.inlinefunction(%struct.A1* %this) unnamed_addr #[[AI]]
+// CHECK-DAG: define internal void @_ZN2A1D1Ev.inlinefunction(%struct.A1* %this) unnamed_

Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-01 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/CodeGen/CodeGenModule.cpp:469-470
@@ +468,4 @@
+  llvm::LLVMContext &Ctx = getModule().getContext();
+  llvm::Function *StubFn =
+  llvm::Function::Create(FT, Fn->getLinkage(), Name, &getModule());
+  assert(StubFn->getName() == Name && "name was uniqued!");

rnk wrote:
> This is a lot of work to do for every always_inline function that got called. 
> Can we do this like:
> 1. Build SmallVector of all non-direct call uses of Fn
> 2. Return if there are no such uses
> 3. Build the stub function replacement
> 4. `for (Use *U : IndirectUses) U->set(StubFn)`
This is a very good idea. It's not exactly as easy as that, but it works, see 
the new code.


Comment at: test/CodeGen/2008-05-19-AlwaysInline.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - | not grep sabrina
+// RUN: %clang_cc1 %s -emit-llvm -o - | not grep 'call.*sabrina('
 

rnk wrote:
> FileCheck?
Actually, this chunk is not needed with your proposed change.
Reverted.


Repository:
  rL LLVM

http://reviews.llvm.org/D12087



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


r246598 - Revert "Migrate the target attribute parsing code into an extension off of"

2015-09-01 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Sep  1 17:37:03 2015
New Revision: 246598

URL: http://llvm.org/viewvc/llvm-project?rev=246598&view=rev
Log:
Revert "Migrate the target attribute parsing code into an extension off of"

This is failing in release mode. Revert while I figure out what's happening.

This reverts commit r246596.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=246598&r1=246597&r2=246598&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Sep  1 17:37:03 2015
@@ -1315,54 +1315,9 @@ def Pascal : InheritableAttr {
 
 def Target : InheritableAttr {
   let Spellings = [GCC<"target">];
-  let Args = [StringArgument<"featuresStr">];
+  let Args = [StringArgument<"features">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [TargetDocs];
-  let AdditionalMembers = [{
-StringRef CPU;
-std::vector Features;
-bool Parsed;
-StringRef getCPU() {
-   if (!Parsed)
- parse();
-   return CPU;
-}
-std::vector &getFeatures() {
-   if (!Parsed)
- parse();
-   return Features;
-}
-void parse() {
-  StringRef FeaturesStr = getFeaturesStr();
-  SmallVector AttrFeatures;
-  FeaturesStr.split(AttrFeatures, ",");
-
-  // Grab the various features and prepend a "+" to turn on the feature to
-  // the backend and add them to our existing set of features.
-  for (auto &Feature : AttrFeatures) {
-// Go ahead and trim whitespace rather than either erroring or
-// accepting it weirdly.
-Feature = Feature.trim();
-
-// While we're here iterating check for a different target cpu.
-if (Feature.startswith("arch="))
-  CPU = Feature.split("=").second.trim();
-else if (Feature.startswith("tune="))
-  // We don't support cpu tuning this way currently.
-  ;
-else if (Feature.startswith("fpmath="))
-  // TODO: Support the fpmath option this way. It will require checking
-  // overall feature validity for the function with the rest of the
-  // attributes on the function.
-  ;
-else if (Feature.startswith("no-"))
-  Features.push_back("-" + Feature.split("-").second.str());
-else
-  Features.push_back("+" + Feature.str());
-  }
-  Parsed = true;
-}
-  }];
 }
 
 def TransparentUnion : InheritableAttr {

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=246598&r1=246597&r2=246598&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Sep  1 17:37:03 2015
@@ -1499,19 +1499,40 @@ void CodeGenModule::ConstructAttributeLi
 const FunctionDecl *FD = dyn_cast_or_null(TargetDecl);
 if (FD && FD->hasAttr()) {
   llvm::StringMap FeatureMap;
-  auto *TD = FD->getAttr();
+  const auto *TD = FD->getAttr();
 
   // Make a copy of the features as passed on the command line.
   std::vector FnFeatures =
   getTarget().getTargetOpts().FeaturesAsWritten;
 
-  std::vector &AttrFeatures = TD->getFeatures();
-  std::copy(AttrFeatures.begin(), AttrFeatures.end(),
-std::back_inserter(FnFeatures));
+  // Grab the target attribute string.
+  StringRef FeaturesStr = TD->getFeatures();
+  SmallVector AttrFeatures;
+  FeaturesStr.split(AttrFeatures, ",");
 
-  if (TD->getCPU() != "")
-   TargetCPU = TD->getCPU();
+  // Grab the various features and prepend a "+" to turn on the feature to
+  // the backend and add them to our existing set of features.
+  for (auto &Feature : AttrFeatures) {
+// Go ahead and trim whitespace rather than either erroring or
+// accepting it weirdly.
+Feature = Feature.trim();
 
+// While we're here iterating check for a different target cpu.
+if (Feature.startswith("arch="))
+  TargetCPU = Feature.split("=").second.trim();
+else if (Feature.startswith("tune="))
+  // We don't support cpu tuning this way currently.
+  ;
+else if (Feature.startswith("fpmath="))
+  // TODO: Support the fpmath option this way. It will require checking
+  // overall feature validity for the function with the rest of the
+  // attributes on the function.
+  ;
+else if (Feature.startswith("no-"))
+  FnFeatures.push_back("-" + Feature.split("-").second.str());
+else
+  FnFeatures.push_back("+" + Feature.str());
+  }
   // Now populate the feature map, first with

r246600 - Fix assertion failure in TransformOpaqueValueExpr

2015-09-01 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Tue Sep  1 17:50:31 2015
New Revision: 246600

URL: http://llvm.org/viewvc/llvm-project?rev=246600&view=rev
Log:
Fix assertion failure in TransformOpaqueValueExpr

Summary:
`OpaqueValueExpr`s may not have a source expression (as in the case when
they are created due to a default argument error).
This can cause an assertion failure in `TransformOpaqueValueExpr` during
template instantiation.

This patch fixes the assertion failure.

Reviewers: hfinkel, rsmith

Subscribers: fraggamuffin, cfe-commits

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

Patch by Rachel Craik!

Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaTemplate/default-arguments.cpp

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=246600&r1=246599&r2=246600&view=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Sep  1 17:50:31 2015
@@ -7806,7 +7806,7 @@ TreeTransform::TransformOffsetO
 template
 ExprResult
 TreeTransform::TransformOpaqueValueExpr(OpaqueValueExpr *E) {
-  assert(getDerived().AlreadyTransformed(E->getType()) &&
+  assert((!E->getSourceExpr() || 
getDerived().AlreadyTransformed(E->getType())) &&
  "opaque value expression requires transformation");
   return E;
 }

Modified: cfe/trunk/test/SemaTemplate/default-arguments.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-arguments.cpp?rev=246600&r1=246599&r2=246600&view=diff
==
--- cfe/trunk/test/SemaTemplate/default-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-arguments.cpp Tue Sep  1 17:50:31 2015
@@ -166,3 +166,9 @@ namespace NondefDecls {
   }
   template void f1();  // expected-note{{in instantiation of function 
template specialization 'NondefDecls::f1' requested here}}
 }
+
+template 
+struct C {
+  C(T t = ); // expected-error {{expected expression}}
+};
+C obj;


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


[PATCH] D12544: Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.

2015-09-01 Thread Ivan Krasin via cfe-commits
krasin created this revision.
krasin added reviewers: pcc, rsmith.
krasin added a subscriber: cfe-commits.

Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.

Introduce a frontend option -fdepfile-entry, and only insert them
for the user-defined sanitizer blacklists. In frontend, grab ExtraDeps
from -fdepfile-entry, instead of -fsanitize-blacklist.

http://reviews.llvm.org/D12544

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/fsanitize-blacklist.c
  test/Frontend/print-header-includes.c

Index: test/Frontend/print-header-includes.c
===
--- test/Frontend/print-header-includes.c
+++ test/Frontend/print-header-includes.c
@@ -14,7 +14,7 @@
 // MS-NOT: Note
 
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang_cc1 -fsanitize=address -fsanitize-blacklist=%t.blacklist -E --show-includes -o %t.out %s > %t.stdout
+// RUN: %clang_cc1 -fsanitize=address -fdepfile-entry=%t.blacklist -E --show-includes -o %t.out %s > %t.stdout
 // RUN: FileCheck --check-prefix=MS-BLACKLIST < %t.stdout %s
 // MS-BLACKLIST: Note: including file: {{.*\.blacklist}}
 // MS-BLACKLIST: Note: including file: {{.*test.h}}
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -13,8 +13,7 @@
 // RUN: echo "badline" > %t.bad
 
 // RUN: %clang -fsanitize=address -fsanitize-blacklist=%t.good -fsanitize-blacklist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST
-// CHECK-BLACKLIST: -fsanitize-blacklist={{.*}}.good
-// CHECK-BLACKLIST: -fsanitize-blacklist={{.*}}.second
+// CHECK-BLACKLIST: -fsanitize-blacklist={{.*}}.good" "-fsanitize-blacklist={{.*}}.second
 
 // Ignore -fsanitize-blacklist flag if there is no -fsanitize flag.
 // RUN: %clang -fsanitize-blacklist=%t.good %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SANITIZE --check-prefix=DELIMITERS
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -709,7 +709,7 @@
   // Add sanitizer blacklists as extra dependencies.
   // They won't be discovered by the regular preprocessor, so
   // we let make / ninja to know about this implicit dependency.
-  Opts.ExtraDeps = Args.getAllArgValues(OPT_fsanitize_blacklist);
+  Opts.ExtraDeps = Args.getAllArgValues(OPT_fdepfile_entry);
   auto ModuleFiles = Args.getAllArgValues(OPT_fmodule_file);
   Opts.ExtraDeps.insert(Opts.ExtraDeps.end(), ModuleFiles.begin(),
 ModuleFiles.end());
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -176,6 +176,7 @@
   RecoverableSanitizers.clear();
   TrapSanitizers.clear();
   BlacklistFiles.clear();
+  ExtraDeps.clear();
   CoverageFeatures = 0;
   MsanTrackOrigins = 0;
   MsanUseAfterDtor = false;
@@ -383,13 +384,16 @@
 if (Arg->getOption().matches(options::OPT_fsanitize_blacklist)) {
   Arg->claim();
   std::string BLPath = Arg->getValue();
-  if (llvm::sys::fs::exists(BLPath))
+  if (llvm::sys::fs::exists(BLPath)) {
 BlacklistFiles.push_back(BLPath);
-  else
+ExtraDeps.push_back(BLPath);
+  } else
 D.Diag(clang::diag::err_drv_no_such_file) << BLPath;
+
 } else if (Arg->getOption().matches(options::OPT_fno_sanitize_blacklist)) {
   Arg->claim();
   BlacklistFiles.clear();
+  ExtraDeps.clear();
 }
   }
   // Validate blacklists format.
@@ -563,6 +567,11 @@
 BlacklistOpt += BLPath;
 CmdArgs.push_back(Args.MakeArgString(BlacklistOpt));
   }
+  for (const auto &Dep : ExtraDeps) {
+SmallString<64> ExtraDepOpt("-fdepfile-entry=");
+ExtraDepOpt += Dep;
+CmdArgs.push_back(Args.MakeArgString(ExtraDepOpt));
+  }
 
   if (MsanTrackOrigins)
 CmdArgs.push_back(Args.MakeArgString("-fsanitize-memory-track-origins=" +
Index: include/clang/Driver/SanitizerArgs.h
===
--- include/clang/Driver/SanitizerArgs.h
+++ include/clang/Driver/SanitizerArgs.h
@@ -27,6 +27,7 @@
   SanitizerSet TrapSanitizers;
 
   std::vector BlacklistFiles;
+  std::vector ExtraDeps;
   int CoverageFeatures;
   int MsanTrackOrigins;
   bool MsanUseAfterDtor;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -495,6 +495,8 @@
   Flags<[DriverOption]>;
 def fdebug_pass_arguments : Flag<["-"], "fdebug-pass-arguments">, Group;
 def fdebug_pass_structure : Flag<["-"], "fdebug-pass-structure">, Group;
+def fdepfile_entry : Joined<["-"], "fdepfile-

Re: [PATCH] D11963: Create a __config_site file to capture configuration decisions.

2015-09-01 Thread Evgeniy Stepanov via cfe-commits
eugenis added a subscriber: eugenis.
eugenis added a comment.

This would greatly simplify the abi versioning change in 
http://reviews.llvm.org/D11740. Thanks for working on this!



Comment at: include/CMakeLists.txt:24
@@ +23,3 @@
+  -P ${LIBCXX_SOURCE_DIR}/cmake/Modules/CopyLibcxxHeaders.cmake
+  WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
+

This is creative :)
I don't know the usual cmake conventions, but CopyLibcxxHeaders is very 
different from other files in cmake/Modules in that it is a standalone script 
and not an included file. Should it be moved to smth like cmake/Scripts, or 
named differently?



http://reviews.llvm.org/D11963



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


Re: [PATCH] D12544: Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.

2015-09-01 Thread Peter Collingbourne via cfe-commits
pcc added a comment.

It's probably time to add something like the driver test I was talking about in 
http://reviews.llvm.org/D12021. Without that, you will have no test coverage 
for the functional change here.


http://reviews.llvm.org/D12544



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


Re: [PATCH] D12453: [CUDA] Allow function overloads based on host/device attributes.

2015-09-01 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/Builtins.h:85
@@ +84,3 @@
+  /// \brief Return true if this function is a target-specific builtin
+  bool isTSBuiltin(unsigned ID) const {
+return ID >= Builtin::FirstTSBuiltin;

I would prefer the more verbose `isTargetBuiltin` or `isTargetSpecificBuiltin` 
-- I don't think it will be obvious at call sites what this does if we use this 
abbreviation in the public interface.


Comment at: lib/Sema/SemaExprCXX.cpp:2259
@@ -2258,1 +2258,3 @@
 
+  // Filter out unsuitable CUDA functions.
+  if (getLangOpts().CUDA) {

I don't see any test coverage for this; please add some tests that declare 
usual deallocation functions with CUDA host/device attributes and check that 
they behave as expected.


Comment at: lib/Sema/SemaExprCXX.cpp:2276
@@ +2275,3 @@
+Matches[I] = Matches[--N];
+Matches.set_size(N);
+  } else {

Use `resize`, not `set_size`.


Comment at: lib/Sema/SemaOverload.cpp:10119-10143
@@ -10102,1 +10118,27 @@
 
+  void EliminateSuboptimalCudaMatches() {
+assert(S.getLangOpts().CUDATargetOverloads &&
+   "Should not be called w/o enabled target overloads.");
+
+// Find the best call preference among the functions in Matches.
+FunctionDecl *Caller = dyn_cast(S.CurContext);
+Sema::CUDAFunctionPreference BestCFP = Sema::CFP_Never;
+for (auto const& Match: Matches) {
+  Sema::CUDAFunctionPreference P =
+  S.IdentifyCUDAPreference(Caller, Match.second);
+  if (P > BestCFP)
+BestCFP = P;
+}
+
+assert(BestCFP != Sema::CFP_Never && "No usable CUDA functions.");
+// If any suitable functions found, remove all items that are
+// *not* suitable.
+for (unsigned I = 0, N = Matches.size(); I != N;)
+  if (S.IdentifyCUDAPreference(Caller, Matches[I].second) != BestCFP) {
+Matches[I] = Matches[--N];
+Matches.set_size(N);
+  } else {
+++I;
+  }
+  }
+

Please factor out the common code shared by this and 
`FindUsualDeallocationFunction`.


http://reviews.llvm.org/D12453



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


Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-09-01 Thread Naomi Musgrave via cfe-commits
nmusgrave updated this revision to Diff 33752.
nmusgrave marked 13 inline comments as done.
nmusgrave added a comment.

- Simplified implementation of class field poisoning, to avoid redundant 
counting and conditional checks. Expensive checks delayed.


http://reviews.llvm.org/D12022

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
  test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp

Index: test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
@@ -0,0 +1,30 @@
+// Test -fsanitize-memory-use-after-dtor
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O2 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {}
+};
+
+// Virtual function table for the derived class only contains
+// its own destructors, with no aliasing to base class dtors.
+struct Base {
+  Vector v;
+  int x;
+  Base() { x = 5; }
+  virtual ~Base() {}
+};
+
+struct Derived : public Base {
+  int z;
+  Derived() { z = 10; }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Definition of virtual function table
+// CHECK: @_ZTV7Derived = {{.*}}@_ZN7DerivedD1Ev{{.*}}@_ZN7DerivedD0Ev
Index: test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
===
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsanitize=memory -O0 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+
+template 
+class Vector {
+public:
+  int size;
+  ~Vector() {
+size += 1;
+  }
+};
+
+struct Base {
+  int b1;
+  double b2;
+  Base() {
+b1 = 5;
+b2 = 10.989;
+  }
+  virtual ~Base() {}
+};
+
+struct VirtualBase {
+  int vb1;
+  int vb2;
+  VirtualBase() {
+vb1 = 10;
+vb2 = 11;
+  }
+  virtual ~VirtualBase() {}
+};
+
+struct Derived : public Base, public virtual VirtualBase {
+  int d1;
+  Vector v;
+  int d2;
+  Derived() {
+d1 = 10;
+  }
+  ~Derived() {}
+};
+
+Derived d;
+
+// Destruction order:
+// Derived: int, Vector, Base, VirtualBase
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD1Ev
+// CHECK: call void {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN7DerivedD0Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD1Ev
+// CHECK: ret void
+
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD0Ev
+// CHECK: ret void
+
+// poison 2 ints
+// CHECK-LABEL: define {{.*}}ZN11VirtualBaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: ret void
+
+// poison int and double
+// CHECK-LABEL: define {{.*}}ZN4BaseD2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 16)
+// CHECK: ret void
+
+// poison int, ignore vector, poison int
+// CHECK-LABEL: define {{.*}}ZN7DerivedD2Ev
+// CHECK: call void {{.*}}ZN6VectorIiED1Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: call void {{.*}}ZN4BaseD2Ev
+// CHECK: ret void
+
+// poison int
+// CHECK-LABEL: define {{.*}}ZN6VectorIiED2Ev
+// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4)
+// CHECK: ret void
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -1099,6 +1099,13 @@
   /// are emitted lazily.
   void EmitGlobal(GlobalDecl D);
 
+  bool
+  HasTrivialDestructorBody(ASTContext &Context,
+   const CXXRecordDecl *BaseClassDecl,
+   const CXXRecordDecl *MostDerivedClassDecl);
+  bool
+  FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
+
   bool TryEmitDefinitionAsAlias(GlobalDecl Alias, GlobalDecl Target,
 bool InEveryTU);
   bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D);
Index: lib/CodeGen/CGClass.cpp
===
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1286,11 +1286,7 @@
   CM.finish();
 }
 
-static bool
-FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field);
-
-static bool
-HasTrivialDestructorBody(ASTContext &Context,
+bool CodeGenModule::HasTrivialDestructorBody(ASTContext &Context,
  const CXXRecordDecl *BaseClassDecl,
  const CXXRecordDecl *MostDerivedClas

Re: [PATCH] D12022: Refactored dtor sanitizing into EHScopeStack

2015-09-01 Thread Naomi Musgrave via cfe-commits
nmusgrave added inline comments.


Comment at: lib/CodeGen/CGCXX.cpp:42-44
@@ -33,1 +41,5 @@
 bool CodeGenModule::TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D) {
+  // If sanitizing memory to check for use-after-dtor, do not emit as
+  // an alias, unless it has no fields or has only fields with non-trivial
+  // destructors.
+  if (getCodeGenOpts().SanitizeMemoryUseAfterDtor)

vptr poisoning will be implemented in another CL after this is approved


http://reviews.llvm.org/D12022



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


r246610 - Migrate the target attribute parsing code into an extension off of

2015-09-01 Thread Eric Christopher via cfe-commits
Author: echristo
Date: Tue Sep  1 19:12:02 2015
New Revision: 246610

URL: http://llvm.org/viewvc/llvm-project?rev=246610&view=rev
Log:
Migrate the target attribute parsing code into an extension off of
the main attribute and cache the results so we don't have to parse
a single attribute more than once.

This reapplies r246596 with a fix for an uninitialized class member,
and a couple of cleanups and formatting changes.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=246610&r1=246609&r2=246610&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Sep  1 19:12:02 2015
@@ -1315,9 +1315,52 @@ def Pascal : InheritableAttr {
 
 def Target : InheritableAttr {
   let Spellings = [GCC<"target">];
-  let Args = [StringArgument<"features">];
+  let Args = [StringArgument<"featuresStr">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [TargetDocs];
+  let AdditionalMembers = [{
+StringRef CPU;
+std::vector Features;
+bool Parsed = false;
+StringRef getCPU() {
+  if (!Parsed)
+parse();
+  return CPU;
+}
+std::vector &getFeatures() {
+  if (!Parsed)
+parse();
+  return Features;
+}
+void parse() {
+  SmallVector AttrFeatures;
+  getFeaturesStr().split(AttrFeatures, ",");
+
+  // Grab the various features and prepend a "+" to turn on the feature to
+  // the backend and add them to our existing set of features.
+  for (auto &Feature : AttrFeatures) {
+// Go ahead and trim whitespace rather than either erroring or
+// accepting it weirdly.
+Feature = Feature.trim();
+
+// We don't support cpu tuning this way currently.
+// TODO: Support the fpmath option. It will require checking
+// overall feature validity for the function with the rest of the
+// attributes on the function.
+if (Feature.startswith("fpmath=") || Feature.startswith("tune="))
+ continue;
+
+// While we're here iterating check for a different target cpu.
+if (Feature.startswith("arch="))
+  CPU = Feature.split("=").second.trim();
+else if (Feature.startswith("no-"))
+  Features.push_back("-" + Feature.split("-").second.str());
+else
+  Features.push_back("+" + Feature.str());
+  }
+  Parsed = true;
+}
+  }];
 }
 
 def TransparentUnion : InheritableAttr {

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=246610&r1=246609&r2=246610&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Sep  1 19:12:02 2015
@@ -1499,40 +1499,19 @@ void CodeGenModule::ConstructAttributeLi
 const FunctionDecl *FD = dyn_cast_or_null(TargetDecl);
 if (FD && FD->hasAttr()) {
   llvm::StringMap FeatureMap;
-  const auto *TD = FD->getAttr();
+  auto *TD = FD->getAttr();
 
   // Make a copy of the features as passed on the command line.
   std::vector FnFeatures =
   getTarget().getTargetOpts().FeaturesAsWritten;
 
-  // Grab the target attribute string.
-  StringRef FeaturesStr = TD->getFeatures();
-  SmallVector AttrFeatures;
-  FeaturesStr.split(AttrFeatures, ",");
+  std::vector &AttrFeatures = TD->getFeatures();
+  std::copy(AttrFeatures.begin(), AttrFeatures.end(),
+std::back_inserter(FnFeatures));
 
-  // Grab the various features and prepend a "+" to turn on the feature to
-  // the backend and add them to our existing set of features.
-  for (auto &Feature : AttrFeatures) {
-// Go ahead and trim whitespace rather than either erroring or
-// accepting it weirdly.
-Feature = Feature.trim();
+  if (TD->getCPU() != "")
+   TargetCPU = TD->getCPU();
 
-// While we're here iterating check for a different target cpu.
-if (Feature.startswith("arch="))
-  TargetCPU = Feature.split("=").second.trim();
-else if (Feature.startswith("tune="))
-  // We don't support cpu tuning this way currently.
-  ;
-else if (Feature.startswith("fpmath="))
-  // TODO: Support the fpmath option this way. It will require checking
-  // overall feature validity for the function with the rest of the
-  // attributes on the function.
-  ;
-else if (Feature.startswith("no-"))
-  FnFeatures.push_back("-" + Feature.split("-").second.str());
-else
-  FnFeatures.push_back("+" + Feature.str());
-  }
   // Now populate the fea

Re: [PATCH] D12544: Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.

2015-09-01 Thread Ivan Krasin via cfe-commits
krasin updated this revision to Diff 33764.
krasin added a comment.

Add a test for default blacklist.


http://reviews.llvm.org/D12544

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/Inputs/resource_dir/asan_blacklist.txt
  test/Driver/fsanitize-blacklist.c
  test/Frontend/print-header-includes.c

Index: test/Frontend/print-header-includes.c
===
--- test/Frontend/print-header-includes.c
+++ test/Frontend/print-header-includes.c
@@ -14,7 +14,7 @@
 // MS-NOT: Note
 
 // RUN: echo "fun:foo" > %t.blacklist
-// RUN: %clang_cc1 -fsanitize=address -fsanitize-blacklist=%t.blacklist -E --show-includes -o %t.out %s > %t.stdout
+// RUN: %clang_cc1 -fsanitize=address -fdepfile-entry=%t.blacklist -E --show-includes -o %t.out %s > %t.stdout
 // RUN: FileCheck --check-prefix=MS-BLACKLIST < %t.stdout %s
 // MS-BLACKLIST: Note: including file: {{.*\.blacklist}}
 // MS-BLACKLIST: Note: including file: {{.*test.h}}
Index: test/Driver/fsanitize-blacklist.c
===
--- test/Driver/fsanitize-blacklist.c
+++ test/Driver/fsanitize-blacklist.c
@@ -13,13 +13,26 @@
 // RUN: echo "badline" > %t.bad
 
 // RUN: %clang -fsanitize=address -fsanitize-blacklist=%t.good -fsanitize-blacklist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST
-// CHECK-BLACKLIST: -fsanitize-blacklist={{.*}}.good
-// CHECK-BLACKLIST: -fsanitize-blacklist={{.*}}.second
+// CHECK-BLACKLIST: -fsanitize-blacklist={{.*}}.good" "-fsanitize-blacklist={{.*}}.second
+
+// Now, check for -fdepfile-entry flags.
+// RUN: %clang -fsanitize=address -fsanitize-blacklist=%t.good -fsanitize-blacklist=%t.second %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-BLACKLIST2
+// CHECK-BLACKLIST2: -fdepfile-entry={{.*}}.good" "-fdepfile-entry={{.*}}.second
+
+// Check that the default blacklist is not added as an extra dependency.
+// RUN: %clang -fsanitize=address -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST
+// CHECK-DEFAULT-BLACKLIST: -fsanitize-blacklist={{.*}}asan_blacklist.txt
+// CHECK-DEFAULT-BLACKLIST-NOT: -fdepfile-entry
 
 // Ignore -fsanitize-blacklist flag if there is no -fsanitize flag.
 // RUN: %clang -fsanitize-blacklist=%t.good %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SANITIZE --check-prefix=DELIMITERS
 // CHECK-NO-SANITIZE-NOT: -fsanitize-blacklist
 
+// Ignore -fsanitize-blacklist flag if there is no -fsanitize flag.
+// Now, check for the absense of -fdepfile-entry flags.
+// RUN: %clang -fsanitize-blacklist=%t.good %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SANITIZE2 --check-prefix=DELIMITERS
+// CHECK-NO-SANITIZE2-NOT: -fdepfile-entry
+
 // Flag -fno-sanitize-blacklist wins if it is specified later.
 // RUN: %clang -fsanitize=address -fsanitize-blacklist=%t.good -fno-sanitize-blacklist %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-BLACKLIST --check-prefix=DELIMITERS
 // CHECK-NO-BLACKLIST-NOT: -fsanitize-blacklist
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -709,7 +709,7 @@
   // Add sanitizer blacklists as extra dependencies.
   // They won't be discovered by the regular preprocessor, so
   // we let make / ninja to know about this implicit dependency.
-  Opts.ExtraDeps = Args.getAllArgValues(OPT_fsanitize_blacklist);
+  Opts.ExtraDeps = Args.getAllArgValues(OPT_fdepfile_entry);
   auto ModuleFiles = Args.getAllArgValues(OPT_fmodule_file);
   Opts.ExtraDeps.insert(Opts.ExtraDeps.end(), ModuleFiles.begin(),
 ModuleFiles.end());
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -176,6 +176,7 @@
   RecoverableSanitizers.clear();
   TrapSanitizers.clear();
   BlacklistFiles.clear();
+  ExtraDeps.clear();
   CoverageFeatures = 0;
   MsanTrackOrigins = 0;
   MsanUseAfterDtor = false;
@@ -383,13 +384,16 @@
 if (Arg->getOption().matches(options::OPT_fsanitize_blacklist)) {
   Arg->claim();
   std::string BLPath = Arg->getValue();
-  if (llvm::sys::fs::exists(BLPath))
+  if (llvm::sys::fs::exists(BLPath)) {
 BlacklistFiles.push_back(BLPath);
-  else
+ExtraDeps.push_back(BLPath);
+  } else
 D.Diag(clang::diag::err_drv_no_such_file) << BLPath;
+
 } else if (Arg->getOption().matches(options::OPT_fno_sanitize_blacklist)) {
   Arg->claim();
   BlacklistFiles.clear();
+  ExtraDeps.clear();
 }
   }
   // Validate blacklists format.
@@ -563,6 +567,11 @@
 BlacklistOpt += BLPath;
 CmdArgs.push_back(Args.MakeArgString(BlacklistOpt));
   }
+  for (const auto &Dep : ExtraDeps

Re: [PATCH] D12544: Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.

2015-09-01 Thread Ivan Krasin via cfe-commits
krasin added a comment.

In http://reviews.llvm.org/D12544#237819, @pcc wrote:

> It's probably time to add something like the driver test I was talking about 
> in http://reviews.llvm.org/D12021. Without that, you will have no test 
> coverage for the functional change here.


Done, please, take a look.


http://reviews.llvm.org/D12544



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


[PATCH] D12547: Add support for function attribute "disable_tail_calls"

2015-09-01 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a subscriber: cfe-commits.

There have been requests for a function attribute that disables tail call 
optimizations in the backend. This patch defines such an attribute.

http://reviews.llvm.org/D12547

Files:
  include/clang/Basic/Attr.td
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-disable-tail-calls.c

Index: test/CodeGen/attr-disable-tail-calls.c
===
--- test/CodeGen/attr-disable-tail-calls.c
+++ test/CodeGen/attr-disable-tail-calls.c
@@ -1,11 +1,19 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm 
-mdisable-tail-calls -o - | FileCheck %s -check-prefix=CHECK 
-check-prefix=DISABLE
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | 
FileCheck %s -check-prefix=CHECK -check-prefix=ENABLE
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm 
-mdisable-tail-calls -o - | FileCheck %s -check-prefix=DISABLE
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | 
FileCheck %s -check-prefix=ENABLE
 
-// CHECK: define i32 @f1() [[ATTR:#[0-9]+]] {
+// DISABLE: define i32 @f1() [[ATTRTRUE:#[0-9]+]] {
+// DISABLE: define i32 @f2() [[ATTRTRUE]] {
+// ENABLE: define i32 @f1() [[ATTRFALSE:#[0-9]+]] {
+// ENABLE: define i32 @f2() [[ATTRTRUE:#[0-9]+]] {
 
 int f1() {
   return 0;
 }
 
-// DISABLE: attributes [[ATTR]] = { {{.*}} "disable-tail-calls"="true" {{.*}} }
-// ENABLE: attributes [[ATTR]] = { {{.*}} "disable-tail-calls"="false" {{.*}} }
+int f2() __attribute__((disable_tail_calls)) {
+  return 0;
+}
+
+// DISABLE: attributes [[ATTRTRUE]] = { {{.*}} "disable-tail-calls"="true" 
{{.*}} }
+// ENABLE: attributes [[ATTRFALSE]] = { {{.*}} "disable-tail-calls"="false" 
{{.*}} }
+// ENABLE: attributes [[ATTRTRUE]] = { {{.*}} "disable-tail-calls"="true" 
{{.*}} }
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4878,6 +4878,9 @@
   case AttributeList::AT_ReturnsTwice:
 handleSimpleAttribute(S, D, Attr);
 break;
+  case AttributeList::AT_DisableTailCalls:
+handleSimpleAttribute(S, D, Attr);
+break;
   case AttributeList::AT_Used:
 handleUsedAttr(S, D, Attr);
 break;
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1474,8 +1474,12 @@
   FuncAttrs.addAttribute("no-frame-pointer-elim-non-leaf");
 }
 
-FuncAttrs.addAttribute("disable-tail-calls",
-   llvm::toStringRef(CodeGenOpts.DisableTailCalls));
+if ((TargetDecl && TargetDecl->hasAttr()) ||
+CodeGenOpts.DisableTailCalls)
+  FuncAttrs.addAttribute("disable-tail-calls", "true");
+else
+  FuncAttrs.addAttribute("disable-tail-calls", "false");
+
 FuncAttrs.addAttribute("less-precise-fpmad",
llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
 FuncAttrs.addAttribute("no-infs-fp-math",
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -891,6 +891,12 @@
   let Documentation = [Undocumented];
 }
 
+def DisableTailCalls : InheritableAttr {
+  let Spellings = [GNU<"disable_tail_calls">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}
+
 def NoAlias : InheritableAttr {
   let Spellings = [Declspec<"noalias">];
   let Subjects = SubjectList<[Function]>;


Index: test/CodeGen/attr-disable-tail-calls.c
===
--- test/CodeGen/attr-disable-tail-calls.c
+++ test/CodeGen/attr-disable-tail-calls.c
@@ -1,11 +1,19 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -mdisable-tail-calls -o - | FileCheck %s -check-prefix=CHECK -check-prefix=DISABLE
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK -check-prefix=ENABLE
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -mdisable-tail-calls -o - | FileCheck %s -check-prefix=DISABLE
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 %s -emit-llvm -o - | FileCheck %s -check-prefix=ENABLE
 
-// CHECK: define i32 @f1() [[ATTR:#[0-9]+]] {
+// DISABLE: define i32 @f1() [[ATTRTRUE:#[0-9]+]] {
+// DISABLE: define i32 @f2() [[ATTRTRUE]] {
+// ENABLE: define i32 @f1() [[ATTRFALSE:#[0-9]+]] {
+// ENABLE: define i32 @f2() [[ATTRTRUE:#[0-9]+]] {
 
 int f1() {
   return 0;
 }
 
-// DISABLE: attributes [[ATTR]] = { {{.*}} "disable-tail-calls"="true" {{.*}} }
-// ENABLE: attributes [[ATTR]] = { {{.*}} "disable-tail-calls"="false" {{.*}} }
+int f2() __attribute__((disable_tail_calls)) {
+  return 0;
+}
+
+// DISABLE: attributes [[ATTRTRUE]] = { {{.*}} "disable-tail-calls"="true" {{.*}} }
+// ENABLE: att

Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-01 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a reviewer: rnk.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm



Comment at: lib/CodeGen/CodeGenModule.cpp:463
@@ +462,3 @@
+
+// if (U.getUser() == GV) continue;
+

Commented out code?


Comment at: lib/CodeGen/CodeGenModule.cpp:479-480
@@ +478,4 @@
+if (C && !isa(C)) {
+  for (llvm::Use &U : C->uses())
+U->dump();
+  C->handleOperandChange(V, Replacement, U);

Some debugging code maybe?


Repository:
  rL LLVM

http://reviews.llvm.org/D12087



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


Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-01 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 33766.

Repository:
  rL LLVM

http://reviews.llvm.org/D12087

Files:
  lib/CodeGen/CGCXX.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGen/always-inline.c
  test/CodeGen/always_inline.c
  test/CodeGen/alwaysinline-unused.c
  test/CodeGen/alwaysinline.c
  test/CodeGen/function-attributes.c
  test/CodeGen/pr9614.c
  test/CodeGenCXX/alwaysinline.cpp
  test/Frontend/optimization-remark-line-directive.c
  test/Frontend/optimization-remark.c
  test/Modules/cxx-irgen.cpp

Index: test/Modules/cxx-irgen.cpp
===
--- test/Modules/cxx-irgen.cpp
+++ test/Modules/cxx-irgen.cpp
@@ -26,14 +26,14 @@
   };
 }
 
-// CHECK-DAG: define available_externally hidden {{.*}}{{signext i32|i32}} @_ZN1SIiE1gEv({{.*}} #[[ALWAYS_INLINE:.*]] align
+// CHECK-DAG: define internal i32 @_ZN1SIiE1gEv.inlinefunction() #[[ALWAYS_INLINE:.*]] align
 int a = S::g();
 
 int b = h();
 
 // CHECK-DAG: define linkonce_odr {{.*}}{{signext i32|i32}} @_Z3minIiET_S0_S0_(i32
 int c = min(1, 2);
-// CHECK: define available_externally {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv({{.*}} #[[ALWAYS_INLINE]] align
+// CHECK-DAG: define internal {{.*}}{{signext i32|i32}} @_ZN1SIiE1fEv.inlinefunction() #[[ALWAYS_INLINE]] align
 
 namespace ImplicitSpecialMembers {
   // CHECK-LABEL: define {{.*}} @_ZN22ImplicitSpecialMembers1BC2ERKS0_(
Index: test/Frontend/optimization-remark.c
===
--- test/Frontend/optimization-remark.c
+++ test/Frontend/optimization-remark.c
@@ -32,6 +32,8 @@
 // CHECK-NOT: !llvm.dbg.cu = !{
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+2 {{foo.inlinefunction should always be inlined}}
+// expected-remark@+1 {{foo.inlinefunction inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
 float foz(int x, int y) __attribute__((noinline));
@@ -45,7 +47,7 @@
 // expected-remark@+5 {{foz will not be inlined into bar}}
 // expected-remark@+4 {{foz should never be inlined}}
 // expected-remark@+3 {{foz will not be inlined into bar}}
-// expected-remark@+2 {{foo should always be inlined}}
-// expected-remark@+1 {{foo inlined into bar}}
+// expected-remark@+2 {{foo.inlinefunction should always be inlined}}
+// expected-remark@+1 {{foo.inlinefunction inlined into bar}}
   return foo(j, j - 2) * foz(j - 2, j);
 }
Index: test/Frontend/optimization-remark-line-directive.c
===
--- test/Frontend/optimization-remark-line-directive.c
+++ test/Frontend/optimization-remark-line-directive.c
@@ -5,8 +5,9 @@
 // RUN: %clang_cc1 %s -Rpass=inline -gline-tables-only -dwarf-column-info -emit-llvm-only -verify
 
 int foo(int x, int y) __attribute__((always_inline));
+// expected-remark@+1 {{foo.inlinefunction inlined into foo}}
 int foo(int x, int y) { return x + y; }
 
-// expected-remark@+2 {{foo inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
+// expected-remark@+2 {{foo.inlinefunction inlined into bar}} expected-note@+2 {{could not determine the original source location for /bad/path/to/original.c:1230:25}}
 #line 1230 "/bad/path/to/original.c"
 int bar(int j) { return foo(j, j - 2); }
Index: test/CodeGenCXX/alwaysinline.cpp
===
--- /dev/null
+++ test/CodeGenCXX/alwaysinline.cpp
@@ -0,0 +1,68 @@
+// Test different kinds of alwaysinline *structor definitions.
+
+// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -mconstructor-aliases -disable-llvm-optzns -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-CALL
+
+struct A1 {
+  __attribute__((__always_inline__)) A1() {}
+  __attribute__((__always_inline__)) ~A1() {}
+};
+
+void g1() {
+  A1 a1;
+}
+
+struct A2 {
+  inline __attribute__((__always_inline__)) A2() {}
+  inline __attribute__((__always_inline__)) ~A2() {}
+};
+
+void g2() {
+  A2 a2;
+}
+
+struct A3 {
+  inline __attribute__((gnu_inline, __always_inline__)) A3() {}
+  inline __attribute__((gnu_inline, __always_inline__)) ~A3() {}
+};
+
+void g3() {
+  A3 a3;
+}
+
+// CHECK-DAG: define internal void @_ZN2A1C1Ev.inlinefunction(%struct.A1* %this) unnamed_addr #[[AI:[01-9]+]]
+// CHECK-DAG: define internal void @_ZN2A1C2Ev.inlinefunction(%struct.A1* %this) unnamed_addr #[[AI]]
+// CHECK-DAG: define internal void @_ZN2A1D1Ev.inlinefunction(%struct.A1* %this) unnamed_addr #[[AI]]
+// CHECK-DAG: define internal void @_ZN2A1D2Ev.inlinefunction(%struct.A1* %this) unna

Re: [PATCH] D12087: always_inline codegen rewrite

2015-09-01 Thread Evgeniy Stepanov via cfe-commits
eugenis marked 2 inline comments as done.
eugenis added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D12087



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


Re: r203885 - [Modules] Emit the module file paths as dependencies of the PCH when we are building one.

2015-09-01 Thread Argyrios Kyrtzidis via cfe-commits
(Apologies for the long delay).

> On Aug 8, 2015, at 6:30 PM, Richard Smith  wrote:
> 
> On Thu, Mar 13, 2014 at 8:07 PM, Argyrios Kyrtzidis  > wrote:
> Author: akirtzidis
> Date: Thu Mar 13 22:07:38 2014
> New Revision: 203885
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=203885&view=rev 
> 
> Log:
> [Modules] Emit the module file paths as dependencies of the PCH when we are 
> building one.
> 
> This is because the PCH is tied to the module files, if one of the module 
> files changes or gets removed
> the build system should re-build the PCH file.
> 
> Is there any reason this has its own -cc1 flag instead of being tied to 
> -emit-pch?

Offers a bit of flexibility and separation of concerns between dependency file 
generation and output file generation.
But I don’t have a strong preference, if it simplifies things to not have a 
separate option I’m fine with removing it.

>  
> rdar://16321245
> 
> Added:
> cfe/trunk/test/Driver/pch-deps.c
> cfe/trunk/test/Modules/dependency-gen-pch.m
> Modified:
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Frontend/DependencyFile.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> 
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=203885&r1=203884&r2=203885&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Mar 13 22:07:38 2014
> @@ -223,6 +223,8 @@ def dependent_lib : Joined<["--"], "depe
> 
>  def sys_header_deps : Flag<["-"], "sys-header-deps">,
>HelpText<"Include system headers in dependency output">;
> +def module_file_deps : Flag<["-"], "module-file-deps">,
> +  HelpText<"Include module files in dependency output">;
>  def header_include_file : Separate<["-"], "header-include-file">,
>HelpText<"Filename (or -) to write header include output to">;
>  def show_includes : Flag<["--"], "show-includes">,
> 
> Modified: cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h?rev=203885&r1=203884&r2=203885&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h (original)
> +++ cfe/trunk/include/clang/Frontend/DependencyOutputOptions.h Thu Mar 13 
> 22:07:38 2014
> @@ -26,6 +26,7 @@ public:
>   /// problems.
>unsigned AddMissingHeaderDeps : 1; ///< Add missing headers to dependency 
> list
>unsigned PrintShowIncludes : 1; ///< Print cl.exe style /showIncludes info.
> +  unsigned IncludeModuleFiles : 1; ///< Include module file dependencies.
> 
>/// The file to write dependency output to.
>std::string OutputFile;
> @@ -50,6 +51,7 @@ public:
>  UsePhonyTargets = 0;
>  AddMissingHeaderDeps = 0;
>  PrintShowIncludes = 0;
> +IncludeModuleFiles = 0;
>}
>  };
> 
> 
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=203885&r1=203884&r2=203885&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Mar 13 22:07:38 2014
> @@ -171,6 +171,9 @@ public:
>virtual void ReadCounter(const serialization::ModuleFile &M,
> unsigned Value) {}
> 
> +  /// This is called for each AST file loaded.
> +  virtual void visitModuleFile(StringRef Filename) {}
> +
>/// \brief Returns true if this \c ASTReaderListener wants to receive the
>/// input files of the AST file via \c visitInputFile, false otherwise.
>virtual bool needsInputFileVisitation() { return false; }
> @@ -217,6 +220,7 @@ public:
>void ReadCounter(const serialization::ModuleFile &M, unsigned Value) 
> override;
>bool needsInputFileVisitation() override;
>bool needsSystemInputFileVisitation() override;
> +  void visitModuleFile(StringRef Filename)

Re: [PATCH] D11380: Implement LFTS searchers. Boyer_Moore and Boyer_Moore_Horspool

2015-09-01 Thread Marshall Clow via cfe-commits
mclow.lists updated this revision to Diff 33770.
mclow.lists added a comment.

Updated based on Eric's comments.


http://reviews.llvm.org/D11380

Files:
  include/experimental/functional
  test/std/experimental/algorithms/alg.search/search.pass.cpp
  
test/std/experimental/func/func.searchers/func.searchers.boyer_moore/default.pass.cpp
  
test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pass.cpp
  
test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp
  
test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp
  
test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/default.pass.cpp
  
test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pass.cpp
  
test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pred.pass.cpp
  
test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp

Index: test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp
===
--- test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp
+++ test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp
@@ -0,0 +1,130 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+
+// 
+
+// boyer_moore_horspool searcher
+// template::value_type>,
+//  class BinaryPredicate = equal_to<>>
+// class boyer_moore_horspool_searcher {
+// public:
+//   boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last,
+// Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate());
+// 
+//   template
+//   RandomAccessIterator2
+//   operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
+// 
+// private:
+//   RandomAccessIterator1 pat_first_; // exposition only
+//   RandomAccessIterator1 pat_last_;  // exposition only
+//   Hash  hash_;  // exposition only
+//   BinaryPredicate   pred_;  // exposition only
+// };
+
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+
+struct count_equal
+{
+static unsigned count;
+template 
+bool operator()(const T& x, const T& y) const
+{++count; return x == y;}
+};
+
+unsigned count_equal::count = 0;
+
+template 
+void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned max_count) {
+std::experimental::boyer_moore_horspool_searcher::value_type>::type>, count_equal> s{b2, e2};
+count_equal::count = 0;
+assert(result == std::experimental::search(b1, e1, s));
+//assert(count_equal::count <= max_count);
+}
+
+template 
+void
+test()
+{
+int ia[] = {0, 1, 2, 3, 4, 5};
+const unsigned sa = sizeof(ia)/sizeof(ia[0]);
+do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia),  Iter2(ia),Iter1(ia),  0);
+do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia),  Iter2(ia+1),  Iter1(ia),  sa);
+do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia+1),Iter2(ia+2),  Iter1(ia+1),sa);
+do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia+2),Iter2(ia+2),  Iter1(ia),  0);
+do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia+2),Iter2(ia+3),  Iter1(ia+2),sa);
+do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia+2),Iter2(ia+3),  Iter1(ia+2),sa);
+do_search(Iter1(ia), Iter1(ia),  Iter2(ia+2),Iter2(ia+3),  Iter1(ia),  0);
+do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa);
+do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa);
+do_search(Iter1(ia), Iter1(ia+sa),   Iter2(ia),  Iter2(ia+sa), Iter1(ia),  sa*sa);
+do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia),  Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa);
+do_search(Iter1(ia), Iter1(ia+1),Iter2(ia),  Iter2(ia+sa), Iter1(ia+1),sa);
+int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4};
+const unsigned sb = sizeof(ib)/sizeof(ib[0]);
+int ic[] = {1};
+do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb);
+int id[] = {1, 2};
+do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2);
+int ie[] = {1, 2, 3};
+do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3);
+int ig[] = {1, 2, 3, 4};
+do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4);
+int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4};
+const unsigned sh = 

Re: [PATCH] D11380: Implement LFTS searchers. Boyer_Moore and Boyer_Moore_Horspool

2015-09-01 Thread Marshall Clow via cfe-commits
mclow.lists marked 3 inline comments as done.
mclow.lists added a comment.

http://reviews.llvm.org/D11380



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


Re: [PATCH] D12312: Emiting invariant.group.barrier and adding -fstrict-vptrs

2015-09-01 Thread Piotr Padlewski via cfe-commits
Prazek marked 3 inline comments as done.


Comment at: lib/CodeGen/CGClass.cpp:1279
@@ +1278,3 @@
+  if (CGM.getCodeGenOpts().StrictVPtrs && BaseVPtrsInitialized)
+CXXThisValue = Builder.CreateInvariantGroupBarrier(LoadCXXThis());
+

rjmccall wrote:
> Prazek wrote:
> > rjmccall wrote:
> > > Prazek wrote:
> > > > rjmccall wrote:
> > > > > Should this just be in InitializeVTablePointers?
> > > > I want to add invariant.group.barrier only if it's needed. F.e. I don't 
> > > > want to put before I initialize vptrs for base, or when my class 
> > > > doesn't inherit frome anything. I want emit barrier after I will 
> > > > initialize some other vptrs.
> > > > 
> > > > InitializeVptrs is called in EmitBaseInitializer, and also I woudnt 
> > > > want to put some extra flag if it must produce barrier or not (because 
> > > > it is hard to distinguish it from inside)
> > > Fair enough.
> > > 
> > > Do we need to emit these barriers in unoptimized builds?
> > It depends - if we will not add invariant.group metadata to loads/stores 
> > without optimizations, then we can not add theis invariant barrier stuff. 
> > My question is, if I will run clang
> > 
> > clang++ stuff.cpp -O0 -fstrict-vptrs 
> > 
> > does it mean, that I don't want any optimizations, or it means that I don't 
> > want any optimizations except strict-vptrs?
> > If answer is second one, then I think not checking for optimizations is 
> > fine (If we will change it to be default, then we will have to add 
> > Optmizations turned check)
> Well, we're not actually going to do the optimizations at -O0 in any case, 
> and "please emit the information necessary to do the optimizations without 
> actually doing them" is not an intermediate state that users actually want.
> 
> The basic problem here continues to be that, as designed, this optimization 
> is unsound without cooperation from every module that emitted any IR.  In 
> order for this optimization to qualify as a non-experimental feature, you 
> will need to actually fix that so that it decays gracefully in the presence 
> of a non-cooperating module.  Once you do that, it will also be reasonable to 
> omit these barriers at -O0.
> 
> When we talked about this before, we had a workable, if conservative, plan 
> for how to implement that graceful decay: you need to tag cooperating 
> functions and then untag them when information is merged (e.g. by the 
> inliner) from non-cooperating functions.  Do you still see that as practical?
Ok, I think I won't add invariant.barrier with O0.

I want to concentrate on !invariant.group optimization more now, so for now the 
plan is this:

 if we are in O0, then we don't care at all about invariant.group.barrier, we 
just skip emiting it.
If we are in opt, and fstrict-vtable-pointers is true, then we will add module 
metadata about it
and when LTO will try to link 2 modules
one with strict-vptrs and one without
then for now, we can just raise an error.
In the future we can strip invariant stuff from module without flag.

Because optimizer doesn't care about invariant.group.barrier now, I will add 
module metadata in next patch.


http://reviews.llvm.org/D12312



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


Re: [PATCH] D12312: Emiting invariant.group.barrier and adding -fstrict-vptrs

2015-09-01 Thread Piotr Padlewski via cfe-commits
Prazek updated the summary for this revision.
Prazek updated this revision to Diff 33775.

http://reviews.llvm.org/D12312

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp

Index: test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- /dev/null
+++ test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -0,0 +1,193 @@
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -disable-llvm-optzns -O2 -emit-llvm -o %t.ll
+// RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
+// RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
+// RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
+
+typedef __typeof__(sizeof(0)) size_t;
+void *operator new(size_t, void*) throw();
+
+struct NotTrivialDtor {
+  ~NotTrivialDtor();
+};
+
+struct DynamicBase1 {
+  NotTrivialDtor obj;
+  virtual void foo();
+};
+
+struct DynamicDerived : DynamicBase1 {
+  void foo();
+};
+
+struct DynamicBase2 {
+  virtual void bar();
+  ~DynamicBase2() {
+bar();
+  }
+};
+
+struct DynamicDerivedMultiple : DynamicBase1, DynamicBase2 {
+  virtual void foo();
+  virtual void bar();
+};
+
+struct StaticBase {
+  NotTrivialDtor obj;
+  void bar();
+};
+
+struct DynamicFromStatic : StaticBase {
+  virtual void bar();
+};
+
+struct DynamicFromVirtualStatic1 : virtual StaticBase {
+};
+
+struct DynamicFromVirtualStatic2 : virtual StaticBase {
+};
+
+struct DynamicFrom2Virtuals :
+DynamicFromVirtualStatic1,
+DynamicFromVirtualStatic2 {
+};
+
+// CHECK-NEW-LABEL: define void @_Z12LocalObjectsv()
+// CHECK-NEW-NOT: @llvm.invariant.group.barrier(
+// CHECK-NEW-LABEL: }
+void LocalObjects() {
+  DynamicBase1 DB;
+  DB.foo();
+  DynamicDerived DD;
+  DD.foo();
+
+  DynamicBase2 DB2;
+  DB2.bar();
+
+  StaticBase SB;
+  SB.bar();
+
+  DynamicDerivedMultiple DDM;
+  DDM.foo();
+  DDM.bar();
+
+  DynamicFromStatic DFS;
+  DFS.bar();
+  DynamicFromVirtualStatic1 DFVS1;
+  DFVS1.bar();
+  DynamicFrom2Virtuals DF2V;
+  DF2V.bar();
+}
+
+struct DynamicFromVirtualStatic1;
+// CHECK-CTORS-LABEL: define linkonce_odr void @_ZN25DynamicFromVirtualStatic1C1Ev
+// CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
+// CHECK-CTORS-LABEL: }
+
+struct DynamicFrom2Virtuals;
+// CHECK-CTORS-LABEL: define linkonce_odr void @_ZN20DynamicFrom2VirtualsC1Ev
+// CHECK-CTORS: call i8* @llvm.invariant.group.barrier(
+// CHECK-CTORS-LABEL: }
+
+
+// CHECK-NEW-LABEL: define void @_Z9Pointers1v()
+// CHECK-NEW-NOT: @llvm.invariant.group.barrier(
+// CHECK-NEW-LABEL: call void @_ZN12DynamicBase1C1Ev(
+
+// CHECK-NEW: %[[THIS3:.*]] = call i8* @llvm.invariant.group.barrier(i8* %[[THIS2:.*]])
+// CHECK-NEW: %[[THIS4:.*]] = bitcast i8* %[[THIS3]] to %[[DynamicDerived:.*]]*
+// CHECK-NEW: call void @_ZN14DynamicDerivedC1Ev(%[[DynamicDerived:.*]]* %[[THIS4]])
+// CHECK-NEW-LABEL: }
+void Pointers1() {
+  DynamicBase1 *DB = new DynamicBase1;
+  DB->foo();
+
+  DynamicDerived *DD = new (DB) DynamicDerived;
+  DD->foo();
+  DD->~DynamicDerived();
+}
+
+// CHECK-NEW-LABEL: define void @_Z14HackingObjectsv()
+// CHECK-NEW:  call void @_ZN12DynamicBase1C1Ev
+// CHECK-NEW:  call i8* @llvm.invariant.group.barrier(
+// CHECK-NEW:  call void @_ZN14DynamicDerivedC1Ev(
+// CHECK-NEW:  call i8* @llvm.invariant.group.barrier(
+// CHECK-NEW: call void @_ZN12DynamicBase1C1Ev(
+// CHECK-NEW-LABEL: }
+void HackingObjects() {
+  DynamicBase1 DB;
+  DB.foo();
+
+  DynamicDerived *DB2 = new (&DB) DynamicDerived;
+  // Using DB now is prohibited.
+  DB2->foo();
+  DB2->~DynamicDerived();
+
+  // We have to get back to the previous type to avoid calling wrong destructor
+  new (&DB) DynamicBase1;
+  DB.foo();
+}
+
+/*** Testing Constructors ***/
+struct DynamicBase1;
+// CHECK-CTORS-LABEL: define linkonce_odr void @_ZN12DynamicBase1C2Ev(
+// CHECK-CTORS-NOT: call i8* @llvm.invariant.group.barrier(
+// CHECK-CTORS-LABEL: }
+
+
+struct DynamicDerived;
+// CHECK-CTORS-LABEL: define linkonce_odr void @_ZN14DynamicDerivedC2Ev(
+// CHECK-CTORS: call void @_ZN12DynamicBase1C2Ev(
+// CHECK-CTORS: %[[THIS1:.*]] = bitcast %[[DynamicDerived:.*]]* %[[THIS0:.*]] to i8*
+// CHECK-CTORS: %[[THIS2:.*]] = call i8* @llvm.invariant.group.barrier(i8* %[[THIS1:.*]])
+// CHECK-CTORS: %[[THIS3:.*]] = bitcast i8* %[[THIS2:.*]] to %[[DynamicDerived]]*
+// CHECK-CTORS: %[[THIS4:.*]] = bitcast %struct.DynamicDerived* %[[THIS3:.*]] to i32 (...)***
+// CHECK-CTORS: store {{.*}} %[[THIS4:.*]]
+// CHECK-CTORS-LABEL: }
+
+struct DynamicDerivedMultiple;
+// CHECK-CTORS-LABEL: define linkonce_odr void @_ZN22DynamicDerivedMultipleC2Ev
+// CHECK-CTORS: call void @_ZN12DynamicBase1C2Ev(
+// CHECK-CTORS-NOT: @llvm.invariant.group.barrier
+// CHECK-CTORS-LABEL: call void @_ZN12DynamicBase2C2Ev(
+// CHECK-CTORS: %[[THIS1:.*]] = bitcast %[[CLASS:.*]]* %[[THIS0:.

Re: [PATCH] D12444: [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)

2015-09-01 Thread David Majnemer via cfe-commits
majnemer accepted this revision.
majnemer added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D12444



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


Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-09-01 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Gentle ping.


http://reviews.llvm.org/D12313



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


Re: [PATCH] D12444: [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)

2015-09-01 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246618: [Sema] Avoid crash on tag-type mismatch (Fixes 
PR24610) (authored by vedantk).

Changed prior to commit:
  http://reviews.llvm.org/D12444?vs=33623&id=33777#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12444

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/enum.c

Index: cfe/trunk/test/Sema/enum.c
===
--- cfe/trunk/test/Sema/enum.c
+++ cfe/trunk/test/Sema/enum.c
@@ -119,3 +119,7 @@
 
 typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
 int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -3560,6 +3560,9 @@
 
 void Sema::setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
 TypedefNameDecl *NewTD) {
+  if (TagFromDeclSpec->isInvalidDecl())
+return;
+
   // Do nothing if the tag already has a name for linkage purposes.
   if (TagFromDeclSpec->hasNameForLinkage())
 return;


Index: cfe/trunk/test/Sema/enum.c
===
--- cfe/trunk/test/Sema/enum.c
+++ cfe/trunk/test/Sema/enum.c
@@ -119,3 +119,7 @@
 
 typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
 int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -3560,6 +3560,9 @@
 
 void Sema::setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
 TypedefNameDecl *NewTD) {
+  if (TagFromDeclSpec->isInvalidDecl())
+return;
+
   // Do nothing if the tag already has a name for linkage purposes.
   if (TagFromDeclSpec->hasNameForLinkage())
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r246618 - [Sema] Avoid crash on tag-type mismatch (Fixes PR24610)

2015-09-01 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Tue Sep  1 22:27:15 2015
New Revision: 246618

URL: http://llvm.org/viewvc/llvm-project?rev=246618&view=rev
Log:
[Sema] Avoid crash on tag-type mismatch (Fixes PR24610)

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/enum.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=246618&r1=246617&r2=246618&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Sep  1 22:27:15 2015
@@ -3560,6 +3560,9 @@ void Sema::handleTagNumbering(const TagD
 
 void Sema::setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec,
 TypedefNameDecl *NewTD) {
+  if (TagFromDeclSpec->isInvalidDecl())
+return;
+
   // Do nothing if the tag already has a name for linkage purposes.
   if (TagFromDeclSpec->hasNameForLinkage())
 return;

Modified: cfe/trunk/test/Sema/enum.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enum.c?rev=246618&r1=246617&r2=246618&view=diff
==
--- cfe/trunk/test/Sema/enum.c (original)
+++ cfe/trunk/test/Sema/enum.c Tue Sep  1 22:27:15 2015
@@ -119,3 +119,7 @@ void crash(enum E* e) // expected-warnin
 
 typedef enum { NegativeShort = (short)-1 } NegativeShortEnum;
 int NegativeShortTest[NegativeShort == -1 ? 1 : -1];
+
+// PR24610
+enum Color { Red, Green, Blue }; // expected-note{{previous use is here}}
+typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}


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


Re: [PATCH] D12544: Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.

2015-09-01 Thread Peter Collingbourne via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM with nit.



Comment at: test/Driver/fsanitize-blacklist.c:25
@@ -18,1 +24,3 @@
+// CHECK-DEFAULT-BLACKLIST: -fsanitize-blacklist={{.*}}asan_blacklist.txt
+// CHECK-DEFAULT-BLACKLIST-NOT: -fdepfile-entry
 

Maybe use `FileCheck -implicit-check-not=` to verify that this doesn't also 
appear on the other side of the `-fsanitize-blacklist`?


http://reviews.llvm.org/D12544



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


Re: [PATCH] D12541: [Sparc][Shave]: Empower the toolchain formerly known as SHAVE to do more.

2015-09-01 Thread Douglas Katzman via cfe-commits
dougk updated the summary for this revision.
dougk updated this revision to Diff 33778.
dougk added a comment.

Revised tests.


http://reviews.llvm.org/D12541

Files:
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtbegin.o
  test/Driver/shave-toolchain.c

Index: test/Driver/shave-toolchain.c
===
--- test/Driver/shave-toolchain.c
+++ test/Driver/shave-toolchain.c
@@ -1,3 +1,9 @@
+// RUN: %clang -no-canonical-prefixes -### -target sparc-myriad-rtems-elf %s \
+// RUN: -B %S/Inputs/basic_myriad_tree 2>&1 | FileCheck %s -check-prefix=LINK_WITH_RTEMS
+// LINK_WITH_RTEMS: crti.o
+// LINK_WITH_RTEMS: crtbegin.o
+// LINK_WITH_RTEMS: -lrtems
+
 // Ensure that '-target shave' picks a different compiler.
 // Also check that '-I' is turned into '-i:' for the assembler.
 
@@ -8,20 +14,20 @@
 // As such, we test only for a trailing quote in its rendering.
 // The same goes for "moviAsm".
 
-// RUN: %clang -target shave -c -### %s -Icommon 2>&1 \
+// RUN: %clang -target shave-myriad -c -### %s -Icommon 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
 // MOVICOMPILE: moviCompile" "-DMYRIAD2" "-mcpu=myriad2" "-S" "-I" "common"
 // MOVICOMPILE: moviAsm" "-no6thSlotCompression" "-cv:myriad2" "-noSPrefixing" "-a" "-i:common" "-elf"
 
-// RUN: %clang -target shave -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
+// RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFINES
 // DEFINES: "-D" "EFINE_ME" "-U" "NDEFINE_ME"
 
-// RUN: %clang -target shave -c -### %s -Icommon -iquote quotepath -isystem syspath 2>&1 \
+// RUN: %clang -target shave-myriad -c -### %s -Icommon -iquote quotepath -isystem syspath 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=INCLUDES
 // INCLUDES: "-iquote" "quotepath" "-isystem" "syspath"
 
-// RUN: %clang -target shave -c -### %s -g -fno-inline-functions \
+// RUN: %clang -target shave-myriad -c -### %s -g -fno-inline-functions \
 // RUN: -fno-inline-functions-called-once -Os -Wall \
 // RUN: -ffunction-sections 2>&1 | FileCheck %s -check-prefix=F_G_O_W_OPTIONS
 // F_G_O_W_OPTIONS: "-g" "-fno-inline-functions" "-fno-inline-functions-called-once"
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -792,6 +792,17 @@
 const llvm::opt::ArgList &TCArgs,
 const char *LinkingOutput) const override;
 };
+
+class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
+public:
+  Linker(const ToolChain &TC) : GnuTool("shave::Linker", "ld", TC) {}
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
 } // end namespace SHAVE
 
 } // end namespace tools
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -9651,3 +9651,81 @@
   C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Exec),
   CmdArgs, Inputs));
 }
+
+void tools::SHAVE::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output,
+const InputInfoList &Inputs,
+const ArgList &Args,
+const char *LinkingOutput) const {
+  const auto &TC =
+  static_cast(getToolChain());
+  const llvm::Triple &T = TC.getTriple();
+  ArgStringList CmdArgs;
+  bool UseStartfiles = !Args.hasArg(options::OPT_nostartfiles);
+
+  std::string StartFilesDir, BuiltinLibDir;
+  TC.getCompilerSupportDir(StartFilesDir);
+  TC.getBuiltinLibDir(BuiltinLibDir);
+
+  CmdArgs.push_back("-EL"); // Endianness = little
+
+  // The remaining logic is mostly like gnutools::Linker::ConstructJob,
+  // but we never pass through a --sysroot option and various other bits.
+  // For example, there are no sanitizers (yet) nor gold linker.
+
+  // Eat some arguments that may be present but have no effect.
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  Args.ClaimAllArgs(options::OPT_w);
+  Args.ClaimAllArgs(options::OPT_static_libgcc);
+
+  if (Args.hasArg(options::OPT_s)) // Pass the 'strip' option.
+CmdArgs.push_back("-s");
+
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(Output.getFilename());
+
+  if (UseStartfiles) {
+if (T.getOS() == llvm::Triple::RTEMS) {
+  CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crti.o"));
+  CmdArgs.push_back(A

  1   2   >