This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] PointerToIntegral casts
ClosedPublic

Authored by tbaeder on May 19 2023, 2:14 AM.

Details

Summary

Add a new opcode doing the cast and emit a diagnostic in case we're in a constant context.

Diff Detail

Event Timeline

tbaeder created this revision.May 19 2023, 2:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2023, 2:14 AM
tbaeder requested review of this revision.May 19 2023, 2:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2023, 2:14 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Hm, this works for pointers, but not for function pointers (which we map to FunctionPointer).

shafik accepted this revision.May 19 2023, 9:21 AM

LGTM

This revision is now accepted and ready to land.May 19 2023, 9:21 AM
This revision was landed with ongoing or failed builds.Jul 26 2023, 4:40 AM
This revision was automatically updated to reflect the committed changes.
phosek added a subscriber: phosek.Jul 26 2023, 3:35 PM

This test is failing on our Windows builders with the following error:

Script:
--
: 'RUN: at line 1';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
: 'RUN: at line 2';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++20 -verify C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
: 'RUN: at line 3';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -std=c++11 -fms-extensions -verify=ref C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
: 'RUN: at line 4';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -std=c++20 -fms-extensions -verify=ref C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
--
Exit Code: 1

Command Output (stdout):
--
$ ":" "RUN: at line 1"
$ "c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe" "-cc1" "-internal-isystem" "c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include" "-nostdsysteminc" "-fexperimental-new-constant-interpreter" "-fms-extensions" "-std=c++11" "-verify" "C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp"
# command stderr:
error: 'warning' diagnostics seen but not expected: 
  File C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp Line 946: cast to smaller integer type 'long' from 'char *'
1 error generated.

error: command failed with exit status: 1

Would it be possible to either quickly address the issue or revert the change?

This test is failing on our Windows builders with the following error:

Script:
--
: 'RUN: at line 1';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
: 'RUN: at line 2';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++20 -verify C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
: 'RUN: at line 3';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -std=c++11 -fms-extensions -verify=ref C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
: 'RUN: at line 4';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -std=c++20 -fms-extensions -verify=ref C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
--
Exit Code: 1

Command Output (stdout):
--
$ ":" "RUN: at line 1"
$ "c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe" "-cc1" "-internal-isystem" "c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include" "-nostdsysteminc" "-fexperimental-new-constant-interpreter" "-fms-extensions" "-std=c++11" "-verify" "C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp"
# command stderr:
error: 'warning' diagnostics seen but not expected: 
  File C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp Line 946: cast to smaller integer type 'long' from 'char *'
1 error generated.

error: command failed with exit status: 1

Would it be possible to either quickly address the issue or revert the change?

Did the changes in 2a6cfc4baa784ff299a81f8c5e7163207c93eafe address the issue for you?

This test is failing on our Windows builders with the following error:

Script:
--
: 'RUN: at line 1';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
: 'RUN: at line 2';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -fexperimental-new-constant-interpreter -fms-extensions -std=c++20 -verify C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
: 'RUN: at line 3';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -std=c++11 -fms-extensions -verify=ref C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
: 'RUN: at line 4';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe -cc1 -internal-isystem c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include -nostdsysteminc -std=c++20 -fms-extensions -verify=ref C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp
--
Exit Code: 1

Command Output (stdout):
--
$ ":" "RUN: at line 1"
$ "c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe" "-cc1" "-internal-isystem" "c:\b\s\w\ir\x\w\llvm_build\lib\clang\18\include" "-nostdsysteminc" "-fexperimental-new-constant-interpreter" "-fms-extensions" "-std=c++11" "-verify" "C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp"
# command stderr:
error: 'warning' diagnostics seen but not expected: 
  File C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\AST\Interp\literals.cpp Line 946: cast to smaller integer type 'long' from 'char *'
1 error generated.

error: command failed with exit status: 1

Would it be possible to either quickly address the issue or revert the change?

Did the changes in 2a6cfc4baa784ff299a81f8c5e7163207c93eafe address the issue for you?

That fixed it, thank you.