[cfe-commits] r143846 - in /cfe/trunk: lib/Driver/Compilation.cpp lib/Driver/Tools.cpp lib/Driver/Tools.h test/Driver/crash-cleanup.c

Chad Rosier mcrosier at apple.com
Sat Nov 5 19:17:13 PDT 2011


Hi Peter,
This commit is causing the buildbots to fail in phase 1.  The code looks great, but you'll need to massage the test case a bit to get it to work.  I think you're assuming clang will return a -1 upon failure when in fact it does not.  At least thats what I gather from your use of the 'not' before '%clang'.

Chad-Rosiers-MacBook-Pro:~ mcrosier$ ~/llvm-clean/build/Debug+Asserts/bin/clang ~/llvm-clean/clang/test/Driver/crash-cleanup.c
0  clang             0x00000001023d9733 PrintStackTrace(void*) + 51
1  clang             0x00000001023d9c3d SignalHandler(int) + 333
2  libSystem.B.dylib 0x00007fff859af1ba _sigtramp + 26
3  libSystem.B.dylib 0x0000000107830b80 _sigtramp + 2179471840
4  clang             0x000000010123f67d clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, clang::PragmaIntroducerKind, clang::Token&) + 261
5  clang             0x000000010123f67d clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, clang::PragmaIntroducerKind, clang::Token&) + 261
6  clang             0x00000001012422c0 clang::Preprocessor::HandlePragmaDirective(unsigned int) + 122
7  clang             0x0000000101225ceb clang::Preprocessor::HandleDirective(clang::Token&) + 1203
8  clang             0x000000010120aba2 clang::Lexer::LexTokenInternal(clang::Token&) + 11702
9  clang             0x000000010015a52b clang::Lexer::Lex(clang::Token&) + 91
10 clang             0x00000001004f2179 clang::Preprocessor::Lex(clang::Token&) + 105
11 clang             0x0000000101208054 clang::Lexer::LexTokenInternal(clang::Token&) + 616
12 clang             0x000000010015a52b clang::Lexer::Lex(clang::Token&) + 91
13 clang             0x00000001004f2179 clang::Preprocessor::Lex(clang::Token&) + 105
14 clang             0x000000010050e78d clang::Parser::ConsumeToken() + 301
15 clang             0x000000010051c861 clang::Parser::ConsumeAnyToken() + 227
16 clang             0x00000001005116ef clang::Parser::ExpectAndConsume(clang::tok::TokenKind, unsigned int, char const*, clang::tok::TokenKind) + 155
17 clang             0x00000001004a55dd clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int, bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 2597
18 clang             0x00000001004af941 clang::Parser::ParseSimpleDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, bool, clang::Parser::ForRangeInit*) + 621
19 clang             0x00000001004afd96 clang::Parser::ParseDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 1060
20 clang             0x00000001005174c3 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::Parser::ParsingDeclSpec*) + 2403
21 clang             0x0000000100518090 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 382
22 clang             0x0000000100494aeb clang::ParseAST(clang::Sema&, bool) + 523
23 clang             0x000000010011ddb5 clang::ASTFrontendAction::ExecuteAction() + 365
24 clang             0x00000001004246ea clang::CodeGenAction::ExecuteAction() + 1238
25 clang             0x000000010011df8f clang::FrontendAction::Execute() + 401
26 clang             0x00000001000f26f4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1082
27 clang             0x00000001000c33e5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1285
28 clang             0x00000001000b7ad6 cc1_main(char const**, char const**, char const*, void*) + 1270
29 clang             0x00000001000c0513 main + 643
30 clang             0x00000001000b7038 start + 52
Stack dump:
0.	Program arguments: /Users/mcrosier/llvm-clean/build/Debug+Asserts/bin/clang -cc1 -triple x86_64-apple-macosx10.6.8 -emit-obj -mrelax-all -disable-free -main-file-name crash-cleanup.c -pic-level 1 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 97.17 -resource-dir /Users/mcrosier/llvm-clean/build/Debug+Asserts/bin/../lib/clang/3.1 -fmodule-cache-path /var/folders/HL/HLcs1B2JHr8ZCoYgCVVNdk+++TI/-Tmp-/clang-module-cache -fdebug-compilation-dir /Users/mcrosier -ferror-limit 19 -fmessage-length 127 -stack-protector 1 -fblocks -fobjc-dispatch-method=mixed -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/HL/HLcs1B2JHr8ZCoYgCVVNdk+++TI/-Tmp-/crash-cleanup-nPD7Ss.o -x c /Users/mcrosier/llvm-clean/clang/test/Driver/crash-cleanup.c 
1.	/Users/mcrosier/llvm-clean/clang/test/Driver/crash-cleanup.c:7:2: current parser token 'pragma'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal 2 (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://llvm.org/bugs/ and include command line arguments and all diagnostic information.
clang: error: unable to execute command: Segmentation fault
clang: note: diagnostic msg: Error generating preprocessed source(s).
Chad-Rosiers-MacBook-Pro:~ mcrosier$ echo $?
254

 Chad

On Nov 5, 2011, at 5:40 PM, Peter Collingbourne wrote:

> Author: pcc
> Date: Sat Nov  5 19:40:05 2011
> New Revision: 143846
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=143846&view=rev
> Log:
> Add the depfile as a result file so that it is deleted if we crash,
> and prevent the diagnostic preprocessor run from writing a depfile.
> 
> Added:
>    cfe/trunk/test/Driver/crash-cleanup.c
> Modified:
>    cfe/trunk/lib/Driver/Compilation.cpp
>    cfe/trunk/lib/Driver/Tools.cpp
>    cfe/trunk/lib/Driver/Tools.h
> 
> Modified: cfe/trunk/lib/Driver/Compilation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=143846&r1=143845&r2=143846&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/Compilation.cpp (original)
> +++ cfe/trunk/lib/Driver/Compilation.cpp Sat Nov  5 19:40:05 2011
> @@ -217,8 +217,12 @@
> 
>   // Remove any user specified output.  Claim any unclaimed arguments, so as
>   // to avoid emitting warnings about unused args.
> -  if (TranslatedArgs->hasArg(options::OPT_o))
> -    TranslatedArgs->eraseArg(options::OPT_o);
> +  OptSpecifier OutputOpts[] = { options::OPT_o, options::OPT_MD,
> +                                options::OPT_MMD };
> +  for (unsigned i = 0; i != sizeof(OutputOpts)/sizeof(OutputOpts[0]); ++i) {
> +    if (TranslatedArgs->hasArg(OutputOpts[i]))
> +      TranslatedArgs->eraseArg(OutputOpts[i]);
> +  }
>   TranslatedArgs->ClaimAllArgs();
> 
>   // Redirect stdout/stderr to /dev/null.
> 
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=143846&r1=143845&r2=143846&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Sat Nov  5 19:40:05 2011
> @@ -203,7 +203,8 @@
>   }
> }
> 
> -void Clang::AddPreprocessingOptions(const Driver &D,
> +void Clang::AddPreprocessingOptions(Compilation &C,
> +                                    const Driver &D,
>                                     const ArgList &Args,
>                                     ArgStringList &CmdArgs,
>                                     const InputInfo &Output,
> @@ -225,11 +226,13 @@
>       DepFile = Output.getFilename();
>     } else if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
>       DepFile = MF->getValue(Args);
> +      C.addResultFile(DepFile);
>     } else if (A->getOption().matches(options::OPT_M) ||
>                A->getOption().matches(options::OPT_MM)) {
>       DepFile = "-";
>     } else {
>       DepFile = darwin::CC1::getDependencyFileName(Args, Inputs);
> +      C.addResultFile(DepFile);
>     }
>     CmdArgs.push_back("-dependency-file");
>     CmdArgs.push_back(DepFile);
> @@ -1541,7 +1544,7 @@
>   //
>   // FIXME: Support -fpreprocessed
>   if (types::getPreprocessedType(InputType) != types::TY_INVALID)
> -    AddPreprocessingOptions(D, Args, CmdArgs, Output, Inputs);
> +    AddPreprocessingOptions(C, D, Args, CmdArgs, Output, Inputs);
> 
>   // Don't warn about "clang -c -DPIC -fPIC test.i" because libtool.m4 assumes
>   // that "The compiler can only warn and ignore the option if not recognized".
> 
> Modified: cfe/trunk/lib/Driver/Tools.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=143846&r1=143845&r2=143846&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.h (original)
> +++ cfe/trunk/lib/Driver/Tools.h Sat Nov  5 19:40:05 2011
> @@ -29,7 +29,8 @@
> 
>   /// \brief Clang compiler tool.
>   class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
> -    void AddPreprocessingOptions(const Driver &D,
> +    void AddPreprocessingOptions(Compilation &C,
> +                                 const Driver &D,
>                                  const ArgList &Args,
>                                  ArgStringList &CmdArgs,
>                                  const InputInfo &Output,
> 
> Added: cfe/trunk/test/Driver/crash-cleanup.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-cleanup.c?rev=143846&view=auto
> ==============================================================================
> --- cfe/trunk/test/Driver/crash-cleanup.c (added)
> +++ cfe/trunk/test/Driver/crash-cleanup.c Sat Nov  5 19:40:05 2011
> @@ -0,0 +1,7 @@
> +// RUN: not %clang -o %t.o -MMD -MF %t.d %s
> +// RUN: test ! -f %t.o
> +// RUN: test ! -f %t.d
> +// REQUIRES: shell
> +// REQUIRES: crash-recovery
> +
> +#pragma clang __debug crash
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list