[PATCH] D63648: [Preprocessor] Honor absolute paths in diagnostics

Alexandre Ganea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 17 11:33:40 PDT 2019


aganea added a comment.

The problem is that it is not `cl.exe`'s behavior - it always makes paths absolute:

  F:\svn\test>cl /c test.cc /showIncludes
  Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27031.1 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  test.cc
  Note: including file: f:\svn\test\foo/test.h
  
  F:\svn\test>c:
  
  C:\Windows\System32>cl /c f:test.cc /showIncludes
  Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27031.1 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  test.cc
  Note: including file: f:\svn\test\foo/test.h

So maybe `Driver::IsCLMode()` should take precedence over `-fdiagnostics-absolute-paths` when using `/showIncludes`?

The behavior between `clang-cl` and `cl` is also very different when using `-E`:

  C:\Windows\System32>f:\svn\build\Debug\bin\clang-cl /c f:test.cc /E
  clang-cl: error: no such file or directory: 'f:test.cc'
  clang-cl: error: no input files
  
  C:\Windows\System32>f:
  
  F:\svn\test>f:\svn\build\Debug\bin\clang-cl /c test.cc /E
  # 1 "test.cc"
  # 1 "<built-in>" 1
  # 1 "<built-in>" 3
  # 361 "<built-in>" 3
  # 1 "<command line>" 1
  # 1 "<built-in>" 2
  # 1 "test.cc" 2
  # 1 "./foo/test.h" 1
  void f();
  # 1 "test.cc" 2
  
  
  F:\svn\test>cl /c test.cc /E
  Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27031.1 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  test.cc
  #line 1 "test.cc"
  #line 1 "f:\\svn\\test\\foo/test.h"
  void f();
  #line 2 "test.cc"
  
  F:\svn\test>cl /c test.cc /E /FC
  Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27031.1 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  test.cc
  #line 1 "f:\\svn\\test\\test.cc"
  #line 1 "f:\\svn\\test\\foo\\test.h"
  void f();
  #line 2 "f:\\svn\\test\\test.cc"

So maybe I should also implement `/FC` <https://docs.microsoft.com/en-us/cpp/build/reference/fc-full-path-of-source-code-file-in-diagnostics?view=vs-2019> along the way, and make the defaults match between `clang-cl` and `cl`? WDYT?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63648/new/

https://reviews.llvm.org/D63648





More information about the cfe-commits mailing list